diff --git a/Pilz.Updating.Client.GUI/Pilz.Updating.Client.GUI.csproj b/Pilz.Updating.Client.GUI/Pilz.Updating.Client.GUI.csproj
index 810e57f..13354f3 100644
--- a/Pilz.Updating.Client.GUI/Pilz.Updating.Client.GUI.csproj
+++ b/Pilz.Updating.Client.GUI/Pilz.Updating.Client.GUI.csproj
@@ -11,10 +11,14 @@
-
+
True
True
- LangRes.resx
+ GeneralLangRes.resx
+
+
+
+ Form
SimpleActionDialog.cs
@@ -22,12 +26,22 @@
Form
+
+ UpdateInstallerLangRes.de.resx
+ True
+ True
+
+
+ UpdateInstallerLangRes.resx
+ True
+ True
+
UpdatesAvailableDialog.cs
Form
-
+
True
True
UpdatingClientGuiLangRes.resx
@@ -35,9 +49,9 @@
-
+
ResXFileCodeGenerator
- LangRes.Designer.cs
+ GeneralLangRes.Designer.cs
SimpleActionDialog.cs
@@ -45,17 +59,27 @@
SimpleActionDialog.cs
+
+ Pilz.Updating.UpdateInstaller.My.Resources
+ UpdateInstallerLangRes.de.Designer.cs
+ ResXFileCodeGenerator
+
+
+ Pilz.Updating.UpdateInstaller.My.Resources
+ UpdateInstallerLangRes.Designer.cs
+ ResXFileCodeGenerator
+
UpdatesAvailableDialog.cs
UpdatesAvailableDialog.cs
-
+
Pilz.Updating.Client.GUI
-
+
Pilz.Updating.Client.GUI
ResXFileCodeGenerator
UpdatingClientGuiLangRes.Designer.cs
@@ -65,7 +89,6 @@
-
diff --git a/Pilz.Updating.Client.GUI/SimpleActionDialog.Designer.cs b/Pilz.Updating.Client.GUI/SimpleActionDialog.Designer.cs
index 0fb3156..3f7193a 100644
--- a/Pilz.Updating.Client.GUI/SimpleActionDialog.Designer.cs
+++ b/Pilz.Updating.Client.GUI/SimpleActionDialog.Designer.cs
@@ -1,7 +1,7 @@
using System.Diagnostics;
using System.Runtime.CompilerServices;
-namespace Pilz.Updating.Client.GUI
+namespace Pilz.Updating.Client.Gui
{
[Microsoft.VisualBasic.CompilerServices.DesignerGenerated()]
public partial class SimpleActionDialog : Telerik.WinControls.UI.RadForm
diff --git a/Pilz.Updating.Client.GUI/SimpleActionDialog.cs b/Pilz.Updating.Client.GUI/SimpleActionDialog.cs
index 8a7e964..1fd7592 100644
--- a/Pilz.Updating.Client.GUI/SimpleActionDialog.cs
+++ b/Pilz.Updating.Client.GUI/SimpleActionDialog.cs
@@ -1,4 +1,4 @@
-namespace Pilz.Updating.Client.GUI;
+namespace Pilz.Updating.Client.Gui;
public partial class SimpleActionDialog
{
diff --git a/Pilz.Updating.Client.GUI/UpdateClientGUI.cs b/Pilz.Updating.Client.GUI/UpdateClientGUI.cs
index 6909c45..156074c 100644
--- a/Pilz.Updating.Client.GUI/UpdateClientGUI.cs
+++ b/Pilz.Updating.Client.GUI/UpdateClientGUI.cs
@@ -1,18 +1,19 @@
-using Microsoft.VisualBasic.CompilerServices;
-using Pilz.UI;
+using Pilz.UI;
using Pilz.UI.Telerik.Dialogs;
+using Pilz.Updating.Client.Gui.LangRes;
+using Pilz.Updating.Client.GUI;
using Pilz.Updating.GUIBase;
using System.ComponentModel;
using Telerik.WinControls;
-namespace Pilz.Updating.Client.GUI;
+namespace Pilz.Updating.Client.Gui;
-public class UpdateClientGUI
+public class UpdateClientGui
{
// F i e l d s
private Form parentForm;
- private SimpleActionDialog curProgressDialog;
+ private UpdateWindow curProgressDialog;
private readonly UpdateClient updateClient;
// P r o p e r t i e s
@@ -23,23 +24,15 @@ public class UpdateClientGUI
// C o n s t r u c t o r s
- public UpdateClientGUI(UpdateClient updateClient)
+ public UpdateClientGui(UpdateClient updateClient)
{
this.updateClient = updateClient;
- updateClient.UpdateStatusChanged += MyUpdateClient_UpdateStatusChanged;
- updateClient.DownloadingUpdate += MyUpdateClient_DownloadingUpdate;
- updateClient.InstallingUpdate += MyUpdateClient_InstallingUpdate;
- updateClient.UpdateInstallerStarted += MyUpdateClient_FinishWork;
- updateClient.NoUpdatesFound += MyUpdateClient_NoUpdatesFound;
+ updateClient.OnStatusChanged += UpdateClient_OnStatusChanged;
}
- ~UpdateClientGUI()
+ ~UpdateClientGui()
{
- updateClient.UpdateStatusChanged -= MyUpdateClient_UpdateStatusChanged;
- updateClient.DownloadingUpdate -= MyUpdateClient_DownloadingUpdate;
- updateClient.InstallingUpdate -= MyUpdateClient_InstallingUpdate;
- updateClient.UpdateInstallerStarted -= MyUpdateClient_FinishWork;
- updateClient.NoUpdatesFound -= MyUpdateClient_NoUpdatesFound;
+ updateClient.OnStatusChanged -= UpdateClient_OnStatusChanged;
}
// F e a t u r e s
@@ -52,33 +45,81 @@ public class UpdateClientGUI
private void EndUpdating()
{
- curProgressDialog?.Invoke(new Action(() => curProgressDialog.Close()));
+ curProgressDialog?.Invoke(curProgressDialog.Close);
}
- private void MyUpdateClient_UpdateStatusChanged(UpdateStatus newStatus)
+ // E v e n t s
+
+ private void UpdateClient_OnStatusChanged(object sender, UpdateStatusEventArgs e)
{
- bool useGui = false;
- if (!(newStatus == UpdateStatus.Searching && UseHiddenSearch))
+ void setStatus()
+ {
+ if (e.Event == UpdateStatusEvent.PreEvent)
+ SetStatus(e.Status);
+ }
+
+ switch (e.Status)
+ {
+ case UpdateStatus.Downloading:
+ setStatus();
+ if (e.Event == UpdateStatusEvent.PostEvent)
+ {
+ if (e.Client.UpdatePackageInfo == null && !UseHiddenSearch)
+ RadMessageBox.Show(UpdatingClientGuiLangRes.MsgBox_NoUpdatesFound, UpdatingClientGuiLangRes.MsgBox_NoUpdatesFound_Titel, MessageBoxButtons.OK, RadMessageIcon.Info);
+
+ if (e.Client.UpdatePackageInfo != null && !ShowUpdatesAvailable(e.Client.UpdatePackageInfo))
+ e.Cancel = true;
+ }
+ break;
+ }
+
+ switch (e.Status)
+ {
+ case UpdateStatus.Downloading:
+ case UpdateStatus.Extracting:
+ case UpdateStatus.Copying:
+ case UpdateStatus.Cleanup:
+ case UpdateStatus.Waiting:
+ setStatus();
+ break;
+ }
+
+ switch (e.Status)
+ {
+ case UpdateStatus.Done:
+ case UpdateStatus.Failed:
+ case UpdateStatus.Canceled:
+ EndUpdating();
+ break;
+ }
+ }
+
+ private void SetStatus(UpdateStatus status)
+ {
+ var useGui = false;
+
+ if (!(status == UpdateStatus.Searching && UseHiddenSearch))
{
useGui = true;
}
if (useGui && curProgressDialog is null)
{
- parentForm.Invoke(new Action(() =>
+ parentForm.Invoke(() =>
{
- curProgressDialog = new SimpleActionDialog();
- curProgressDialog.SetCurrentState(UpdateStatus.Waiting);
+ curProgressDialog = new UpdateWindow();
+ curProgressDialog.SetStatus(UpdateStatus.Waiting);
curProgressDialog.Show(parentForm);
- }));
+ });
}
- curProgressDialog?.Invoke(new Action(() => curProgressDialog.SetCurrentState(newStatus)));
+ curProgressDialog?.Invoke(() => curProgressDialog.SetStatus(status));
}
- private void MyUpdateClient_DownloadingUpdate(UpdatePackageInfo pkg, CancelEventArgs e)
+ private bool ShowUpdatesAvailable(UpdatePackageInfo pkg)
{
var dres = default(DialogResult);
+ bool cancel;
// Hide progress dialog
curProgressDialog?.Invoke(new Action(curProgressDialog.Hide));
@@ -97,38 +138,22 @@ public class UpdateClientGUI
pkg.Notes,
updateClient.InstallAsAdmin);
var symbol = GlobalSymbolFactory.Instance.GetImage(GlobalSymbols.software_installer, UI.Telerik.SvgImageSize.Small).ToIcon();
- dres = RadDialogBase.ShowDialog(dialog, parentForm, LangRes.Title_UpdatesAvailable, symbol).Result;
+ dres = RadDialogBase.ShowDialog(dialog, parentForm, GeneralLangRes.Title_UpdatesAvailable, symbol).Result;
});
if (dres != DialogResult.OK)
{
- // Finish updating
- e.Cancel = true;
+ // Cancel
+ cancel = true;
EndUpdating();
}
else
{
- // Cancel
- e.Cancel = false;
+ // Continue
+ cancel = false;
curProgressDialog?.Invoke(new Action(curProgressDialog.Show));
}
- }
- private void MyUpdateClient_InstallingUpdate(UpdatePackageInfo pkg, CancelEventArgs e)
- {
- e.Cancel = false;
- }
-
- private void MyUpdateClient_FinishWork()
- {
- EndUpdating();
- }
-
- private void MyUpdateClient_NoUpdatesFound()
- {
- EndUpdating();
-
- if (!UseHiddenSearch)
- RadMessageBox.Show(UpdatingClientGuiLangRes.MsgBox_NoUpdatesFound, UpdatingClientGuiLangRes.MsgBox_NoUpdatesFound_Titel, MessageBoxButtons.OK, RadMessageIcon.Info);
+ return cancel;
}
}
\ No newline at end of file
diff --git a/Pilz.Updating.Client.GUI/LangRes.Designer.cs b/Pilz.Updating.Client.Gui/LangRes/GeneralLangRes.Designer.cs
similarity index 95%
rename from Pilz.Updating.Client.GUI/LangRes.Designer.cs
rename to Pilz.Updating.Client.Gui/LangRes/GeneralLangRes.Designer.cs
index 2034eed..7a3ea43 100644
--- a/Pilz.Updating.Client.GUI/LangRes.Designer.cs
+++ b/Pilz.Updating.Client.Gui/LangRes/GeneralLangRes.Designer.cs
@@ -8,7 +8,7 @@
//
//------------------------------------------------------------------------------
-namespace Pilz.Updating.Client.GUI {
+namespace Pilz.Updating.Client.Gui.LangRes {
using System;
@@ -22,14 +22,14 @@ namespace Pilz.Updating.Client.GUI {
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class LangRes {
+ internal class GeneralLangRes {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal LangRes() {
+ internal GeneralLangRes() {
}
///
@@ -39,7 +39,7 @@ namespace Pilz.Updating.Client.GUI {
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Pilz.Updating.Client.GUI.LangRes", typeof(LangRes).Assembly);
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Pilz.Updating.Client.Gui.LangRes.GeneralLangRes", typeof(GeneralLangRes).Assembly);
resourceMan = temp;
}
return resourceMan;
diff --git a/Pilz.Updating.Client.GUI/LangRes.resx b/Pilz.Updating.Client.Gui/LangRes/GeneralLangRes.resx
similarity index 100%
rename from Pilz.Updating.Client.GUI/LangRes.resx
rename to Pilz.Updating.Client.Gui/LangRes/GeneralLangRes.resx
diff --git a/Pilz.Updating.UpdateInstaller/UpdateInstallerGuiLangRes.Designer.cs b/Pilz.Updating.Client.Gui/LangRes/UpdateInstallerLangRes.Designer.cs
similarity index 96%
rename from Pilz.Updating.UpdateInstaller/UpdateInstallerGuiLangRes.Designer.cs
rename to Pilz.Updating.Client.Gui/LangRes/UpdateInstallerLangRes.Designer.cs
index 97ccb12..d93dfe4 100644
--- a/Pilz.Updating.UpdateInstaller/UpdateInstallerGuiLangRes.Designer.cs
+++ b/Pilz.Updating.Client.Gui/LangRes/UpdateInstallerLangRes.Designer.cs
@@ -22,14 +22,14 @@ namespace Pilz.Updating.UpdateInstaller.My.Resources {
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class UpdateInstallerGuiLangRes {
+ internal class UpdateInstallerLangRes {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal UpdateInstallerGuiLangRes() {
+ internal UpdateInstallerLangRes() {
}
///
@@ -39,7 +39,7 @@ namespace Pilz.Updating.UpdateInstaller.My.Resources {
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Pilz.Updating.UpdateInstaller.UpdateInstallerGuiLangRes", typeof(UpdateInstallerGuiLangRes).Assembly);
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Pilz.Updating.Client.Gui.LangRes.UpdateInstallerLangRes", typeof(UpdateInstallerLangRes).Assembly);
resourceMan = temp;
}
return resourceMan;
diff --git a/Pilz.Updating.UpdateInstaller/UpdateInstallerGuiLangRes.de.Designer.cs b/Pilz.Updating.Client.Gui/LangRes/UpdateInstallerLangRes.de.Designer.cs
similarity index 100%
rename from Pilz.Updating.UpdateInstaller/UpdateInstallerGuiLangRes.de.Designer.cs
rename to Pilz.Updating.Client.Gui/LangRes/UpdateInstallerLangRes.de.Designer.cs
diff --git a/Pilz.Updating.UpdateInstaller/UpdateInstallerGuiLangRes.de.resx b/Pilz.Updating.Client.Gui/LangRes/UpdateInstallerLangRes.de.resx
similarity index 100%
rename from Pilz.Updating.UpdateInstaller/UpdateInstallerGuiLangRes.de.resx
rename to Pilz.Updating.Client.Gui/LangRes/UpdateInstallerLangRes.de.resx
diff --git a/Pilz.Updating.UpdateInstaller/UpdateInstallerGuiLangRes.resx b/Pilz.Updating.Client.Gui/LangRes/UpdateInstallerLangRes.resx
similarity index 100%
rename from Pilz.Updating.UpdateInstaller/UpdateInstallerGuiLangRes.resx
rename to Pilz.Updating.Client.Gui/LangRes/UpdateInstallerLangRes.resx
diff --git a/Pilz.Updating.Client.GUI/UpdatingClientGuiLangRes.Designer.cs b/Pilz.Updating.Client.Gui/LangRes/UpdatingClientGuiLangRes.Designer.cs
similarity index 98%
rename from Pilz.Updating.Client.GUI/UpdatingClientGuiLangRes.Designer.cs
rename to Pilz.Updating.Client.Gui/LangRes/UpdatingClientGuiLangRes.Designer.cs
index ca2e014..9e58932 100644
--- a/Pilz.Updating.Client.GUI/UpdatingClientGuiLangRes.Designer.cs
+++ b/Pilz.Updating.Client.Gui/LangRes/UpdatingClientGuiLangRes.Designer.cs
@@ -39,7 +39,7 @@ namespace Pilz.Updating.Client.GUI {
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Pilz.Updating.Client.GUI.UpdatingClientGuiLangRes", typeof(UpdatingClientGuiLangRes).Assembly);
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Pilz.Updating.Client.Gui.LangRes.UpdatingClientGuiLangRes", typeof(UpdatingClientGuiLangRes).Assembly);
resourceMan = temp;
}
return resourceMan;
diff --git a/Pilz.Updating.Client.GUI/UpdatingClientGuiLangRes.de.resx b/Pilz.Updating.Client.Gui/LangRes/UpdatingClientGuiLangRes.de.resx
similarity index 100%
rename from Pilz.Updating.Client.GUI/UpdatingClientGuiLangRes.de.resx
rename to Pilz.Updating.Client.Gui/LangRes/UpdatingClientGuiLangRes.de.resx
diff --git a/Pilz.Updating.Client.GUI/UpdatingClientGuiLangRes.resx b/Pilz.Updating.Client.Gui/LangRes/UpdatingClientGuiLangRes.resx
similarity index 100%
rename from Pilz.Updating.Client.GUI/UpdatingClientGuiLangRes.resx
rename to Pilz.Updating.Client.Gui/LangRes/UpdatingClientGuiLangRes.resx
diff --git a/Pilz.Updating.UpdateInstaller/Pilz.Updating.UpdateInstaller.csproj b/Pilz.Updating.Client.Gui/Pilz - Backup.Updating.Client.GUI.csproj
similarity index 52%
rename from Pilz.Updating.UpdateInstaller/Pilz.Updating.UpdateInstaller.csproj
rename to Pilz.Updating.Client.Gui/Pilz - Backup.Updating.Client.GUI.csproj
index 42531c6..0e36402 100644
--- a/Pilz.Updating.UpdateInstaller/Pilz.Updating.UpdateInstaller.csproj
+++ b/Pilz.Updating.Client.Gui/Pilz - Backup.Updating.Client.GUI.csproj
@@ -1,108 +1,119 @@
- WinExe
net8.0-windows
true
enable
- false
-
+
3.0.0
-
-
- Main.cs
+
+ True
+ True
+ LangRes.resx
+
+
Form
-
- True
- True
- MyIcons.resx
+
+ Form
-
- True
- True
- Resources.resx
+
+ SimpleActionDialog.cs
-
- True
- Settings.settings
- True
+
+ Form
UpdateInstallerGuiLangRes.de.resx
- True
True
+ True
+ UpdateInstallerGuiLangRes.resx
+ True
+ True
+
+
+
+ UpdatesAvailableDialog.cs
+ Form
+
+
True
True
- UpdateInstallerGuiLangRes.resx
+ UpdatingClientGuiLangRes.resx
+
+ ResXFileCodeGenerator
+ LangRes.Designer.cs
+
Main.cs
-
- ResXFileCodeGenerator
- MyIcons.Designer.cs
+
+ SimpleActionDialog.cs
-
- ResXFileCodeGenerator
- Resources.Designer.cs
- Pilz.Updating.UpdateInstaller.My.Resources
- Designer
+
+ SimpleActionDialog.cs
- ResXFileCodeGenerator
- UpdateInstallerGuiLangRes.de.Designer.cs
Pilz.Updating.UpdateInstaller.My.Resources
+ UpdateInstallerGuiLangRes.de.Designer.cs
+ ResXFileCodeGenerator
Pilz.Updating.UpdateInstaller.My.Resources
- ResXFileCodeGenerator
UpdateInstallerGuiLangRes.Designer.cs
+ ResXFileCodeGenerator
+
+
+ UpdatesAvailableDialog.cs
+
+
+ UpdatesAvailableDialog.cs
+
+
+
+ Pilz.Updating.Client.GUI
+
+
+ Pilz.Updating.Client.GUI
+ ResXFileCodeGenerator
+ UpdatingClientGuiLangRes.Designer.cs
-
- SettingsSingleFileGenerator
- Pilz.Updating.UpdateInstaller.My
- Settings.Designer.cs
-
-
-
-
-
-
-
-
-
+
+
-
+
-
-
+
+
-
-
-
-
+
+
+
+
+
-
+
+
@@ -113,7 +124,6 @@
-
-
+
\ No newline at end of file
diff --git a/Pilz.Updating.UpdateInstaller/Main.Designer.cs b/Pilz.Updating.Client.Gui/UpdateWindow.Designer.cs
similarity index 81%
rename from Pilz.Updating.UpdateInstaller/Main.Designer.cs
rename to Pilz.Updating.Client.Gui/UpdateWindow.Designer.cs
index 2f6b2c1..3a9f0e2 100644
--- a/Pilz.Updating.UpdateInstaller/Main.Designer.cs
+++ b/Pilz.Updating.Client.Gui/UpdateWindow.Designer.cs
@@ -1,11 +1,10 @@
using Microsoft.VisualBasic.CompilerServices;
using System.Diagnostics;
-using System.Runtime.CompilerServices;
-namespace Pilz.Updating.UpdateInstaller
+namespace Pilz.Updating.Client.Gui
{
[DesignerGenerated()]
- public partial class Main : Telerik.WinControls.UI.RadForm
+ public partial class UpdateWindow
{
// Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen.
@@ -34,13 +33,13 @@ namespace Pilz.Updating.UpdateInstaller
[DebuggerStepThrough()]
private void InitializeComponent()
{
- System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Main));
- _Panel1 = new Panel();
+ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(UpdateWindow));
+ panel1 = new Panel();
radWaitingBar1 = new Telerik.WinControls.UI.RadWaitingBar();
dotsLineWaitingBarIndicatorElement1 = new Telerik.WinControls.UI.DotsLineWaitingBarIndicatorElement();
radLabel_Status = new Telerik.WinControls.UI.RadLabel();
radLabel_Header = new Telerik.WinControls.UI.RadLabel();
- _Panel1.SuspendLayout();
+ panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)radWaitingBar1).BeginInit();
((System.ComponentModel.ISupportInitialize)radLabel_Status).BeginInit();
((System.ComponentModel.ISupportInitialize)radLabel_Header).BeginInit();
@@ -49,15 +48,15 @@ namespace Pilz.Updating.UpdateInstaller
//
// _Panel1
//
- _Panel1.BackColor = Color.Transparent;
- _Panel1.Controls.Add(radWaitingBar1);
- _Panel1.Controls.Add(radLabel_Status);
- _Panel1.Controls.Add(radLabel_Header);
- _Panel1.Dock = DockStyle.Fill;
- _Panel1.Location = new Point(0, 0);
- _Panel1.Name = "_Panel1";
- _Panel1.Size = new Size(692, 87);
- _Panel1.TabIndex = 1;
+ panel1.BackColor = Color.Transparent;
+ panel1.Controls.Add(radWaitingBar1);
+ panel1.Controls.Add(radLabel_Status);
+ panel1.Controls.Add(radLabel_Header);
+ panel1.Dock = DockStyle.Fill;
+ panel1.Location = new Point(0, 0);
+ panel1.Name = "_Panel1";
+ panel1.Size = new Size(692, 87);
+ panel1.TabIndex = 1;
//
// radWaitingBar1
//
@@ -94,7 +93,6 @@ namespace Pilz.Updating.UpdateInstaller
//
radLabel_Header.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
radLabel_Header.AutoSize = false;
- radLabel_Header.Image = MyIcons.icons8_installing_updates_48px;
radLabel_Header.Location = new Point(3, 3);
radLabel_Header.Name = "radLabel_Header";
radLabel_Header.Size = new Size(686, 57);
@@ -109,7 +107,7 @@ namespace Pilz.Updating.UpdateInstaller
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(692, 87);
- Controls.Add(_Panel1);
+ Controls.Add(panel1);
FormBorderStyle = FormBorderStyle.FixedSingle;
Icon = (Icon)resources.GetObject("$this.Icon");
MaximizeBox = false;
@@ -117,7 +115,7 @@ namespace Pilz.Updating.UpdateInstaller
Name = "Main";
StartPosition = FormStartPosition.CenterScreen;
Text = "Installing";
- _Panel1.ResumeLayout(false);
+ panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)radWaitingBar1).EndInit();
((System.ComponentModel.ISupportInitialize)radLabel_Status).EndInit();
((System.ComponentModel.ISupportInitialize)radLabel_Header).EndInit();
@@ -125,32 +123,10 @@ namespace Pilz.Updating.UpdateInstaller
ResumeLayout(false);
}
- private Panel _Panel1;
+ private Panel panel1;
private Telerik.WinControls.UI.RadLabel radLabel_Status;
private Telerik.WinControls.UI.RadLabel radLabel_Header;
private Telerik.WinControls.UI.RadWaitingBar radWaitingBar1;
private Telerik.WinControls.UI.DotsLineWaitingBarIndicatorElement dotsLineWaitingBarIndicatorElement1;
-
- internal Panel Panel1
- {
- [MethodImpl(MethodImplOptions.Synchronized)]
- get
- {
- return _Panel1;
- }
-
- [MethodImpl(MethodImplOptions.Synchronized)]
- set
- {
- if (_Panel1 != null)
- {
- }
-
- _Panel1 = value;
- if (_Panel1 != null)
- {
- }
- }
- }
}
}
\ No newline at end of file
diff --git a/Pilz.Updating.Client.Gui/UpdateWindow.cs b/Pilz.Updating.Client.Gui/UpdateWindow.cs
new file mode 100644
index 0000000..9b6af9d
--- /dev/null
+++ b/Pilz.Updating.Client.Gui/UpdateWindow.cs
@@ -0,0 +1,115 @@
+namespace Pilz.Updating.Client.Gui;
+
+public partial class UpdateWindow : Telerik.WinControls.UI.RadForm
+{
+ // C o n s t r u c t o r s
+
+ public UpdateWindow()
+ {
+ // Init Form
+ InitializeComponent();
+
+ // Events
+ Shown += Main_Shown;
+ FormClosed += Main_FormClosed;
+ FormClosing += Main_FormClosing;
+
+ // Init Application Header Text
+ string header;
+ if (!string.IsNullOrEmpty(installer.Configuration.ApplicationName))
+ header = string.Format(My.Resources.UpdateInstallerGuiLangRes.String_UpdatingApplicationX, installer.Configuration.ApplicationName);
+ else
+ header = My.Resources.UpdateInstallerGuiLangRes.String_UpdateIsRunning;
+
+ radLabel_Header.Text = $"{header}";
+ }
+
+ // F i e l d s
+
+ private bool allowClose = false;
+
+ // F e a t u r e s
+
+ public void SetStatus(UpdateStatus status)
+ {
+ string newStatusText = string.Empty;
+ Image newStatusImage = null;
+
+ switch (status)
+ {
+ case UpdateStatus.Copying:
+ newStatusText = My.Resources.UpdateInstallerGuiLangRes.Status_CopyingFiles;
+ break;
+ case UpdateStatus.Done:
+ newStatusText = My.Resources.UpdateInstallerGuiLangRes.Status_Done;
+ break;
+ case UpdateStatus.Extracting:
+ newStatusText = My.Resources.UpdateInstallerGuiLangRes.Status_Extracting;
+ break;
+ case UpdateStatus.Cleanup:
+ newStatusText = My.Resources.UpdateInstallerGuiLangRes.Status_RemovingFiles;
+ break;
+ case UpdateStatus.Waiting:
+ newStatusText = My.Resources.UpdateInstallerGuiLangRes.Status_Waiting;
+ break;
+ }
+
+ switch (status)
+ {
+ case UpdateStatus.Copying:
+ newStatusImage = MyIcons.icons8_copy_16px;
+ break;
+ case UpdateStatus.Extracting:
+ newStatusImage = MyIcons.icons8_open_archive_16px;
+ break;
+ case UpdateStatus.Cleanup:
+ newStatusImage = MyIcons.icons8_recycle_bin_16px;
+ break;
+ case UpdateStatus.Waiting:
+ newStatusImage = MyIcons.icons8_sand_timer_16px;
+ break;
+ case UpdateStatus.Done:
+ newStatusImage = MyIcons.icons8_checkmark_16px;
+ break;
+ }
+
+ radLabel_Status.Text = newStatusText;
+ radLabel_Status.Image = newStatusImage;
+ }
+
+ private async Task WaitforHostApp()
+ {
+ SetStatus(UpdateStatus.Waiting);
+ await Task.Run(installer.WaitForHostApplication);
+ }
+
+ private async void ExecuteUpdate()
+ {
+ await Task.Run(installer.InstallUpdate);
+ allowClose = true;
+ Close();
+ }
+
+ private async void Main_Shown(object sender, EventArgs e)
+ {
+ radWaitingBar1.StartWaiting();
+ await WaitforHostApp();
+ ExecuteUpdate();
+ }
+
+ private void Main_FormClosed(object sender, FormClosedEventArgs e)
+ {
+ installer.StartHostApplication();
+ }
+
+ private void Main_FormClosing(object sender, FormClosingEventArgs e)
+ {
+ radWaitingBar1.StopWaiting();
+ e.Cancel = !allowClose;
+ }
+
+ private void Installer_StatusChanges(object sender, UpdateClientStatusChangedEventArgs e)
+ {
+ Invoke(new Action(() => SetStatus(e.NewStatus)));
+ }
+}
\ No newline at end of file
diff --git a/Pilz.Updating.UpdateInstaller/Main.resx b/Pilz.Updating.Client.Gui/UpdateWindow.resx
similarity index 100%
rename from Pilz.Updating.UpdateInstaller/Main.resx
rename to Pilz.Updating.Client.Gui/UpdateWindow.resx
diff --git a/Pilz.Updating.Client/Delegates.cs b/Pilz.Updating.Client/Delegates.cs
new file mode 100644
index 0000000..4d16947
--- /dev/null
+++ b/Pilz.Updating.Client/Delegates.cs
@@ -0,0 +1,4 @@
+namespace Pilz.Updating.Client;
+
+public delegate void UpdateClientEventHandler(object sender, UpdateClientEventArgs e);
+public delegate void UpdateClientStatusChangedEventHandler(object sender, UpdateStatusEventArgs e);
diff --git a/Pilz.Updating.Client/General.cs b/Pilz.Updating.Client/General.cs
new file mode 100644
index 0000000..6139efe
--- /dev/null
+++ b/Pilz.Updating.Client/General.cs
@@ -0,0 +1,46 @@
+namespace Pilz.Updating.Client;
+
+internal static class General
+{
+ public static void CopyFiles(DirectoryInfo sourceDir, DirectoryInfo destinationDir)
+ {
+ if (!destinationDir.Exists)
+ destinationDir.Create();
+
+ foreach (FileInfo sFile in sourceDir.EnumerateFiles("*", SearchOption.TopDirectoryOnly))
+ {
+ var dFile = new FileInfo(Path.Combine(destinationDir.FullName, sFile.Name));
+ var triesLeft = 1;
+
+ while (triesLeft > 0)
+ {
+ triesLeft--;
+
+ try
+ {
+ sFile.CopyTo(dFile.FullName, true);
+ }
+ catch (IOException)
+ {
+ if (triesLeft == 0 && File.Exists(dFile.FullName))
+ {
+ var oldFile = dFile.FullName + ".old";
+ File.Delete(oldFile);
+ File.Move(dFile.FullName, oldFile, true);
+ File.Delete(oldFile);
+ triesLeft++;
+ }
+ }
+ catch (Exception)
+ {
+ }
+ }
+ }
+
+ foreach (DirectoryInfo sDir in sourceDir.EnumerateDirectories("*", SearchOption.TopDirectoryOnly))
+ {
+ var dDir = destinationDir.CreateSubdirectory(sDir.Name);
+ CopyFiles(sDir, dDir);
+ }
+ }
+}
diff --git a/Pilz.Updating.Client/UpdateClient.cs b/Pilz.Updating.Client/UpdateClient.cs
index 4a52e8f..c769b21 100644
--- a/Pilz.Updating.Client/UpdateClient.cs
+++ b/Pilz.Updating.Client/UpdateClient.cs
@@ -1,97 +1,72 @@
-using Pilz.Updating.UpdateInstaller;
-using System.ComponentModel;
+using System.ComponentModel;
+using System.Configuration;
using System.Diagnostics;
using System.IO.Compression;
+using System.Runtime.CompilerServices;
+using System.Security.Principal;
+using Z.IO.Extensions;
-namespace Pilz.Updating;
+namespace Pilz.Updating.Client;
-public class UpdateClient(string updateUrl, ApplicationVersion currentVersion, Channels minimumChannel)
+public class UpdateClient(string updateUrl, AppVersion currentVersion, Channels minimumChannel)
{
+ // E v e n t s
- // E b v e n t s
-
- public event UpdateStatusChangedEventHandler UpdateStatusChanged;
-
- public delegate void UpdateStatusChangedEventHandler(UpdateStatus newStatus);
-
- public event DownloadingUpdateEventHandler DownloadingUpdate;
-
- public delegate void DownloadingUpdateEventHandler(UpdatePackageInfo pkg, CancelEventArgs e);
-
- public event InstallingUpdateEventHandler InstallingUpdate;
-
- public delegate void InstallingUpdateEventHandler(UpdatePackageInfo pkg, CancelEventArgs e);
-
- public event UpdateInstallerStartedEventHandler UpdateInstallerStarted;
-
- public delegate void UpdateInstallerStartedEventHandler();
-
- public event NoUpdatesFoundEventHandler NoUpdatesFound;
-
- public delegate void NoUpdatesFoundEventHandler();
+ public event UpdateClientStatusChangedEventHandler OnStatusChanged;
// F i e l d s
private readonly Dictionary dicPackagePaths = [];
- private UpdateStatus curDownloadingStatus = UpdateStatus.Waiting;
// P r o p e r t i e s
public HttpClient WebClient { get; private set; } = new();
public string UpdateUrl { get; private set; } = updateUrl;
- public ApplicationVersion CurrentVersion { get; private set; } = currentVersion;
+ public AppVersion CurrentVersion { get; private set; } = currentVersion;
public Channels MinimumChannel { get; private set; } = (Channels)Math.Max((int)minimumChannel, (int)currentVersion.Channel);
public UpdateInfo UpdateInfo { get; private set; } = null;
public UpdatePackageInfo UpdatePackageInfo { get; private set; } = null;
public bool AutoCloseHostApplication { get; set; } = false;
- public bool AutoRestartHostApplication { get; set; } = false;
public string RestartHostApplicationArguments { get; set; }
public string HostApplicationPath { get; set; } = string.Empty;
public string ApplicationName { get; set; } = string.Empty;
public bool InstallAsAdmin { get; set; } = false;
- public uint MillisecondsToWaitForHostApplicationToClose { get; set; } = 10000;
- public bool ForceClosingHostApplication { get; set; } = true;
public bool UIDarkMode { get; set; } = false;
+ public bool HasUpdates => UpdatePackageInfo != null;
// E v e n t M e t h o d s
- private bool RaiseDownloadingUpdate(UpdatePackageInfo pkg)
+ private void RaiseStatusChanged(UpdateStatus status)
{
- var e = new CancelEventArgs(false);
- DownloadingUpdate?.Invoke(pkg, e);
- return e.Cancel;
+ RaiseStatusChanged(status, UpdateStatusEvent.Default);
}
- private bool RaiseInstallingUpdate(UpdatePackageInfo pkg)
+ private void RaiseStatusChanged(UpdateStatus status, UpdateStatusEvent statusEvent)
{
- var e = new CancelEventArgs(true);
- InstallingUpdate?.Invoke(pkg, e);
- return e.Cancel;
+ RaiseStatusChanged(status, statusEvent, false);
}
- // U p d a t e R o u t i n e s
+ private bool RaiseStatusChanged(UpdateStatus status, UpdateStatusEvent statusEvent, bool canCancel)
+ {
+ var args = new UpdateStatusEventArgs(this, status, statusEvent, canCancel);
+ OnStatusChanged?.Invoke(this, args);
+ return args.CanCancel && args.Cancel;
+ }
+
+ // U p d a t e r o u t i n e s
public async Task UpdateInteractive()
{
var latestVersion = await CheckForUpdate();
- if (latestVersion is null)
- NoUpdatesFound?.Invoke();
- else
+
+ if (HasUpdates)
await UpdateInteractive(latestVersion);
}
public async Task UpdateInteractive(UpdatePackageInfo package)
{
- if (!RaiseDownloadingUpdate(package) && await DownloadPackageAsync(package))
- {
- if (!RaiseInstallingUpdate(package))
- await InstallPackage(package);
- }
- }
-
- public void RaiseUpdateStatusChanged(UpdateStatus newStatus)
- {
- UpdateStatusChanged?.Invoke(newStatus);
+ if (await DownloadPackageAsync(package))
+ await InstallPackageAsync(package);
}
// F e a t u r e s
@@ -103,21 +78,23 @@ public class UpdateClient(string updateUrl, ApplicationVersion currentVersion, C
return info;
}
- public async Task CheckForUpdate()
+ private async Task CheckForUpdate()
{
- RaiseUpdateStatusChanged(UpdateStatus.Searching);
+ RaiseStatusChanged(UpdateStatus.Searching, UpdateStatusEvent.PreEvent);
+
UpdateInfo = await GetUpdateInfo();
- if (UpdateInfo is not null)
- return CheckForUpdate(UpdateInfo);
- else
+
+ if (UpdateInfo is null)
return null;
+
+ return CheckForUpdate(UpdateInfo);
}
- public UpdatePackageInfo CheckForUpdate(UpdateInfo updateInfo)
+ private UpdatePackageInfo CheckForUpdate(UpdateInfo updateInfo)
{
UpdatePackageInfo foundPkgInfo = null;
var latestVersion = CurrentVersion;
- RaiseUpdateStatusChanged(UpdateStatus.Searching);
+
foreach (UpdatePackageInfo pkgInfo in updateInfo.Packages)
{
if (pkgInfo.Version.Channel <= MinimumChannel && pkgInfo.Version > latestVersion)
@@ -128,13 +105,20 @@ public class UpdateClient(string updateUrl, ApplicationVersion currentVersion, C
}
UpdatePackageInfo = foundPkgInfo;
+
+ if (!RaiseStatusChanged(UpdateStatus.Searching, UpdateStatusEvent.PostEvent, true))
+ {
+ UpdatePackageInfo = null;
+ return null;
+ }
+
return foundPkgInfo;
}
public async Task DownloadPackageAsync(UpdatePackageInfo package)
{
- curDownloadingStatus = UpdateStatus.DownloadingPackage;
- RaiseUpdateStatusChanged(curDownloadingStatus);
+ RaiseStatusChanged(UpdateStatus.Downloading, UpdateStatusEvent.PreEvent);
+
var dirPath = Path.Combine(MyPaths.GetMyAppDataPath(), package.GetHashCode().ToString());
var zipPath = Path.Combine(dirPath, "package.zip");
var dir = new DirectoryInfo(dirPath);
@@ -159,88 +143,57 @@ public class UpdateClient(string updateUrl, ApplicationVersion currentVersion, C
return false;
}
+ if (!RaiseStatusChanged(UpdateStatus.Downloading, UpdateStatusEvent.PostEvent, true))
+ {
+ RaiseStatusChanged(UpdateStatus.Canceled);
+ return false;
+ }
+
return true;
}
- private async Task DownloadUpdateInstaller()
+ private void InstallPackage(UpdatePackageInfo package)
{
- curDownloadingStatus = UpdateStatus.DownloadingInstaller;
- RaiseUpdateStatusChanged(curDownloadingStatus);
-
- // Ensure update installer path is empty
- var installerDirPath = new DirectoryInfo(Path.Combine(MyPaths.GetMyAppDataPath(), "UpdateInstallerTool"));
- if (installerDirPath.Exists)
- installerDirPath.Delete(true);
-
- await Task.Delay(100);
- installerDirPath.Create();
- await Task.Delay(100);
-
- // Download update installer zip
- var installerZipPath = Path.Combine(installerDirPath.FullName, "UpdatenInstaller.zip");
- using (var installerZipFile = new FileStream(installerZipPath, FileMode.Create, FileAccess.ReadWrite))
+ // Extract Package
+ if (!RaiseStatusChanged(UpdateStatus.Extracting, UpdateStatusEvent.PreEvent, true))
{
- using var installerZipStream = await WebClient.GetStreamAsync(UpdateInfo.UpdateInstallerLink);
- await installerZipStream.CopyToAsync(installerZipFile);
+ RaiseStatusChanged(UpdateStatus.Canceled);
+ return;
}
+ if (!dicPackagePaths.TryGetValue(package, out var packagePath))
+ {
+ RaiseStatusChanged(UpdateStatus.Failed);
+ return;
+ }
+ var dataPath = packagePath + ".extracted";
+ var packagePathDir = new DirectoryInfo(packagePath);
+ if (packagePathDir.Exists)
+ {
+ packagePathDir.Delete(true);
+ Task.Delay(1000);
+ }
+ ZipFile.ExtractToDirectory(packagePath, dataPath);
+ RaiseStatusChanged(UpdateStatus.Extracting, UpdateStatusEvent.PostEvent);
- // Extract update installer
- var installerExtractPath = installerDirPath.CreateSubdirectory("extracted");
- ZipFile.ExtractToDirectory(installerZipPath, installerExtractPath.FullName);
- File.Delete(installerZipPath);
+ // Install Package
+ RaiseStatusChanged(UpdateStatus.Copying, UpdateStatusEvent.PreEvent);
+ var dataPathDir = new DirectoryInfo(dataPath);
+ var destDir = new DirectoryInfo(HostApplicationPath);
+ General.CopyFiles(dataPathDir, destDir);
+ RaiseStatusChanged(UpdateStatus.Copying, UpdateStatusEvent.PostEvent);
- // Get UpdateInstaller.exe file
- return installerExtractPath.EnumerateFiles("*.exe").FirstOrDefault();
+ // Delete Package
+ RaiseStatusChanged(UpdateStatus.Cleanup, UpdateStatusEvent.PreEvent);
+ File.Delete(packagePath);
+ Directory.Delete(dataPath, true);
+ RaiseStatusChanged(UpdateStatus.Cleanup, UpdateStatusEvent.PostEvent);
+
+ // Finish
+ RaiseStatusChanged(UpdateStatus.Done, UpdateStatusEvent.Default);
}
- private void StartUpdateInstaller(string packagePath, string installerPath)
+ public Task InstallPackageAsync(UpdatePackageInfo package)
{
- RaiseUpdateStatusChanged(UpdateStatus.StartingInstaller);
-
- // Create update settings
- var myAppPath = IO.Extensions.GetExecutablePath();
- var updateConfig = new UpdateInstallerConfig
- {
- PackagePath = packagePath,
- RestartHostApplication = AutoRestartHostApplication,
- RestartHostApplicationArguments = AutoRestartHostApplication ? RestartHostApplicationArguments : string.Empty,
- ApplicationName = ApplicationName,
- HostApplicationPath = string.IsNullOrEmpty(HostApplicationPath) ? Path.GetDirectoryName(myAppPath) : HostApplicationPath,
- HostApplicationProcessPath = myAppPath,
- MillisecondsToWaitForHostApplicationToClose = MillisecondsToWaitForHostApplicationToClose,
- ForceClosingHostApplication = ForceClosingHostApplication,
- UIDarkMode = UIDarkMode
- };
-
- // Start UpdateInstaller
- var procStartInfo = new ProcessStartInfo
- {
- FileName = installerPath,
- Arguments = updateConfig.ToString(),
- UseShellExecute = false,
- Verb = InstallAsAdmin ? "runas" : string.Empty
- };
- Process.Start(procStartInfo);
- UpdateInstallerStarted?.Invoke();
- }
-
- public async Task InstallPackage(UpdatePackageInfo package)
- {
- if (dicPackagePaths.TryGetValue(package, out var packagePath))
- {
- // Download update installer
- var installerPath = await DownloadUpdateInstaller();
-
- // Start update installer
- StartUpdateInstaller(packagePath, installerPath.FullName);
-
- // Close Host Application
- if (AutoCloseHostApplication)
- Environment.Exit(Environment.ExitCode);
-
- return true;
- }
-
- return false;
+ return Task.Run(() => InstallPackage(package));
}
}
\ No newline at end of file
diff --git a/Pilz.Updating.Client/UpdateClientEventArgs.cs b/Pilz.Updating.Client/UpdateClientEventArgs.cs
new file mode 100644
index 0000000..007d3db
--- /dev/null
+++ b/Pilz.Updating.Client/UpdateClientEventArgs.cs
@@ -0,0 +1,8 @@
+using Pilz.Updating.Client.Installer;
+
+namespace Pilz.Updating.Client;
+
+public class UpdateClientEventArgs(UpdateClient client) : EventArgs
+{
+ public UpdateClient Client { get; init; } = client;
+}
diff --git a/Pilz.Updating.Client/UpdateStatus.cs b/Pilz.Updating.Client/UpdateStatus.cs
index ea1601b..83d592a 100644
--- a/Pilz.Updating.Client/UpdateStatus.cs
+++ b/Pilz.Updating.Client/UpdateStatus.cs
@@ -1,10 +1,14 @@
-namespace Pilz.Updating;
+namespace Pilz.Updating.Client;
public enum UpdateStatus
{
Waiting,
Searching,
- DownloadingPackage,
- DownloadingInstaller,
- StartingInstaller
+ Downloading,
+ Extracting,
+ Copying,
+ Cleanup,
+ Done,
+ Failed,
+ Canceled,
}
\ No newline at end of file
diff --git a/Pilz.Updating.Client/UpdateStatusEvent.cs b/Pilz.Updating.Client/UpdateStatusEvent.cs
new file mode 100644
index 0000000..1bbef44
--- /dev/null
+++ b/Pilz.Updating.Client/UpdateStatusEvent.cs
@@ -0,0 +1,8 @@
+namespace Pilz.Updating.Client;
+
+public enum UpdateStatusEvent
+{
+ Default,
+ PreEvent,
+ PostEvent
+}
diff --git a/Pilz.Updating.Client/UpdateStatusEventArgs.cs b/Pilz.Updating.Client/UpdateStatusEventArgs.cs
new file mode 100644
index 0000000..b6b2120
--- /dev/null
+++ b/Pilz.Updating.Client/UpdateStatusEventArgs.cs
@@ -0,0 +1,11 @@
+using Pilz.Updating.Client.Installer;
+
+namespace Pilz.Updating.Client;
+
+public class UpdateStatusEventArgs(UpdateClient client, UpdateStatus status, UpdateStatusEvent state, bool canCancel) : UpdateClientEventArgs(client)
+{
+ public UpdateStatus Status { get; } = status;
+ public UpdateStatusEvent Event { get; } = state;
+ public bool CanCancel { get; } = canCancel;
+ public bool Cancel { get; set; }
+}
diff --git a/Pilz.Updating.Client/Utils.cs b/Pilz.Updating.Client/Utils.cs
new file mode 100644
index 0000000..acbfdb8
--- /dev/null
+++ b/Pilz.Updating.Client/Utils.cs
@@ -0,0 +1,5 @@
+namespace Pilz.Updating.Client;
+
+public static class Utils
+{
+}
diff --git a/Pilz.Updating.UpdateInstaller.Lib/Pilz.Updating.UpdateInstaller.Lib.csproj b/Pilz.Updating.UpdateInstaller.Lib/Pilz.Updating.UpdateInstaller.Lib.csproj
deleted file mode 100644
index 802f3a7..0000000
--- a/Pilz.Updating.UpdateInstaller.Lib/Pilz.Updating.UpdateInstaller.Lib.csproj
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
- net8.0-windows
- enable
- enable
-
-
-
- 3.0.0
-
-
-
-
-
-
-
-
diff --git a/Pilz.Updating.UpdateInstaller.Lib/UpdateInstaller.cs b/Pilz.Updating.UpdateInstaller.Lib/UpdateInstaller.cs
deleted file mode 100644
index 1418341..0000000
--- a/Pilz.Updating.UpdateInstaller.Lib/UpdateInstaller.cs
+++ /dev/null
@@ -1,172 +0,0 @@
-using Microsoft.VisualBasic.CompilerServices;
-using System.Diagnostics;
-using System.IO.Compression;
-
-namespace Pilz.Updating.UpdateInstaller.Lib;
-
-public class UpdateInstaller(UpdateInstallerConfig config)
-{
- // E v e n t s
-
- public delegate void UpdateInstallerEventHandler(object sender, UpdateInstallerEventArgs e);
- public delegate void UpdateInstallerStepEventHandler(object sender, UpdateInstallerStepEventArgs e);
- public delegate void StatusChangesEventHandler(object sender, UpdateInstallerStatusChangedEventArgs e);
-
- public event StatusChangesEventHandler? StatusChanges;
- public event UpdateInstallerStepEventHandler? OnStep;
-
- // F i e l d s
-
- private string dataPath = string.Empty;
-
- // P r o p e r t i e s
-
- public UpdateInstallerConfig Configuration { get; private set; } = config;
-
- // F e a t u r e s
-
- private void ChangeStep(UpdateInstallerStep step, UpdateInstallerStepState state)
- {
- OnStep?.Invoke(this, new UpdateInstallerStepEventArgs(this, step, state));
- }
-
- private void ChangeStatus(UpdateInstallerStatus newStatus)
- {
- StatusChanges?.Invoke(this, new UpdateInstallerStatusChangedEventArgs(newStatus));
- }
-
- public void StartHostApplication()
- {
- if (!string.IsNullOrEmpty(Conversions.ToString(Configuration.RestartHostApplication)) && File.Exists(Configuration.HostApplicationProcessPath))
- Process.Start(Configuration.HostApplicationProcessPath, Configuration.RestartHostApplicationArguments);
- }
-
- public void InstallUpdate()
- {
- ChangeStep(UpdateInstallerStep.Startup, UpdateInstallerStepState.Default);
-
- // Extract Package
- ChangeStatus(UpdateInstallerStatus.Extracting);
- ChangeStep(UpdateInstallerStep.ExtractPackage, UpdateInstallerStepState.PreEvent);
- ExtractPackage();
- ChangeStep(UpdateInstallerStep.ExtractPackage, UpdateInstallerStepState.PostEvent);
-
- // Install Package
- ChangeStatus(UpdateInstallerStatus.CopyingFiles);
- ChangeStep(UpdateInstallerStep.CopyFiles, UpdateInstallerStepState.PreEvent);
- CopyFiles();
- ChangeStep(UpdateInstallerStep.CopyFiles, UpdateInstallerStepState.PostEvent);
-
- // Delete Package
- ChangeStatus(UpdateInstallerStatus.RemovingFiles);
- ChangeStep(UpdateInstallerStep.DeletePackage, UpdateInstallerStepState.PreEvent);
- DeletePackage();
- ChangeStep(UpdateInstallerStep.DeletePackage, UpdateInstallerStepState.PostEvent);
-
- // Finish
- ChangeStatus(UpdateInstallerStatus.Done);
- ChangeStep(UpdateInstallerStep.Finish, UpdateInstallerStepState.Default);
- }
-
- public void WaitForHostApplication()
- {
- bool forcedKill = false;
- bool enabled = true;
- var stw = new Stopwatch();
- stw.Start();
- Process[] getProcesses() => Process.GetProcessesByName(Path.GetFileNameWithoutExtension(Configuration.HostApplicationProcessPath));
- while (enabled)
- {
- if (getProcesses().Any())
- {
- if (stw.ElapsedMilliseconds >= Configuration.MillisecondsToWaitForHostApplicationToClose)
- {
- if (!forcedKill && Configuration.ForceClosingHostApplication)
- {
- foreach (Process p in getProcesses())
- p.Kill();
- stw.Reset();
- forcedKill = true;
- }
- else
- {
- stw.Stop();
- enabled = false;
- }
- }
- }
- else
- enabled = false;
- }
- }
-
- private void ExtractPackage()
- {
- string packagePath = Configuration.PackagePath;
- string zipPath = packagePath;
- dataPath = Path.Combine(packagePath + ".extracted");
- var dataPathDir = new DirectoryInfo(dataPath);
-
- if (dataPathDir.Exists)
- {
- dataPathDir.Delete(true);
- Task.Delay(100);
- }
-
- ZipFile.ExtractToDirectory(zipPath, dataPath);
- }
-
- private void CopyFiles()
- {
- var sourceDir = new DirectoryInfo(dataPath);
- var destDir = new DirectoryInfo(Configuration.HostApplicationPath);
- CopyFiles(sourceDir, destDir);
- }
-
- private void CopyFiles(DirectoryInfo sourceDir, DirectoryInfo destinationDir)
- {
- if (!destinationDir.Exists)
- destinationDir.Create();
-
- foreach (FileInfo sFile in sourceDir.EnumerateFiles("*", SearchOption.TopDirectoryOnly))
- {
- var dFile = new FileInfo(Path.Combine(destinationDir.FullName, sFile.Name));
- var triesLeft = 1;
-
- while (triesLeft > 0)
- {
- triesLeft--;
-
- try
- {
- sFile.CopyTo(dFile.FullName, true);
- }
- catch (IOException)
- {
- if (triesLeft == 0 && File.Exists(dFile.FullName))
- {
- var oldFile = dFile.FullName + ".old";
- File.Delete(oldFile);
- File.Move(dFile.FullName, oldFile, true);
- File.Delete(oldFile);
- triesLeft++;
- }
- }
- catch (Exception)
- {
- }
- }
- }
-
- foreach (DirectoryInfo sDir in sourceDir.EnumerateDirectories("*", SearchOption.TopDirectoryOnly))
- {
- var dDir = destinationDir.CreateSubdirectory(sDir.Name);
- CopyFiles(sDir, dDir);
- }
- }
-
- private void DeletePackage()
- {
- Directory.Delete(Configuration.PackagePath, true);
- }
-}
\ No newline at end of file
diff --git a/Pilz.Updating.UpdateInstaller.Lib/UpdateInstallerEventArgs.cs b/Pilz.Updating.UpdateInstaller.Lib/UpdateInstallerEventArgs.cs
deleted file mode 100644
index 1f90fd6..0000000
--- a/Pilz.Updating.UpdateInstaller.Lib/UpdateInstallerEventArgs.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace Pilz.Updating.UpdateInstaller.Lib;
-
-public class UpdateInstallerEventArgs(UpdateInstaller updateInstaller) : EventArgs
-{
- public UpdateInstaller UpdateInstaller { get; init; } = updateInstaller;
-}
diff --git a/Pilz.Updating.UpdateInstaller.Lib/UpdateInstallerStatus.cs b/Pilz.Updating.UpdateInstaller.Lib/UpdateInstallerStatus.cs
deleted file mode 100644
index 72217ae..0000000
--- a/Pilz.Updating.UpdateInstaller.Lib/UpdateInstallerStatus.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-
-namespace Pilz.Updating.UpdateInstaller.Lib;
-
-public enum UpdateInstallerStatus
-{
- Waiting,
- Extracting,
- CopyingFiles,
- RemovingFiles,
- Done
-}
\ No newline at end of file
diff --git a/Pilz.Updating.UpdateInstaller.Lib/UpdateInstallerStatusChangedEventArgs.cs b/Pilz.Updating.UpdateInstaller.Lib/UpdateInstallerStatusChangedEventArgs.cs
deleted file mode 100644
index b037893..0000000
--- a/Pilz.Updating.UpdateInstaller.Lib/UpdateInstallerStatusChangedEventArgs.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-namespace Pilz.Updating.UpdateInstaller.Lib;
-
-public class UpdateInstallerStatusChangedEventArgs : EventArgs
-{
- public UpdateInstallerStatus NewStatus { get; private set; }
-
- public UpdateInstallerStatusChangedEventArgs(UpdateInstallerStatus newStatus) : base()
- {
- NewStatus = newStatus;
- }
-}
\ No newline at end of file
diff --git a/Pilz.Updating.UpdateInstaller.Lib/UpdateInstallerStep.cs b/Pilz.Updating.UpdateInstaller.Lib/UpdateInstallerStep.cs
deleted file mode 100644
index 8ff2659..0000000
--- a/Pilz.Updating.UpdateInstaller.Lib/UpdateInstallerStep.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace Pilz.Updating.UpdateInstaller.Lib;
-
-public enum UpdateInstallerStep
-{
- Startup,
- ExtractPackage,
- CopyFiles,
- DeletePackage,
- Finish
-}
diff --git a/Pilz.Updating.UpdateInstaller.Lib/UpdateInstallerStepEventArgs.cs b/Pilz.Updating.UpdateInstaller.Lib/UpdateInstallerStepEventArgs.cs
deleted file mode 100644
index ae13184..0000000
--- a/Pilz.Updating.UpdateInstaller.Lib/UpdateInstallerStepEventArgs.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-namespace Pilz.Updating.UpdateInstaller.Lib;
-
-public class UpdateInstallerStepEventArgs : UpdateInstallerEventArgs
-{
- public UpdateInstallerStep Step { get; init; }
- public UpdateInstallerStepState State { get; init; }
-
- public UpdateInstallerStepEventArgs(UpdateInstaller updateInstaller, UpdateInstallerStep step, UpdateInstallerStepState state) : base(updateInstaller)
- {
- Step = step;
- State = state;
- }
-}
diff --git a/Pilz.Updating.UpdateInstaller.Lib/UpdateInstallerStepState.cs b/Pilz.Updating.UpdateInstaller.Lib/UpdateInstallerStepState.cs
deleted file mode 100644
index e5390bf..0000000
--- a/Pilz.Updating.UpdateInstaller.Lib/UpdateInstallerStepState.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace Pilz.Updating.UpdateInstaller.Lib;
-
-public enum UpdateInstallerStepState
-{
- Default,
- PreEvent,
- PostEvent
-}
diff --git a/Pilz.Updating.UpdateInstaller/App.config b/Pilz.Updating.UpdateInstaller/App.config
deleted file mode 100644
index 61c5262..0000000
--- a/Pilz.Updating.UpdateInstaller/App.config
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Pilz.Updating.UpdateInstaller/General.cs b/Pilz.Updating.UpdateInstaller/General.cs
deleted file mode 100644
index adb1edf..0000000
--- a/Pilz.Updating.UpdateInstaller/General.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-using Pilz.Plugins;
-
-namespace Pilz.Updating.UpdateInstaller;
-
-internal static class General
-{
- private static string p = null;
-
- public static string MyAppPath
- {
- get
- {
- if (string.IsNullOrEmpty(p))
- p = Path.GetDirectoryName(IO.Extensions.GetExecutablePath());
- return p;
- }
- }
-
- public static void LoadAddons(Lib.UpdateInstaller installer)
- {
- var pluginsPath = Path.Combine(MyAppPath, "AddOns");
- if (Directory.Exists(pluginsPath))
- {
- foreach (var subdir in Directory.GetDirectories(pluginsPath, string.Empty, SearchOption.TopDirectoryOnly))
- {
- var pluginPath = Path.Combine(subdir, Path.GetFileName(subdir) + ".dll");
- if (File.Exists(pluginPath))
- PluginManager.Instance.LoadPlugin(pluginPath, installer);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/Pilz.Updating.UpdateInstaller/Main.cs b/Pilz.Updating.UpdateInstaller/Main.cs
deleted file mode 100644
index 394d3b6..0000000
--- a/Pilz.Updating.UpdateInstaller/Main.cs
+++ /dev/null
@@ -1,142 +0,0 @@
-using Pilz.Updating.UpdateInstaller.Lib;
-using Telerik.WinControls;
-using Telerik.WinControls.Themes;
-
-namespace Pilz.Updating.UpdateInstaller;
-
-public partial class Main
-{
- // C o n s t r u c t o r s
-
- public Main()
- {
- // G u i
- this.Shown += Main_Shown;
- this.FormClosed += Main_FormClosed;
- this.FormClosing += Main_FormClosing;
-
- // Get arguments
- var args = Environment.GetCommandLineArgs().Skip(1).ToArray();
- if (args.Length != 0)
- {
- // Load config
- installer = new Lib.UpdateInstaller(UpdateInstallerConfig.Parse(args[0]));
- General.LoadAddons(installer);
-
- // Init Form
- InitializeComponent();
-
- // Init Style
- RadThemeComponentBase themeToUse = installer.Configuration.UIDarkMode ? new FluentDarkTheme() : new FluentTheme();
- ThemeResolutionService.ApplicationThemeName = themeToUse.ThemeName;
-
- // Init Application Header Text
- string header;
- if (!string.IsNullOrEmpty(installer.Configuration.ApplicationName))
- header = string.Format(My.Resources.UpdateInstallerGuiLangRes.String_UpdatingApplicationX, installer.Configuration.ApplicationName);
- else
- header = My.Resources.UpdateInstallerGuiLangRes.String_UpdateIsRunning;
-
- radLabel_Header.Text = $"{header}";
- }
-
- if (installer is null)
- Environment.Exit(0);
- }
-
- // F i e l d s
-
- private bool allowClose = false;
- private readonly Lib.UpdateInstaller installer;
-
- // F e a t u r e s
-
- private void SetStatus(UpdateInstallerStatus newStatus)
- {
- string newStatusText = string.Empty;
- Image newStatusImage = null;
-
- switch (newStatus)
- {
- case UpdateInstallerStatus.CopyingFiles:
- newStatusText = My.Resources.UpdateInstallerGuiLangRes.Status_CopyingFiles;
- break;
- case UpdateInstallerStatus.Done:
- newStatusText = My.Resources.UpdateInstallerGuiLangRes.Status_Done;
- break;
- case UpdateInstallerStatus.Extracting:
- newStatusText = My.Resources.UpdateInstallerGuiLangRes.Status_Extracting;
- break;
- case UpdateInstallerStatus.RemovingFiles:
- newStatusText = My.Resources.UpdateInstallerGuiLangRes.Status_RemovingFiles;
- break;
- case UpdateInstallerStatus.Waiting:
- newStatusText = My.Resources.UpdateInstallerGuiLangRes.Status_Waiting;
- break;
- }
-
- switch (newStatus)
- {
- case UpdateInstallerStatus.CopyingFiles:
- newStatusImage = MyIcons.icons8_copy_16px;
- break;
- case UpdateInstallerStatus.Extracting:
- newStatusImage = MyIcons.icons8_open_archive_16px;
- break;
- case UpdateInstallerStatus.RemovingFiles:
- newStatusImage = MyIcons.icons8_recycle_bin_16px;
- break;
- case UpdateInstallerStatus.Waiting:
- newStatusImage = MyIcons.icons8_sand_timer_16px;
- break;
- case UpdateInstallerStatus.Done:
- newStatusImage = MyIcons.icons8_checkmark_16px;
- break;
- }
-
- radLabel_Status.Text = newStatusText;
- radLabel_Status.Image = newStatusImage;
-
- //if (newStatus == UpdateInstallerStatus.Done)
- //{
- // allowClose = true;
- // Close();
- //}
- }
-
- private async Task WaitforHostApp()
- {
- SetStatus(UpdateInstallerStatus.Waiting);
- await Task.Run(() => installer.WaitForHostApplication());
- }
-
- private async void ExecuteUpdate()
- {
- await Task.Run(() => installer.InstallUpdate());
- allowClose = true;
- Close();
- }
-
- private async void Main_Shown(object sender, EventArgs e)
- {
- radWaitingBar1.StartWaiting();
- await WaitforHostApp();
- ExecuteUpdate();
- }
-
- private void Main_FormClosed(object sender, FormClosedEventArgs e)
- {
- installer.StartHostApplication();
- }
-
- private void Main_FormClosing(object sender, FormClosingEventArgs e)
- {
- radWaitingBar1.StopWaiting();
- e.Cancel = !allowClose;
- }
-
- private void Installer_StatusChanges(object sender, UpdateInstallerStatusChangedEventArgs e)
- {
- base.Invoke(new Action(() => SetStatus(e.NewStatus)));
- }
-}
\ No newline at end of file
diff --git a/Pilz.Updating.UpdateInstaller/MyIcons.Designer.cs b/Pilz.Updating.UpdateInstaller/MyIcons.Designer.cs
deleted file mode 100644
index 45a47f4..0000000
--- a/Pilz.Updating.UpdateInstaller/MyIcons.Designer.cs
+++ /dev/null
@@ -1,203 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// Dieser Code wurde von einem Tool generiert.
-// Laufzeitversion:4.0.30319.42000
-//
-// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
-// der Code erneut generiert wird.
-//
-//------------------------------------------------------------------------------
-
-namespace Pilz.Updating.UpdateInstaller {
- using System;
-
-
- ///
- /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
- ///
- // Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert
- // -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert.
- // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
- // mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class MyIcons {
-
- private static global::System.Resources.ResourceManager resourceMan;
-
- private static global::System.Globalization.CultureInfo resourceCulture;
-
- [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal MyIcons() {
- }
-
- ///
- /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Resources.ResourceManager ResourceManager {
- get {
- if (object.ReferenceEquals(resourceMan, null)) {
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Pilz.Updating.UpdateInstaller.MyIcons", typeof(MyIcons).Assembly);
- resourceMan = temp;
- }
- return resourceMan;
- }
- }
-
- ///
- /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
- /// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden.
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Globalization.CultureInfo Culture {
- get {
- return resourceCulture;
- }
- set {
- resourceCulture = value;
- }
- }
-
- ///
- /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
- ///
- internal static System.Drawing.Bitmap icons8_checkmark_16px {
- get {
- object obj = ResourceManager.GetObject("icons8_checkmark_16px", resourceCulture);
- return ((System.Drawing.Bitmap)(obj));
- }
- }
-
- ///
- /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
- ///
- internal static System.Drawing.Bitmap icons8_console_16px_1 {
- get {
- object obj = ResourceManager.GetObject("icons8_console_16px_1", resourceCulture);
- return ((System.Drawing.Bitmap)(obj));
- }
- }
-
- ///
- /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
- ///
- internal static System.Drawing.Bitmap icons8_copy_16px {
- get {
- object obj = ResourceManager.GetObject("icons8_copy_16px", resourceCulture);
- return ((System.Drawing.Bitmap)(obj));
- }
- }
-
- ///
- /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
- ///
- internal static System.Drawing.Bitmap icons8_installing_updates_12px {
- get {
- object obj = ResourceManager.GetObject("icons8_installing_updates_12px", resourceCulture);
- return ((System.Drawing.Bitmap)(obj));
- }
- }
-
- ///
- /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
- ///
- internal static System.Drawing.Bitmap icons8_installing_updates_16px {
- get {
- object obj = ResourceManager.GetObject("icons8_installing_updates_16px", resourceCulture);
- return ((System.Drawing.Bitmap)(obj));
- }
- }
-
- ///
- /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
- ///
- internal static System.Drawing.Bitmap icons8_installing_updates_32px {
- get {
- object obj = ResourceManager.GetObject("icons8_installing_updates_32px", resourceCulture);
- return ((System.Drawing.Bitmap)(obj));
- }
- }
-
- ///
- /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
- ///
- internal static System.Drawing.Bitmap icons8_installing_updates_48px {
- get {
- object obj = ResourceManager.GetObject("icons8_installing_updates_48px", resourceCulture);
- return ((System.Drawing.Bitmap)(obj));
- }
- }
-
- ///
- /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
- ///
- internal static System.Drawing.Bitmap icons8_open_archive_16px {
- get {
- object obj = ResourceManager.GetObject("icons8_open_archive_16px", resourceCulture);
- return ((System.Drawing.Bitmap)(obj));
- }
- }
-
- ///
- /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
- ///
- internal static System.Drawing.Bitmap icons8_recycle_bin_16px {
- get {
- object obj = ResourceManager.GetObject("icons8_recycle_bin_16px", resourceCulture);
- return ((System.Drawing.Bitmap)(obj));
- }
- }
-
- ///
- /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
- ///
- internal static System.Drawing.Bitmap icons8_sand_timer_16px {
- get {
- object obj = ResourceManager.GetObject("icons8_sand_timer_16px", resourceCulture);
- return ((System.Drawing.Bitmap)(obj));
- }
- }
-
- ///
- /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
- ///
- internal static System.Drawing.Bitmap icons8_uninstalling_updates_12px {
- get {
- object obj = ResourceManager.GetObject("icons8_uninstalling_updates_12px", resourceCulture);
- return ((System.Drawing.Bitmap)(obj));
- }
- }
-
- ///
- /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
- ///
- internal static System.Drawing.Bitmap icons8_uninstalling_updates_16px {
- get {
- object obj = ResourceManager.GetObject("icons8_uninstalling_updates_16px", resourceCulture);
- return ((System.Drawing.Bitmap)(obj));
- }
- }
-
- ///
- /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
- ///
- internal static System.Drawing.Bitmap icons8_uninstalling_updates_32px {
- get {
- object obj = ResourceManager.GetObject("icons8_uninstalling_updates_32px", resourceCulture);
- return ((System.Drawing.Bitmap)(obj));
- }
- }
-
- ///
- /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
- ///
- internal static System.Drawing.Bitmap icons8_uninstalling_updates_48px {
- get {
- object obj = ResourceManager.GetObject("icons8_uninstalling_updates_48px", resourceCulture);
- return ((System.Drawing.Bitmap)(obj));
- }
- }
- }
-}
diff --git a/Pilz.Updating.UpdateInstaller/MyIcons.resx b/Pilz.Updating.UpdateInstaller/MyIcons.resx
deleted file mode 100644
index a5f1195..0000000
--- a/Pilz.Updating.UpdateInstaller/MyIcons.resx
+++ /dev/null
@@ -1,163 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
-
- Resources\icons8_checkmark_16px.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
-
- Resources\icons8_console_16px_1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
-
- Resources\icons8_copy_16px.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
-
- Resources\icons8_installing_updates_12px.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
-
- Resources\icons8_installing_updates_16px.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
-
- Resources\icons8_installing_updates_32px.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
-
- Resources\icons8_installing_updates_48px.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
-
- Resources\icons8_open_archive_16px.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
-
- Resources\icons8_recycle_bin_16px.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
-
- Resources\icons8_sand_timer_16px.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
-
- Resources\icons8_uninstalling_updates_12px.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
-
- Resources\icons8_uninstalling_updates_16px.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
-
- Resources\icons8_uninstalling_updates_32px.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
-
- Resources\icons8_uninstalling_updates_48px.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
-
\ No newline at end of file
diff --git a/Pilz.Updating.UpdateInstaller/Program.cs b/Pilz.Updating.UpdateInstaller/Program.cs
deleted file mode 100644
index 8a2d7b6..0000000
--- a/Pilz.Updating.UpdateInstaller/Program.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-namespace Pilz.Updating.UpdateInstaller;
-
-internal static class Program
-{
- internal static void Main(string[] args)
- {
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
- Application.SetHighDpiMode(HighDpiMode.PerMonitorV2);
- Application.Run(new Main());
- }
-}
diff --git a/Pilz.Updating.UpdateInstaller/Properties/AssemblyInfo.cs b/Pilz.Updating.UpdateInstaller/Properties/AssemblyInfo.cs
deleted file mode 100644
index 5778bea..0000000
--- a/Pilz.Updating.UpdateInstaller/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-using global::System;
-using global::System.Runtime.InteropServices;
-[assembly: ComVisible(false)]
-
-// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird.
-[assembly: Guid("fe45e614-7cad-436a-b284-ee197d062ded")]
-
diff --git a/Pilz.Updating.UpdateInstaller/Properties/PublishProfiles/FolderProfile.pubxml b/Pilz.Updating.UpdateInstaller/Properties/PublishProfiles/FolderProfile.pubxml
deleted file mode 100644
index de0c3db..0000000
--- a/Pilz.Updating.UpdateInstaller/Properties/PublishProfiles/FolderProfile.pubxml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
- Release
- Any CPU
- bin\publish\
- FileSystem
- <_TargetId>Folder
- net8.0-windows
- win-x86
- true
- true
- false
-
-
\ No newline at end of file
diff --git a/Pilz.Updating.UpdateInstaller/Properties/Resources.Designer.cs b/Pilz.Updating.UpdateInstaller/Properties/Resources.Designer.cs
deleted file mode 100644
index edb29c2..0000000
--- a/Pilz.Updating.UpdateInstaller/Properties/Resources.Designer.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// Dieser Code wurde von einem Tool generiert.
-// Laufzeitversion:4.0.30319.42000
-//
-// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
-// der Code erneut generiert wird.
-//
-//------------------------------------------------------------------------------
-
-namespace Pilz.Updating.UpdateInstaller.My.Resources {
- using System;
-
-
- ///
- /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
- ///
- // Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert
- // -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert.
- // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
- // mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class Resources {
-
- private static global::System.Resources.ResourceManager resourceMan;
-
- private static global::System.Globalization.CultureInfo resourceCulture;
-
- [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal Resources() {
- }
-
- ///
- /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Resources.ResourceManager ResourceManager {
- get {
- if (object.ReferenceEquals(resourceMan, null)) {
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Pilz.Updating.UpdateInstaller.Properties.Resources", typeof(Resources).Assembly);
- resourceMan = temp;
- }
- return resourceMan;
- }
- }
-
- ///
- /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
- /// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden.
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Globalization.CultureInfo Culture {
- get {
- return resourceCulture;
- }
- set {
- resourceCulture = value;
- }
- }
- }
-}
diff --git a/Pilz.Updating.UpdateInstaller/Properties/Resources.resx b/Pilz.Updating.UpdateInstaller/Properties/Resources.resx
deleted file mode 100644
index 1af7de1..0000000
--- a/Pilz.Updating.UpdateInstaller/Properties/Resources.resx
+++ /dev/null
@@ -1,120 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
\ No newline at end of file
diff --git a/Pilz.Updating.UpdateInstaller/Properties/Settings.Designer.cs b/Pilz.Updating.UpdateInstaller/Properties/Settings.Designer.cs
deleted file mode 100644
index dfb5f04..0000000
--- a/Pilz.Updating.UpdateInstaller/Properties/Settings.Designer.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// Dieser Code wurde von einem Tool generiert.
-// Laufzeitversion:4.0.30319.42000
-//
-// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
-// der Code erneut generiert wird.
-//
-//------------------------------------------------------------------------------
-
-namespace Pilz.Updating.UpdateInstaller.My {
-
-
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")]
- internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
-
- private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
-
- public static Settings Default {
- get {
- return defaultInstance;
- }
- }
- }
-}
diff --git a/Pilz.Updating.UpdateInstaller/Properties/Settings.settings b/Pilz.Updating.UpdateInstaller/Properties/Settings.settings
deleted file mode 100644
index 85b890b..0000000
--- a/Pilz.Updating.UpdateInstaller/Properties/Settings.settings
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
diff --git a/Pilz.Updating.UpdateInstaller/Resources/icons8_checkmark_16px.png b/Pilz.Updating.UpdateInstaller/Resources/icons8_checkmark_16px.png
deleted file mode 100644
index 15b6e2c..0000000
Binary files a/Pilz.Updating.UpdateInstaller/Resources/icons8_checkmark_16px.png and /dev/null differ
diff --git a/Pilz.Updating.UpdateInstaller/Resources/icons8_console_16px_1.png b/Pilz.Updating.UpdateInstaller/Resources/icons8_console_16px_1.png
deleted file mode 100644
index 90e7af2..0000000
Binary files a/Pilz.Updating.UpdateInstaller/Resources/icons8_console_16px_1.png and /dev/null differ
diff --git a/Pilz.Updating.UpdateInstaller/Resources/icons8_copy_16px.png b/Pilz.Updating.UpdateInstaller/Resources/icons8_copy_16px.png
deleted file mode 100644
index ea7ac18..0000000
Binary files a/Pilz.Updating.UpdateInstaller/Resources/icons8_copy_16px.png and /dev/null differ
diff --git a/Pilz.Updating.UpdateInstaller/Resources/icons8_installing_updates_12px.png b/Pilz.Updating.UpdateInstaller/Resources/icons8_installing_updates_12px.png
deleted file mode 100644
index fd633e2..0000000
Binary files a/Pilz.Updating.UpdateInstaller/Resources/icons8_installing_updates_12px.png and /dev/null differ
diff --git a/Pilz.Updating.UpdateInstaller/Resources/icons8_installing_updates_16px.png b/Pilz.Updating.UpdateInstaller/Resources/icons8_installing_updates_16px.png
deleted file mode 100644
index 24206ff..0000000
Binary files a/Pilz.Updating.UpdateInstaller/Resources/icons8_installing_updates_16px.png and /dev/null differ
diff --git a/Pilz.Updating.UpdateInstaller/Resources/icons8_installing_updates_32px.png b/Pilz.Updating.UpdateInstaller/Resources/icons8_installing_updates_32px.png
deleted file mode 100644
index d582bff..0000000
Binary files a/Pilz.Updating.UpdateInstaller/Resources/icons8_installing_updates_32px.png and /dev/null differ
diff --git a/Pilz.Updating.UpdateInstaller/Resources/icons8_installing_updates_48px.png b/Pilz.Updating.UpdateInstaller/Resources/icons8_installing_updates_48px.png
deleted file mode 100644
index 89b1fc6..0000000
Binary files a/Pilz.Updating.UpdateInstaller/Resources/icons8_installing_updates_48px.png and /dev/null differ
diff --git a/Pilz.Updating.UpdateInstaller/Resources/icons8_open_archive_16px.png b/Pilz.Updating.UpdateInstaller/Resources/icons8_open_archive_16px.png
deleted file mode 100644
index 45d2ad0..0000000
Binary files a/Pilz.Updating.UpdateInstaller/Resources/icons8_open_archive_16px.png and /dev/null differ
diff --git a/Pilz.Updating.UpdateInstaller/Resources/icons8_recycle_bin_16px.png b/Pilz.Updating.UpdateInstaller/Resources/icons8_recycle_bin_16px.png
deleted file mode 100644
index 81a9d1b..0000000
Binary files a/Pilz.Updating.UpdateInstaller/Resources/icons8_recycle_bin_16px.png and /dev/null differ
diff --git a/Pilz.Updating.UpdateInstaller/Resources/icons8_sand_timer_16px.png b/Pilz.Updating.UpdateInstaller/Resources/icons8_sand_timer_16px.png
deleted file mode 100644
index e7b3b55..0000000
Binary files a/Pilz.Updating.UpdateInstaller/Resources/icons8_sand_timer_16px.png and /dev/null differ
diff --git a/Pilz.Updating.UpdateInstaller/Resources/icons8_uninstalling_updates_12px.png b/Pilz.Updating.UpdateInstaller/Resources/icons8_uninstalling_updates_12px.png
deleted file mode 100644
index 01da636..0000000
Binary files a/Pilz.Updating.UpdateInstaller/Resources/icons8_uninstalling_updates_12px.png and /dev/null differ
diff --git a/Pilz.Updating.UpdateInstaller/Resources/icons8_uninstalling_updates_16px.png b/Pilz.Updating.UpdateInstaller/Resources/icons8_uninstalling_updates_16px.png
deleted file mode 100644
index 550d18f..0000000
Binary files a/Pilz.Updating.UpdateInstaller/Resources/icons8_uninstalling_updates_16px.png and /dev/null differ
diff --git a/Pilz.Updating.UpdateInstaller/Resources/icons8_uninstalling_updates_32px.png b/Pilz.Updating.UpdateInstaller/Resources/icons8_uninstalling_updates_32px.png
deleted file mode 100644
index 6bc8c5b..0000000
Binary files a/Pilz.Updating.UpdateInstaller/Resources/icons8_uninstalling_updates_32px.png and /dev/null differ
diff --git a/Pilz.Updating.UpdateInstaller/Resources/icons8_uninstalling_updates_48px.png b/Pilz.Updating.UpdateInstaller/Resources/icons8_uninstalling_updates_48px.png
deleted file mode 100644
index 64ce6dd..0000000
Binary files a/Pilz.Updating.UpdateInstaller/Resources/icons8_uninstalling_updates_48px.png and /dev/null differ
diff --git a/Pilz.Updating.UpdateInstaller/icons8_software_installer.ico b/Pilz.Updating.UpdateInstaller/icons8_software_installer.ico
deleted file mode 100644
index 7bd06f7..0000000
Binary files a/Pilz.Updating.UpdateInstaller/icons8_software_installer.ico and /dev/null differ
diff --git a/Pilz.Updating.sln b/Pilz.Updating.sln
index 93f7ffd..67120bc 100644
--- a/Pilz.Updating.sln
+++ b/Pilz.Updating.sln
@@ -7,16 +7,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Pilz.Updating.Client", "Pil
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Pilz.Updating.GUIBase", "Pilz.Updating.GUIBase\Pilz.Updating.GUIBase.csproj", "{F668FCAA-0155-4C5C-8881-731AA9BC389C}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Pilz.Updating.UpdateInstaller", "Pilz.Updating.UpdateInstaller\Pilz.Updating.UpdateInstaller.csproj", "{6CF782BA-019D-4651-9B00-48D2729B808F}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Pilz.Updating.Client.GUI", "Pilz.Updating.Client.GUI\Pilz.Updating.Client.GUI.csproj", "{4C91A7F0-FC08-4CA9-85E1-5B6304E033F3}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Pilz.Updating.Client.Gui", "Pilz.Updating.Client.Gui\Pilz.Updating.Client.Gui.csproj", "{4C91A7F0-FC08-4CA9-85E1-5B6304E033F3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Pilz.Updating", "Pilz.Updating\Pilz.Updating.csproj", "{CFC81C75-299C-4DE4-9F19-8E061972E271}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Pilz.Updating.UpdateInstaller.Lib", "Pilz.Updating.UpdateInstaller.Lib\Pilz.Updating.UpdateInstaller.Lib.csproj", "{F05AAEA2-386F-4307-AE5E-6831F4EA2B66}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Pilz.Updating.Test", "Pilz.Updating.Test\Pilz.Updating.Test.csproj", "{B98D1EA1-0C02-4337-97AD-B321EDD443E3}"
-EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -31,10 +25,6 @@ Global
{F668FCAA-0155-4C5C-8881-731AA9BC389C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F668FCAA-0155-4C5C-8881-731AA9BC389C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F668FCAA-0155-4C5C-8881-731AA9BC389C}.Release|Any CPU.Build.0 = Release|Any CPU
- {6CF782BA-019D-4651-9B00-48D2729B808F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {6CF782BA-019D-4651-9B00-48D2729B808F}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {6CF782BA-019D-4651-9B00-48D2729B808F}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {6CF782BA-019D-4651-9B00-48D2729B808F}.Release|Any CPU.Build.0 = Release|Any CPU
{4C91A7F0-FC08-4CA9-85E1-5B6304E033F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4C91A7F0-FC08-4CA9-85E1-5B6304E033F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4C91A7F0-FC08-4CA9-85E1-5B6304E033F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -43,14 +33,6 @@ Global
{CFC81C75-299C-4DE4-9F19-8E061972E271}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CFC81C75-299C-4DE4-9F19-8E061972E271}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CFC81C75-299C-4DE4-9F19-8E061972E271}.Release|Any CPU.Build.0 = Release|Any CPU
- {F05AAEA2-386F-4307-AE5E-6831F4EA2B66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {F05AAEA2-386F-4307-AE5E-6831F4EA2B66}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {F05AAEA2-386F-4307-AE5E-6831F4EA2B66}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {F05AAEA2-386F-4307-AE5E-6831F4EA2B66}.Release|Any CPU.Build.0 = Release|Any CPU
- {B98D1EA1-0C02-4337-97AD-B321EDD443E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {B98D1EA1-0C02-4337-97AD-B321EDD443E3}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {B98D1EA1-0C02-4337-97AD-B321EDD443E3}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {B98D1EA1-0C02-4337-97AD-B321EDD443E3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/Pilz.Updating/AppVersion.cs b/Pilz.Updating/AppVersion.cs
new file mode 100644
index 0000000..245ca98
--- /dev/null
+++ b/Pilz.Updating/AppVersion.cs
@@ -0,0 +1,109 @@
+using Newtonsoft.Json;
+
+namespace Pilz.Updating;
+
+public class AppVersion(Version version, int build, Channels channel)
+{
+ // P r o p e r t i e s
+
+ [JsonConverter(typeof(Newtonsoft.Json.Converters.VersionConverter))]
+ public Version Version { get; set; } = version;
+ [JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
+ public Channels Channel { get; set; } = channel;
+ public int Build { get; set; } = build;
+
+ // C o n s t r u c t o r s
+
+ public AppVersion() : this(new Version("1.0.0.0"))
+ {
+ }
+
+ public AppVersion(Version version) : this(version, 1, Channels.Stable)
+ {
+ }
+
+ // F e a t u r e s
+
+ public override string ToString()
+ {
+ if (Channel == Channels.Stable && Build == 1)
+ return Version.ToString();
+
+ return $"{Version} {Channel} {Build}";
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(this, obj))
+ return true;
+ if (obj is not AppVersion applicationVersion)
+ return false;
+ return applicationVersion == this;
+ }
+
+ public override int GetHashCode()
+ {
+ return ToString().GetHashCode();
+ }
+
+ public static bool TryParse(string input, out AppVersion version)
+ {
+ try
+ {
+ version = Parse(input);
+ }
+ catch(Exception)
+ {
+ version = null;
+ }
+ return version != null;
+ }
+
+ public static AppVersion Parse(string input)
+ {
+ var splitted = input.Split(' ');
+
+ if (splitted.Length < 1 || !Version.TryParse(splitted[0], out Version? version) || version == null)
+ throw new FormatException();
+
+ if (splitted.Length < 2 || !Enum.TryParse(splitted[1], out Channels channel))
+ channel = Channels.Stable;
+
+ if (splitted.Length < 3 || !int.TryParse(splitted[2], out int build))
+ build = 1;
+
+ return new AppVersion(version, build, channel);
+ }
+
+ // O p e r a t o r s
+
+ public static bool operator >(AppVersion a, AppVersion b)
+ {
+ return a.Version > b.Version || a.Version == b.Version && (a.Channel < b.Channel || (a.Channel == b.Channel && a.Build > b.Build));
+ }
+
+ public static bool operator <(AppVersion a, AppVersion b)
+ {
+ return a.Version < b.Version || a.Version == b.Version && (a.Channel > b.Channel || (a.Channel == b.Channel && a.Build < b.Build));
+ }
+
+ public static bool operator ==(AppVersion a, AppVersion b)
+ {
+ return a.Version == b.Version && a.Channel == b.Channel && a.Build == b.Build;
+ }
+
+ public static bool operator !=(AppVersion a, AppVersion b)
+ {
+ return a.Version != b.Version || a.Channel != b.Channel || a.Build != b.Build;
+ }
+
+ public static bool operator >=(AppVersion a, AppVersion b)
+ {
+ return a == b || a > b;
+ }
+
+ public static bool operator <=(AppVersion a, AppVersion b)
+ {
+ return a == b || a < b;
+ }
+}
\ No newline at end of file
diff --git a/Pilz.Updating/ApplicationVersion.cs b/Pilz.Updating/ApplicationVersion.cs
deleted file mode 100644
index feea620..0000000
--- a/Pilz.Updating/ApplicationVersion.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-using Newtonsoft.Json;
-
-namespace Pilz.Updating;
-
-public class ApplicationVersion(Version version, int build, Channels channel)
-{
- // P r o p e r t i e s
-
- [JsonConverter(typeof(Newtonsoft.Json.Converters.VersionConverter))]
- public Version Version { get; set; } = version;
- public int Build { get; set; } = build;
- [JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
- public Channels Channel { get; set; } = channel;
-
- // C o n s t r u c t o r s
-
- public ApplicationVersion() : this(new Version("1.0.0.0"))
- {
- }
-
- public ApplicationVersion(Version version) : this(version, 1, Channels.Stable)
- {
- }
-
- // F e a t u r e s
-
- public override string ToString()
- {
- return $"{Version.ToString()} {Channel.ToString()} {Build}";
- }
-
- // O p e r a t o r s
-
- public static bool operator >(ApplicationVersion a, ApplicationVersion b)
- {
- return a.Version > b.Version || a.Version == b.Version && (a.Channel < b.Channel || (a.Channel == b.Channel && a.Build > b.Build));
- }
-
- public static bool operator <(ApplicationVersion a, ApplicationVersion b)
- {
- return a.Version < b.Version || a.Version == b.Version && (a.Channel > b.Channel || (a.Channel == b.Channel && a.Build < b.Build));
- }
-
- public static bool operator ==(ApplicationVersion a, ApplicationVersion b)
- {
- return a.Version == b.Version && a.Channel == b.Channel && a.Build == b.Build;
- }
-
- public static bool operator !=(ApplicationVersion a, ApplicationVersion b)
- {
- return a.Version != b.Version || a.Channel != b.Channel || a.Build != b.Build;
- }
-
- public static bool operator >=(ApplicationVersion a, ApplicationVersion b)
- {
- return a == b || a > b;
- }
-
- public static bool operator <=(ApplicationVersion a, ApplicationVersion b)
- {
- return a == b || a < b;
- }
-}
\ No newline at end of file
diff --git a/Pilz.Updating/Json/AppVersionStringJsonConverter.cs b/Pilz.Updating/Json/AppVersionStringJsonConverter.cs
new file mode 100644
index 0000000..3256b89
--- /dev/null
+++ b/Pilz.Updating/Json/AppVersionStringJsonConverter.cs
@@ -0,0 +1,82 @@
+using Newtonsoft.Json.Serialization;
+using Newtonsoft.Json;
+using System.Globalization;
+using Newtonsoft.Json.Linq;
+
+namespace Pilz.Updating.Json;
+
+public class AppVersionStringJsonConverter : JsonConverter
+{
+ ///
+ /// Writes the JSON representation of the object.
+ ///
+ /// The to write to.
+ /// The value.
+ /// The calling serializer.
+ public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
+ {
+ if (value == null)
+ {
+ writer.WriteNull();
+ return;
+ }
+
+ if (value is not AppVersion appVersion)
+ writer.WriteValue(value);
+ else
+ writer.WriteValue(appVersion.ToString());
+ }
+
+ ///
+ /// Reads the JSON representation of the object.
+ ///
+ /// The to read from.
+ /// Type of the object.
+ /// The existing value of object being read.
+ /// The calling serializer.
+ /// The object value.
+ public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)
+ {
+ if (reader.TokenType == JsonToken.Null)
+ return null;
+
+ try
+ {
+ if (reader.TokenType == JsonToken.String)
+ {
+ var strValue = reader.Value?.ToString();
+
+ if (string.IsNullOrWhiteSpace(strValue))
+ return null;
+
+ return AppVersion.Parse(strValue);
+
+ }
+
+ if (reader.TokenType == JsonToken.StartObject)
+ {
+ return JToken.ReadFrom(reader).ToObject();
+ }
+
+ }
+ catch (Exception ex)
+ {
+ throw new JsonSerializationException("Error converting value {0} to type '{1}'.", ex);
+ }
+
+ // we don't actually expect to get here.
+ throw new JsonSerializationException("Unexpected token {0} when parsing app version.");
+ }
+
+ ///
+ /// Determines whether this instance can convert the specified object type.
+ ///
+ /// Type of the object.
+ ///
+ /// true if this instance can convert the specified object type; otherwise, false.
+ ///
+ public override bool CanConvert(Type objectType)
+ {
+ return objectType == typeof(AppVersion);
+ }
+}
diff --git a/Pilz.Updating/Pilz.Updating.csproj b/Pilz.Updating/Pilz.Updating.csproj
index 7fbc8eb..e0ad418 100644
--- a/Pilz.Updating/Pilz.Updating.csproj
+++ b/Pilz.Updating/Pilz.Updating.csproj
@@ -3,6 +3,7 @@
net8.0-windows
enable
+ annotations
diff --git a/Pilz.Updating/UpdateInfo.cs b/Pilz.Updating/UpdateInfo.cs
index d1d4020..a4ebef1 100644
--- a/Pilz.Updating/UpdateInfo.cs
+++ b/Pilz.Updating/UpdateInfo.cs
@@ -4,7 +4,6 @@ namespace Pilz.Updating;
public class UpdateInfo
{
- public string UpdateInstallerLink { get; set; }
public List Packages { get; set; } = [];
public static UpdateInfo Parse(string str)
diff --git a/Pilz.Updating/UpdateInstaller/UpdateInstallerConfig.cs b/Pilz.Updating/UpdateInstaller/UpdateInstallerConfig.cs
deleted file mode 100644
index 3fbda79..0000000
--- a/Pilz.Updating/UpdateInstaller/UpdateInstallerConfig.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using Newtonsoft.Json;
-
-namespace Pilz.Updating.UpdateInstaller;
-
-public class UpdateInstallerConfig
-{
- public string PackagePath { get; set; }
- public bool RestartHostApplication { get; set; }
- public string RestartHostApplicationArguments { get; set; }
- public string ApplicationName { get; set; }
- public string HostApplicationPath { get; set; }
- public string HostApplicationProcessPath { get; set; }
- public bool ForceClosingHostApplication { get; set; }
- public uint MillisecondsToWaitForHostApplicationToClose { get; set; }
- public bool UIDarkMode { get; set; }
- public ApplicationVersion CurrentApplicationVersion { get; set; }
- public ApplicationVersion NewApplicationVersion { get; set; }
-
- public static UpdateInstallerConfig Parse(string str)
- {
- return JsonConvert.DeserializeObject(System.Text.Encoding.Default.GetString(Convert.FromBase64String(str)));
- }
-
- public override string ToString()
- {
- return Convert.ToBase64String(System.Text.Encoding.Default.GetBytes(JsonConvert.SerializeObject(this)));
- }
-}
\ No newline at end of file
diff --git a/Pilz.Updating/UpdatePackageInfo.cs b/Pilz.Updating/UpdatePackageInfo.cs
index 21f4bca..2af4147 100644
--- a/Pilz.Updating/UpdatePackageInfo.cs
+++ b/Pilz.Updating/UpdatePackageInfo.cs
@@ -3,7 +3,7 @@
public class UpdatePackageInfo
{
public string Name { get; set; }
- public ApplicationVersion Version { get; set; }
+ public AppVersion Version { get; set; }
public UpdateNotes Notes { get; } = new();
public string Packagelink { get; set; }
}
\ No newline at end of file