Skip to content

Commit 4a288d2

Browse files
committed
Added update checker to standalone Encrypt and Decrypt forms and fixed a typo in the Settings panel
1 parent 760e260 commit 4a288d2

10 files changed

Lines changed: 6613 additions & 29 deletions

FileAES/DecryptForm.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ namespace FAES_GUI
77
{
88
public partial class DecryptForm : Form
99
{
10+
private UpdateForm _updateForm;
11+
1012
public DecryptForm(FAES_File faesFile)
1113
{
1214
InitializeComponent();
@@ -17,6 +19,12 @@ public DecryptForm(FAES_File faesFile)
1719
decryptPanel.LockFileSelect(true);
1820
decryptPanel.setCloseAfterOperationSuccessful(true);
1921
decryptPanel.SetFileToDecrypt(faesFile);
22+
23+
if (!Program.programManager.GetSkipUpdates())
24+
{
25+
_updateForm = new UpdateForm();
26+
_updateForm.CheckForUpdate();
27+
}
2028
}
2129

2230
private void titleBar_Paint(object sender, PaintEventArgs e)

FileAES/EncryptForm.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
using FAES;
22
using System;
33
using System.Drawing;
4+
using System.Threading;
45
using System.Windows.Forms;
56

67
namespace FAES_GUI
78
{
89
public partial class EncryptForm : Form
910
{
11+
private UpdateForm _updateForm;
12+
1013
public EncryptForm(FAES_File faesFile)
1114
{
1215
InitializeComponent();
@@ -17,6 +20,12 @@ public EncryptForm(FAES_File faesFile)
1720
encryptPanel.LockFileSelect(true);
1821
encryptPanel.setCloseAfterOperationSuccessful(true);
1922
encryptPanel.SetFileToEncrypt(faesFile);
23+
24+
if (!Program.programManager.GetSkipUpdates())
25+
{
26+
_updateForm = new UpdateForm();
27+
_updateForm.CheckForUpdate();
28+
}
2029
}
2130

2231
private void titleBar_Paint(object sender, PaintEventArgs e)

FileAES/FileAES.csproj

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@
9191
<Compile Include="CustomControls\TextProgressBar.cs">
9292
<SubType>Component</SubType>
9393
</Compile>
94+
<Compile Include="UpdateForm.cs">
95+
<SubType>Form</SubType>
96+
</Compile>
97+
<Compile Include="UpdateForm.Designer.cs">
98+
<DependentUpon>UpdateForm.cs</DependentUpon>
99+
</Compile>
94100
<Compile Include="DevForm.cs">
95101
<SubType>Form</SubType>
96102
</Compile>
@@ -158,6 +164,9 @@
158164
<EmbeddedResource Include="CustomControls\SubMenuButton.resx">
159165
<DependentUpon>SubMenuButton.cs</DependentUpon>
160166
</EmbeddedResource>
167+
<EmbeddedResource Include="UpdateForm.resx">
168+
<DependentUpon>UpdateForm.cs</DependentUpon>
169+
</EmbeddedResource>
161170
<EmbeddedResource Include="DevForm.resx">
162171
<DependentUpon>DevForm.cs</DependentUpon>
163172
</EmbeddedResource>
@@ -229,7 +238,7 @@
229238
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
230239
</PropertyGroup>
231240
<Error Condition="!Exists('..\packages\Costura.Fody.4.1.0\build\Costura.Fody.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.4.1.0\build\Costura.Fody.props'))" />
232-
<Error Condition="!Exists('..\packages\Fody.6.2.6\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.6.2.6\build\Fody.targets'))" />
241+
<Error Condition="!Exists('..\packages\Fody.6.3.0\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.6.3.0\build\Fody.targets'))" />
233242
</Target>
234-
<Import Project="..\packages\Fody.6.2.6\build\Fody.targets" Condition="Exists('..\packages\Fody.6.2.6\build\Fody.targets')" />
243+
<Import Project="..\packages\Fody.6.3.0\build\Fody.targets" Condition="Exists('..\packages\Fody.6.3.0\build\Fody.targets')" />
235244
</Project>

FileAES/MenuPanels/SettingsPanel.Designer.cs

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FileAES/MenuPanels/aboutPanel.cs

Lines changed: 48 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public partial class aboutPanel : UserControl
1717
private string _latestVersion, _lastCheckedBranch;
1818
private bool _updateThreadRunning = false;
1919
private bool _updateUI = false;
20+
private bool _isUpdate = false;
2021

2122
private Action _onIsUpdateAction;
2223

@@ -26,9 +27,7 @@ public aboutPanel()
2627

2728
miscVersionLabel.Text = String.Format("FAES Version: {0}\n\rSSM Version: {1}", ConvertVersionToFormatted(FAES.FileAES_Utilities.GetVersion()), ConvertVersionToFormatted(SimpleSettingsManager.SSM.GetVersion()));
2829
GetCurrentVersion();
29-
CheckForUpdate();
3030
}
31-
3231
public enum UpdateStatus
3332
{
3433
ServerError,
@@ -37,6 +36,11 @@ public enum UpdateStatus
3736
AppNewer
3837
};
3938

39+
public bool IsUpdate()
40+
{
41+
return _isUpdate;
42+
}
43+
4044
private void GetCurrentVersion()
4145
{
4246
currentVerLabel.Text = Program.GetVersion();
@@ -69,6 +73,7 @@ private void UpdateUI()
6973
reinstallCurrentButton.Enabled = true;
7074
updateDescLabel.Text = "You are on the latest version!";
7175
latestVerLabel.Text = latestVersion;
76+
_isUpdate = false;
7277

7378
Logging.Log(String.Format("FAES_GUI(AboutPanel): UpdateUI set to AppLatest."), Severity.DEBUG);
7479
}
@@ -82,6 +87,7 @@ private void UpdateUI()
8287
reinstallCurrentButton.Enabled = false;
8388
updateDescLabel.Text = "You are on a private build.";
8489
latestVerLabel.Text = latestVersion;
90+
_isUpdate = false;
8591

8692
Logging.Log(String.Format("FAES_GUI(AboutPanel): UpdateUI set to AppNewer."), Severity.DEBUG);
8793
}
@@ -95,6 +101,7 @@ private void UpdateUI()
95101
reinstallCurrentButton.Enabled = false;
96102
updateDescLabel.Text = "Unable to connect to the update server.";
97103
latestVerLabel.Text = "SERVER ERROR!";
104+
_isUpdate = false;
98105

99106
Logging.Log(String.Format("FAES_GUI(AboutPanel): UpdateUI set to ServerError."), Severity.DEBUG);
100107
}
@@ -108,6 +115,7 @@ private void UpdateUI()
108115
reinstallCurrentButton.Enabled = true;
109116
updateDescLabel.Text = "An update is available!";
110117
latestVerLabel.Text = latestVersion;
118+
_isUpdate = true;
111119

112120
Logging.Log(String.Format("FAES_GUI(AboutPanel): UpdateUI set to AppOutdated."), Severity.DEBUG);
113121
}
@@ -161,32 +169,45 @@ private bool DoesVersionExist(string version, string branch)
161169

162170
public void CheckForUpdate()
163171
{
164-
if (!_updateThreadRunning)
172+
try
165173
{
166-
_updateThreadRunning = true;
167-
168-
Thread threaddedUpdateCheck = new Thread(() =>
174+
if (!_updateThreadRunning)
169175
{
170-
string updateVersion;
176+
_updateThreadRunning = true;
171177

172-
Logging.Log(String.Format("Checking for update..."), Severity.DEBUG);
173-
UpdateStatus updateInfo = GetUpdateStatus(out updateVersion);
178+
Thread threaddedUpdateCheck = new Thread(() =>
179+
{
180+
try
181+
{
182+
string updateVersion;
174183

175-
if (updateVersion != "v0.0.0")
176-
Logging.Log(String.Format("Latest FAES_GUI version: {0}", updateVersion), Severity.DEBUG);
177-
else
178-
Logging.Log(String.Format("Update check failed!"), Severity.WARN);
184+
Logging.Log(String.Format("Checking for update..."), Severity.DEBUG);
185+
UpdateStatus updateInfo = GetUpdateStatus(out updateVersion);
179186

180-
_appUpdateStatus = updateInfo;
181-
_latestVersion = updateVersion;
182-
_lastCheckedBranch = Program.programManager.GetBranch();
183-
_updateUI = true;
184-
_updateThreadRunning = false;
187+
if (updateVersion != "v0.0.0")
188+
Logging.Log(String.Format("Latest FAES_GUI version: {0}", updateVersion), Severity.DEBUG);
189+
else
190+
Logging.Log(String.Format("Update check failed!"), Severity.WARN);
185191

186-
if (_appUpdateStatus == UpdateStatus.AppOutdated && !Program.programManager.GetSkipUpdates()) DoIsUpdateAction();
187-
});
188-
threaddedUpdateCheck.Start();
192+
_appUpdateStatus = updateInfo;
193+
_latestVersion = updateVersion;
194+
_lastCheckedBranch = Program.programManager.GetBranch();
195+
_updateUI = true;
196+
_updateThreadRunning = false;
197+
198+
if (_appUpdateStatus == UpdateStatus.AppOutdated && !Program.programManager.GetSkipUpdates()) DoIsUpdateAction();
199+
}
200+
catch { } // Hacky solution to stop VS2019 crashing when viewing some forms...
201+
});
202+
threaddedUpdateCheck.Start();
203+
}
189204
}
205+
catch { } // Hacky solution to stop VS2019 crashing when viewing some forms...
206+
}
207+
208+
public bool IsUpdateCheckRunning()
209+
{
210+
return _updateThreadRunning;
190211
}
191212

192213
public void SetIsUpdateAction(Action action)
@@ -427,8 +448,12 @@ private static void RunAsAdmin()
427448

428449
private void Runtime_Tick(object sender, EventArgs e)
429450
{
430-
if (_updateThreadRunning || _updateUI) UpdateUI();
431-
if (Program.programManager.GetBranch() != _lastCheckedBranch) CheckForUpdate();
451+
try
452+
{
453+
if (_updateThreadRunning || _updateUI) UpdateUI();
454+
if (Program.programManager.GetBranch() != _lastCheckedBranch) CheckForUpdate();
455+
}
456+
catch { } // Hacky solution to stop VS2019 crashing when viewing some forms...
432457
}
433458

434459
private void UpdatePanel_Paint(object sender, PaintEventArgs e)

FileAES/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace FAES_GUI
1414
static class Program
1515
{
1616
private const string devAppendTag = "";
17-
private const string betaAppendTag = "BETA 6";
17+
private const string betaAppendTag = "BETA 7";
1818

1919
private static bool _verbose = false;
2020
private static bool _purgeTemp = false;

FileAES/UpdateForm.Designer.cs

Lines changed: 151 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)