-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.axaml.cs
More file actions
38 lines (31 loc) · 923 Bytes
/
App.axaml.cs
File metadata and controls
38 lines (31 loc) · 923 Bytes
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
using System;
using System.IO;
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
namespace PaintPower;
public partial class App : Application
{
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}
public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.MainWindow = new MainWindow();
// NEW: handle startup file
if (desktop.Args is { Length: > 0 })
{
string file = desktop.Args[0];
if (File.Exists(file) && file.EndsWith(".xPaint", StringComparison.OrdinalIgnoreCase))
{
// Pass file to MainWindow
((MainWindow)desktop.MainWindow).StartupProjectPath = file;
}
}
}
base.OnFrameworkInitializationCompleted();
}
}