-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.xaml.cs
More file actions
78 lines (69 loc) · 2.49 KB
/
App.xaml.cs
File metadata and controls
78 lines (69 loc) · 2.49 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
using Aimmy2.Theme;
using Class;
using System.Windows;
namespace Aimmy2
{
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
// Initialize the application theme from saved settings
InitializeTheme();
// Set shutdown mode to prevent app from closing when startup window closes
ShutdownMode = ShutdownMode.OnExplicitShutdown;
#if DEBUG
var _mainWindow = new MainWindow();
MainWindow = _mainWindow;
_mainWindow.Show();
return;
#endif
// code IS reachable, only in release though
try
{
// Create and show startup window
var startupWindow = new StartupWindow();
startupWindow.Show();
// Reset shutdown mode after startup window is shown
ShutdownMode = ShutdownMode.OnMainWindowClose;
}
catch (Exception ex)
{
// If startup window fails, launch main window directly
MessageBox.Show($"Startup animation failed: {ex.Message}\nLaunching main application...",
"Aimmy AI", MessageBoxButton.OK, MessageBoxImage.Information);
var mainWindow = new MainWindow();
MainWindow = mainWindow;
mainWindow.Show();
ShutdownMode = ShutdownMode.OnMainWindowClose;
}
}
private void InitializeTheme()
{
try
{
// Load the color state configuration
var colorState = new Dictionary<string, dynamic>
{
{ "Theme Color", "#FF722ED1" }
};
// Load saved colors
SaveDictionary.LoadJSON(colorState, "bin\\colors.cfg");
// Apply theme color if found
if (colorState.TryGetValue("Theme Color", out var themeColor) && themeColor is string colorString)
{
ThemeManager.SetThemeColor(colorString);
}
else
{
// Use default purple if no saved color
ThemeManager.SetThemeColor("#FF722ED1");
}
}
catch (Exception ex)
{
// Log error and use default color
ThemeManager.SetThemeColor("#FF722ED1");
}
}
}
}