-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.axaml.cs
More file actions
83 lines (74 loc) · 2.42 KB
/
Copy pathApp.axaml.cs
File metadata and controls
83 lines (74 loc) · 2.42 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using System;
using System.Diagnostics;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using LocalLLMServerManager.Views;
namespace LocalLLMServerManager;
public partial class App : Application
{
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}
public static void SetThemeStyle(string styleName)
{
if (styleName.Equals("semi", StringComparison.OrdinalIgnoreCase))
{
LocalLLMServerManager.Shared.Services.ThemeService.Instance.SetTheme(
LocalLLMServerManager.Shared.Services.AppTheme.MatteCarbon);
}
else if (styleName.Equals("fluent", StringComparison.OrdinalIgnoreCase))
{
LocalLLMServerManager.Shared.Services.ThemeService.Instance.SetTheme(
LocalLLMServerManager.Shared.Services.AppTheme.OledBlack);
}
}
public override void OnFrameworkInitializationCompleted()
{
LocalLLMServerManager.Shared.ViewModels.MainViewModel.EnableAutomaticPolling = true;
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.ShutdownMode = ShutdownMode.OnExplicitShutdown;
desktop.MainWindow = new MainWindow();
try { desktop.MainWindow.Show(); } catch { }
}
var icons = TrayIcon.GetIcons(this);
if (icons != null)
{
foreach (var icon in icons)
{
icon.IsVisible = true;
}
}
base.OnFrameworkInitializationCompleted();
}
public void OnOpenDashboardClick(object? sender, EventArgs e)
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
if (desktop.MainWindow == null)
{
desktop.MainWindow = new MainWindow();
}
try
{
desktop.MainWindow.Show();
desktop.MainWindow.Activate();
}
catch { }
}
}
public void OnOpenWebUiClick(object? sender, EventArgs e)
{
LocalLLMServerManager.Shared.Services.BrowserLauncher.OpenUrl("http://127.0.0.1:5246");
}
public void OnExitClick(object? sender, EventArgs e)
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.Shutdown();
}
}
}