-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMainWindow.axaml.cs
41 lines (33 loc) · 1018 Bytes
/
MainWindow.axaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using System.IO;
using System.Linq;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Threading;
using MercuryMapper.Config;
namespace MercuryMapper;
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
AddHandler(DragDrop.DropEvent, Window_Drop);
PointerPressed += (_, _) =>
{
Focus();
};
}
private void Window_Drop(object? sender, DragEventArgs e)
{
Uri? path = e.Data.GetFiles()?.First().Path;
if (path == null || !File.Exists(path.LocalPath) || Path.GetExtension(path.LocalPath) is not (".mer" or ".map")) return;
MainView.DragDrop(path.LocalPath);
e.Handled = true;
}
private void Window_OnClosing(object? sender, WindowClosingEventArgs e)
{
if (MainView.CanShutdown) return;
e.Cancel = true;
Dispatcher.UIThread.Post(() => MainView.MenuItemExit_OnClick(null, new()));
}
}