Skip to content

Commit 45d1a76

Browse files
committed
* Added ability to check for updates
1 parent 96354d6 commit 45d1a76

File tree

5 files changed

+42
-2
lines changed

5 files changed

+42
-2
lines changed

MemPlus.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 15
4-
VisualStudioVersion = 15.0.27130.2027
4+
VisualStudioVersion = 15.0.27130.2026
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MemPlus", "MemPlus\MemPlus.csproj", "{DB7B448C-7643-4B9E-AA41-ED67DD02E3A9}"
77
EndProject

MemPlus/MemPlus.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@
5858
<Reference Include="System.Xaml">
5959
<RequiredTargetFramework>4.0</RequiredTargetFramework>
6060
</Reference>
61+
<Reference Include="UpdateManager">
62+
<HintPath>..\..\UpdateManager\UpdateManager\bin\Release\UpdateManager.dll</HintPath>
63+
</Reference>
6164
<Reference Include="WindowsBase" />
6265
<Reference Include="PresentationCore" />
6366
<Reference Include="PresentationFramework" />

MemPlus/Windows/MainWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
</MenuItem.Icon>
109109
</MenuItem>
110110
<Separator />
111-
<MenuItem Header="Check for updates">
111+
<MenuItem Header="Check for updates" Click="UpdateMenuItem_OnClick">
112112
<MenuItem.Icon>
113113
<Image Width="16" Height="16" Source="/Resources/Images/update.png"/>
114114
</MenuItem.Icon>

MemPlus/Windows/MainWindow.xaml.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Reflection;
23
using System.Windows;
34
using System.Windows.Media;
45
using MemPlus.Classes.GUI;
@@ -16,6 +17,10 @@ public partial class MainWindow
1617
{
1718
#region Variables
1819
/// <summary>
20+
/// The UpdateManager object that checks for application updates
21+
/// </summary>
22+
private readonly UpdateManager.UpdateManager _updateManager;
23+
/// <summary>
1924
/// The RamController object that can be used to clear the memory and view memory statistics
2025
/// </summary>
2126
private readonly RamController _ramController;
@@ -36,6 +41,7 @@ public partial class MainWindow
3641
public MainWindow()
3742
{
3843
_logController = new LogController(600000);
44+
_updateManager = new UpdateManager.UpdateManager(Assembly.GetExecutingAssembly().GetName().Version, "https://codedead.com/Software/MemPlus/update.xml", "MemPlus");
3945
_logController.AddLog(new ApplicationLog("Initializing MainWindow"));
4046

4147
InitializeComponent();
@@ -56,9 +62,32 @@ public MainWindow()
5662
app.Deactivated += Passive;
5763

5864
LoadProperties();
65+
AutoUpdate();
66+
5967
_logController.AddLog(new ApplicationLog("Done initializing MainWindow"));
6068
}
6169

70+
/// <summary>
71+
/// Automatically check for updates
72+
/// </summary>
73+
private void AutoUpdate()
74+
{
75+
_logController.AddLog(new ApplicationLog("Checking for application updates"));
76+
try
77+
{
78+
if (Properties.Settings.Default.AutoUpdate)
79+
{
80+
_updateManager.CheckForUpdate(false, false);
81+
}
82+
}
83+
catch (Exception ex)
84+
{
85+
_logController.AddLog(new ApplicationLog(ex.Message));
86+
MessageBox.Show(ex.Message, "MemPlus", MessageBoxButton.OK, MessageBoxImage.Error);
87+
}
88+
_logController.AddLog(new ApplicationLog("Done checking for application updates"));
89+
}
90+
6291
/// <summary>
6392
/// Load the properties into the GUI
6493
/// </summary>
@@ -488,5 +517,12 @@ private void HelpMenuItem_OnClick(object sender, RoutedEventArgs e)
488517
MessageBox.Show(ex.Message, "MemPlus", MessageBoxButton.OK, MessageBoxImage.Error);
489518
}
490519
}
520+
521+
private void UpdateMenuItem_OnClick(object sender, RoutedEventArgs e)
522+
{
523+
_logController.AddLog(new ApplicationLog("Checking for application updates"));
524+
_updateManager.CheckForUpdate(true, true);
525+
_logController.AddLog(new ApplicationLog("Done checking for application updates"));
526+
}
491527
}
492528
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ MemPlus is an entirely free, completely functional 'memory optimizer' that will
1010
* [Syncfusion](https://syncfusion.com) ([Community edition available](https://www.syncfusion.com/products/communitylicense))
1111
* [Paomedia small-n-flat](https://github.com/paomedia/small-n-flat) (Images)
1212
* [Hardcodet.NotifyIcon.Wpf](https://www.nuget.org/packages/Hardcodet.NotifyIcon.Wpf/)
13+
* [UpdateManager](https://github.com/CodeDead/UpdateManager)
1314

1415
# Anything else?
1516
Don't fall for these memory optimizers that will speed up your system by 100000% percent scams. This will actually free up your memory, but it might cost you dearly in performance and might cause system instability. Do not use these tools on any essential devices. And we, CodeDead, are not responsible for any damages that this type of software can cause to your system.

0 commit comments

Comments
 (0)