@@ -27,16 +27,14 @@ public MainWindow()
2727
2828 InitializeComponent ( ) ;
2929 ChangeVisualStyle ( ) ;
30- LoadProperties ( ) ;
3130
32- _ramController = new RamController ( Dispatcher , CgRamUsage , LblTotalPhysicalMemory , LblAvailablePhysicalMemory , 1000 , _logController ) ;
33- _rmEnabledBeforeInvisible = true ;
34- _ramController . EnableMonitor ( ) ;
31+ _ramController = new RamController ( Dispatcher , CgRamUsage , LblTotalPhysicalMemory , LblAvailablePhysicalMemory , 1000 , _logController ) ;
3532
3633 Application app = Application . Current ;
3734 app . Activated += Active ;
3835 app . Deactivated += Passive ;
3936
37+ LoadProperties ( ) ;
4038 _logController . AddLog ( new ApplicationLog ( "Done initializing MainWindow" ) ) ;
4139 }
4240
@@ -45,13 +43,27 @@ private void LoadProperties()
4543 _logController . AddLog ( new ApplicationLog ( "Loading properties" ) ) ;
4644 MniDisableInactive . IsChecked = Properties . Settings . Default . DisableOnInactive ;
4745 MniOnTop . IsChecked = Properties . Settings . Default . Topmost ;
46+ MniRamMonitor . IsChecked = Properties . Settings . Default . RamMonitor ;
4847 _logController . AddLog ( new ApplicationLog ( "Done loading properties" ) ) ;
48+
49+ if ( Properties . Settings . Default . RamMonitor )
50+ {
51+ _rmEnabledBeforeInvisible = true ;
52+ _ramController . EnableMonitor ( ) ;
53+ }
54+ else
55+ {
56+ _rmEnabledBeforeInvisible = false ;
57+ }
4958 }
5059
5160 private void Active ( object sender , EventArgs args )
5261 {
5362 if ( ! Properties . Settings . Default . DisableOnInactive ) return ;
54- _ramController . EnableMonitor ( ) ;
63+ if ( Properties . Settings . Default . RamMonitor )
64+ {
65+ _ramController . EnableMonitor ( ) ;
66+ }
5567 Overlay . Visibility = Visibility . Collapsed ;
5668 }
5769
@@ -245,5 +257,27 @@ private void DisableInactiveMenuItem_OnCheckedChanged(object sender, RoutedEvent
245257 Properties . Settings . Default . DisableOnInactive = MniDisableInactive . IsChecked ;
246258 Properties . Settings . Default . Save ( ) ;
247259 }
260+
261+ private void SettingsMenuItem_OnClick ( object sender , RoutedEventArgs e )
262+ {
263+ new SettingsWindow ( this , _logController ) . ShowDialog ( ) ;
264+ }
265+
266+ private void RamMonitorMenuItem_OnCheckedChanged ( object sender , RoutedEventArgs e )
267+ {
268+ if ( MniRamMonitor . IsChecked )
269+ {
270+ Properties . Settings . Default . RamMonitor = true ;
271+ _rmEnabledBeforeInvisible = false ;
272+ _ramController . EnableMonitor ( ) ;
273+ }
274+ else
275+ {
276+ Properties . Settings . Default . RamMonitor = false ;
277+ _ramController . DisableMonitor ( ) ;
278+ }
279+
280+ Properties . Settings . Default . Save ( ) ;
281+ }
248282 }
249283}
0 commit comments