Skip to content

Commit 844f521

Browse files
committed
* Code improvements
* Design code improvements
1 parent 83f346a commit 844f521

File tree

9 files changed

+68
-73
lines changed

9 files changed

+68
-73
lines changed

MemPlus/Business/RAM/RamController.cs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ private void OnTimedEvent(object source, ElapsedEventArgs e)
242242
/// <summary>
243243
/// Clear all non-essential RAM
244244
/// </summary>
245-
/// <returns>Nothing</returns>
245+
/// <returns>A Task</returns>
246246
internal async Task ClearMemory()
247247
{
248248
_lastAutoOptimizeTime = DateTime.Now;
@@ -281,7 +281,7 @@ await Task.Run(async () =>
281281
/// <summary>
282282
/// Clear the working set of all processes, excluding the exclusion list
283283
/// </summary>
284-
/// <returns>Nothing</returns>
284+
/// <returns>A Task</returns>
285285
internal async Task ClearWorkingSets()
286286
{
287287
_logController.AddLog(new ApplicationLog("Clearing process working sets"));
@@ -312,7 +312,7 @@ await Task.Run(async () =>
312312
/// <summary>
313313
/// Clear the FileSystem cache
314314
/// </summary>
315-
/// <returns>Nothing</returns>
315+
/// <returns>A Task</returns>
316316
internal async Task ClearFileSystemCaches()
317317
{
318318
_logController.AddLog(new ApplicationLog("Clearing FileSystem cache"));
@@ -357,18 +357,16 @@ private void ClearingStatistcs()
357357
message = "You saved " + ramSavings.ToString("F2") + " MB of RAM!";
358358
}
359359

360-
if (ShowStatistics)
360+
if (!ShowStatistics) return;
361+
// ReSharper disable once SwitchStatementMissingSomeCases
362+
switch (_mainWindow.Visibility)
361363
{
362-
// ReSharper disable once SwitchStatementMissingSomeCases
363-
switch (_mainWindow.Visibility)
364-
{
365-
default:
366-
MessageBox.Show(message, "MemPlus", MessageBoxButton.OK, MessageBoxImage.Information);
367-
break;
368-
case Visibility.Hidden when _mainWindow.TbiIcon.Visibility == Visibility.Visible:
369-
_mainWindow.TbiIcon.ShowBalloonTip("MemPlus", message, BalloonIcon.Info);
370-
break;
371-
}
364+
default:
365+
MessageBox.Show(message, "MemPlus", MessageBoxButton.OK, MessageBoxImage.Information);
366+
break;
367+
case Visibility.Hidden when _mainWindow.TbiIcon.Visibility == Visibility.Visible:
368+
_mainWindow.TbiIcon.ShowBalloonTip("MemPlus", message, BalloonIcon.Info);
369+
break;
372370
}
373371
}
374372

MemPlus/Business/RAM/RamData.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
namespace MemPlus.Business.RAM
22
{
33
/// <summary>
4-
/// ViewModal for displaying RAM information inside a treeview
4+
/// Class for displaying RAM information inside a treeview
55
/// </summary>
66
internal sealed class RamData
77
{

MemPlus/Business/RAM/RamStick.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
23

34
namespace MemPlus.Business.RAM
45
{
@@ -49,7 +50,7 @@ internal string GetValue(string key)
4950
{
5051
foreach(RamData r in _ramData)
5152
{
52-
if (r.Key.ToLower() == key.ToLower())
53+
if (string.Equals(r.Key, key, StringComparison.CurrentCultureIgnoreCase))
5354
{
5455
return r.Value;
5556
}

MemPlus/Business/RAM/RamSticksExporter.cs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,10 @@ internal static void ExportText(string path, List<RamStick> ramSticks)
4747
}
4848
}
4949

50-
if (index != ramSticks.Count - 1)
51-
{
52-
exportData += Environment.NewLine;
53-
exportData += "----------";
54-
exportData += Environment.NewLine;
55-
}
50+
if (index == ramSticks.Count - 1) continue;
51+
exportData += Environment.NewLine;
52+
exportData += "----------";
53+
exportData += Environment.NewLine;
5654
}
5755

5856
Export(path, exportData);
@@ -150,12 +148,10 @@ private static void ExportDelimiter(string path, string delimiter, List<RamStick
150148
}
151149
}
152150

153-
if (i != ramSticks.Count - 1)
154-
{
155-
exportData += Environment.NewLine;
156-
exportData += "----------" + delimiter + "----------";
157-
exportData += Environment.NewLine;
158-
}
151+
if (i == ramSticks.Count - 1) continue;
152+
exportData += Environment.NewLine;
153+
exportData += "----------" + delimiter + "----------";
154+
exportData += Environment.NewLine;
159155
}
160156

161157
Export(path, exportData);

MemPlus/Views/Windows/AboutWindow.xaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@
2222
<ColumnDefinition Width="Auto" />
2323
<ColumnDefinition Width="Auto" />
2424
</Grid.ColumnDefinitions>
25-
<Image Width="64" Height="64" Source="/MemPlus;component/Resources/Images/ram.png"></Image>
25+
<Image Width="64" Height="64" Source="/MemPlus;component/Resources/Images/ram.png" />
2626
<Separator Margin="5" Grid.Column="1" Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" />
2727
<TextBlock Grid.Column="2">
28-
MemPlus was created by DeadLine.<LineBreak></LineBreak>
29-
<LineBreak></LineBreak>
30-
Images: small-n-flat by paomedia<LineBreak></LineBreak>
31-
Theme: Syncfusion<LineBreak></LineBreak>
32-
Version: 1.1.0.0<LineBreak></LineBreak>
33-
<LineBreak></LineBreak>
28+
MemPlus was created by DeadLine.<LineBreak />
29+
<LineBreak />
30+
Images: small-n-flat by paomedia<LineBreak />
31+
Theme: Syncfusion<LineBreak />
32+
Version: 1.1.1.0<LineBreak />
33+
<LineBreak />
3434
Copyright © CodeDead 2018
3535
</TextBlock>
3636
</Grid>

MemPlus/Views/Windows/AnalyzerWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<Separator />
3030
<MenuItem Header="Export" Click="BtnExport_OnClick">
3131
<MenuItem.Icon>
32-
<Image Width="16" Height="16" Source="/MemPlus;component/Resources/Images/export.png"></Image>
32+
<Image Width="16" Height="16" Source="/MemPlus;component/Resources/Images/export.png" />
3333
</MenuItem.Icon>
3434
</MenuItem>
3535
<MenuItem Header="Refresh" Click="BtnRefresh_OnClick">

MemPlus/Views/Windows/LogWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<Separator />
3939
<MenuItem Header="Export" Click="BtnExport_OnClick">
4040
<MenuItem.Icon>
41-
<Image Width="16" Height="16" Source="/MemPlus;component/Resources/Images/export.png"></Image>
41+
<Image Width="16" Height="16" Source="/MemPlus;component/Resources/Images/export.png" />
4242
</MenuItem.Icon>
4343
</MenuItem>
4444
</ContextMenu>

MemPlus/Views/Windows/MainWindow.xaml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<Grid.RowDefinitions>
1717
<RowDefinition Height="Auto" />
1818
<RowDefinition Height="Auto" />
19-
<RowDefinition></RowDefinition>
19+
<RowDefinition />
2020
</Grid.RowDefinitions>
2121

2222
<tb:TaskbarIcon x:Name="TbiIcon"
@@ -104,13 +104,13 @@
104104
<MenuItem x:Name="MniRamMonitor" Header="RAM Monitor" IsCheckable="True" Checked="RamMonitorMenuItem_OnCheckedChanged" Unchecked="RamMonitorMenuItem_OnCheckedChanged" />
105105
<MenuItem Header="RAM Analyzer" Click="RamAnalyzerMenuItem_OnClick">
106106
<MenuItem.Icon>
107-
<Image Width="16" Height="16" Source="/Resources/Images/ram_tab.png"/>
107+
<Image Width="16" Height="16" Source="/Resources/Images/ram_tab.png" />
108108
</MenuItem.Icon>
109109
</MenuItem>
110110
<Separator />
111111
<MenuItem Header="Logs">
112112
<MenuItem.Icon>
113-
<Image Width="16" Height="16" Source="/Resources/Images/log.png"/>
113+
<Image Width="16" Height="16" Source="/Resources/Images/log.png" />
114114
</MenuItem.Icon>
115115
<MenuItem Header="RAM logs" Click="RamLogsMenuItem_OnClick" />
116116
<MenuItem Header="Application logs" Click="ApplicationLogsMenuItem_OnClick" />
@@ -120,50 +120,50 @@
120120
<Separator />
121121
<MenuItem Header="GUI">
122122
<MenuItem.Icon>
123-
<Image Width="16" Height="16" Source="/Resources/Images/monitor.png"/>
123+
<Image Width="16" Height="16" Source="/Resources/Images/monitor.png" />
124124
</MenuItem.Icon>
125125
<MenuItem x:Name="MniOnTop" Header="Always on top" IsCheckable="True" Checked="TopMenuItem_OnCheckedChanged" Unchecked="TopMenuItem_OnCheckedChanged" />
126126
<MenuItem x:Name="MniDisableInactive" Header="Disable when inactive" IsCheckable="True" Checked="DisableInactiveMenuItem_OnCheckedChanged" Unchecked="DisableInactiveMenuItem_OnCheckedChanged" />
127127
</MenuItem>
128128
<MenuItem Header="Settings" Click="SettingsMenuItem_OnClick">
129129
<MenuItem.Icon>
130-
<Image Width="16" Height="16" Source="/Resources/Images/settings.png"/>
130+
<Image Width="16" Height="16" Source="/Resources/Images/settings.png" />
131131
</MenuItem.Icon>
132132
</MenuItem>
133133
</MenuItem>
134134

135135
<MenuItem Header="_Help">
136136
<MenuItem Header="Help" Click="HelpMenuItem_OnClick">
137137
<MenuItem.Icon>
138-
<Image Width="16" Height="16" Source="/Resources/Images/help.png"/>
138+
<Image Width="16" Height="16" Source="/Resources/Images/help.png" />
139139
</MenuItem.Icon>
140140
</MenuItem>
141141
<Separator />
142142
<MenuItem Header="Check for updates" Click="UpdateMenuItem_OnClick">
143143
<MenuItem.Icon>
144-
<Image Width="16" Height="16" Source="/Resources/Images/update.png"/>
144+
<Image Width="16" Height="16" Source="/Resources/Images/update.png" />
145145
</MenuItem.Icon>
146146
</MenuItem>
147147
<Separator />
148148
<MenuItem Header="Homepage" Click="HomePageMenuItem_OnClick">
149149
<MenuItem.Icon>
150-
<Image Width="16" Height="16" Source="/Resources/Images/home.png"/>
150+
<Image Width="16" Height="16" Source="/Resources/Images/home.png" />
151151
</MenuItem.Icon>
152152
</MenuItem>
153153
<MenuItem Header="License" Click="LicenseMenuItem_OnClick">
154154
<MenuItem.Icon>
155-
<Image Width="16" Height="16" Source="/Resources/Images/pdf.png"/>
155+
<Image Width="16" Height="16" Source="/Resources/Images/pdf.png" />
156156
</MenuItem.Icon>
157157
</MenuItem>
158158
<Separator />
159159
<MenuItem Header="Donate" Click="DonateMenuItem_OnClick">
160160
<MenuItem.Icon>
161-
<Image Width="16" Height="16" Source="/Resources/Images/donate.png"/>
161+
<Image Width="16" Height="16" Source="/Resources/Images/donate.png" />
162162
</MenuItem.Icon>
163163
</MenuItem>
164164
<MenuItem Header="About" Click="AboutMenuItem_OnClick">
165165
<MenuItem.Icon>
166-
<Image Width="16" Height="16" Source="/Resources/Images/about.png"/>
166+
<Image Width="16" Height="16" Source="/Resources/Images/about.png" />
167167
</MenuItem.Icon>
168168
</MenuItem>
169169
</MenuItem>
@@ -209,8 +209,8 @@
209209
x:Name="BtnClearMemory" Click="BtnClearMemory_OnClick" IsMultiLine="False"
210210
MinHeight="25" HorizontalAlignment="Stretch" Margin="10,5">
211211
<syncfusion:DropDownMenuGroup>
212-
<syncfusion:DropDownMenuItem Header="Clear Working sets" Click="ClearWorkingSetsDropDownMenuItem_OnClick"/>
213-
<syncfusion:DropDownMenuItem Header="Clear FileSystem cache" Click="ClearFileSystemCacheDropDownMenuItem_OnClick"/>
212+
<syncfusion:DropDownMenuItem Header="Clear Working sets" Click="ClearWorkingSetsDropDownMenuItem_OnClick" />
213+
<syncfusion:DropDownMenuItem Header="Clear FileSystem cache" Click="ClearFileSystemCacheDropDownMenuItem_OnClick" />
214214
</syncfusion:DropDownMenuGroup>
215215
</syncfusion:SplitButtonAdv>
216216
</Grid>

MemPlus/Views/Windows/SettingsWindow.xaml

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
Title="MemPlus - Settings" Height="380" Width="450" Icon="/MemPlus;component/Resources/Images/ram.png">
1414
<Grid>
1515
<Grid.RowDefinitions>
16-
<RowDefinition></RowDefinition>
17-
<RowDefinition Height="Auto"></RowDefinition>
16+
<RowDefinition />
17+
<RowDefinition Height="Auto" />
1818
</Grid.RowDefinitions>
1919
<syncfusion:TabControlExt CloseButtonType="Hide" EnableLabelEdit="False"
2020
AllowDragDrop="False" DefaultContextMenuItemVisibility="Hidden">
@@ -23,7 +23,7 @@
2323

2424
<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
2525
<Grid.RowDefinitions>
26-
<RowDefinition Height="Auto"></RowDefinition>
26+
<RowDefinition Height="Auto" />
2727
</Grid.RowDefinitions>
2828

2929
<GroupBox Grid.Row="0" Header="MemPlus" MinWidth="250" Margin="3">
@@ -142,26 +142,26 @@
142142
<GroupBox Grid.Row="1" Header="Working Set Exclusions" MinWidth="250" Margin="3">
143143
<Grid>
144144
<Grid.RowDefinitions>
145-
<RowDefinition Height="Auto"/>
145+
<RowDefinition Height="Auto" />
146146
<RowDefinition Height="Auto" />
147147
</Grid.RowDefinitions>
148148
<ListView x:Name="LsvExclusions" Margin="3" Height="80" Width="300" AllowDrop="True" Drop="LsvExclusions_OnDrop">
149149
<ListView.ContextMenu>
150150
<ContextMenu>
151151
<MenuItem Header="Copy" Click="CopyExclusionMenuItem_OnClick">
152152
<MenuItem.Icon>
153-
<Image Width="16" Height="16" Source="/MemPlus;component/Resources/Images/log.png" ></Image>
153+
<Image Width="16" Height="16" Source="/MemPlus;component/Resources/Images/log.png" />
154154
</MenuItem.Icon>
155155
</MenuItem>
156156
<Separator />
157157
<MenuItem Header="Delete" Click="DeleteExclusionMenuItem_OnClick">
158158
<MenuItem.Icon>
159-
<Image Width="16" Height="16" Source="/MemPlus;component/Resources/Images/delete.png" ></Image>
159+
<Image Width="16" Height="16" Source="/MemPlus;component/Resources/Images/delete.png" />
160160
</MenuItem.Icon>
161161
</MenuItem>
162162
<MenuItem Header="Clear" Click="ClearExclusionsMenuItem_OnClick">
163163
<MenuItem.Icon>
164-
<Image Width="16" Height="16" Source="/MemPlus;component/Resources/Images/exit.png" ></Image>
164+
<Image Width="16" Height="16" Source="/MemPlus;component/Resources/Images/exit.png" />
165165
</MenuItem.Icon>
166166
</MenuItem>
167167
</ContextMenu>
@@ -202,21 +202,21 @@
202202
</Grid.ColumnDefinitions>
203203
<Label Margin="3" Content="Style:" />
204204
<ComboBox Margin="3" x:Name="CboStyle" SelectedValuePath="Content" Grid.Row="0" Grid.Column="1" IsReadOnly="True">
205-
<ComboBoxItem>Metro</ComboBoxItem>
206-
<ComboBoxItem>Blend</ComboBoxItem>
207-
<ComboBoxItem>VS2010</ComboBoxItem>
208-
<ComboBoxItem>Office2003</ComboBoxItem>
209-
<ComboBoxItem>Office2007Blue</ComboBoxItem>
210-
<ComboBoxItem>Office2007Black</ComboBoxItem>
211-
<ComboBoxItem>Office2007Silver</ComboBoxItem>
212-
<ComboBoxItem>Office2010Blue</ComboBoxItem>
213-
<ComboBoxItem>Office2010Black</ComboBoxItem>
214-
<ComboBoxItem>Office2010Silver</ComboBoxItem>
215-
<ComboBoxItem>ShinyRed</ComboBoxItem>
216-
<ComboBoxItem>ShinyBlue</ComboBoxItem>
217-
<ComboBoxItem>SyncOrange</ComboBoxItem>
218-
<ComboBoxItem>Transparent</ComboBoxItem>
219-
<ComboBoxItem>None</ComboBoxItem>
205+
<ComboBoxItem Content="Metro" />
206+
<ComboBoxItem Content="Blend" />
207+
<ComboBoxItem Content="VS2010" />
208+
<ComboBoxItem Content="Office2003" />
209+
<ComboBoxItem Content="Office2007Blue" />
210+
<ComboBoxItem Content="Office2007Black" />
211+
<ComboBoxItem Content="Office2007Silver" />
212+
<ComboBoxItem Content="Office2010Blue" />
213+
<ComboBoxItem Content="Office2010Black" />
214+
<ComboBoxItem Content="Office2010Silver" />
215+
<ComboBoxItem Content="ShinyRed" />
216+
<ComboBoxItem Content="ShinyBlue" />
217+
<ComboBoxItem Content="SyncOrange" />
218+
<ComboBoxItem Content="Transparent" />
219+
<ComboBoxItem Content="None" />
220220
</ComboBox>
221221
<Label Margin="3" Grid.Row="1" Grid.Column="0" Content="Metro brush:" />
222222
<syncfusion:ColorPicker Margin="3" x:Name="CpMetroBrush" Grid.Row="1" Grid.Column="1" />

0 commit comments

Comments
 (0)