Skip to content

Commit 0b29096

Browse files
committed
* Added ability to display RAM statistics in the notifyicon
1 parent b168f5a commit 0b29096

File tree

7 files changed

+52
-3
lines changed

7 files changed

+52
-3
lines changed

MemPlus/App.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@
8585
<setting name="WindowResizeBorder" serializeAs="String">
8686
<value>3</value>
8787
</setting>
88+
<setting name="NotifyIconStatistics" serializeAs="String">
89+
<value>True</value>
90+
</setting>
8891
</MemPlus.Properties.Settings>
8992
</userSettings>
9093
</configuration>

MemPlus/Business/RAM/RamController.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ internal sealed class RamController
9292
/// </summary>
9393
internal bool ShowStatistics { get; set; }
9494
/// <summary>
95+
/// Property displaying whether RAM usage statistics should be displayed in the notifyicon
96+
/// </summary>
97+
internal bool ShowNotifyIconStatistics { get; set; }
98+
/// <summary>
9599
/// The last time automatic RAM optimisation was called in terms of RAM percentage threshold settings
96100
/// </summary>
97101
private DateTime _lastAutoOptimizeTime;
@@ -217,10 +221,23 @@ private void UpdateGuiControls()
217221
{
218222
_mainWindow.Dispatcher.Invoke(() =>
219223
{
224+
string ramTotal = (RamTotal / 1024 / 1024 / 1024).ToString("F2") + " GB";
225+
string ramAvailable = (RamUsage / 1024 / 1024 / 1024).ToString("F2") + " GB";
220226
_mainWindow.CgRamUsage.Scales[0].Pointers[0].Value = RamUsagePercentage;
221227
_mainWindow.CgRamUsage.GaugeHeader = "RAM usage (" + RamUsagePercentage.ToString("F2") + "%)";
222-
_mainWindow.LblTotalPhysicalMemory.Content = (RamTotal / 1024 / 1024 / 1024).ToString("F2") + " GB";
223-
_mainWindow.LblAvailablePhysicalMemory.Content = (RamUsage / 1024 / 1024 / 1024).ToString("F2") + " GB";
228+
_mainWindow.LblTotalPhysicalMemory.Content = ramTotal;
229+
_mainWindow.LblAvailablePhysicalMemory.Content = ramAvailable;
230+
231+
if (ShowNotifyIconStatistics)
232+
{
233+
string tooltipText = "DeviceLog";
234+
tooltipText += Environment.NewLine;
235+
tooltipText += "Total physical memory: " + ramTotal;
236+
tooltipText += Environment.NewLine;
237+
tooltipText += "Available physical memory: " + ramAvailable;
238+
239+
_mainWindow.TbiIcon.ToolTipText = tooltipText;
240+
}
224241
});
225242
}
226243

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
@@ -80,5 +80,8 @@
8080
<Setting Name="WindowResizeBorder" Type="System.Double" Scope="User">
8181
<Value Profile="(Default)">3</Value>
8282
</Setting>
83+
<Setting Name="NotifyIconStatistics" Type="System.Boolean" Scope="User">
84+
<Value Profile="(Default)">True</Value>
85+
</Setting>
8386
</Settings>
8487
</SettingsFile>

MemPlus/Views/Windows/MainWindow.xaml.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,16 @@ internal void LoadProperties()
141141
_ramController.AutoOptimizeTimed(Properties.Settings.Default.AutoOptimizeTimed, Properties.Settings.Default.AutoOptimizeTimedInterval);
142142
_ramController.ShowStatistics = Properties.Settings.Default.RamCleaningMessage;
143143

144+
if (Properties.Settings.Default.NotifyIconStatistics)
145+
{
146+
_ramController.ShowNotifyIconStatistics = true;
147+
}
148+
else
149+
{
150+
_ramController.ShowNotifyIconStatistics = false;
151+
TbiIcon.ToolTipText = "DeviceLog";
152+
}
153+
144154
_ramController.AutoOptimizePercentage = Properties.Settings.Default.AutoOptimizePercentage;
145155
_ramController.SetAutoOptimizeThreshold(Properties.Settings.Default.AutoOptimizePercentageThreshold);
146156

MemPlus/Views/Windows/SettingsWindow.xaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
AllowsTransparency="True"
1111
TitleTextAlignment="Center"
1212
WindowStartupLocation="CenterScreen"
13-
Title="MemPlus - Settings" Height="360" Width="450"
13+
Title="MemPlus - Settings" Height="400" Width="450"
1414
Icon="/MemPlus;component/Resources/Images/ram.png">
1515
<Grid>
1616
<Grid.RowDefinitions>
@@ -39,6 +39,7 @@
3939
<RowDefinition Height="Auto" />
4040
<RowDefinition Height="Auto" />
4141
<RowDefinition Height="Auto" />
42+
<RowDefinition Height="Auto" />
4243
</Grid.RowDefinitions>
4344

4445
<CheckBox Grid.Row="0" x:Name="ChbAutoUpdate" Content="Automatic updates" Margin="3" />
@@ -50,6 +51,7 @@
5051
<CheckBox Grid.Row="6" x:Name="ChbNotifyIcon" Content="Display notifyicon" Margin="3" />
5152
<CheckBox Grid.Row="7" x:Name="ChbAdminWarning" Content="Display administrative rights warning" Margin="3" />
5253
<CheckBox Grid.Row="8" x:Name="ChbRamClearingMessage" Content="Display information after clearing RAM" Margin="3" />
54+
<CheckBox Grid.Row="9" x:Name="ChbNotifyIconStatistics" Content="Display RAM statistics in notifyicon" Margin="3" />
5355
</Grid>
5456
</GroupBox>
5557
</Grid>

MemPlus/Views/Windows/SettingsWindow.xaml.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ private void LoadProperties()
9494
}
9595
ChbAdminWarning.IsChecked = Properties.Settings.Default.AdministrativeWarning;
9696
ChbRamClearingMessage.IsChecked = Properties.Settings.Default.RamCleaningMessage;
97+
ChbNotifyIconStatistics.IsChecked = Properties.Settings.Default.NotifyIconStatistics;
9798

9899
//RAM Monitor
99100
ChbRamMonitor.IsChecked = Properties.Settings.Default.RamMonitor;
@@ -214,6 +215,7 @@ private void SaveProperties()
214215
if (ChbWindowDraggable.IsChecked != null) Properties.Settings.Default.WindowDragging = ChbWindowDraggable.IsChecked.Value;
215216
if (ChbAdminWarning.IsChecked != null) Properties.Settings.Default.AdministrativeWarning = ChbAdminWarning.IsChecked.Value;
216217
if (ChbRamClearingMessage.IsChecked != null) Properties.Settings.Default.RamCleaningMessage = ChbRamClearingMessage.IsChecked.Value;
218+
if (ChbNotifyIconStatistics.IsChecked != null) Properties.Settings.Default.NotifyIconStatistics = ChbNotifyIconStatistics.IsChecked.Value;
217219
if (ChbStartHidden.IsChecked != null) Properties.Settings.Default.HideOnStart = ChbStartHidden.IsChecked.Value;
218220
if (ChbStartMinimized.IsChecked != null) Properties.Settings.Default.StartMinimized = ChbStartMinimized.IsChecked.Value;
219221

0 commit comments

Comments
 (0)