@@ -36,10 +36,6 @@ protected override CreateParams CreateParams
3636 public Dashboard ( )
3737 {
3838 InitializeComponent ( ) ;
39- ApplyTheme ( ) ;
40- ApplyFontStyle ( ) ;
41- this . RenderFormPosition ( BatteryNotifierIcon ) ;
42- RenderTitleBarCursor ( ) ;
4339 _debouncer = new Debouncer . Debouncer ( ) ;
4440 }
4541
@@ -88,18 +84,30 @@ private void CloseIcon_MouseLeave(object? sender, EventArgs e)
8884 private void Dashboard_Load ( object ? sender , EventArgs e )
8985 {
9086 SuspendLayout ( ) ;
91- LoadSettings ( ) ;
92- HandleLaunchAtStartup ( ) ;
93- RefreshBatteryStatus ( ) ;
94- LoadNotificationSetting ( ) ;
95- BatteryStatusTimer . Enabled = true ;
96- ShowNotificationTimer . Enabled = true ;
97-
98- ConfigureTimer ( ) ;
99- AttachEventListeners ( ) ;
100-
101- InitializeContextMenu ( ) ;
102- ResumeLayout ( ) ;
87+ try
88+ {
89+ this . RenderFormPosition ( BatteryNotifierIcon ) ;
90+ ApplyTheme ( ) ;
91+ RenderTitleBarCursor ( ) ;
92+ ApplyFontStyle ( ) ;
93+ LoadSettings ( ) ;
94+ HandleLaunchAtStartup ( ) ;
95+ RefreshBatteryStatus ( ) ;
96+ LoadNotificationSetting ( ) ;
97+ BatteryStatusTimer . Enabled = true ;
98+ ShowNotificationTimer . Enabled = true ;
99+ ConfigureTimer ( ) ;
100+ AttachEventListeners ( ) ;
101+ InitializeContextMenu ( ) ;
102+ }
103+ catch ( Exception ex )
104+ {
105+ Notify ( ex . Message ) ;
106+ }
107+ finally
108+ {
109+ ResumeLayout ( ) ;
110+ }
103111 }
104112
105113
@@ -122,9 +130,9 @@ private void LoadSettings()
122130 LowBatterySound . Text = appSetting . Default . lowBatteryNotificationMusic ;
123131 }
124132
125- private bool IsDarkTheme ( ) => appSetting . Default . darkThemeApplied || appSetting . Default . SystemThemeApplied && ! UtilityHelper . IsLightTheme ( ) ;
126-
127- private bool IsLightTheme ( ) => ! appSetting . Default . darkThemeApplied && appSetting . Default . SystemThemeApplied && UtilityHelper . IsLightTheme ( ) ;
133+ private static bool IsDarkTheme ( ) => appSetting . Default . darkThemeApplied || appSetting . Default . SystemThemeApplied && ! UtilityHelper . IsLightTheme ( ) ;
134+
135+ private static bool IsLightTheme ( ) => ! appSetting . Default . darkThemeApplied && appSetting . Default . SystemThemeApplied && UtilityHelper . IsLightTheme ( ) ;
128136
129137 private void HandleLaunchAtStartup ( )
130138 {
@@ -287,7 +295,7 @@ private void FullBatteryTrackbar_Scroll(object? sender, EventArgs e)
287295 FullBatteryNotificationPercentageLabel . Text = RenderBatteryPercentageValue ( fullBatteryTrackbar . Value ) ;
288296 }
289297
290- private string RenderBatteryPercentageValue ( int value )
298+ private static string RenderBatteryPercentageValue ( int value )
291299 {
292300 return $ "({ value } %)";
293301 }
0 commit comments