Skip to content

Commit 8c979d6

Browse files
committed
* Added a setting to disable ram statistics in main window
1 parent 7bc2c06 commit 8c979d6

File tree

7 files changed

+79
-15
lines changed

7 files changed

+79
-15
lines changed

MemPlus/App.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@
114114
<setting name="RunAsAdministrator" serializeAs="String">
115115
<value>False</value>
116116
</setting>
117+
<setting name="WindowRamStatistics" serializeAs="String">
118+
<value>True</value>
119+
</setting>
117120
</MemPlus.Properties.Settings>
118121
</userSettings>
119122
</configuration>

MemPlus/Properties/Settings.Designer.cs

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MemPlus/Properties/Settings.settings

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,8 @@
108108
<Setting Name="RunAsAdministrator" Type="System.Boolean" Scope="User">
109109
<Value Profile="(Default)">False</Value>
110110
</Setting>
111+
<Setting Name="WindowRamStatistics" Type="System.Boolean" Scope="User">
112+
<Value Profile="(Default)">True</Value>
113+
</Setting>
111114
</Settings>
112115
</SettingsFile>

MemPlus/Views/Windows/MainWindow.xaml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@
137137
<MenuItem x:Name="MniOnTop" Header="Always on top" IsCheckable="True" Checked="TopMenuItem_OnCheckedChanged" Unchecked="TopMenuItem_OnCheckedChanged" />
138138
<MenuItem x:Name="MniDisableInactive" Header="Disable when inactive" IsCheckable="True" Checked="DisableInactiveMenuItem_OnCheckedChanged" Unchecked="DisableInactiveMenuItem_OnCheckedChanged" />
139139
<MenuItem x:Name="MniWindowDraggable" Header="Window draggable" IsCheckable="True" Checked="WindowDraggableMenuItem_OnCheckedChanged" Unchecked="WindowDraggableMenuItem_OnCheckedChanged" />
140+
<MenuItem x:Name="MniRamStatistics" Header="Display RAM statistics" IsCheckable="True" Checked="RamStatisticsMenuItem_OnCheckedChanged" Unchecked="RamStatisticsMenuItem_OnCheckedChanged" />
140141
<MenuItem x:Name="MniRamGauge" Header="Display RAM Gauge" IsCheckable="True" Checked="RamGaugeMenuItem_OnCheckedChanged" Unchecked="RamGaugeMenuItem_OnCheckedChanged" />
141142
</MenuItem>
142143
<MenuItem Header="Settings" Click="SettingsMenuItem_OnClick">
@@ -208,17 +209,23 @@
208209
<Grid.RowDefinitions>
209210
<RowDefinition Height="Auto" />
210211
<RowDefinition Height="Auto" />
211-
<RowDefinition Height="Auto" />
212-
<RowDefinition Height="Auto" />
213-
<RowDefinition Height="Auto" />
214212
</Grid.RowDefinitions>
215213

216-
<Label Grid.Row="0" Content="Total physical memory:" FontSize="14" Margin="10,5" />
217-
<Label Grid.Row="1" x:Name="LblTotalPhysicalMemory" Content="" FontSize="14" Foreground="Green" Margin="10,5" />
218-
<Label Grid.Row="2" Content="Used physical memory:" FontSize="14" Margin="10,5" />
219-
<Label Grid.Row="3" x:Name="LblAvailablePhysicalMemory" Content="" FontSize="14" Foreground="Red" Margin="10,5" />
214+
<Grid x:Name="GrdRamStatistics" Grid.Row="0">
215+
<Grid.RowDefinitions>
216+
<RowDefinition />
217+
<RowDefinition />
218+
<RowDefinition />
219+
<RowDefinition />
220+
</Grid.RowDefinitions>
221+
222+
<Label Grid.Row="0" Content="Total physical memory:" FontSize="14" Margin="10,5" />
223+
<Label Grid.Row="1" x:Name="LblTotalPhysicalMemory" Content="" FontSize="14" Foreground="Green" Margin="10,5" />
224+
<Label Grid.Row="2" Content="Used physical memory:" FontSize="14" Margin="10,5" />
225+
<Label Grid.Row="3" x:Name="LblAvailablePhysicalMemory" Content="" FontSize="14" Foreground="Red" Margin="10,5" />
226+
</Grid>
220227

221-
<syncfusion:SplitButtonAdv Grid.Row="4" FontSize="14"
228+
<syncfusion:SplitButtonAdv Grid.Row="1" FontSize="14"
222229
SmallIcon="../../Resources/Images/ram_tab.png" Label="Clear memory"
223230
x:Name="BtnClearMemory" Click="BtnClearMemory_OnClick" IsMultiLine="False"
224231
MinHeight="25" HorizontalAlignment="Stretch" Margin="10,5">

MemPlus/Views/Windows/MainWindow.xaml.cs

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ internal void LoadProperties()
184184
MniDisableInactive.IsChecked = Properties.Settings.Default.DisableOnInactive;
185185
MniOnTop.IsChecked = Properties.Settings.Default.Topmost;
186186
MniWindowDraggable.IsChecked = Properties.Settings.Default.WindowDragging;
187+
MniRamStatistics.IsChecked = Properties.Settings.Default.WindowRamStatistics;
187188
MniRamGauge.IsChecked = Properties.Settings.Default.DisplayGauge;
188189
MniRamMonitor.IsChecked = Properties.Settings.Default.RamMonitor;
189190

@@ -208,17 +209,18 @@ internal void LoadProperties()
208209
_ramController.EnableMonitor();
209210
}
210211

211-
RamGaugeVisibility();
212-
213212
TbiIcon.Visibility = !Properties.Settings.Default.NotifyIcon ? Visibility.Hidden : Visibility.Visible;
214-
WindowDraggable();
215213
}
216214
catch (Exception ex)
217215
{
218216
_logController.AddLog(new ApplicationLog(ex.Message));
219217
MessageBox.Show(ex.Message, "MemPlus", MessageBoxButton.OK, MessageBoxImage.Error);
220218
}
221219

220+
RamGaugeVisibility();
221+
RamStatisticsVisibility();
222+
WindowDraggable();
223+
222224
_logController.AddLog(new ApplicationLog("Done loading MainWindow properties"));
223225
}
224226

@@ -316,6 +318,22 @@ private void RamGaugeVisibility()
316318
}
317319
}
318320

321+
/// <summary>
322+
/// Check whether the RAM statistics should be displayed in the MainWindow
323+
/// </summary>
324+
private void RamStatisticsVisibility()
325+
{
326+
try
327+
{
328+
GrdRamStatistics.Visibility = Properties.Settings.Default.WindowRamStatistics ? Visibility.Visible : Visibility.Collapsed;
329+
}
330+
catch (Exception ex)
331+
{
332+
_logController.AddLog(new ApplicationLog(ex.Message));
333+
MessageBox.Show(ex.Message, "MemPlus", MessageBoxButton.OK, MessageBoxImage.Error);
334+
}
335+
}
336+
319337
/// <summary>
320338
/// Check whether the Window should be draggable or not
321339
/// </summary>
@@ -667,14 +685,33 @@ private void WindowDraggableMenuItem_OnCheckedChanged(object sender, RoutedEvent
667685
{
668686
Properties.Settings.Default.WindowDragging = MniWindowDraggable.IsChecked;
669687
Properties.Settings.Default.Save();
688+
}
689+
catch (Exception ex)
690+
{
691+
_logController.AddLog(new ApplicationLog(ex.Message));
692+
MessageBox.Show(ex.Message, "MemPlus", MessageBoxButton.OK, MessageBoxImage.Error);
693+
}
694+
WindowDraggable();
695+
}
670696

671-
WindowDraggable();
697+
/// <summary>
698+
/// Method that is called when the RAM statistics visibility should be changed
699+
/// </summary>
700+
/// <param name="sender">The object that called this method</param>
701+
/// <param name="e">The RoutedEventArgs</param>
702+
private void RamStatisticsMenuItem_OnCheckedChanged(object sender, RoutedEventArgs e)
703+
{
704+
try
705+
{
706+
Properties.Settings.Default.WindowRamStatistics = MniRamStatistics.IsChecked;
707+
Properties.Settings.Default.Save();
672708
}
673709
catch (Exception ex)
674710
{
675711
_logController.AddLog(new ApplicationLog(ex.Message));
676712
MessageBox.Show(ex.Message, "MemPlus", MessageBoxButton.OK, MessageBoxImage.Error);
677713
}
714+
RamStatisticsVisibility();
678715
}
679716

680717
/// <summary>
@@ -688,14 +725,13 @@ private void RamGaugeMenuItem_OnCheckedChanged(object sender, RoutedEventArgs e)
688725
{
689726
Properties.Settings.Default.DisplayGauge = MniRamGauge.IsChecked;
690727
Properties.Settings.Default.Save();
691-
692-
RamGaugeVisibility();
693728
}
694729
catch (Exception ex)
695730
{
696731
_logController.AddLog(new ApplicationLog(ex.Message));
697732
MessageBox.Show(ex.Message, "MemPlus", MessageBoxButton.OK, MessageBoxImage.Error);
698733
}
734+
RamGaugeVisibility();
699735
}
700736

701737
/// <summary>

MemPlus/Views/Windows/SettingsWindow.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@
5555
<CheckBox Grid.Row="3" Grid.Column="1" x:Name="ChbWindowDraggable" Content="Window draggable" Margin="3" />
5656
<CheckBox Grid.Row="4" Grid.Column="0" x:Name="ChbNotifyIcon" Content="Display notifyicon" Margin="3" />
5757
<CheckBox Grid.Row="4" Grid.Column="1" x:Name="ChbAdminWarning" Content="Display administrative rights warning" Margin="3" />
58-
<CheckBox Grid.Row="5" Grid.Column="0" x:Name="ChbRamClearingMessage" Content="Display information after clearing RAM" Margin="3" />
58+
<CheckBox Grid.Row="5" Grid.Column="0" x:Name="ChbRamClearingMessage" Content="Display statistics after clearing RAM" Margin="3" />
5959
<CheckBox Grid.Row="5" Grid.Column="1" x:Name="ChbNotifyIconStatistics" Content="Display RAM statistics in notifyicon" Margin="3" />
6060
<CheckBox Grid.Row="6" Grid.Column="0" x:Name="ChbDisplayGauge" Content="Display RAM Gauge" Margin="3" />
61+
<CheckBox Grid.Row="6" Grid.Column="1" x:Name="ChbWindowRamStatistics" Content="Display RAM statistics in window" Margin="3" />
6162
</Grid>
6263
</GroupBox>
6364
</Grid>

MemPlus/Views/Windows/SettingsWindow.xaml.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ private void LoadProperties()
109109
ChbRamClearingMessage.IsChecked = Properties.Settings.Default.RamCleaningMessage;
110110
ChbNotifyIconStatistics.IsChecked = Properties.Settings.Default.NotifyIconStatistics;
111111
ChbDisplayGauge.IsChecked = Properties.Settings.Default.DisplayGauge;
112+
ChbWindowRamStatistics.IsChecked = Properties.Settings.Default.WindowRamStatistics;
112113

113114
//RAM Monitor
114115
ChbRamMonitor.IsChecked = Properties.Settings.Default.RamMonitor;
@@ -238,6 +239,7 @@ private void SaveProperties()
238239
if (ChbRamClearingMessage.IsChecked != null) Properties.Settings.Default.RamCleaningMessage = ChbRamClearingMessage.IsChecked.Value;
239240
if (ChbNotifyIconStatistics.IsChecked != null) Properties.Settings.Default.NotifyIconStatistics = ChbNotifyIconStatistics.IsChecked.Value;
240241
if (ChbDisplayGauge.IsChecked != null) Properties.Settings.Default.DisplayGauge = ChbDisplayGauge.IsChecked.Value;
242+
if (ChbWindowRamStatistics.IsChecked != null) Properties.Settings.Default.WindowRamStatistics = ChbWindowRamStatistics.IsChecked.Value;
241243
if (ChbStartHidden.IsChecked != null) Properties.Settings.Default.HideOnStart = ChbStartHidden.IsChecked.Value;
242244
if (ChbHideOnClose.IsChecked != null) Properties.Settings.Default.HideOnClose = ChbHideOnClose.IsChecked.Value;
243245
if (ChbRunAsAdmin.IsChecked != null) Properties.Settings.Default.RunAsAdministrator = ChbRunAsAdmin.IsChecked.Value;

0 commit comments

Comments
 (0)