Error handling system added
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using Avalonia.Controls;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using GazpromApp.Messages;
|
||||
using GazpromApp.ViewModels;
|
||||
|
||||
namespace GazpromApp.Views;
|
||||
|
||||
@@ -11,14 +12,26 @@ public partial class NewEquipmentDialog : Window
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
// done entering new equipment
|
||||
WeakReferenceMessenger.Default.Register<NewEquipmentDialog, NewEquipmentDone>(this, static (w, m) =>
|
||||
{
|
||||
w.Close(m.Equipment);
|
||||
});
|
||||
|
||||
// register to work with errors
|
||||
WeakReferenceMessenger.Default.Register<NewEquipmentDialog, ErrorMessage>(this, static (w, m) =>
|
||||
{
|
||||
ErrorView dialog = new ErrorView()
|
||||
{
|
||||
DataContext = m.Error
|
||||
};
|
||||
m.Reply(dialog.ShowDialog<ErrorViewModel?>(w));
|
||||
});
|
||||
}
|
||||
|
||||
private void Window_OnClosed(object? sender, EventArgs e)
|
||||
{
|
||||
WeakReferenceMessenger.Default.Unregister<NewEquipmentDone>(this);
|
||||
WeakReferenceMessenger.Default.Unregister<ErrorMessage>(this);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user