-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainWindow.axaml.cs
More file actions
55 lines (39 loc) · 1.26 KB
/
MainWindow.axaml.cs
File metadata and controls
55 lines (39 loc) · 1.26 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Interactivity;
using System;
namespace PaintPower;
public partial class MainWindow : Window
{
public bool saveNeeded = false;
#pragma warning disable
public static PaintPower_Engine App = new PaintPower_Engine();
public static MainWindow window;
public string? StartupProjectPath { get; set; }
#pragma warning enable
public MainWindow()
{
InitializeComponent();
WindowStartupLocation = WindowStartupLocation.CenterScreen;
// After, make a static reference.
window = this;
}
protected override async void OnOpened(EventArgs e)
{
base.OnOpened(e);
Tools.Keyboard.KeyPress.init(); // Initialize the key mapping
App.attachWindow(this);
App.attachEditorPart(editorPart.attachPaintPower(App));
App.Start();
AddHandler(KeyDownEvent, OnKeyDown, RoutingStrategies.Tunnel);
// Load project if opened via double-click
if (!string.IsNullOrWhiteSpace(StartupProjectPath))
{
PaintPower_Engine.App.OpenProjectFile(StartupProjectPath);
}
}
private void OnKeyDown(object? sender, KeyEventArgs e)
{
PaintPower_Engine.App.HandleKeyDown(e);
}
}