Skip to content

Commit 36f600a

Browse files
committed
* Added new settings
* Code improvements
1 parent ab882e6 commit 36f600a

File tree

6 files changed

+58
-27
lines changed

6 files changed

+58
-27
lines changed

MemPlus/App.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@
5252
<setting name="AutoOptimizeTimedInterval" serializeAs="String">
5353
<value>600000</value>
5454
</setting>
55+
<setting name="HideOnStart" serializeAs="String">
56+
<value>False</value>
57+
</setting>
5558
</MemPlus.Properties.Settings>
5659
</userSettings>
5760
</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
@@ -47,5 +47,8 @@
4747
<Setting Name="AutoOptimizeTimedInterval" Type="System.Int32" Scope="User">
4848
<Value Profile="(Default)">600000</Value>
4949
</Setting>
50+
<Setting Name="HideOnStart" Type="System.Boolean" Scope="User">
51+
<Value Profile="(Default)">False</Value>
52+
</Setting>
5053
</Settings>
5154
</SettingsFile>

MemPlus/Windows/MainWindow.xaml.cs

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -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

MemPlus/Windows/SettingsWindow.xaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,14 @@
3232
<Grid.RowDefinitions>
3333
<RowDefinition Height="Auto"></RowDefinition>
3434
<RowDefinition Height="Auto"></RowDefinition>
35+
<RowDefinition Height="Auto"></RowDefinition>
36+
<RowDefinition Height="Auto"></RowDefinition>
3537
</Grid.RowDefinitions>
3638

37-
<CheckBox Grid.Row="0" x:Name="ChbAutoUpdate" Content="Automatic updates" Margin="3" />
38-
<CheckBox Grid.Row="1" x:Name="ChbTopmost" Content="Topmost" Margin="3" />
39+
<CheckBox Grid.Row="0" x:Name="ChbAutoStart" Content="Automatic start MemPlus when Windows starts" Margin="3" />
40+
<CheckBox Grid.Row="1" x:Name="ChbStartMinimized" Content="Hide MemPlus when loaded" Margin="3" />
41+
<CheckBox Grid.Row="2" x:Name="ChbAutoUpdate" Content="Automatic updates" Margin="3" />
42+
<CheckBox Grid.Row="3" x:Name="ChbTopmost" Content="Topmost" Margin="3" />
3943

4044
</Grid>
4145
</GroupBox>
@@ -121,7 +125,7 @@
121125
<RowDefinition></RowDefinition>
122126
<RowDefinition Height="Auto"></RowDefinition>
123127
</Grid.RowDefinitions>
124-
<ListView x:Name="LsvExclusions" Margin="3" Height="50" Width="250">
128+
<ListView x:Name="LsvExclusions" Margin="3" Height="100" Width="250">
125129
<ListView.ContextMenu>
126130
<ContextMenu>
127131
<MenuItem Header="Copy" Click="CopyExclusionMenuItem_OnClick">

MemPlus/Windows/SettingsWindow.xaml.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ private void LoadProperties()
6868
{
6969
//General
7070
ChbAutoUpdate.IsChecked = Properties.Settings.Default.AutoUpdate;
71+
ChbStartMinimized.IsChecked = Properties.Settings.Default.HideOnStart;
7172
if (Properties.Settings.Default.Topmost)
7273
{
7374
ChbTopmost.IsChecked = Properties.Settings.Default.Topmost;
@@ -129,6 +130,7 @@ private void SaveProperties()
129130
//General
130131
if (ChbAutoUpdate.IsChecked != null) Properties.Settings.Default.AutoUpdate = ChbAutoUpdate.IsChecked.Value;
131132
if (ChbTopmost.IsChecked != null) Properties.Settings.Default.Topmost = ChbTopmost.IsChecked.Value;
133+
if (ChbStartMinimized.IsChecked != null) Properties.Settings.Default.HideOnStart = ChbStartMinimized.IsChecked.Value;
132134

133135
//RAM Monitor
134136
if (ChbRamMonitor.IsChecked != null) Properties.Settings.Default.RamMonitor = ChbRamMonitor.IsChecked.Value;

0 commit comments

Comments
 (0)