2026-02-18 10:43:27 -05:00
|
|
|
using Avalonia.Controls;
|
2026-02-25 08:05:44 -05:00
|
|
|
using OTSSignsOrchestrator.Desktop.ViewModels;
|
2026-02-18 10:43:27 -05:00
|
|
|
|
|
|
|
|
namespace OTSSignsOrchestrator.Desktop.Views;
|
|
|
|
|
|
|
|
|
|
public partial class InstancesView : UserControl
|
|
|
|
|
{
|
2026-02-25 08:05:44 -05:00
|
|
|
private InstancesViewModel? _vm;
|
|
|
|
|
|
2026-02-18 10:43:27 -05:00
|
|
|
public InstancesView()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2026-02-25 08:05:44 -05:00
|
|
|
DataContextChanged += OnDataContextChanged;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnDataContextChanged(object? sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (_vm is not null)
|
|
|
|
|
_vm.OpenDetailsRequested -= OnOpenDetailsRequested;
|
|
|
|
|
|
|
|
|
|
_vm = DataContext as InstancesViewModel;
|
|
|
|
|
|
|
|
|
|
if (_vm is not null)
|
2026-03-04 21:33:29 -05:00
|
|
|
{
|
2026-02-25 08:05:44 -05:00
|
|
|
_vm.OpenDetailsRequested += OnOpenDetailsRequested;
|
2026-03-04 21:33:29 -05:00
|
|
|
_vm.ConfirmAsync = ShowConfirmationAsync;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task<bool> ShowConfirmationAsync(string title, string message)
|
|
|
|
|
{
|
|
|
|
|
var owner = TopLevel.GetTopLevel(this) as Window;
|
|
|
|
|
if (owner is null) return false;
|
|
|
|
|
return await ConfirmationDialog.ShowAsync(owner, title, message);
|
2026-02-25 08:05:44 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async void OnOpenDetailsRequested(InstanceDetailsViewModel detailsVm)
|
|
|
|
|
{
|
|
|
|
|
var window = new InstanceDetailsWindow { DataContext = detailsVm };
|
|
|
|
|
var owner = TopLevel.GetTopLevel(this) as Window;
|
|
|
|
|
if (owner is not null)
|
|
|
|
|
await window.ShowDialog(owner);
|
|
|
|
|
else
|
|
|
|
|
window.Show();
|
2026-02-18 10:43:27 -05:00
|
|
|
}
|
|
|
|
|
}
|
2026-02-25 08:05:44 -05:00
|
|
|
|