@@ -28,10 +28,6 @@ public partial class MainWindow
2828 /// The LogController object that can be used to add new logs
2929 /// </summary>
3030 private readonly LogController _logController ;
31- /// <summary>
32- /// A boolean to indicate whether the RAM Monitor was enabled or not before an operation
33- /// </summary>
34- private bool _rmEnabledBeforeInvisible ;
3531 #endregion
3632
3733 /// <inheritdoc />
@@ -64,6 +60,17 @@ public MainWindow()
6460 LoadProperties ( ) ;
6561 AutoUpdate ( ) ;
6662
63+ try
64+ {
65+ if ( ! Properties . Settings . Default . HideOnStart ) return ;
66+ Hide ( ) ;
67+ }
68+ catch ( Exception ex )
69+ {
70+ _logController . AddLog ( new ApplicationLog ( ex . Message ) ) ;
71+ MessageBox . Show ( ex . Message , "MemPlus" , MessageBoxButton . OK , MessageBoxImage . Error ) ;
72+ }
73+
6774 _logController . AddLog ( new ApplicationLog ( "Done initializing MainWindow" ) ) ;
6875 }
6976
@@ -112,13 +119,8 @@ internal void LoadProperties()
112119
113120 if ( Properties . Settings . Default . RamMonitor )
114121 {
115- _rmEnabledBeforeInvisible = true ;
116122 _ramController . EnableMonitor ( ) ;
117123 }
118- else
119- {
120- _rmEnabledBeforeInvisible = false ;
121- }
122124 }
123125 catch ( Exception ex )
124126 {
@@ -404,25 +406,31 @@ private void ApplicationExportMenuItem_OnClick(object sender, RoutedEventArgs e)
404406 /// <param name="e">The RoutedEventArgs</param>
405407 private void OpenTbItem_Click ( object sender , RoutedEventArgs e )
406408 {
407- if ( IsVisible )
409+ try
408410 {
409- Hide ( ) ;
410-
411- if ( _rmEnabledBeforeInvisible )
411+ if ( IsVisible )
412412 {
413- _ramController . DisableMonitor ( ) ;
413+ Hide ( ) ;
414+ if ( Properties . Settings . Default . DisableOnInactive )
415+ {
416+ _ramController . DisableMonitor ( ) ;
417+ }
418+ _logController . AddLog ( new ApplicationLog ( "MainWindow is now hidden" ) ) ;
414419 }
415- _logController . AddLog ( new ApplicationLog ( "MainWindow is now hidden" ) ) ;
416- }
417- else
418- {
419- Show ( ) ;
420-
421- if ( _rmEnabledBeforeInvisible )
420+ else
422421 {
423- _ramController . EnableMonitor ( ) ;
422+ Show ( ) ;
423+ if ( Properties . Settings . Default . RamMonitor )
424+ {
425+ _ramController . EnableMonitor ( ) ;
426+ }
427+ _logController . AddLog ( new ApplicationLog ( "MainWindow is now visible" ) ) ;
424428 }
425- _logController . AddLog ( new ApplicationLog ( "MainWindow is now visible" ) ) ;
429+ }
430+ catch ( Exception ex )
431+ {
432+ MessageBox . Show ( ex . Message , "MemPlus" , MessageBoxButton . OK , MessageBoxImage . Error ) ;
433+ _logController . AddLog ( new ApplicationLog ( ex . Message ) ) ;
426434 }
427435 }
428436
@@ -467,7 +475,6 @@ private void RamMonitorMenuItem_OnCheckedChanged(object sender, RoutedEventArgs
467475 if ( MniRamMonitor . IsChecked )
468476 {
469477 Properties . Settings . Default . RamMonitor = true ;
470- _rmEnabledBeforeInvisible = false ;
471478 _ramController . EnableMonitor ( ) ;
472479 }
473480 else
0 commit comments