Skip to content

Commit e8e93f9

Browse files
committed
Updated to 4.5
1 parent f49b886 commit e8e93f9

File tree

6 files changed

+58
-10
lines changed

6 files changed

+58
-10
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [4.5] - 2018-10-08
6+
- Improved: You can now update the app automatically by clicking Check for update in Options
7+
58
## [4.4] - 2018-09-21
69
- Improved: Disable Automatic Updates (Windows 10)
710
- Added: Make HOSTS file read-only

Optimizer/AboutForm.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ private void t2_Tick(object sender, EventArgs e)
150150

151151
private void l2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
152152
{
153-
Process.Start("https://carcinos.eu/deadmoon");
153+
Process.Start("https://github.com/hellzerg/optimizer");
154154
}
155155
}
156156
}

Optimizer/MainForm.cs

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public partial class MainForm : Form
3333
DesktopTypePosition _desktopItemPosition = DesktopTypePosition.Top;
3434

3535
readonly string _latestVersionLink = "https://raw.githubusercontent.com/hellzerg/optimizer/master/version.txt";
36-
readonly string _releasesLink = "https://github.com/hellzerg/optimizer/releases";
3736
readonly string _changelogLink = "https://github.com/hellzerg/optimizer/blob/master/CHANGELOG.md";
3837

3938
readonly string _noNewVersionMessage = "You already have the latest version!";
@@ -49,9 +48,14 @@ public partial class MainForm : Form
4948
readonly string _errorModernAppsMessage = "The following app(s) couldn't be uninstalled:\n";
5049
readonly string _resetMessage = "Are you sure you want to reset configuration?\n\nThis will reset all your preferences, including any icons you extracted or downloaded using Integrator, but will not touch anything on your computer!";
5150

52-
private string NewVersionMessage(string latest)
51+
private string NewVersionMessage(string latestVersion)
5352
{
54-
return string.Format("There is a new version available!\n\nLatest version: {0}\nCurrent version: {1}\n\nDo you want to download it now?", latest, Program.GetCurrentVersionTostring());
53+
return string.Format("There is a new version available!\n\nLatest version: {0}\nCurrent version: {1}\n\nDo you want to download it now?", latestVersion, Program.GetCurrentVersionTostring());
54+
}
55+
56+
private string NewDownloadLink(string latestVersion)
57+
{
58+
return string.Format("https://github.com/hellzerg/optimizer/releases/download/{0}/Optimizer-{0}.exe", latestVersion);
5559
}
5660

5761
private void CheckForUpdate()
@@ -77,11 +81,45 @@ private void CheckForUpdate()
7781
{
7882
if (MessageBox.Show(NewVersionMessage(latestVersion), "Update available", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
7983
{
84+
// PATCHING PROCESS
8085
try
8186
{
82-
Process.Start(_releasesLink);
87+
Assembly currentAssembly = Assembly.GetEntryAssembly();
88+
89+
if (currentAssembly == null)
90+
{
91+
currentAssembly = Assembly.GetCallingAssembly();
92+
}
93+
94+
string appFolder = Path.GetDirectoryName(currentAssembly.Location);
95+
string appName = Path.GetFileNameWithoutExtension(currentAssembly.Location);
96+
string appExtension = Path.GetExtension(currentAssembly.Location);
97+
98+
string archiveFile = Path.Combine(appFolder, appName + "_old" + appExtension);
99+
string appFile = Path.Combine(appFolder, appName + appExtension);
100+
string tempFile = Path.Combine(appFolder, appName + "_tmp" + appExtension);
101+
102+
// DOWNLOAD NEW VERSION
103+
client.DownloadFile(NewDownloadLink(latestVersion), tempFile);
104+
105+
// DELETE PREVIOUS BACK-UP
106+
if (File.Exists(archiveFile))
107+
{
108+
File.Delete(archiveFile);
109+
}
110+
111+
// MAKE BACK-UP
112+
File.Move(appFile, archiveFile);
113+
114+
// PATCH
115+
File.Move(tempFile, appFile);
116+
117+
Application.Restart();
118+
}
119+
catch (Exception ex)
120+
{
121+
MessageBox.Show(ex.Message);
83122
}
84-
catch { }
85123
}
86124
}
87125
else if (float.Parse(latestVersion) == Program.GetCurrentVersion())
@@ -95,6 +133,11 @@ private void CheckForUpdate()
95133
}
96134
}
97135

136+
private void Patch()
137+
{
138+
139+
}
140+
98141
private void EnableToggleEvents()
99142
{
100143
toggleSwitch12.Click += new EventHandler(toggleSwitch12_Click);
@@ -220,6 +263,8 @@ public MainForm()
220263
CheckForIllegalCrossThreadCalls = false;
221264
Options.ApplyTheme(this);
222265

266+
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
267+
223268
if (Utilities.CurrentWindowsVersion == WindowsVersion.Unsupported)
224269
{
225270
tabCollection.TabPages.Remove(universalTab);

Optimizer/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ static class Program
1818

1919
// Enter current version here
2020
internal readonly static float Major = 4;
21-
internal readonly static float Minor = 4;
21+
internal readonly static float Minor = 5;
2222

2323
internal static string GetCurrentVersionTostring()
2424
{

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ https://github.com/hellzerg/optimizer/blob/master/IMAGES.md
3737

3838
## Details: ##
3939

40-
* Latest version: 4.4
41-
* Released: September 21, 2018
40+
* Latest version: 4.5
41+
* Released: October 8, 2018

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.4
1+
4.5

0 commit comments

Comments
 (0)