47 lines
1.2 KiB
C#
47 lines
1.2 KiB
C#
using System;
|
|
using Avalonia.Controls;
|
|
using CommunityToolkit.Mvvm.Messaging;
|
|
using GazpromApp.Messages;
|
|
using GazpromApp.Models;
|
|
using GazpromApp.ViewModels;
|
|
|
|
namespace GazpromApp.Views;
|
|
|
|
public partial class EditPointDialog : Window
|
|
{
|
|
public Point? Point;
|
|
|
|
public EditPointDialog()
|
|
{
|
|
InitializeComponent();
|
|
|
|
if (Design.IsDesignMode)
|
|
return;
|
|
|
|
// view image
|
|
WeakReferenceMessenger.Default.Register<EditPointDialog, ViewImageMessage>(this, static (w, m) =>
|
|
{
|
|
ImageView dialog = new ImageView()
|
|
{
|
|
DataContext = m.Image
|
|
};
|
|
m.Reply(dialog.ShowDialog<ImageViewModel?>(w));
|
|
});
|
|
|
|
WeakReferenceMessenger.Default.Register<EditPointDialog, EditPointDone>(this, static (w, m) =>
|
|
{
|
|
w.Close(m.Point);
|
|
});
|
|
}
|
|
|
|
private void Window_OnClosing(object? sender, WindowClosingEventArgs e)
|
|
{
|
|
if (DataContext is EditPointDialogViewModel { IsClosed: false } vm)
|
|
vm.CancelEditCommand.Execute(this);
|
|
}
|
|
|
|
private void Window_OnClosed(object? sender, EventArgs e)
|
|
{
|
|
WeakReferenceMessenger.Default.Unregister<ViewImageMessage>(this);
|
|
}
|
|
} |