36 lines
959 B
C#
36 lines
959 B
C#
using System;
|
|
using Avalonia.Controls;
|
|
using CommunityToolkit.Mvvm.Messaging;
|
|
using GazpromApp.Messages;
|
|
using GazpromApp.ViewModels;
|
|
|
|
namespace GazpromApp.Views;
|
|
|
|
public partial class NewPointDialog : Window
|
|
{
|
|
public NewPointDialog()
|
|
{
|
|
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);
|
|
}
|
|
} |