Error handling system added
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using Avalonia.Controls;
|
||||
using System;
|
||||
using Avalonia.Controls;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using GazpromApp.Messages;
|
||||
using GazpromApp.ViewModels;
|
||||
|
||||
namespace GazpromApp.Views;
|
||||
|
||||
@@ -10,9 +12,25 @@ public partial class NewPointDialog : Window
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
// done entering new point
|
||||
WeakReferenceMessenger.Default.Register<NewPointDialog, NewPointDone>(this, static (w, m) =>
|
||||
{
|
||||
w.Close(m.Point);
|
||||
});
|
||||
|
||||
// register to work with errors
|
||||
WeakReferenceMessenger.Default.Register<NewPointDialog, 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<ErrorMessage>(this);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user