diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..2d9dd2a --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,10 @@ + + + https://git.pilzinsel64.de/pilz-framework + MIT + False + True + True + 1591 + + \ No newline at end of file diff --git a/NuGet.Config b/NuGet.Config index d40b44d..99ddf3e 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,7 +1,3 @@  - - - - \ No newline at end of file diff --git a/Pilz.Updating.Administration.GUI/ApplicationVersionInput.cs b/Pilz.Updating.Administration.GUI/ApplicationVersionInput.cs index de99baa..15a6c1b 100644 --- a/Pilz.Updating.Administration.GUI/ApplicationVersionInput.cs +++ b/Pilz.Updating.Administration.GUI/ApplicationVersionInput.cs @@ -1,76 +1,74 @@ using System; -using Microsoft.VisualBasic.CompilerServices; using Telerik.WinControls.UI; -namespace Pilz.Updating.Administration.GUI +namespace Pilz.Updating.Administration.GUI; + +public partial class ApplicationVersionInput { - public partial class ApplicationVersionInput + + // C o n s t r u c t o r s + + public ApplicationVersionInput() { + InitializeComponent(); - // C o n s t r u c t o r s + // Init Channel-ComboBox + radDropDownList_Channel.Items.Add(new RadListDataItem() { Text = My.Resources.UpdatingAdministrationLangRes.Channel_Stable, Tag = Channels.Stable }); + radDropDownList_Channel.Items.Add(new RadListDataItem() { Text = My.Resources.UpdatingAdministrationLangRes.Channel_PreRelease, Tag = Channels.PreRelease }); + radDropDownList_Channel.Items.Add(new RadListDataItem() { Text = My.Resources.UpdatingAdministrationLangRes.Channel_Beta, Tag = Channels.Beta }); + radDropDownList_Channel.Items.Add(new RadListDataItem() { Text = My.Resources.UpdatingAdministrationLangRes.Channel_Alpha, Tag = Channels.Alpha }); + radDropDownList_Channel.SelectedIndex = 0; + } - public ApplicationVersionInput() + // P r o p e r t i e s + + public Version Version + { + get { - InitializeComponent(); - - // Init Channel-ComboBox - radDropDownList_Channel.Items.Add(new RadListDataItem() { Text = My.Resources.UpdatingAdministrationLangRes.Channel_Stable, Tag = Channels.Stable }); - radDropDownList_Channel.Items.Add(new RadListDataItem() { Text = My.Resources.UpdatingAdministrationLangRes.Channel_PreRelease, Tag = Channels.PreRelease }); - radDropDownList_Channel.Items.Add(new RadListDataItem() { Text = My.Resources.UpdatingAdministrationLangRes.Channel_Beta, Tag = Channels.Beta }); - radDropDownList_Channel.Items.Add(new RadListDataItem() { Text = My.Resources.UpdatingAdministrationLangRes.Channel_Alpha, Tag = Channels.Alpha }); - radDropDownList_Channel.SelectedIndex = 0; + return new Version(radTextBoxControl_Version.Text.Trim()); } - // P r o p e r t i e s - - public Version Version + set { - get - { - return new Version(radTextBoxControl_Version.Text.Trim()); - } + radTextBoxControl_Version.Text = value.ToString(); + } + } - set - { - radTextBoxControl_Version.Text = value.ToString(); - } + public Channels Channel + { + get + { + return (Channels)radDropDownList_Channel.SelectedItem.Tag; } - public Channels Channel + set { - get + foreach (var ci in radDropDownList_Channel.Items) { - return (Channels)radDropDownList_Channel.SelectedItem.Tag; - } - - set - { - foreach (var ci in radDropDownList_Channel.Items) + if ((Channels)ci.Tag == value) { - if ((Channels)ci.Tag == value) - { - radDropDownList_Channel.SelectedItem = ci; - } + radDropDownList_Channel.SelectedItem = ci; } } } + } - public int Build + public int Build + { + get { - get - { - return (int)Math.Round(radSpinEditor_Build.Value); - } - - set - { - radSpinEditor_Build.Value = value; - } + return (int)Math.Round(radSpinEditor_Build.Value); } - private void radButton_Accept_Click(object sender, EventArgs e) + set { - + radSpinEditor_Build.Value = value; } } + + private void radButton_Accept_Click(object sender, EventArgs e) + { + + } } \ No newline at end of file diff --git a/Pilz.Updating.Administration.GUI/DiscordBotSettingsWindow.cs b/Pilz.Updating.Administration.GUI/DiscordBotSettingsWindow.cs index 8810724..fbe93db 100644 --- a/Pilz.Updating.Administration.GUI/DiscordBotSettingsWindow.cs +++ b/Pilz.Updating.Administration.GUI/DiscordBotSettingsWindow.cs @@ -1,70 +1,63 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; -using System.Windows.Forms; using Pilz.Updating.Administration.Discord; +using System; using Telerik.WinControls.UI; -namespace Pilz.Updating.Administration.GUI +namespace Pilz.Updating.Administration.GUI; + +public partial class DiscordBotSettingsWindow : RadForm { - public partial class DiscordBotSettingsWindow : RadForm + private readonly DiscordBotConfig config = null; + private Channels currentChannel = Channels.Stable; + private readonly bool hasInit = false; + + public DiscordBotSettingsWindow(DiscordBotConfig config) { - private readonly DiscordBotConfig config = null; - private Channels currentChannel = Channels.Stable; - private readonly bool hasInit = false; + this.config = config; - public DiscordBotSettingsWindow(DiscordBotConfig config) - { - this.config = config; + InitializeComponent(); - InitializeComponent(); + foreach (var value in Enum.GetValues()) + radDropDownList_PresetChannel.Items.Add(new RadListDataItem(Enum.GetName(value), value)); + radDropDownList_PresetChannel.SelectedValue = Channels.Stable; - foreach (var value in Enum.GetValues()) - radDropDownList_PresetChannel.Items.Add(new RadListDataItem(Enum.GetName(value), value)); - radDropDownList_PresetChannel.SelectedValue = Channels.Stable; + radTextBoxControl_BotToken.Text = config.DiscordBotToken; + radTextBoxControl_DefaultProgramName.Text = config.DefaultAppName; + ShowDefaultMessage(); + radToggleSwitch_UseProxy.Value = config.UseProxy; - radTextBoxControl_BotToken.Text = config.DiscordBotToken; - radTextBoxControl_DefaultProgramName.Text = config.DefaultAppName; - ShowDefaultMessage(); - radToggleSwitch_UseProxy.Value = config.UseProxy; + hasInit = true; + } - hasInit = true; - } + private Channels GetCurrentChannel() + { + return radDropDownList_PresetChannel?.SelectedValue as Channels? ?? Channels.Stable; + } - private Channels GetCurrentChannel() - { - return radDropDownList_PresetChannel?.SelectedValue as Channels? ?? Channels.Stable; - } + private void ShowDefaultMessage() + { + radTextBox_DefaultMessage.Text = config.DefaultUpdateMessages[currentChannel]; + } - private void ShowDefaultMessage() - { - radTextBox_DefaultMessage.Text = config.DefaultUpdateMessages[currentChannel]; - } + private void SaveDefaultMessage() + { + config.DefaultUpdateMessages[currentChannel] = radTextBox_DefaultMessage.Text.Trim(); + } - private void SaveDefaultMessage() - { - config.DefaultUpdateMessages[currentChannel] = radTextBox_DefaultMessage.Text.Trim(); - } + private void ButtonX_Okay_Click(object sender, EventArgs e) + { + SaveDefaultMessage(); + config.DefaultAppName = radTextBoxControl_DefaultProgramName.Text.Trim(); + config.DiscordBotToken = radTextBoxControl_BotToken.Text.Trim(); + config.UseProxy = radToggleSwitch_UseProxy.Value; + } - private void ButtonX_Okay_Click(object sender, EventArgs e) - { + private void radDropDownList_PresetChannel_SelectedValueChanged(object sender, EventArgs e) + { + if (hasInit) SaveDefaultMessage(); - config.DefaultAppName = radTextBoxControl_DefaultProgramName.Text.Trim(); - config.DiscordBotToken = radTextBoxControl_BotToken.Text.Trim(); - config.UseProxy = radToggleSwitch_UseProxy.Value; - } - private void radDropDownList_PresetChannel_SelectedValueChanged(object sender, EventArgs e) - { - if (hasInit) - SaveDefaultMessage(); + currentChannel = radDropDownList_PresetChannel?.SelectedValue as Channels? ?? Channels.Stable; - currentChannel = radDropDownList_PresetChannel?.SelectedValue as Channels? ?? Channels.Stable; - - ShowDefaultMessage(); - } + ShowDefaultMessage(); } } \ No newline at end of file diff --git a/Pilz.Updating.Administration.GUI/DiscordPostDialog.cs b/Pilz.Updating.Administration.GUI/DiscordPostDialog.cs index 33a367c..f943f40 100644 --- a/Pilz.Updating.Administration.GUI/DiscordPostDialog.cs +++ b/Pilz.Updating.Administration.GUI/DiscordPostDialog.cs @@ -1,91 +1,85 @@ using Pilz.Updating.Administration.Discord; using System; -using System.Collections.Generic; -using System.ComponentModel; using System.Data; -using System.Drawing; using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Forms; using Telerik.WinControls; using Telerik.WinControls.UI; -namespace Pilz.Updating.Administration.GUI +namespace Pilz.Updating.Administration.GUI; + +public partial class DiscordPostDialog : RadForm { - public partial class DiscordPostDialog : RadForm + // F i e l d s + + private readonly DiscordBot bot; + private readonly UpdatePackageInfo package; + + // C o n s t r u c t o r + + public DiscordPostDialog(DiscordBot bot, UpdatePackageInfo package) { - // F i e l d s + this.bot = bot; + this.package = package; - private readonly DiscordBot bot; - private readonly UpdatePackageInfo package; + InitializeComponent(); - // C o n s t r u c t o r + radTextBoxControl_ProgramName.Text = General.CurProject.DiscordBotConfig.DefaultAppName; + radTextBox_Message.Text = General.CurProject.DiscordBotConfig.DefaultUpdateMessages[package.Version.Channel]; - public DiscordPostDialog(DiscordBot bot, UpdatePackageInfo package) + LoadBgrTree(); + } + + private void LoadBgrTree() + { + radTreeView_Channels.BeginUpdate(); + radTreeView_Channels.Nodes.Clear(); + + foreach (var guild in bot.GetGuilds()) { - this.bot = bot; - this.package = package; - - InitializeComponent(); - - radTextBoxControl_ProgramName.Text = General.CurProject.DiscordBotConfig.DefaultAppName; - radTextBox_Message.Text = General.CurProject.DiscordBotConfig.DefaultUpdateMessages[package.Version.Channel]; - - LoadBgrTree(); - } - - private void LoadBgrTree() - { - radTreeView_Channels.BeginUpdate(); - radTreeView_Channels.Nodes.Clear(); - - foreach (var guild in bot.GetGuilds()) + var nGuild = new RadTreeNode() { - var nGuild = new RadTreeNode() + Name = "g" + guild.Key, + Text = guild.Value, + Tag = guild.Key, + Expanded = true + }; + + foreach (var channel in bot.GetTextChannels(guild.Key).OrderBy((n) => n.Value)) + { + var nChannel = new RadTreeNode() { - Name = "g" + guild.Key, - Text = guild.Value, - Tag = guild.Key, - Expanded = true + Name = "c" + channel.Key, + Text = "#" + channel.Value, + Tag = channel.Key }; - foreach (var channel in bot.GetTextChannels(guild.Key).OrderBy((n) => n.Value)) - { - var nChannel = new RadTreeNode() - { - Name = "c" + channel.Key, - Text = "#" + channel.Value, - Tag = channel.Key - }; - - nGuild.Nodes.Add(nChannel); - } - - radTreeView_Channels.Nodes.Add(nGuild); + nGuild.Nodes.Add(nChannel); } - radTreeView_Channels.EndUpdate(); + radTreeView_Channels.Nodes.Add(nGuild); } - private async void ButtonX_SendMsg_Click(object sender, EventArgs e) + radTreeView_Channels.EndUpdate(); + } + + private async void ButtonX_SendMsg_Click(object sender, EventArgs e) + { + try { - try - { - var selNode = radTreeView_Channels.SelectedNode; - ulong gID = (ulong)selNode.Parent.Tag; - ulong cID = (ulong)selNode.Tag; - var msg = radTextBox_Message.Text; + var selNode = radTreeView_Channels.SelectedNode; + ulong gID = (ulong)selNode.Parent.Tag; + ulong cID = (ulong)selNode.Tag; + var msg = radTextBox_Message.Text; - await bot.SendUpdateNotification(package, gID, cID, radTextBoxControl_ProgramName.Text, msg, radCheckBox_AttachDescription.Checked, radCheckBoxPingAtEveryone.Checked); + await bot.SendUpdateNotification(package, gID, cID, radTextBoxControl_ProgramName.Text, msg, radCheckBox_AttachDescription.Checked, radCheckBoxPingAtEveryone.Checked); - RadMessageBox.Show(this, "Nachricht erfolgreich gesendet.", string.Empty, MessageBoxButtons.OK, RadMessageIcon.Info); - DialogResult = DialogResult.OK; - } - catch(Exception) - { - RadMessageBox.Show(this, "Fehler beim Senden der Nachricht.", string.Empty, MessageBoxButtons.OK, RadMessageIcon.Error); - } + RadMessageBox.Show(this, "Nachricht erfolgreich gesendet.", string.Empty, MessageBoxButtons.OK, RadMessageIcon.Info); + DialogResult = DialogResult.OK; + } + catch (Exception) + { + RadMessageBox.Show(this, "Fehler beim Senden der Nachricht.", string.Empty, MessageBoxButtons.OK, RadMessageIcon.Error); } } } diff --git a/Pilz.Updating.Administration.GUI/General.cs b/Pilz.Updating.Administration.GUI/General.cs index 88cfb6a..2fb4cf6 100644 --- a/Pilz.Updating.Administration.GUI/General.cs +++ b/Pilz.Updating.Administration.GUI/General.cs @@ -1,35 +1,28 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; +using System.IO; using System.Net; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; -namespace Pilz.Updating.Administration.GUI +namespace Pilz.Updating.Administration.GUI; + +public static class General { - public static class General + private static string myAppPath = string.Empty; + public static UpdateProject CurProject { get; set; } = null; + + public static string MyAppPath { - private static string myAppPath = string.Empty; - public static UpdateProject CurProject { get; set; } = null; - - public static string MyAppPath + get { - get - { - if (string.IsNullOrEmpty(myAppPath)) - Path.GetDirectoryName(IO.Extensions.GetExecutablePath()); - return myAppPath; - } - } - - public static void SetProxyConfig() - { - if (CurProject.ProxyConfig.UseProxyAuth) - WebRequest.DefaultWebProxy.Credentials = new NetworkCredential(CurProject.ProxyConfig.Username, CurProject.ProxyConfig.Password); - else - WebRequest.DefaultWebProxy.Credentials = null; + if (string.IsNullOrEmpty(myAppPath)) + Path.GetDirectoryName(IO.Extensions.GetExecutablePath()); + return myAppPath; } } + + public static void SetProxyConfig() + { + if (CurProject.ProxyConfig.UseProxyAuth) + WebRequest.DefaultWebProxy.Credentials = new NetworkCredential(CurProject.ProxyConfig.Username, CurProject.ProxyConfig.Password); + else + WebRequest.DefaultWebProxy.Credentials = null; + } } diff --git a/Pilz.Updating.Administration.GUI/My Project/Application.Designer.cs b/Pilz.Updating.Administration.GUI/My Project/Application.Designer.cs deleted file mode 100644 index 9907884..0000000 --- a/Pilz.Updating.Administration.GUI/My Project/Application.Designer.cs +++ /dev/null @@ -1,38 +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. -// -// ------------------------------------------------------------------------------ - -using System.Diagnostics; - -namespace Pilz.Updating.Administration.GUI.My -{ - - // HINWEIS: Diese Datei wird automatisch generiert und darf nicht direkt bearbeitet werden. Wenn Sie Änderungen vornehmen möchten - // oder in dieser Datei Buildfehler auftreten, wechseln Sie zum Projekt-Designer. - // (Wechseln Sie dazu zu den Projekteigenschaften, oder doppelklicken Sie auf den Knoten "Mein Projekt" im - // Projektmappen-Explorer). Nehmen Sie auf der Registerkarte "Anwendung" entsprechende Änderungen vor. - // - internal partial class MyApplication - { - [DebuggerStepThrough()] - public MyApplication() : base(Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows) - { - IsSingleInstance = false; - EnableVisualStyles = true; - SaveMySettingsOnExit = true; - ShutdownStyle = Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterAllFormsClose; - } - - [DebuggerStepThrough()] - protected override void OnCreateMainForm() - { - MainForm = MyProject.Forms.UpdateManagerWindow; - } - } -} \ No newline at end of file diff --git a/Pilz.Updating.Administration.GUI/My Project/Application.myapp b/Pilz.Updating.Administration.GUI/My Project/Application.myapp deleted file mode 100644 index 77a5d2e..0000000 --- a/Pilz.Updating.Administration.GUI/My Project/Application.myapp +++ /dev/null @@ -1,10 +0,0 @@ - - - true - ToolSelectionWindow - false - 1 - true - 0 - true - \ No newline at end of file diff --git a/Pilz.Updating.Administration.GUI/My Project/MyNamespace.Dynamic.Designer.cs b/Pilz.Updating.Administration.GUI/My Project/MyNamespace.Dynamic.Designer.cs deleted file mode 100644 index 19f613e..0000000 --- a/Pilz.Updating.Administration.GUI/My Project/MyNamespace.Dynamic.Designer.cs +++ /dev/null @@ -1,81 +0,0 @@ -using global::System; -using global::System.ComponentModel; -using global::System.Diagnostics; - -namespace Pilz.Updating.Administration.GUI.My -{ - internal static partial class MyProject - { - internal partial class MyForms - { - [EditorBrowsable(EditorBrowsableState.Never)] - public ApplicationVersionInput m_ApplicationVersionInput; - - public ApplicationVersionInput ApplicationVersionInput - { - [DebuggerHidden] - get - { - m_ApplicationVersionInput = MyForms.Create__Instance__(m_ApplicationVersionInput); - return m_ApplicationVersionInput; - } - - [DebuggerHidden] - set - { - if (value == m_ApplicationVersionInput) - return; - if (value is object) - throw new ArgumentException("Property can only be set to Nothing"); - Dispose__Instance__(ref m_ApplicationVersionInput); - } - } - - [EditorBrowsable(EditorBrowsableState.Never)] - public UpdateManagerWindow m_UpdateManagerWindow; - - public UpdateManagerWindow UpdateManagerWindow - { - [DebuggerHidden] - get - { - m_UpdateManagerWindow = MyForms.Create__Instance__(m_UpdateManagerWindow); - return m_UpdateManagerWindow; - } - - [DebuggerHidden] - set - { - if (value == m_UpdateManagerWindow) - return; - if (value is object) - throw new ArgumentException("Property can only be set to Nothing"); - Dispose__Instance__(ref m_UpdateManagerWindow); - } - } - - [EditorBrowsable(EditorBrowsableState.Never)] - public UpdateServerInfoEditor m_UpdateServerInfoEditor; - - public UpdateServerInfoEditor UpdateServerInfoEditor - { - [DebuggerHidden] - get - { - m_UpdateServerInfoEditor = MyForms.Create__Instance__(m_UpdateServerInfoEditor); - return m_UpdateServerInfoEditor; - } - - [DebuggerHidden] - set - { - if (value == m_UpdateServerInfoEditor) - return; - if (value is object) - throw new ArgumentException("Property can only be set to Nothing"); - Dispose__Instance__(ref m_UpdateServerInfoEditor); - } - } - } - } -} \ No newline at end of file diff --git a/Pilz.Updating.Administration.GUI/My Project/MyNamespace.Static.1.Designer.cs b/Pilz.Updating.Administration.GUI/My Project/MyNamespace.Static.1.Designer.cs deleted file mode 100644 index c8b31a5..0000000 --- a/Pilz.Updating.Administration.GUI/My Project/MyNamespace.Static.1.Designer.cs +++ /dev/null @@ -1,305 +0,0 @@ -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Collections; -using System.Diagnostics; -using System.Windows.Forms; -using Microsoft.VisualBasic; - -/* TODO ERROR: Skipped IfDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia */ - /* TODO ERROR: Skipped IfDirectiveTrivia */ - /* TODO ERROR: Skipped DefineDirectiveTrivia *//* TODO ERROR: Skipped DefineDirectiveTrivia *//* TODO ERROR: Skipped DefineDirectiveTrivia *//* TODO ERROR: Skipped DefineDirectiveTrivia *//* TODO ERROR: Skipped DefineDirectiveTrivia */ - /* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia */ - /* TODO ERROR: Skipped IfDirectiveTrivia */ -namespace Pilz.Updating.Administration.GUI.My -{ - - /* TODO ERROR: Skipped IfDirectiveTrivia */ - [System.CodeDom.Compiler.GeneratedCode("MyTemplate", "11.0.0.0")] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - - /* TODO ERROR: Skipped IfDirectiveTrivia */ - internal partial class MyApplication : Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase - { - /* TODO ERROR: Skipped IfDirectiveTrivia */ - [STAThread()] - [DebuggerHidden()] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)] - internal static void Main(string[] Args) - { - try - { - Application.SetCompatibleTextRenderingDefault(UseCompatibleTextRendering); - } - finally - { - } - - MyProject.Application.Run(Args); - } - /* TODO ERROR: Skipped EndIfDirectiveTrivia */ - /* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia */ - } - - /* TODO ERROR: Skipped EndIfDirectiveTrivia */ - /* TODO ERROR: Skipped IfDirectiveTrivia */ - [System.CodeDom.Compiler.GeneratedCode("MyTemplate", "11.0.0.0")] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - - /* TODO ERROR: Skipped IfDirectiveTrivia */ - internal partial class MyComputer : Microsoft.VisualBasic.Devices.Computer - { - /* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia */ - [DebuggerHidden()] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public MyComputer() : base() - { - } - } - /* TODO ERROR: Skipped EndIfDirectiveTrivia */ - [HideModuleName()] - [System.CodeDom.Compiler.GeneratedCode("MyTemplate", "11.0.0.0")] - internal static partial class MyProject - { - - /* TODO ERROR: Skipped IfDirectiveTrivia */ - [System.ComponentModel.Design.HelpKeyword("My.Computer")] - internal static MyComputer Computer - { - [DebuggerHidden()] - get - { - return m_ComputerObjectProvider.GetInstance; - } - } - - private readonly static ThreadSafeObjectProvider m_ComputerObjectProvider = new ThreadSafeObjectProvider(); - /* TODO ERROR: Skipped EndIfDirectiveTrivia */ - /* TODO ERROR: Skipped IfDirectiveTrivia */ - [System.ComponentModel.Design.HelpKeyword("My.Application")] - internal static MyApplication Application - { - [DebuggerHidden()] - get - { - return m_AppObjectProvider.GetInstance; - } - } - - private readonly static ThreadSafeObjectProvider m_AppObjectProvider = new ThreadSafeObjectProvider(); - /* TODO ERROR: Skipped EndIfDirectiveTrivia */ - /* TODO ERROR: Skipped IfDirectiveTrivia */ - [System.ComponentModel.Design.HelpKeyword("My.User")] - internal static Microsoft.VisualBasic.ApplicationServices.User User - { - [DebuggerHidden()] - get - { - return m_UserObjectProvider.GetInstance; - } - } - - private readonly static ThreadSafeObjectProvider m_UserObjectProvider = new ThreadSafeObjectProvider(); - /* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia */ - /* TODO ERROR: Skipped IfDirectiveTrivia */ - /* TODO ERROR: Skipped DefineDirectiveTrivia */ - [System.ComponentModel.Design.HelpKeyword("My.Forms")] - internal static MyForms Forms - { - [DebuggerHidden()] - get - { - return m_MyFormsObjectProvider.GetInstance; - } - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [MyGroupCollection("System.Windows.Forms.Form", "Create__Instance__", "Dispose__Instance__", "My.MyProject.Forms")] - internal sealed partial class MyForms - { - [DebuggerHidden()] - private static T Create__Instance__(T Instance) where T : Form, new() - { - if (Instance is null || Instance.IsDisposed) - { - if (m_FormBeingCreated is object) - { - if (m_FormBeingCreated.ContainsKey(typeof(T)) == true) - { - throw new InvalidOperationException(Microsoft.VisualBasic.CompilerServices.Utils.GetResourceString("WinForms_RecursiveFormCreate")); - } - } - else - { - m_FormBeingCreated = new Hashtable(); - } - - m_FormBeingCreated.Add(typeof(T), null); - try - { - return new T(); - } - catch (System.Reflection.TargetInvocationException ex) when (ex.InnerException is object) - { - string BetterMessage = Microsoft.VisualBasic.CompilerServices.Utils.GetResourceString("WinForms_SeeInnerException", ex.InnerException.Message); - throw new InvalidOperationException(BetterMessage, ex.InnerException); - } - finally - { - m_FormBeingCreated.Remove(typeof(T)); - } - } - else - { - return Instance; - } - } - - [DebuggerHidden()] - private void Dispose__Instance__(ref T instance) where T : Form - { - instance.Dispose(); - instance = null; - } - - [DebuggerHidden()] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public MyForms() : base() - { - } - - [ThreadStatic()] - private static Hashtable m_FormBeingCreated; - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public override bool Equals(object o) - { - return base.Equals(o); - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public override int GetHashCode() - { - return base.GetHashCode(); - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - internal new Type GetType() - { - return typeof(MyForms); - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public override string ToString() - { - return base.ToString(); - } - } - - private static ThreadSafeObjectProvider m_MyFormsObjectProvider = new ThreadSafeObjectProvider(); - - /* TODO ERROR: Skipped EndIfDirectiveTrivia */ - /* TODO ERROR: Skipped IfDirectiveTrivia */ - [System.ComponentModel.Design.HelpKeyword("My.WebServices")] - internal static MyWebServices WebServices - { - [DebuggerHidden()] - get - { - return m_MyWebServicesObjectProvider.GetInstance; - } - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [MyGroupCollection("System.Web.Services.Protocols.SoapHttpClientProtocol", "Create__Instance__", "Dispose__Instance__", "")] - internal sealed class MyWebServices - { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [DebuggerHidden()] - public override bool Equals(object o) - { - return base.Equals(o); - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [DebuggerHidden()] - public override int GetHashCode() - { - return base.GetHashCode(); - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [DebuggerHidden()] - internal new Type GetType() - { - return typeof(MyWebServices); - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [DebuggerHidden()] - public override string ToString() - { - return base.ToString(); - } - - [DebuggerHidden()] - private static T Create__Instance__(T instance) where T : new() - { - if (instance == null) - { - return new T(); - } - else - { - return instance; - } - } - - [DebuggerHidden()] - private void Dispose__Instance__(ref T instance) - { - instance = default; - } - - [DebuggerHidden()] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public MyWebServices() : base() - { - } - } - - private readonly static ThreadSafeObjectProvider m_MyWebServicesObjectProvider = new ThreadSafeObjectProvider(); - /* TODO ERROR: Skipped EndIfDirectiveTrivia */ - /* TODO ERROR: Skipped IfDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia */ - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [System.Runtime.InteropServices.ComVisible(false)] - internal sealed class ThreadSafeObjectProvider where T : new() - { - internal T GetInstance - { - /* TODO ERROR: Skipped IfDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped ElseDirectiveTrivia */ - [DebuggerHidden()] - get - { - if (m_ThreadStaticValue == null) - m_ThreadStaticValue = new T(); - return m_ThreadStaticValue; - } - /* TODO ERROR: Skipped EndIfDirectiveTrivia */ - } - - [DebuggerHidden()] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public ThreadSafeObjectProvider() : base() - { - } - - /* TODO ERROR: Skipped IfDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped ElseDirectiveTrivia */ - [System.Runtime.CompilerServices.CompilerGenerated()] - [ThreadStatic()] - private static T m_ThreadStaticValue; - /* TODO ERROR: Skipped EndIfDirectiveTrivia */ - } - } -} -/* TODO ERROR: Skipped EndIfDirectiveTrivia */ diff --git a/Pilz.Updating.Administration.GUI/My Project/MyNamespace.Static.2.Designer.cs b/Pilz.Updating.Administration.GUI/My Project/MyNamespace.Static.2.Designer.cs deleted file mode 100644 index 1ecf79d..0000000 --- a/Pilz.Updating.Administration.GUI/My Project/MyNamespace.Static.2.Designer.cs +++ /dev/null @@ -1,253 +0,0 @@ -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -// See Compiler::LoadXmlSolutionExtension -using System.Collections; -using System.Collections.Generic; -using System.Data; -using System.Diagnostics; -using System.Linq; -using System.Xml.Linq; -using Microsoft.VisualBasic; -using Microsoft.VisualBasic.CompilerServices; - -namespace Pilz.Updating.Administration.GUI.My -{ - [Embedded()] - [DebuggerNonUserCode()] - [System.Runtime.CompilerServices.CompilerGenerated()] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - internal sealed class InternalXmlHelper - { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - private InternalXmlHelper() - { - } - - public static string get_Value(IEnumerable source) - { - foreach (XElement item in source) - return item.Value; - return null; - } - - public static void set_Value(IEnumerable source, string value) - { - foreach (XElement item in source) - { - item.Value = value; - break; - } - } - - public static string get_AttributeValue(IEnumerable source, XName name) - { - foreach (XElement item in source) - return Conversions.ToString(item.Attribute(name)); - return null; - } - - public static void set_AttributeValue(IEnumerable source, XName name, string value) - { - foreach (XElement item in source) - { - item.SetAttributeValue(name, value); - break; - } - } - - public static string get_AttributeValue(XElement source, XName name) - { - return Conversions.ToString(source.Attribute(name)); - } - - public static void set_AttributeValue(XElement source, XName name, string value) - { - source.SetAttributeValue(name, value); - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static XAttribute CreateAttribute(XName name, object value) - { - if (value is null) - { - return null; - } - - return new XAttribute(name, value); - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static XAttribute CreateNamespaceAttribute(XName name, XNamespace ns) - { - var a = new XAttribute(name, ns.NamespaceName); - a.AddAnnotation(ns); - return a; - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static object RemoveNamespaceAttributes(string[] inScopePrefixes, XNamespace[] inScopeNs, List attributes, object obj) - { - if (obj is object) - { - XElement elem = obj as XElement; - if (elem is object) - { - return RemoveNamespaceAttributes(inScopePrefixes, inScopeNs, attributes, elem); - } - else - { - IEnumerable elems = obj as IEnumerable; - if (elems is object) - { - return RemoveNamespaceAttributes(inScopePrefixes, inScopeNs, attributes, elems); - } - } - } - - return obj; - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static IEnumerable RemoveNamespaceAttributes(string[] inScopePrefixes, XNamespace[] inScopeNs, List attributes, IEnumerable obj) - { - if (obj is object) - { - IEnumerable elems = obj as IEnumerable; - if (elems is object) - { - return elems.Select(new RemoveNamespaceAttributesClosure(inScopePrefixes, inScopeNs, attributes).ProcessXElement); - } - else - { - return obj.Cast().Select(new RemoveNamespaceAttributesClosure(inScopePrefixes, inScopeNs, attributes).ProcessObject); - } - } - - return obj; - } - - [DebuggerNonUserCode()] - [System.Runtime.CompilerServices.CompilerGenerated()] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - private sealed class RemoveNamespaceAttributesClosure - { - private readonly string[] m_inScopePrefixes; - private readonly XNamespace[] m_inScopeNs; - private readonly List m_attributes; - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - internal RemoveNamespaceAttributesClosure(string[] inScopePrefixes, XNamespace[] inScopeNs, List attributes) - { - m_inScopePrefixes = inScopePrefixes; - m_inScopeNs = inScopeNs; - m_attributes = attributes; - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - internal XElement ProcessXElement(XElement elem) - { - return RemoveNamespaceAttributes(m_inScopePrefixes, m_inScopeNs, m_attributes, elem); - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - internal object ProcessObject(object obj) - { - XElement elem = obj as XElement; - if (elem is object) - { - return RemoveNamespaceAttributes(m_inScopePrefixes, m_inScopeNs, m_attributes, elem); - } - else - { - return obj; - } - } - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static XElement RemoveNamespaceAttributes(string[] inScopePrefixes, XNamespace[] inScopeNs, List attributes, XElement e) - { - if (e is object) - { - var a = e.FirstAttribute; - while (a is object) - { - var nextA = a.NextAttribute; - if (a.IsNamespaceDeclaration) - { - var ns = a.Annotation(); - string prefix = a.Name.LocalName; - if (ns is object) - { - if (inScopePrefixes is object && inScopeNs is object) - { - int lastIndex = inScopePrefixes.Length - 1; - for (int i = 0, loopTo = lastIndex; i <= loopTo; i++) - { - string currentInScopePrefix = inScopePrefixes[i]; - var currentInScopeNs = inScopeNs[i]; - if (prefix.Equals(currentInScopePrefix)) - { - if (ns == currentInScopeNs) - { - // prefix and namespace match. Remove the unneeded ns attribute - a.Remove(); - } - - // prefix is in scope but refers to something else. Leave the ns attribute. - a = null; - break; - } - } - } - - if (a is object) - { - // Prefix is not in scope - // Now check whether it's going to be in scope because it is in the attributes list - - if (attributes is object) - { - int lastIndex = attributes.Count - 1; - for (int i = 0, loopTo1 = lastIndex; i <= loopTo1; i++) - { - var currentA = attributes[i]; - string currentInScopePrefix = currentA.Name.LocalName; - var currentInScopeNs = currentA.Annotation(); - if (currentInScopeNs is object) - { - if (prefix.Equals(currentInScopePrefix)) - { - if (ns == currentInScopeNs) - { - // prefix and namespace match. Remove the unneeded ns attribute - a.Remove(); - } - - // prefix is in scope but refers to something else. Leave the ns attribute. - a = null; - break; - } - } - } - } - - if (a is object) - { - // Prefix is definitely not in scope - a.Remove(); - // namespace is not defined either. Add this attributes list - attributes.Add(a); - } - } - } - } - - a = nextA; - } - } - - return e; - } - } -} \ No newline at end of file diff --git a/Pilz.Updating.Administration.GUI/My Project/MyNamespace.Static.3.Designer.cs b/Pilz.Updating.Administration.GUI/My Project/MyNamespace.Static.3.Designer.cs deleted file mode 100644 index b2b5044..0000000 --- a/Pilz.Updating.Administration.GUI/My Project/MyNamespace.Static.3.Designer.cs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; - -namespace Microsoft.VisualBasic -{ - [Embedded()] - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Module | AttributeTargets.Assembly, Inherited = false)] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [System.Runtime.CompilerServices.CompilerGenerated()] - internal sealed class Embedded : Attribute - { - } -} \ No newline at end of file diff --git a/Pilz.Updating.Administration.GUI/MyApplicationExtension.cs b/Pilz.Updating.Administration.GUI/MyApplicationExtension.cs deleted file mode 100644 index 09774d8..0000000 --- a/Pilz.Updating.Administration.GUI/MyApplicationExtension.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Microsoft.VisualBasic.ApplicationServices; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; -using Telerik.WinControls; -using Telerik.WinControls.Themes; - -namespace Pilz.Updating.Administration.GUI.My -{ - - // HINWEIS: Diese Datei wird automatisch generiert und darf nicht direkt bearbeitet werden. Wenn Sie Änderungen vornehmen möchten - // oder in dieser Datei Buildfehler auftreten, wechseln Sie zum Projekt-Designer. - // (Wechseln Sie dazu zu den Projekteigenschaften, oder doppelklicken Sie auf den Knoten "Mein Projekt" im - // Projektmappen-Explorer). Nehmen Sie auf der Registerkarte "Anwendung" entsprechende Änderungen vor. - // - internal partial class MyApplication - { - protected override bool OnStartup(StartupEventArgs eventArgs) - { - var success = ThemeResolutionService.LoadPackageResource("Pilz.Updating.Administration.GUI.CustomThemes.Office2019DarkPurple.tssp"); - if (success) - ThemeResolutionService.ApplicationThemeName = "Office2019DarkPurple"; - return base.OnStartup(eventArgs); - } - } -} diff --git a/Pilz.Updating.Administration.GUI/PackageDescriptionEditor.cs b/Pilz.Updating.Administration.GUI/PackageDescriptionEditor.cs index b7aabb7..a574b4f 100644 --- a/Pilz.Updating.Administration.GUI/PackageDescriptionEditor.cs +++ b/Pilz.Updating.Administration.GUI/PackageDescriptionEditor.cs @@ -1,62 +1,60 @@ using System; -using Microsoft.VisualBasic.CompilerServices; using Telerik.WinControls.UI; -namespace Pilz.Updating.Administration.GUI +namespace Pilz.Updating.Administration.GUI; + +public partial class PackageDescriptionEditor { - public partial class PackageDescriptionEditor + + // C o n s t r u c t o r s + + public PackageDescriptionEditor() { + InitializeComponent(); - // C o n s t r u c t o r s - - public PackageDescriptionEditor() + radDropDownList_Formatting.Items.AddRange(new RadListDataItem[] { - InitializeComponent(); + new() { Text = "Nur Text", Tag = UpdateNotesContentType.PlainText }, + new() { Text = "Markdown", Tag = UpdateNotesContentType.Markdown }, + new() { Text = "HTML", Tag = UpdateNotesContentType.HTML }, + }); + } - radDropDownList_Formatting.Items.AddRange(new RadListDataItem[] - { - new RadListDataItem { Text = "Nur Text", Tag = UpdateNotesContentType.PlainText }, - new RadListDataItem { Text = "Markdown", Tag = UpdateNotesContentType.Markdown }, - new RadListDataItem { Text = "HTML", Tag = UpdateNotesContentType.HTML }, - }); + // P r o p e r t i e s + + public string Titel + { + get + { + return radTextBoxControl_Titel.Text; } - - // P r o p e r t i e s - - public string Titel + set { - get - { - return radTextBoxControl_Titel.Text; - } - set - { - radTextBoxControl_Titel.Text = value; - } + radTextBoxControl_Titel.Text = value; } + } - public string Description + public string Description + { + get { - get - { - return radTextBox_Description.Text; - } - set - { - radTextBox_Description.Text = value ?? String.Empty; - } + return radTextBox_Description.Text; } - - public UpdateNotesContentType DescriptionType + set { - get => - (UpdateNotesContentType)radDropDownList_Formatting.SelectedItem?.Tag; - set - { - foreach (var item in radDropDownList_Formatting.Items) - if ((UpdateNotesContentType)item.Tag == value) - radDropDownList_Formatting.SelectedItem = item; - } + radTextBox_Description.Text = value ?? String.Empty; + } + } + + public UpdateNotesContentType DescriptionType + { + get => + (UpdateNotesContentType)radDropDownList_Formatting.SelectedItem?.Tag; + set + { + foreach (var item in radDropDownList_Formatting.Items) + if ((UpdateNotesContentType)item.Tag == value) + radDropDownList_Formatting.SelectedItem = item; } } } \ No newline at end of file diff --git a/Pilz.Updating.Administration.GUI/Pilz.Updating.Administration.GUI.csproj b/Pilz.Updating.Administration.GUI/Pilz.Updating.Administration.GUI.csproj index 95ac27d..672e751 100644 --- a/Pilz.Updating.Administration.GUI/Pilz.Updating.Administration.GUI.csproj +++ b/Pilz.Updating.Administration.GUI/Pilz.Updating.Administration.GUI.csproj @@ -48,13 +48,10 @@ - + - - 2023.1.117 - @@ -71,15 +68,11 @@ - - Form - + DiscordBotSettingsWindow.cs - - Form - + DiscordPostDialog.cs @@ -90,17 +83,11 @@ ApplicationVersionInput.cs - - Form - + UpdateManagerWindow.cs - - True - Application.myapp - True True @@ -111,9 +98,7 @@ Settings.settings True - - Form - + ProxyConfigEditor.cs @@ -162,10 +147,6 @@ - - MyApplicationCodeGenerator - Application.Designer.cs - SettingsSingleFileGenerator Pilz.Updating.Administration.GUI.My @@ -217,9 +198,11 @@ - + + + diff --git a/Pilz.Updating.Administration.GUI/Program.cs b/Pilz.Updating.Administration.GUI/Program.cs new file mode 100644 index 0000000..f5ff5f7 --- /dev/null +++ b/Pilz.Updating.Administration.GUI/Program.cs @@ -0,0 +1,21 @@ +using Pilz.Updating.Administration.GUI; +using System.Windows.Forms; +using Telerik.WinControls; + +namespace Pilz.Updating.UpdateInstaller; + +internal static class Program +{ + internal static void Main(string[] args) + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.SetHighDpiMode(HighDpiMode.PerMonitorV2); + + var success = ThemeResolutionService.LoadPackageResource("Pilz.Updating.Administration.GUI.CustomThemes.Office2019DarkPurple.tssp"); + if (success) + ThemeResolutionService.ApplicationThemeName = "Office2019DarkPurple"; + + Application.Run(new UpdateManagerWindow()); + } +} diff --git a/Pilz.Updating.Administration.GUI/Properties/AssemblyInfo.cs b/Pilz.Updating.Administration.GUI/Properties/AssemblyInfo.cs index f18f55d..3cace83 100644 --- a/Pilz.Updating.Administration.GUI/Properties/AssemblyInfo.cs +++ b/Pilz.Updating.Administration.GUI/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using global::System; -using global::System.Reflection; using global::System.Runtime.InteropServices; [assembly: ComVisible(false)] diff --git a/Pilz.Updating.Administration.GUI/ProxyConfigEditor.cs b/Pilz.Updating.Administration.GUI/ProxyConfigEditor.cs index 5caef2b..b80d725 100644 --- a/Pilz.Updating.Administration.GUI/ProxyConfigEditor.cs +++ b/Pilz.Updating.Administration.GUI/ProxyConfigEditor.cs @@ -1,38 +1,29 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; using Telerik.WinControls.UI; -namespace Pilz.Updating.Administration.GUI +namespace Pilz.Updating.Administration.GUI; + +public partial class ProxyConfigEditor : RadForm { - public partial class ProxyConfigEditor : RadForm + private readonly ProxyConfiguration config = null; + + public ProxyConfigEditor(ProxyConfiguration config) { - private readonly ProxyConfiguration config = null; + this.config = config; + InitializeComponent(); + } - public ProxyConfigEditor(ProxyConfiguration config) - { - this.config = config; - InitializeComponent(); - } + private void UpdateServerInfoEditor_Shown(object sender, EventArgs e) + { + radToggleSwitch_UserProxy.Value = config.UseProxyAuth; + radTextBoxControl_Username.Text = config.Username; + radTextBoxControl_Password.Text = config.Password ?? string.Empty; + } - private void UpdateServerInfoEditor_Shown(object sender, EventArgs e) - { - radToggleSwitch_UserProxy.Value = config.UseProxyAuth; - radTextBoxControl_Username.Text = config.Username; - radTextBoxControl_Password.Text = config.Password ?? string.Empty; - } - - private void ButtonX_OK_Click(object sender, EventArgs e) - { - config.UseProxyAuth = radToggleSwitch_UserProxy.Value; - config.Username = radTextBoxControl_Username.Text.Trim(); - config.Password = radTextBoxControl_Password.Text; - } + private void ButtonX_OK_Click(object sender, EventArgs e) + { + config.UseProxyAuth = radToggleSwitch_UserProxy.Value; + config.Username = radTextBoxControl_Username.Text.Trim(); + config.Password = radTextBoxControl_Password.Text; } } diff --git a/Pilz.Updating.Administration.GUI/UpdateManagerWindow.cs b/Pilz.Updating.Administration.GUI/UpdateManagerWindow.cs index 7442947..f2d96d9 100644 --- a/Pilz.Updating.Administration.GUI/UpdateManagerWindow.cs +++ b/Pilz.Updating.Administration.GUI/UpdateManagerWindow.cs @@ -1,725 +1,726 @@ -using System; -using System.Collections.Generic; -using global::System.IO; -using System.Linq; -using System.Windows.Forms; +using global::System.IO; using Microsoft.VisualBasic.CompilerServices; -using Z.Collections.Extensions; -using System.Threading.Tasks; using Pilz.Updating.Administration.Discord; -using Telerik.WinControls.UI; -using Telerik.WinControls; using Pilz.Updating.Administration.Packaging; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using System.Windows.Forms; +using Telerik.WinControls; +using Telerik.WinControls.UI; +using Z.Collections.Extensions; -namespace Pilz.Updating.Administration.GUI +namespace Pilz.Updating.Administration.GUI; + +public partial class UpdateManagerWindow { - public partial class UpdateManagerWindow + + // C o n s t a n t s + + private const string FILTER_UPDATEINFO_CONFIGURATION = "JSON (*.json)|*.json"; + private const string FILTER_UPDATEPROJECT = "Update-Info-Konfiguration (*.udic)|*.udic"; + private const string FILTER_UPDATEPACKAGE = "ZIP-Archiv (*.zip)|*.zip"; + private const string FILTER_PACKAGE_TEMPLATE = "Update-Paket-Vorlagen (*.udpt)|*.udpt"; + private const string FILTER_PACKAGE_ZIP_PACKAGE = "ZIP-Paket (*.zip)|*.zip"; + private const string FILTER_PACKAGE_ADDON = "Anwendungserweiterung (*.dll)|*.dll"; + + // F i e l d s + + private string curProjectFilePath; + private UpdateServerManager manager = null; + private DiscordBot discordBot = null; + private readonly UpdatePackageManager packageManager = new UpdatePackageManager(); + private string curPackageTemplatePath = string.Empty; + + // P r o p e r t i e s + + public string TempPackageFilePath { get; private set; } = string.Empty; + + // C o n s t r u c t o r s + + public UpdateManagerWindow() { + this.Shown += UpdateManagerWindow_Shown; + this.Load += UpdateManagerWindow_Load; + this.FormClosing += UpdateManagerWindow_FormClosing; + InitializeComponent(); + this.AllowAero = false; + SetEnabledUiControls(false); + } - // C o n s t a n t s + // F e a t u r e s - private const string FILTER_UPDATEINFO_CONFIGURATION = "JSON (*.json)|*.json"; - private const string FILTER_UPDATEPROJECT = "Update-Info-Konfiguration (*.udic)|*.udic"; - private const string FILTER_UPDATEPACKAGE = "ZIP-Archiv (*.zip)|*.zip"; - private const string FILTER_PACKAGE_TEMPLATE = "Update-Paket-Vorlagen (*.udpt)|*.udpt"; - private const string FILTER_PACKAGE_ZIP_PACKAGE = "ZIP-Paket (*.zip)|*.zip"; - private const string FILTER_PACKAGE_ADDON = "Anwendungserweiterung (*.dll)|*.dll"; + private void ProgressControls(bool enabled) + { + if (enabled) + radWaitingBar_PackageLoading.StartWaiting(); + else + radWaitingBar_PackageLoading.StopWaiting(); + } - // F i e l d s + private void ProgressPackagingControls(bool enabled) + { + if (enabled) + radWaitingBar_PackageCreation.StartWaiting(); + else + radWaitingBar_PackageCreation.StopWaiting(); + } - private string curProjectFilePath; - private UpdateServerManager manager = null; - private DiscordBot discordBot = null; - private readonly UpdatePackageManager packageManager = new UpdatePackageManager(); - private string curPackageTemplatePath = string.Empty; + private void SetEnabledUiControls(bool enabled, bool setProjectOptionsAlwayToTrue = false) + { + radRibbonBarGroup_Options.Enabled = enabled || setProjectOptionsAlwayToTrue; + radButtonElement_SaveProject.Enabled = enabled || setProjectOptionsAlwayToTrue; + radRibbonBarGroup_Configuration.Enabled = enabled; + radRibbonBarGroup_NewPackage.Enabled = enabled; + } - // P r o p e r t i e s - - public string TempPackageFilePath { get; private set; } = string.Empty; - - // C o n s t r u c t o r s - - public UpdateManagerWindow() - { - this.Shown += UpdateManagerWindow_Shown; - this.Load += UpdateManagerWindow_Load; - this.FormClosing += UpdateManagerWindow_FormClosing; - InitializeComponent(); - this.AllowAero = false; - SetEnabledUiControls(false); - } - - // F e a t u r e s - - private void ProgressControls(bool enabled) - { - if (enabled) - radWaitingBar_PackageLoading.StartWaiting(); - else - radWaitingBar_PackageLoading.StopWaiting(); - } - - private void ProgressPackagingControls(bool enabled) - { - if (enabled) - radWaitingBar_PackageCreation.StartWaiting(); - else - radWaitingBar_PackageCreation.StopWaiting(); - } - - private void SetEnabledUiControls(bool enabled, bool setProjectOptionsAlwayToTrue = false) - { - radRibbonBarGroup_Options.Enabled = enabled || setProjectOptionsAlwayToTrue; - radButtonElement_SaveProject.Enabled = enabled || setProjectOptionsAlwayToTrue; - radRibbonBarGroup_Configuration.Enabled = enabled; - radRibbonBarGroup_NewPackage.Enabled = enabled; - } - - private async Task CreateNewProject(string filePath) - { - var oldProject = General.CurProject; - General.CurProject = new UpdateProject(); - if (My.MyProject.Forms.UpdateServerInfoEditor.ShowDialog(this) == DialogResult.OK) - { - curProjectFilePath = filePath; - SaveProject(curProjectFilePath); - await LoadManager(); - } - else - General.CurProject = oldProject; - } - - private async Task OpenProject(string filePath) + private async Task CreateNewProject(string filePath) + { + var oldProject = General.CurProject; + General.CurProject = new UpdateProject(); + if (new UpdateServerInfoEditor().ShowDialog(this) == DialogResult.OK) { curProjectFilePath = filePath; - General.CurProject = UpdateProject.Load(filePath); - General.SetProxyConfig(); - await LoadManager(); - } - - private void SaveProject(string filePath) - { - General.CurProject.Save(filePath); - } - - private async Task LoadManager() - { - bool hasError; - ProgressControls(true); - - try - { - manager = new UpdateServerManager(General.CurProject.UpdateServerConfig); - - if (await manager.LoadInfoFromServer()) - { - await LoadPackageList(); - LoadUpdateInstallerInfos(); - - hasError = false; - } - else - hasError = true; - } - catch (Exception) - { - hasError = true; - } - - if (hasError) - { - RadMessageBox.Show(this, "Ein Fehler ist aufgetreten beim laden des Servers.", string.Empty, MessageBoxButtons.OK, RadMessageIcon.Error); - SetEnabledUiControls(false, true); - } - else - SetEnabledUiControls(true); - - ProgressControls(false); - } - - private async Task LoadPackageList() - { - ProgressControls(true); - radListView_Packages.BeginUpdate(); - radListView_Packages.Items.Clear(); - - foreach (var pkgVersion in await manager.GetUpdatePackagesList()) - { - var name = manager.GetPackageDescription(pkgVersion).name; - var cells = new List(); - - cells.Add(string.IsNullOrEmpty(name) ? "" : name); - cells.Add(pkgVersion.Version.ToString()); - cells.Add(pkgVersion.Channel.ToString()); - cells.Add(pkgVersion.Build.ToString()); - cells.Add("Ja"); - - var item = new ListViewDataItem(String.Empty, cells.ToArray()) - { - Tag = pkgVersion - }; - - radListView_Packages.Items.Add(item); - } - - radListView_Packages.EndUpdate(); - ProgressControls(false); - - if (radListView_Packages.HasChildren) - radListView_Packages.SelectedItem = radListView_Packages.Items[0]; - } - - private void LoadUpdateInstallerInfos() - { - radTextBoxControl_DownloadURL.Text = manager.UpdateInfo.UpdateInstallerLink; - } - - private ApplicationVersion GetSelectedPackageVersion() - { - return radListView_Packages.SelectedItem?.Tag as ApplicationVersion; - } - - private async Task UploadPackage(string filePath) - { - var success = false; - var resVersion = EditApplicationVersion(); - - if (!resVersion.canceled) - { - ProgressControls(true); - if (await manager.UploadPackage(filePath, resVersion.newVersion)) - success = true; - ProgressControls(false); - await SaveInfoToServer(); - } - - return success; - } - - private (ApplicationVersion newVersion, bool canceled) EditApplicationVersion() - { - return EditApplicationVersion(new ApplicationVersion()); - } - - private (ApplicationVersion newVersion, bool canceled) EditApplicationVersion(ApplicationVersion inputVersion) - { - var frm = new ApplicationVersionInput() - { - Version = inputVersion.Version, - Channel = inputVersion.Channel, - Build = inputVersion.Build - }; - - if (frm.ShowDialog(this) == DialogResult.OK) - return (new ApplicationVersion(frm.Version, frm.Build, frm.Channel), false); - else - return (inputVersion, true); - } - - private async Task DeletePackage(ApplicationVersion version) - { - ProgressControls(true); - bool success = await manager.DeletePackage(version); - ProgressControls(false); - return success; - } - - private async Task SaveInfoToServer() - { - ProgressControls(true); - bool success = await manager.SaveInfoToServer(); - ProgressControls(false); - return success; - } - - private async Task ChangePackageVersion(ApplicationVersion version) - { - bool success = false; - var (newVersion, canceled) = EditApplicationVersion(version); - - if (!canceled) - { - ProgressControls(true); - success = await manager.ChangePackageVersion(version, newVersion); - ProgressControls(false); - } - - return success; - } - - // G u i - - private void UpdateManagerWindow_Shown(object sender, EventArgs e) - { - } - - private async void UpdateManagerWindow_Load(object sender, EventArgs e) - { - string[] args = Environment.GetCommandLineArgs(); - - if (args.Length > 1) - { - try - { - await OpenProject(args[1]); - } - catch (Exception) { } - } - } - - private void UpdateManagerWindow_FormClosing(object sender, FormClosingEventArgs e) - { - if (discordBot is object) - discordBot.Stop(); - } - - private async void ButtonItem_NewProject_Click(object sender, EventArgs e) - { - var sfd_updateadministration_upa = new RadSaveFileDialog() - { - Filter = "Update Project Files (*.upa)|*.upa" - }; - if (sfd_updateadministration_upa.ShowDialog(this) == DialogResult.OK) - { - await CreateNewProject(sfd_updateadministration_upa.FileName); - } - } - - private async void ButtonItem_OpenProject_Click(object sender, EventArgs e) - { - var ofd_updateadministration_upa = new RadOpenFileDialog() - { - Filter = "Update Project Files (*.upa)|*.upa" - }; - if (ofd_updateadministration_upa.ShowDialog(this) == DialogResult.OK) - { - await OpenProject(ofd_updateadministration_upa.FileName); - } - } - - private void ButtonItem_SaveProject_Click(object sender, EventArgs e) - { SaveProject(curProjectFilePath); - } - - private async void ButtonItem_ProjectOptions_Click(object sender, EventArgs e) - { - My.MyProject.Forms.UpdateServerInfoEditor.ShowDialog(this); await LoadManager(); } + else + General.CurProject = oldProject; + } - private async void ButtonItem_UploadUpdateConfiguration_Click(object sender, EventArgs e) + private async Task OpenProject(string filePath) + { + curProjectFilePath = filePath; + General.CurProject = UpdateProject.Load(filePath); + General.SetProxyConfig(); + await LoadManager(); + } + + private void SaveProject(string filePath) + { + General.CurProject.Save(filePath); + } + + private async Task LoadManager() + { + bool hasError; + ProgressControls(true); + + try { + manager = new UpdateServerManager(General.CurProject.UpdateServerConfig); + + if (await manager.LoadInfoFromServer()) + { + await LoadPackageList(); + LoadUpdateInstallerInfos(); + + hasError = false; + } + else + hasError = true; + } + catch (Exception) + { + hasError = true; + } + + if (hasError) + { + RadMessageBox.Show(this, "Ein Fehler ist aufgetreten beim laden des Servers.", string.Empty, MessageBoxButtons.OK, RadMessageIcon.Error); + SetEnabledUiControls(false, true); + } + else + SetEnabledUiControls(true); + + ProgressControls(false); + } + + private async Task LoadPackageList() + { + ProgressControls(true); + radListView_Packages.BeginUpdate(); + radListView_Packages.Items.Clear(); + + foreach (var pkgVersion in await manager.GetUpdatePackagesList()) + { + var name = manager.GetPackageDescription(pkgVersion).name; + var cells = new List + { + string.IsNullOrEmpty(name) ? "" : name, + pkgVersion.Version.ToString(), + pkgVersion.Channel.ToString(), + pkgVersion.Build.ToString(), + "Ja" + }; + + var item = new ListViewDataItem(String.Empty, cells.ToArray()) + { + Tag = pkgVersion + }; + + radListView_Packages.Items.Add(item); + } + + radListView_Packages.EndUpdate(); + ProgressControls(false); + + if (radListView_Packages.HasChildren) + radListView_Packages.SelectedItem = radListView_Packages.Items[0]; + } + + private void LoadUpdateInstallerInfos() + { + radTextBoxControl_DownloadURL.Text = manager.UpdateInfo.UpdateInstallerLink; + } + + private ApplicationVersion GetSelectedPackageVersion() + { + return radListView_Packages.SelectedItem?.Tag as ApplicationVersion; + } + + private async Task UploadPackage(string filePath) + { + var success = false; + var resVersion = EditApplicationVersion(); + + if (!resVersion.canceled) + { + ProgressControls(true); + if (await manager.UploadPackage(filePath, resVersion.newVersion)) + success = true; + ProgressControls(false); await SaveInfoToServer(); } - private async void ButtonItem_ExportUpdateConfiguration_Click(object sender, EventArgs e) + return success; + } + + private (ApplicationVersion newVersion, bool canceled) EditApplicationVersion() + { + return EditApplicationVersion(new ApplicationVersion()); + } + + private (ApplicationVersion newVersion, bool canceled) EditApplicationVersion(ApplicationVersion inputVersion) + { + var frm = new ApplicationVersionInput() { - var sfd_UpdateAdministration_UpdateConfiguration = new RadSaveFileDialog() - { - Filter = FILTER_UPDATEINFO_CONFIGURATION - }; - if (sfd_UpdateAdministration_UpdateConfiguration.ShowDialog(this) == DialogResult.OK) - await manager.SaveInfoToFile(sfd_UpdateAdministration_UpdateConfiguration.FileName); - } + Version = inputVersion.Version, + Channel = inputVersion.Channel, + Build = inputVersion.Build + }; - private async void ButtonItem_CreateAndUploadPackage_Click(object sender, EventArgs e) + if (frm.ShowDialog(this) == DialogResult.OK) + return (new ApplicationVersion(frm.Version, frm.Build, frm.Channel), false); + else + return (inputVersion, true); + } + + private async Task DeletePackage(ApplicationVersion version) + { + ProgressControls(true); + bool success = await manager.DeletePackage(version); + ProgressControls(false); + return success; + } + + private async Task SaveInfoToServer() + { + ProgressControls(true); + bool success = await manager.SaveInfoToServer(); + ProgressControls(false); + return success; + } + + private async Task ChangePackageVersion(ApplicationVersion version) + { + bool success = false; + var (newVersion, canceled) = EditApplicationVersion(version); + + if (!canceled) { - var success = false; - - if (await ExportTempUpdatePackage()) - { - if (await UploadPackage(TempPackageFilePath)) - { - await LoadPackageList(); - success = true; - } - } - - if (!success) - RadMessageBox.Show(this, My.Resources.UpdatingAdministrationLangRes.MsgBox_PkgExportSuccess, My.Resources.UpdatingAdministrationLangRes.MsgBox_PkgExportSuccess_Titel, MessageBoxButtons.OK, RadMessageIcon.Info); - } - - private async void ButtonItem_UploadExistingPackage_Click(object sender, EventArgs e) - { - var ofd_UpdateAdministration_UpdatePackage = new RadOpenFileDialog() - { - Filter = FILTER_UPDATEPACKAGE - }; - - if (ofd_UpdateAdministration_UpdatePackage.ShowDialog(this) == DialogResult.OK) - { - if(await UploadPackage(ofd_UpdateAdministration_UpdatePackage.FileName)) - await LoadPackageList(); - } - } - - private async void ButtonItem_RemovePackage_Click(object sender, EventArgs e) - { - var version = GetSelectedPackageVersion(); - if (await DeletePackage(version)) - await LoadPackageList(); - } - - private void TextBoxX_UpdateInstallerDownloadUrl_TextChanged(object sender, EventArgs e) - { - manager.UpdateInfo.UpdateInstallerLink = radTextBoxControl_DownloadURL.Text.Trim(); - } - - private void ButtonItem_PostMsgInDiscord_Click(object sender, EventArgs e) - { - if (discordBot == null) - LoadDiscordBot(); - - if (discordBot is object) - { - var version = GetSelectedPackageVersion(); - var pkg = manager.GetUpdatePackageInfo(version); - var frm = new DiscordPostDialog(discordBot, pkg); - frm.ShowDialog(this); - } - else - RadMessageBox.Show(this, "Offenbar ist ein Fehler ist aufgetreten beim Laden des Discord-Bots.", string.Empty, MessageBoxButtons.OK, RadMessageIcon.Error); - } - - private void LoadDiscordBot() - { - if (discordBot is object) - discordBot.Stop(); - - discordBot = new DiscordBot(General.CurProject.DiscordBotConfig); - - bool hasLoaded = false; - bool hasError = false; - - discordBot.GotReady += (sender, e) => hasLoaded = true; - discordBot.LoggedMsg += (sender, msg, isError) => - { - if (isError) - hasError = true; - }; - - discordBot.Start(); - ProgressControls(true); - while (!hasLoaded && !hasError) - Application.DoEvents(); + success = await manager.ChangePackageVersion(version, newVersion); ProgressControls(false); - - if (hasError) - discordBot = null; } - private async void ButtonItem_ChangeVersion_Click(object sender, EventArgs e) + return success; + } + + // G u i + + private void UpdateManagerWindow_Shown(object sender, EventArgs e) + { + } + + private async void UpdateManagerWindow_Load(object sender, EventArgs e) + { + string[] args = Environment.GetCommandLineArgs(); + + if (args.Length > 1) { - var version = GetSelectedPackageVersion(); - if (await ChangePackageVersion(version)) - { - await SaveInfoToServer(); - await LoadPackageList(); - } - } - - private async void ButtonItem_EditDescription_Click(object sender, EventArgs e) - { - var version = GetSelectedPackageVersion(); - var desc = manager.GetPackageDescription(version); - - var frm = new PackageDescriptionEditor() - { - Titel = desc.name, - Description = desc.description, - DescriptionType = desc.descriptionType - }; - - if (frm.ShowDialog(this) == DialogResult.OK) - { - manager.SetPackageDescription(version, frm.Titel, frm.Description, frm.DescriptionType); - await SaveInfoToServer(); - } - } - - private void ButtonItem_BotSettings_Click(object sender, EventArgs e) - { - var frm = new DiscordBotSettingsWindow(General.CurProject.DiscordBotConfig); - if (frm.ShowDialog(this) == DialogResult.OK) - { - if (discordBot is not null) - LoadDiscordBot(); - } - } - - private void ButtonItem_ProxyConfig_Click(object sender, EventArgs e) - { - var frm = new ProxyConfigEditor(General.CurProject.ProxyConfig); - if (frm.ShowDialog(this) == DialogResult.OK) - General.SetProxyConfig(); - } - - private void RadListView_Packages_SelectedItemChanged(object sender, EventArgs e) - { - var anySelected = radListView_Packages.SelectedItem is not null; - radRibbonBarGroup_Discord.Enabled = anySelected; - radRibbonBarGroup_PackageManagement.Enabled = anySelected; - } - - private void RadListView1_CellFormatting(object sender, ListViewCellFormattingEventArgs e) - { - e.CellElement.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft; - } - - private void RadListView1_CellFormatting_1(object sender, ListViewCellFormattingEventArgs e) - { - e.CellElement.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft; - } - - private void RadPageView1_SelectedPageChanged(object sender, EventArgs e) - { - var selPage = radPageView1.SelectedPage; - - if (selPage == radPageViewPage_Extensions) - { - radRibbonBarGroup_PackageFiles.Visibility = ElementVisibility.Collapsed; - radRibbonBarGroup_PackageExtensions.Visibility = ElementVisibility.Visible; - } - else if (selPage == radPageViewPage_Packaging) - { - radRibbonBarGroup_PackageFiles.Visibility = ElementVisibility.Visible; - radRibbonBarGroup_PackageExtensions.Visibility = ElementVisibility.Collapsed; - } - } - - // F e a t u r e s - P a c k a g i n g - - private void ShowAllPackageTemplateConfig() - { - ShowPackageFiles(); - ShowPackageExtensions(); - } - - private void ShowPackageFiles() - { - radTreeView_PackagingFiles.BeginUpdate(); - radTreeView_PackagingFiles.Nodes.Clear(); - - if (!string.IsNullOrEmpty(packageManager.FilesToCopyPath)) - { - Action nodeCreation = null; - nodeCreation = (parentCollection, p) => - { - bool isDir = (File.GetAttributes(p) & FileAttributes.Directory) == FileAttributes.Directory; - var n = new RadTreeNode() - { - Tag = p, - Text = radTreeView_PackagingFiles.Nodes == parentCollection ? p : Path.GetFileName(p), - ImageIndex = isDir ? 0 : 1 - }; - parentCollection.Add(n); - if (isDir) - { - var dirInfo = new DirectoryInfo(p); - dirInfo.EnumerateDirectories().ForEach(di => nodeCreation(n.Nodes, di.FullName)); - dirInfo.EnumerateFiles().ForEach(fi => nodeCreation(n.Nodes, fi.FullName)); - } - }; - nodeCreation(radTreeView_PackagingFiles.Nodes, packageManager.FilesToCopyPath); - } - - radTreeView_PackagingFiles.EndUpdate(); - } - - private void ShowPackageExtensions() - { - radListView_Extensions.BeginUpdate(); - radListView_Extensions.Items.Clear(); - - foreach (string fAddOn in packageManager.GetAllUpdateInstallerÁddOn()) - { - var cells = new List(); - cells.Add(Path.GetFileName(fAddOn)); - cells.Add(Path.GetDirectoryName(fAddOn)); - - var item = new ListViewDataItem(string.Empty, cells.ToArray()) - { - Tag = fAddOn - }; - - radListView_Extensions.Items.Add(item); - } - - radListView_Extensions.EndUpdate(); - } - - private IEnumerable GetSelectedUpdateInstallAddOns() - { - var list = new List(); - foreach (var item in radListView_Extensions.SelectedItems) - list.Add(Conversions.ToString(item.Tag)); - return list; - } - - private void NewPackageTemplate() - { - packageManager.NewTemplate(); - curPackageTemplatePath = string.Empty; - ShowAllPackageTemplateConfig(); - } - - private void OpenPackageTemplate() - { - var ofd_UpdateAdmin_LoadTemplate = new RadOpenFileDialog() { Filter = FILTER_PACKAGE_TEMPLATE }; - if (ofd_UpdateAdmin_LoadTemplate.ShowDialog() == DialogResult.OK) - { - packageManager.LoadTemplate(ofd_UpdateAdmin_LoadTemplate.FileName); - curPackageTemplatePath = ofd_UpdateAdmin_LoadTemplate.FileName; - ShowAllPackageTemplateConfig(); - } - } - - private void SavePackageTemplate() - { - if (string.IsNullOrEmpty(curPackageTemplatePath)) - { - SavePackageTemplateAs(); - } - else - { - packageManager.SaveTemplate(curPackageTemplatePath); - } - } - - private void SavePackageTemplateAs() - { - var sfd_UpdateAdmin_SaveTemplate = new RadSaveFileDialog() { Filter = FILTER_PACKAGE_TEMPLATE }; - if (sfd_UpdateAdmin_SaveTemplate.ShowDialog() == DialogResult.OK) - { - packageManager.SaveTemplate(sfd_UpdateAdmin_SaveTemplate.FileName); - curPackageTemplatePath = sfd_UpdateAdmin_SaveTemplate.FileName; - } - } - - private void SelectPackageFileFolder() - { - var ofd_UpdateAdmin_PkgFileFolder = new RadOpenFolderDialog(); - if (ofd_UpdateAdmin_PkgFileFolder.ShowDialog() == DialogResult.OK) - { - packageManager.FilesToCopyPath = ofd_UpdateAdmin_PkgFileFolder.FileName; - ShowPackageFiles(); - } - } - - private void RemovePackageFileFolder() - { - packageManager.FilesToCopyPath = string.Empty; - ShowPackageFiles(); - } - - private async Task ExportUpdatePackage(string filePath) - { - bool success = false; - ProgressPackagingControls(true); - try { - await Task.Run(() => packageManager.ExportPackage(filePath)); + await OpenProject(args[1]); + } + catch (Exception) { } + } + } + + private void UpdateManagerWindow_FormClosing(object sender, FormClosingEventArgs e) + { + if (discordBot is object) + discordBot.Stop(); + } + + private async void ButtonItem_NewProject_Click(object sender, EventArgs e) + { + var sfd_updateadministration_upa = new RadSaveFileDialog() + { + Filter = "Update Project Files (*.upa)|*.upa" + }; + if (sfd_updateadministration_upa.ShowDialog(this) == DialogResult.OK) + { + await CreateNewProject(sfd_updateadministration_upa.FileName); + } + } + + private async void ButtonItem_OpenProject_Click(object sender, EventArgs e) + { + var ofd_updateadministration_upa = new RadOpenFileDialog() + { + Filter = "Update Project Files (*.upa)|*.upa" + }; + if (ofd_updateadministration_upa.ShowDialog(this) == DialogResult.OK) + { + await OpenProject(ofd_updateadministration_upa.FileName); + } + } + + private void ButtonItem_SaveProject_Click(object sender, EventArgs e) + { + SaveProject(curProjectFilePath); + } + + private async void ButtonItem_ProjectOptions_Click(object sender, EventArgs e) + { + new UpdateServerInfoEditor().ShowDialog(this); + await LoadManager(); + } + + private async void ButtonItem_UploadUpdateConfiguration_Click(object sender, EventArgs e) + { + await SaveInfoToServer(); + } + + private async void ButtonItem_ExportUpdateConfiguration_Click(object sender, EventArgs e) + { + var sfd_UpdateAdministration_UpdateConfiguration = new RadSaveFileDialog() + { + Filter = FILTER_UPDATEINFO_CONFIGURATION + }; + if (sfd_UpdateAdministration_UpdateConfiguration.ShowDialog(this) == DialogResult.OK) + await manager.SaveInfoToFile(sfd_UpdateAdministration_UpdateConfiguration.FileName); + } + + private async void ButtonItem_CreateAndUploadPackage_Click(object sender, EventArgs e) + { + var success = false; + + if (await ExportTempUpdatePackage()) + { + if (await UploadPackage(TempPackageFilePath)) + { + await LoadPackageList(); success = true; } - catch (Exception) - { - success = false; - } - - ProgressPackagingControls(false); - return success; } - private async Task ExportTempUpdatePackage() - { - var filePath = Path.GetTempFileName(); - bool res = await ExportUpdatePackage(filePath); - if (res) TempPackageFilePath = filePath; - return res; - } + if (!success) + RadMessageBox.Show(this, My.Resources.UpdatingAdministrationLangRes.MsgBox_PkgExportSuccess, My.Resources.UpdatingAdministrationLangRes.MsgBox_PkgExportSuccess_Titel, MessageBoxButtons.OK, RadMessageIcon.Info); + } - private void AddUpdateInstallerExtension() + private async void ButtonItem_UploadExistingPackage_Click(object sender, EventArgs e) + { + var ofd_UpdateAdministration_UpdatePackage = new RadOpenFileDialog() { - var ofd_UpdateAdmin_AddExtension = new RadOpenFileDialog() + Filter = FILTER_UPDATEPACKAGE + }; + + if (ofd_UpdateAdministration_UpdatePackage.ShowDialog(this) == DialogResult.OK) + { + if (await UploadPackage(ofd_UpdateAdministration_UpdatePackage.FileName)) + await LoadPackageList(); + } + } + + private async void ButtonItem_RemovePackage_Click(object sender, EventArgs e) + { + var version = GetSelectedPackageVersion(); + if (await DeletePackage(version)) + await LoadPackageList(); + } + + private void TextBoxX_UpdateInstallerDownloadUrl_TextChanged(object sender, EventArgs e) + { + manager.UpdateInfo.UpdateInstallerLink = radTextBoxControl_DownloadURL.Text.Trim(); + } + + private void ButtonItem_PostMsgInDiscord_Click(object sender, EventArgs e) + { + if (discordBot == null) + LoadDiscordBot(); + + if (discordBot is object) + { + var version = GetSelectedPackageVersion(); + var pkg = manager.GetUpdatePackageInfo(version); + var frm = new DiscordPostDialog(discordBot, pkg); + frm.ShowDialog(this); + } + else + RadMessageBox.Show(this, "Offenbar ist ein Fehler ist aufgetreten beim Laden des Discord-Bots.", string.Empty, MessageBoxButtons.OK, RadMessageIcon.Error); + } + + private void LoadDiscordBot() + { + if (discordBot is object) + discordBot.Stop(); + + discordBot = new DiscordBot(General.CurProject.DiscordBotConfig); + + bool hasLoaded = false; + bool hasError = false; + + discordBot.GotReady += (sender, e) => hasLoaded = true; + discordBot.LoggedMsg += (sender, msg, isError) => + { + if (isError) + hasError = true; + }; + + discordBot.Start(); + + ProgressControls(true); + while (!hasLoaded && !hasError) + Application.DoEvents(); + ProgressControls(false); + + if (hasError) + discordBot = null; + } + + private async void ButtonItem_ChangeVersion_Click(object sender, EventArgs e) + { + var version = GetSelectedPackageVersion(); + if (await ChangePackageVersion(version)) + { + await SaveInfoToServer(); + await LoadPackageList(); + } + } + + private async void ButtonItem_EditDescription_Click(object sender, EventArgs e) + { + var version = GetSelectedPackageVersion(); + var desc = manager.GetPackageDescription(version); + + var frm = new PackageDescriptionEditor() + { + Titel = desc.name, + Description = desc.description, + DescriptionType = desc.descriptionType + }; + + if (frm.ShowDialog(this) == DialogResult.OK) + { + manager.SetPackageDescription(version, frm.Titel, frm.Description, frm.DescriptionType); + await SaveInfoToServer(); + } + } + + private void ButtonItem_BotSettings_Click(object sender, EventArgs e) + { + var frm = new DiscordBotSettingsWindow(General.CurProject.DiscordBotConfig); + if (frm.ShowDialog(this) == DialogResult.OK) + { + if (discordBot is not null) + LoadDiscordBot(); + } + } + + private void ButtonItem_ProxyConfig_Click(object sender, EventArgs e) + { + var frm = new ProxyConfigEditor(General.CurProject.ProxyConfig); + if (frm.ShowDialog(this) == DialogResult.OK) + General.SetProxyConfig(); + } + + private void RadListView_Packages_SelectedItemChanged(object sender, EventArgs e) + { + var anySelected = radListView_Packages.SelectedItem is not null; + radRibbonBarGroup_Discord.Enabled = anySelected; + radRibbonBarGroup_PackageManagement.Enabled = anySelected; + } + + private void RadListView1_CellFormatting(object sender, ListViewCellFormattingEventArgs e) + { + e.CellElement.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft; + } + + private void RadListView1_CellFormatting_1(object sender, ListViewCellFormattingEventArgs e) + { + e.CellElement.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft; + } + + private void RadPageView1_SelectedPageChanged(object sender, EventArgs e) + { + var selPage = radPageView1.SelectedPage; + + if (selPage == radPageViewPage_Extensions) + { + radRibbonBarGroup_PackageFiles.Visibility = ElementVisibility.Collapsed; + radRibbonBarGroup_PackageExtensions.Visibility = ElementVisibility.Visible; + } + else if (selPage == radPageViewPage_Packaging) + { + radRibbonBarGroup_PackageFiles.Visibility = ElementVisibility.Visible; + radRibbonBarGroup_PackageExtensions.Visibility = ElementVisibility.Collapsed; + } + } + + // F e a t u r e s - P a c k a g i n g + + private void ShowAllPackageTemplateConfig() + { + ShowPackageFiles(); + ShowPackageExtensions(); + } + + private void ShowPackageFiles() + { + radTreeView_PackagingFiles.BeginUpdate(); + radTreeView_PackagingFiles.Nodes.Clear(); + + if (!string.IsNullOrEmpty(packageManager.FilesToCopyPath)) + { + Action nodeCreation = null; + nodeCreation = (parentCollection, p) => { - MultiSelect = true, - Filter = FILTER_PACKAGE_ADDON - }; - if (ofd_UpdateAdmin_AddExtension.ShowDialog() == DialogResult.OK) - { - foreach (string f in ofd_UpdateAdmin_AddExtension.FileNames) + bool isDir = (File.GetAttributes(p) & FileAttributes.Directory) == FileAttributes.Directory; + var n = new RadTreeNode() { - if (!packageManager.AddUpdateInstallerAddOn(f)) - { - RadMessageBox.Show(My.Resources.UpdatingAdministrationLangRes.MsgBox_ErrorAddingInstallerAddOn, My.Resources.UpdatingAdministrationLangRes.MsgBox_Error_Titel, MessageBoxButtons.OK, RadMessageIcon.Error); - } + Tag = p, + Text = radTreeView_PackagingFiles.Nodes == parentCollection ? p : Path.GetFileName(p), + ImageIndex = isDir ? 0 : 1 + }; + parentCollection.Add(n); + if (isDir) + { + var dirInfo = new DirectoryInfo(p); + dirInfo.EnumerateDirectories().ForEach(di => nodeCreation(n.Nodes, di.FullName)); + dirInfo.EnumerateFiles().ForEach(fi => nodeCreation(n.Nodes, fi.FullName)); } - } + }; + nodeCreation(radTreeView_PackagingFiles.Nodes, packageManager.FilesToCopyPath); } - private void RemoveUpdateInstallerExtension() + radTreeView_PackagingFiles.EndUpdate(); + } + + private void ShowPackageExtensions() + { + radListView_Extensions.BeginUpdate(); + radListView_Extensions.Items.Clear(); + + foreach (string fAddOn in packageManager.GetAllUpdateInstallerÁddOn()) { - foreach (string fAddOn in GetSelectedUpdateInstallAddOns()) - packageManager.RemoveUpdateInstallerAddOn(fAddOn); + var cells = new List + { + Path.GetFileName(fAddOn), + Path.GetDirectoryName(fAddOn) + }; + + var item = new ListViewDataItem(string.Empty, cells.ToArray()) + { + Tag = fAddOn + }; + + radListView_Extensions.Items.Add(item); } - // G u i - P a c k a g i n g + radListView_Extensions.EndUpdate(); + } - private void ButtonItem_Pkg_NewTemplate_Click(object sender, EventArgs e) + private IEnumerable GetSelectedUpdateInstallAddOns() + { + var list = new List(); + foreach (var item in radListView_Extensions.SelectedItems) + list.Add(Conversions.ToString(item.Tag)); + return list; + } + + private void NewPackageTemplate() + { + packageManager.NewTemplate(); + curPackageTemplatePath = string.Empty; + ShowAllPackageTemplateConfig(); + } + + private void OpenPackageTemplate() + { + var ofd_UpdateAdmin_LoadTemplate = new RadOpenFileDialog() { Filter = FILTER_PACKAGE_TEMPLATE }; + if (ofd_UpdateAdmin_LoadTemplate.ShowDialog() == DialogResult.OK) { - NewPackageTemplate(); + packageManager.LoadTemplate(ofd_UpdateAdmin_LoadTemplate.FileName); + curPackageTemplatePath = ofd_UpdateAdmin_LoadTemplate.FileName; + ShowAllPackageTemplateConfig(); } + } - private void ButtonItem_Pkg_OpenTemplate_Click(object sender, EventArgs e) - { - OpenPackageTemplate(); - } - - private void ButtonItem_Pkg_SaveTemplate_Click(object sender, EventArgs e) - { - SavePackageTemplate(); - } - - private void ButtonItem_Pkg_SaveTemplateAs_Click(object sender, EventArgs e) + private void SavePackageTemplate() + { + if (string.IsNullOrEmpty(curPackageTemplatePath)) { SavePackageTemplateAs(); } - - private void ButtonItem_Pkg_SelectFileFolder_Click(object sender, EventArgs e) + else { - SelectPackageFileFolder(); - } - - private void ButtonItem_Pkg_RemoveFileFolder_Click(object sender, EventArgs e) - { - RemovePackageFileFolder(); - } - - private async void ButtonItem_Pkg_Export_Click(object sender, EventArgs e) - { - var sfd_UpdateAdmin_ExportPkg = new RadSaveFileDialog() - { - Filter = FILTER_PACKAGE_ZIP_PACKAGE - }; - - if (sfd_UpdateAdmin_ExportPkg.ShowDialog() == DialogResult.OK) - { - if (await ExportUpdatePackage(sfd_UpdateAdmin_ExportPkg.FileName)) - RadMessageBox.Show(this, My.Resources.UpdatingAdministrationLangRes.MsgBox_PkgExportSuccess, My.Resources.UpdatingAdministrationLangRes.MsgBox_PkgExportSuccess_Titel, MessageBoxButtons.OK, RadMessageIcon.Info); - } - } - - private void ButtonItem_Pkg_AddExtension_Click(object sender, EventArgs e) - { - AddUpdateInstallerExtension(); - } - - private void ButtonItem_Pkg_RemoveExtension_Click(object sender, EventArgs e) - { - RemoveUpdateInstallerExtension(); + packageManager.SaveTemplate(curPackageTemplatePath); } } + + private void SavePackageTemplateAs() + { + var sfd_UpdateAdmin_SaveTemplate = new RadSaveFileDialog() { Filter = FILTER_PACKAGE_TEMPLATE }; + if (sfd_UpdateAdmin_SaveTemplate.ShowDialog() == DialogResult.OK) + { + packageManager.SaveTemplate(sfd_UpdateAdmin_SaveTemplate.FileName); + curPackageTemplatePath = sfd_UpdateAdmin_SaveTemplate.FileName; + } + } + + private void SelectPackageFileFolder() + { + var ofd_UpdateAdmin_PkgFileFolder = new RadOpenFolderDialog(); + if (ofd_UpdateAdmin_PkgFileFolder.ShowDialog() == DialogResult.OK) + { + packageManager.FilesToCopyPath = ofd_UpdateAdmin_PkgFileFolder.FileName; + ShowPackageFiles(); + } + } + + private void RemovePackageFileFolder() + { + packageManager.FilesToCopyPath = string.Empty; + ShowPackageFiles(); + } + + private async Task ExportUpdatePackage(string filePath) + { + bool success = false; + ProgressPackagingControls(true); + + try + { + await Task.Run(() => packageManager.ExportPackage(filePath)); + success = true; + } + catch (Exception) + { + success = false; + } + + ProgressPackagingControls(false); + return success; + } + + private async Task ExportTempUpdatePackage() + { + var filePath = Path.GetTempFileName(); + bool res = await ExportUpdatePackage(filePath); + if (res) TempPackageFilePath = filePath; + return res; + } + + private void AddUpdateInstallerExtension() + { + var ofd_UpdateAdmin_AddExtension = new RadOpenFileDialog() + { + MultiSelect = true, + Filter = FILTER_PACKAGE_ADDON + }; + if (ofd_UpdateAdmin_AddExtension.ShowDialog() == DialogResult.OK) + { + foreach (string f in ofd_UpdateAdmin_AddExtension.FileNames) + { + if (!packageManager.AddUpdateInstallerAddOn(f)) + { + RadMessageBox.Show(My.Resources.UpdatingAdministrationLangRes.MsgBox_ErrorAddingInstallerAddOn, My.Resources.UpdatingAdministrationLangRes.MsgBox_Error_Titel, MessageBoxButtons.OK, RadMessageIcon.Error); + } + } + } + } + + private void RemoveUpdateInstallerExtension() + { + foreach (string fAddOn in GetSelectedUpdateInstallAddOns()) + packageManager.RemoveUpdateInstallerAddOn(fAddOn); + } + + // G u i - P a c k a g i n g + + private void ButtonItem_Pkg_NewTemplate_Click(object sender, EventArgs e) + { + NewPackageTemplate(); + } + + private void ButtonItem_Pkg_OpenTemplate_Click(object sender, EventArgs e) + { + OpenPackageTemplate(); + } + + private void ButtonItem_Pkg_SaveTemplate_Click(object sender, EventArgs e) + { + SavePackageTemplate(); + } + + private void ButtonItem_Pkg_SaveTemplateAs_Click(object sender, EventArgs e) + { + SavePackageTemplateAs(); + } + + private void ButtonItem_Pkg_SelectFileFolder_Click(object sender, EventArgs e) + { + SelectPackageFileFolder(); + } + + private void ButtonItem_Pkg_RemoveFileFolder_Click(object sender, EventArgs e) + { + RemovePackageFileFolder(); + } + + private async void ButtonItem_Pkg_Export_Click(object sender, EventArgs e) + { + var sfd_UpdateAdmin_ExportPkg = new RadSaveFileDialog() + { + Filter = FILTER_PACKAGE_ZIP_PACKAGE + }; + + if (sfd_UpdateAdmin_ExportPkg.ShowDialog() == DialogResult.OK) + { + if (await ExportUpdatePackage(sfd_UpdateAdmin_ExportPkg.FileName)) + RadMessageBox.Show(this, My.Resources.UpdatingAdministrationLangRes.MsgBox_PkgExportSuccess, My.Resources.UpdatingAdministrationLangRes.MsgBox_PkgExportSuccess_Titel, MessageBoxButtons.OK, RadMessageIcon.Info); + } + } + + private void ButtonItem_Pkg_AddExtension_Click(object sender, EventArgs e) + { + AddUpdateInstallerExtension(); + } + + private void ButtonItem_Pkg_RemoveExtension_Click(object sender, EventArgs e) + { + RemoveUpdateInstallerExtension(); + } } \ No newline at end of file diff --git a/Pilz.Updating.Administration.GUI/UpdateServerInfoEditor.cs b/Pilz.Updating.Administration.GUI/UpdateServerInfoEditor.cs index 21a8edc..6bef1f8 100644 --- a/Pilz.Updating.Administration.GUI/UpdateServerInfoEditor.cs +++ b/Pilz.Updating.Administration.GUI/UpdateServerInfoEditor.cs @@ -1,41 +1,32 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; using Telerik.WinControls.UI; -namespace Pilz.Updating.Administration.GUI +namespace Pilz.Updating.Administration.GUI; + +public partial class UpdateServerInfoEditor : RadForm { - public partial class UpdateServerInfoEditor : RadForm + public UpdateServerInfoEditor() { - public UpdateServerInfoEditor() - { - InitializeComponent(); - } + InitializeComponent(); + } - private void UpdateServerInfoEditor_Shown(object sender, EventArgs e) - { - radTextBoxControl_ServerAddress.Text = General.CurProject.UpdateServerConfig.ServerAdress; - radTextBoxControl_PublicBasisURL.Text = General.CurProject.UpdateServerConfig.PublicPackageBaseURL; - radTextBoxControl_PackageConfigurationFileName.Text = General.CurProject.UpdateServerConfig.UpdateInfoFilename; - radTextBoxControl_Username.Text = General.CurProject.UpdateServerConfig.Username; - radTextBoxControl_Password.Text = General.CurProject.UpdateServerConfig.Password; - radToggleSwitch_UseProxyForWebDAV.Value = General.CurProject.UpdateServerConfig.UseProxyForWebDAV; - } + private void UpdateServerInfoEditor_Shown(object sender, EventArgs e) + { + radTextBoxControl_ServerAddress.Text = General.CurProject.UpdateServerConfig.ServerAdress; + radTextBoxControl_PublicBasisURL.Text = General.CurProject.UpdateServerConfig.PublicPackageBaseURL; + radTextBoxControl_PackageConfigurationFileName.Text = General.CurProject.UpdateServerConfig.UpdateInfoFilename; + radTextBoxControl_Username.Text = General.CurProject.UpdateServerConfig.Username; + radTextBoxControl_Password.Text = General.CurProject.UpdateServerConfig.Password; + radToggleSwitch_UseProxyForWebDAV.Value = General.CurProject.UpdateServerConfig.UseProxyForWebDAV; + } - private void ButtonX_OK_Click(object sender, EventArgs e) - { - General.CurProject.UpdateServerConfig.ServerAdress = radTextBoxControl_ServerAddress.Text.Trim(); - General.CurProject.UpdateServerConfig.PublicPackageBaseURL = radTextBoxControl_PublicBasisURL.Text.Trim(); - General.CurProject.UpdateServerConfig.UpdateInfoFilename = radTextBoxControl_PackageConfigurationFileName.Text.Trim(); - General.CurProject.UpdateServerConfig.Username = radTextBoxControl_Username.Text.Trim(); - General.CurProject.UpdateServerConfig.Password = radTextBoxControl_Password.Text; - General.CurProject.UpdateServerConfig.UseProxyForWebDAV = radToggleSwitch_UseProxyForWebDAV.Value; - } + private void ButtonX_OK_Click(object sender, EventArgs e) + { + General.CurProject.UpdateServerConfig.ServerAdress = radTextBoxControl_ServerAddress.Text.Trim(); + General.CurProject.UpdateServerConfig.PublicPackageBaseURL = radTextBoxControl_PublicBasisURL.Text.Trim(); + General.CurProject.UpdateServerConfig.UpdateInfoFilename = radTextBoxControl_PackageConfigurationFileName.Text.Trim(); + General.CurProject.UpdateServerConfig.Username = radTextBoxControl_Username.Text.Trim(); + General.CurProject.UpdateServerConfig.Password = radTextBoxControl_Password.Text; + General.CurProject.UpdateServerConfig.UseProxyForWebDAV = radToggleSwitch_UseProxyForWebDAV.Value; } } diff --git a/Pilz.Updating.Administration/Discord/DiscordBot.cs b/Pilz.Updating.Administration/Discord/DiscordBot.cs index c525f2e..7c76061 100644 --- a/Pilz.Updating.Administration/Discord/DiscordBot.cs +++ b/Pilz.Updating.Administration/Discord/DiscordBot.cs @@ -4,228 +4,227 @@ using Discord.Net.WebSockets; using Discord.WebSocket; using System; using System.Collections.Generic; -using System.IO; using System.Linq; -using System.Text; using System.Threading.Tasks; -namespace Pilz.Updating.Administration.Discord +namespace Pilz.Updating.Administration.Discord; + +public class DiscordBot { - public class DiscordBot + public delegate void LoggedMsgEventHandler(object sender, string logmsg, bool isError); + + public event EventHandler GotReady; + public event EventHandler HasDisconnected; + public event LoggedMsgEventHandler LoggedMsg; + + public DiscordBotConfig Config { get; private set; } + public DiscordSocketClient Client { get; private set; } + public bool IsReady { get; private set; } = false; + + // C o n s t r u c t o r + + public DiscordBot(DiscordBotConfig config) { - public delegate void LoggedMsgEventHandler(object sender, string logmsg, bool isError); + Config = config; + } - public event EventHandler GotReady; - public event EventHandler HasDisconnected; - public event LoggedMsgEventHandler LoggedMsg; + // M a i n - public DiscordBotConfig Config { get; private set; } - public DiscordSocketClient Client { get; private set; } - public bool IsReady { get; private set; } = false; - - // C o n s t r u c t o r - - public DiscordBot(DiscordBotConfig config) + public async void Start() + { + if (!string.IsNullOrEmpty(Config.DiscordBotToken)) { - Config = config; + var socketConfig = new DiscordSocketConfig + { + RestClientProvider = DefaultRestClientProvider.Create(useProxy: true), + WebSocketProvider = DefaultWebSocketProvider.Create(System.Net.WebRequest.DefaultWebProxy) + }; + + Client = new DiscordSocketClient(socketConfig); + + Client.Log += Client_Log; + Client.Ready += Client_Ready; + Client.Disconnected += Client_Disconnected; + + await Client.LoginAsync(TokenType.Bot, Config.DiscordBotToken); + await Client.StartAsync(); + } + else + LoggedMsg?.Invoke(this, "Disabled or Token invalid", true); + } + + public async void Stop() + { + await Client.StopAsync(); + await Client.LogoutAsync(); + } + + // C l i e n t - E v e n t s + + private Task Client_Disconnected(Exception exception) + { + Task.Run(() => HasDisconnected?.Invoke(this, new EventArgs())); + return Task.CompletedTask; + } + + private Task Client_Ready() + { + Task.Run(() => + { + Task.Delay(10); + IsReady = true; + GotReady?.Invoke(this, new EventArgs()); + }); + return Task.CompletedTask; + } + + private Task Client_Log(LogMessage msg) + { + Task.Run(() => LoggedMsg?.Invoke(this, msg.Message, msg.Exception is object)); + return Task.CompletedTask; + } + + // F e a t u r e s + + public IReadOnlyDictionary GetGuilds() + { + var dic = new Dictionary(); + + foreach (var guild in Client.Guilds) + dic.Add(guild.Id, guild.Name); + + return dic; + } + + public IReadOnlyDictionary GetTextChannels(ulong guildID) + { + var dic = new Dictionary(); + var guild = Client.GetGuild(guildID); + + if (guild is object) + { + foreach (var channel in guild.TextChannels) + dic.Add(channel.Id, channel.Name); } - // M a i n + return dic; + } - public async void Start() + public IReadOnlyDictionary GetRoles(ulong guildID) + { + var dic = new Dictionary(); + + foreach (var role in Client.GetGuild(guildID).Roles) + dic.Add(role.Id, role.Name); + + return dic; + } + + private string GetPingMessage(ulong? pingRole) + { + return pingRole != null ? $"<@&{pingRole ?? default}>" : string.Empty; + } + + //private async Task BuildUpdateMsg(string versionName, ApplicationVersion version, string changelog, ulong guildID, ulong channelID, string appName, string message, bool addChangelog, ulong? pingRole) + //{ + // string msg = string.Empty; + + // // Add ping + // if (pingRole != null) + // msg += $"<{GetPingMessage(pingRole)}\n\n"; + + // // Add version as titel + // var versionString = version.ToString(); + // if (version.Channel == Channels.Stable && version.Build == 1) + // versionString = versionString.Remove(versionString.IndexOf(" ")); + // msg += $"**Update:** {appName} **Version __{versionString}__**"; + + // // Add titel + // if (!string.IsNullOrEmpty(versionName)) + // msg += $"\n> {versionName}"; + + // // Add message + // if (!string.IsNullOrEmpty(message)) + // msg += "\n\n" + message; + + // // Add changelog + // if (addChangelog && !string.IsNullOrEmpty(changelog)) + // { + // var sr = new StringReader(changelog); + // var sw = new StringWriter(); + + // while (sr.Peek() != -1) + // { + // var line = await sr.ReadLineAsync(); + // await sw.WriteLineAsync($"> {line}"); + // } + + // msg += "\n\nChangelog:\n" + sw.ToString(); + // sr.Close(); + // sw.Close(); + // } + + // return msg; + //} + + public async Task SendUpdateNotification(UpdatePackageInfo package, ulong guildID, ulong channelID, string appName, string message, bool addChangelog, bool pingEveryone) + { + ulong? pingRole; + var updateNotifyRoleLower = Config.UpdateNotificationRoll.ToLower(); + + if (pingEveryone) + pingRole = GetRoles(guildID).FirstOrDefault(n => n.Value.ToLower() == updateNotifyRoleLower).Key; + else + pingRole = null; + + string msg = GetPingMessage(pingRole); //await BuildUpdateMsg(versionName, version, changelog, guildID, channelID, appName, message, addChangelog, pingRole); + var embed = BuildEmbed(package, appName, message, addChangelog); + var channel = Client.GetGuild(guildID)?.GetTextChannel(channelID); + + if (string.IsNullOrEmpty(msg)) + msg = null; + + if (channel != null) + await channel.SendMessageAsync(text: msg, embed: embed); + } + + private Embed BuildEmbed(UpdatePackageInfo package, string appName, string message, bool addChangelog) + { + var embed = new EmbedBuilder(); + + // Add titel + var versionString = package.Version.ToString(); + if (package.Version.Channel == Channels.Stable && package.Version.Build == 1) + versionString = versionString.Remove(versionString.IndexOf(" ")); + var strTitle = $"**Update:** {appName} **Version __{versionString}__**"; + + if (!string.IsNullOrEmpty(package.Name)) + strTitle += $"\n{package.Name}"; + + embed.Title = strTitle; + + // Add Description + if (!string.IsNullOrEmpty(message)) + embed.Description += message; + + // Add changelog + if (addChangelog && !string.IsNullOrEmpty(package.Notes.Content) && package.Notes.ContentType != UpdateNotesContentType.HTML) { - if (!string.IsNullOrEmpty(Config.DiscordBotToken)) + switch (true) { - var socketConfig = new DiscordSocketConfig(); - socketConfig.RestClientProvider = DefaultRestClientProvider.Create(useProxy: true); - socketConfig.WebSocketProvider = DefaultWebSocketProvider.Create(System.Net.WebRequest.DefaultWebProxy); - - Client = new DiscordSocketClient(socketConfig); - - Client.Log += Client_Log; - Client.Ready += Client_Ready; - Client.Disconnected += Client_Disconnected; - - await Client.LoginAsync(TokenType.Bot, Config.DiscordBotToken); - await Client.StartAsync(); + case object _ when package.Notes.ContentType == UpdateNotesContentType.PlainText && package.Notes.Content.Length <= 2048: + embed.AddField("Changelog:", package.Notes.Content); + break; + case object _ when package.Notes.ContentType == UpdateNotesContentType.PlainText: + case object _ when package.Notes.ContentType == UpdateNotesContentType.Markdown: + embed.AddField("Changelog:", Markdig.Markdown.ToPlainText(package.Notes.Content)); + break; } - else - LoggedMsg?.Invoke(this, "Disabled or Token invalid", true); } - public async void Stop() - { - await Client.StopAsync(); - await Client.LogoutAsync(); - } + // Author + // ... - // C l i e n t - E v e n t s - - private Task Client_Disconnected(Exception exception) - { - Task.Run(() => HasDisconnected?.Invoke(this, new EventArgs())); - return Task.CompletedTask; - } - - private Task Client_Ready() - { - Task.Run(() => - { - Task.Delay(10); - IsReady = true; - GotReady?.Invoke(this, new EventArgs()); - }); - return Task.CompletedTask; - } - - private Task Client_Log(LogMessage msg) - { - Task.Run(() => LoggedMsg?.Invoke(this, msg.Message, msg.Exception is object)); - return Task.CompletedTask; - } - - // F e a t u r e s - - public IReadOnlyDictionary GetGuilds() - { - var dic = new Dictionary(); - - foreach (var guild in Client.Guilds) - dic.Add(guild.Id, guild.Name); - - return dic; - } - - public IReadOnlyDictionary GetTextChannels(ulong guildID) - { - var dic = new Dictionary(); - var guild = Client.GetGuild(guildID); - - if (guild is object) - { - foreach (var channel in guild.TextChannels) - dic.Add(channel.Id, channel.Name); - } - - return dic; - } - - public IReadOnlyDictionary GetRoles(ulong guildID) - { - var dic = new Dictionary(); - - foreach (var role in Client.GetGuild(guildID).Roles) - dic.Add(role.Id, role.Name); - - return dic; - } - - private string GetPingMessage(ulong? pingRole) - { - return pingRole != null ? $"<@&{pingRole ?? default}>" : string.Empty; - } - - //private async Task BuildUpdateMsg(string versionName, ApplicationVersion version, string changelog, ulong guildID, ulong channelID, string appName, string message, bool addChangelog, ulong? pingRole) - //{ - // string msg = string.Empty; - - // // Add ping - // if (pingRole != null) - // msg += $"<{GetPingMessage(pingRole)}\n\n"; - - // // Add version as titel - // var versionString = version.ToString(); - // if (version.Channel == Channels.Stable && version.Build == 1) - // versionString = versionString.Remove(versionString.IndexOf(" ")); - // msg += $"**Update:** {appName} **Version __{versionString}__**"; - - // // Add titel - // if (!string.IsNullOrEmpty(versionName)) - // msg += $"\n> {versionName}"; - - // // Add message - // if (!string.IsNullOrEmpty(message)) - // msg += "\n\n" + message; - - // // Add changelog - // if (addChangelog && !string.IsNullOrEmpty(changelog)) - // { - // var sr = new StringReader(changelog); - // var sw = new StringWriter(); - - // while (sr.Peek() != -1) - // { - // var line = await sr.ReadLineAsync(); - // await sw.WriteLineAsync($"> {line}"); - // } - - // msg += "\n\nChangelog:\n" + sw.ToString(); - // sr.Close(); - // sw.Close(); - // } - - // return msg; - //} - - public async Task SendUpdateNotification(UpdatePackageInfo package, ulong guildID, ulong channelID, string appName, string message, bool addChangelog, bool pingEveryone) - { - ulong? pingRole; - var updateNotifyRoleLower = Config.UpdateNotificationRoll.ToLower(); - - if (pingEveryone) - pingRole = GetRoles(guildID).FirstOrDefault(n => n.Value.ToLower() == updateNotifyRoleLower).Key; - else - pingRole = null; - - string msg = GetPingMessage(pingRole); //await BuildUpdateMsg(versionName, version, changelog, guildID, channelID, appName, message, addChangelog, pingRole); - var embed = BuildEmbed(package, appName, message, addChangelog); - var channel = Client.GetGuild(guildID)?.GetTextChannel(channelID); - - if (string.IsNullOrEmpty(msg)) - msg = null; - - if (channel != null) - await channel.SendMessageAsync(text:msg, embed:embed); - } - - private Embed BuildEmbed(UpdatePackageInfo package, string appName, string message, bool addChangelog) - { - var embed = new EmbedBuilder(); - - // Add titel - var versionString = package.Version.ToString(); - if (package.Version.Channel == Channels.Stable && package.Version.Build == 1) - versionString = versionString.Remove(versionString.IndexOf(" ")); - var strTitle = $"**Update:** {appName} **Version __{versionString}__**"; - - if (!string.IsNullOrEmpty(package.Name)) - strTitle += $"\n{package.Name}"; - - embed.Title = strTitle; - - // Add Description - if (!string.IsNullOrEmpty(message)) - embed.Description += message; - - // Add changelog - if (addChangelog && !string.IsNullOrEmpty(package.Notes.Content) && package.Notes.ContentType != UpdateNotesContentType.HTML) - { - switch (true) - { - case object _ when package.Notes.ContentType == UpdateNotesContentType.PlainText && package.Notes.Content.Length <= 2048: - embed.AddField("Changelog:", package.Notes.Content); - break; - case object _ when package.Notes.ContentType == UpdateNotesContentType.PlainText: - case object _ when package.Notes.ContentType == UpdateNotesContentType.Markdown: - embed.AddField("Changelog:", Markdig.Markdown.ToPlainText(package.Notes.Content)); - break; - } - } - - // Author - // ... - - return embed.Build(); - } + return embed.Build(); } } diff --git a/Pilz.Updating.Administration/Discord/DiscordBotConfig.cs b/Pilz.Updating.Administration/Discord/DiscordBotConfig.cs index f24c5e4..9ea5c31 100644 --- a/Pilz.Updating.Administration/Discord/DiscordBotConfig.cs +++ b/Pilz.Updating.Administration/Discord/DiscordBotConfig.cs @@ -1,34 +1,30 @@ using Newtonsoft.Json; using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace Pilz.Updating.Administration.Discord +namespace Pilz.Updating.Administration.Discord; + +public class DiscordBotConfig { - public class DiscordBotConfig + public string DiscordBotToken { get; set; } = string.Empty; + public string DefaultAppName { get; set; } = string.Empty; + public string UpdateNotificationRoll { get; set; } = string.Empty; + public bool UseProxy { get; set; } = true; + public Dictionary DefaultUpdateMessages { get; } = new() { - public string DiscordBotToken { get; set; } = string.Empty; - public string DefaultAppName { get; set; } = string.Empty; - public string UpdateNotificationRoll { get; set; } = string.Empty; - public bool UseProxy { get; set; } = true; - public Dictionary DefaultUpdateMessages { get; } = new() - { - { Channels.Stable, null }, - { Channels.PreRelease, null }, - { Channels.Beta, null }, - { Channels.Alpha, null } - }; + { Channels.Stable, null }, + { Channels.PreRelease, null }, + { Channels.Beta, null }, + { Channels.Alpha, null } + }; - [JsonProperty, Obsolete] - private string DefaultUpdateMessage + [JsonProperty, Obsolete] + private string DefaultUpdateMessage + { + set { - set - { - foreach (var keys in DefaultUpdateMessages.Keys) - DefaultUpdateMessages[keys] = value; - } + foreach (var keys in DefaultUpdateMessages.Keys) + DefaultUpdateMessages[keys] = value; } } } diff --git a/Pilz.Updating.Administration/Packaging/UpdatePackageManager.cs b/Pilz.Updating.Administration/Packaging/UpdatePackageManager.cs index e0a90df..da9ed0e 100644 --- a/Pilz.Updating.Administration/Packaging/UpdatePackageManager.cs +++ b/Pilz.Updating.Administration/Packaging/UpdatePackageManager.cs @@ -1,107 +1,106 @@ -using System.Collections.Generic; +using global::Newtonsoft.Json.Linq; using global::System.IO; using global::System.Reflection; using Microsoft.VisualBasic.CompilerServices; -using global::Newtonsoft.Json.Linq; -using Z.Collections.Extensions; using Pilz.Updating.UpdateInstaller; +using System.Collections.Generic; +using Z.Collections.Extensions; -namespace Pilz.Updating.Administration.Packaging +namespace Pilz.Updating.Administration.Packaging; + +internal class UpdatePackageManager { - internal class UpdatePackageManager + + // F i e l d s + + private UpdatePackageTemplate template; + + // P r o p e r t i e s + + public string FilesToCopyPath { - - // F i e l d s - - private UpdatePackageTemplate template; - - // P r o p e r t i e s - - public string FilesToCopyPath + get { - get - { - return template.FilesToCopyPath; - } - - set - { - template.FilesToCopyPath = value; - } + return template.FilesToCopyPath; } - // C o n s t r u c o t r s - - public UpdatePackageManager() + set { - NewTemplate(); - } - - // F e a t u r e s - - public void LoadTemplate(string filePath) - { - template = JObject.Parse(File.ReadAllText(filePath)).ToObject(); - } - - public void SaveTemplate(string filePath) - { - File.WriteAllText(filePath, JObject.FromObject(template).ToString()); - } - - public void NewTemplate() - { - template = new UpdatePackageTemplate(); - } - - public void ExportPackage(string path) - { - var exporter = new UpdatePackagePackager(template); - exporter.Export(path); - } - - private bool CheckUpdateInstallerAddOn(string path) - { - var asm = Assembly.ReflectionOnlyLoadFrom(path); - var t = asm.GetType($"{UpdateInstallerAddOnNameDefinitions.UPDATE_INSTALLER_ADDON_NAMESPACE}.{UpdateInstallerAddOnNameDefinitions.UPDATE_INSTALLER_ADDON_TYPE}", false); - bool isSupported = false; - if (t is object) - { - var mi = t.GetMethod(UpdateInstallerAddOnNameDefinitions.UPDATE_INSTALLER_ADDON_METHOD, BindingFlags.Static | BindingFlags.Public); - if (mi is object) - { - var @params = mi.GetParameters(); - if (@params.Length == 1 && @params.GetType() == typeof(Dictionary)) - { - isSupported = true; - } - } - } - - return isSupported; - } - - public bool AddUpdateInstallerAddOn(string path) - { - if (Conversions.ToBoolean(!template.UpdateInstallerAddOns.Contains(path) && CheckUpdateInstallerAddOn(path))) - { - template.UpdateInstallerAddOns.Add(path); - return true; - } - else - { - return false; - } - } - - public IEnumerable GetAllUpdateInstallerÁddOn() - { - return template.UpdateInstallerAddOns; - } - - public void RemoveUpdateInstallerAddOn(string path) - { - template.UpdateInstallerAddOns.RemoveIfContains(path); + template.FilesToCopyPath = value; } } + + // C o n s t r u c o t r s + + public UpdatePackageManager() + { + NewTemplate(); + } + + // F e a t u r e s + + public void LoadTemplate(string filePath) + { + template = JObject.Parse(File.ReadAllText(filePath)).ToObject(); + } + + public void SaveTemplate(string filePath) + { + File.WriteAllText(filePath, JObject.FromObject(template).ToString()); + } + + public void NewTemplate() + { + template = new UpdatePackageTemplate(); + } + + public void ExportPackage(string path) + { + var exporter = new UpdatePackagePackager(template); + exporter.Export(path); + } + + private bool CheckUpdateInstallerAddOn(string path) + { + var asm = Assembly.ReflectionOnlyLoadFrom(path); + var t = asm.GetType($"{UpdateInstallerAddOnNameDefinitions.UPDATE_INSTALLER_ADDON_NAMESPACE}.{UpdateInstallerAddOnNameDefinitions.UPDATE_INSTALLER_ADDON_TYPE}", false); + bool isSupported = false; + if (t is object) + { + var mi = t.GetMethod(UpdateInstallerAddOnNameDefinitions.UPDATE_INSTALLER_ADDON_METHOD, BindingFlags.Static | BindingFlags.Public); + if (mi is object) + { + var @params = mi.GetParameters(); + if (@params.Length == 1 && @params.GetType() == typeof(Dictionary)) + { + isSupported = true; + } + } + } + + return isSupported; + } + + public bool AddUpdateInstallerAddOn(string path) + { + if (Conversions.ToBoolean(!template.UpdateInstallerAddOns.Contains(path) && CheckUpdateInstallerAddOn(path))) + { + template.UpdateInstallerAddOns.Add(path); + return true; + } + else + { + return false; + } + } + + public IEnumerable GetAllUpdateInstallerÁddOn() + { + return template.UpdateInstallerAddOns; + } + + public void RemoveUpdateInstallerAddOn(string path) + { + template.UpdateInstallerAddOns.RemoveIfContains(path); + } } \ No newline at end of file diff --git a/Pilz.Updating.Administration/Packaging/UpdatePackagePackager.cs b/Pilz.Updating.Administration/Packaging/UpdatePackagePackager.cs index 97e426d..0a01484 100644 --- a/Pilz.Updating.Administration/Packaging/UpdatePackagePackager.cs +++ b/Pilz.Updating.Administration/Packaging/UpdatePackagePackager.cs @@ -1,52 +1,51 @@ -using global::System.IO; -using global::System.IO.Compression; +using System.IO; +using System.IO.Compression; using Pilz.Updating.UpdateInstaller; using Z.IO.Extensions; -namespace Pilz.Updating.Administration.Packaging +namespace Pilz.Updating.Administration.Packaging; + +public class UpdatePackagePackager { - public class UpdatePackagePackager + public UpdatePackageTemplate UpdatePackageTemplate { get; set; } + + public UpdatePackagePackager(UpdatePackageTemplate updatePackageTemplate) { - public UpdatePackageTemplate UpdatePackageTemplate { get; set; } + UpdatePackageTemplate = updatePackageTemplate; + } - public UpdatePackagePackager(UpdatePackageTemplate updatePackageTemplate) - { - UpdatePackageTemplate = updatePackageTemplate; - } + public void Export(string exportPath) + { + string tempPath = MyPaths.GetMyAppDataPath(); + var packageDir = new DirectoryInfo(Path.Combine(tempPath, "UpdatePackageCreation")); - public void Export(string exportPath) - { - string tempPath = MyPaths.GetMyAppDataPath(); - var packageDir = new DirectoryInfo(Path.Combine(tempPath, "UpdatePackageCreation")); - - // Ensure package directory exists and is empty - if (packageDir.Exists) - packageDir.Delete(true); - packageDir.Create(); - - // Copy local data to temp data directory - var dataDir = packageDir.CreateSubdirectory(PackageFileNameDefinations.ZIP_APP_DATA_FILES_DIRECTORY); - var localDataDir = new DirectoryInfo(UpdatePackageTemplate.FilesToCopyPath); - localDataDir.CopyTo(dataDir.FullName, SearchOption.AllDirectories); - - // Copy all UpdateInstaller AddOns - var addOnsDir = packageDir.CreateSubdirectory(PackageFileNameDefinations.ZIP_UPDATE_INSTALLER_ADDONS_DIRECTORY); - uint curAddOnID = 0; - foreach (string fAddOn in UpdatePackageTemplate.UpdateInstallerAddOns) - { - File.Copy(fAddOn, Path.Combine(addOnsDir.FullName, $"installer_addon_{curAddOnID}.dll")); - curAddOnID += 1; - } - - // Ensure destination file doesn't exist - if (File.Exists(exportPath)) - File.Delete(exportPath); - - // Export to ZIP - ZipFile.CreateFromDirectory(packageDir.FullName, exportPath); - - // Delete temp directory + // Ensure package directory exists and is empty + if (packageDir.Exists) packageDir.Delete(true); + packageDir.Create(); + + // Copy local data to temp data directory + var dataDir = packageDir.CreateSubdirectory(PackageFileNameDefinations.ZIP_APP_DATA_FILES_DIRECTORY); + var localDataDir = new DirectoryInfo(UpdatePackageTemplate.FilesToCopyPath); + localDataDir.CopyTo(dataDir.FullName, SearchOption.AllDirectories); + + // Copy all UpdateInstaller AddOns + var addOnsDir = packageDir.CreateSubdirectory(PackageFileNameDefinations.ZIP_UPDATE_INSTALLER_ADDONS_DIRECTORY); + uint curAddOnID = 0; + foreach (string fAddOn in UpdatePackageTemplate.UpdateInstallerAddOns) + { + File.Copy(fAddOn, Path.Combine(addOnsDir.FullName, $"installer_addon_{curAddOnID}.dll")); + curAddOnID += 1; } + + // Ensure destination file doesn't exist + if (File.Exists(exportPath)) + File.Delete(exportPath); + + // Export to ZIP + ZipFile.CreateFromDirectory(packageDir.FullName, exportPath); + + // Delete temp directory + packageDir.Delete(true); } } \ No newline at end of file diff --git a/Pilz.Updating.Administration/Packaging/UpdatePackageTemplate.cs b/Pilz.Updating.Administration/Packaging/UpdatePackageTemplate.cs index a053bc5..5d31643 100644 --- a/Pilz.Updating.Administration/Packaging/UpdatePackageTemplate.cs +++ b/Pilz.Updating.Administration/Packaging/UpdatePackageTemplate.cs @@ -1,10 +1,9 @@ using System.Collections.Generic; -namespace Pilz.Updating.Administration.Packaging +namespace Pilz.Updating.Administration.Packaging; + +public class UpdatePackageTemplate { - public class UpdatePackageTemplate - { - public string FilesToCopyPath { get; set; } - public List UpdateInstallerAddOns { get; set; } = new List(); - } + public string FilesToCopyPath { get; set; } + public List UpdateInstallerAddOns { get; set; } = []; } \ No newline at end of file diff --git a/Pilz.Updating.Administration/Pilz.Updating.Administration.csproj b/Pilz.Updating.Administration/Pilz.Updating.Administration.csproj index 3b0453a..c9cbc3e 100644 --- a/Pilz.Updating.Administration/Pilz.Updating.Administration.csproj +++ b/Pilz.Updating.Administration/Pilz.Updating.Administration.csproj @@ -1,7 +1,7 @@  Pilz.Updating.Administration - net6.0-windows;net8.0-windows + net8.0-windows $(DefaultItemExcludes);$(ProjectDir)**\*.vb latest Pilz.Updating.Server @@ -11,7 +11,6 @@ Pilz.Updating.Administration.xml true 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022,CS1591,CS0660,CS0661,CS0436 - true true @@ -37,13 +36,12 @@ TRACE;RelMono - True 2.0.0 - + @@ -92,8 +90,8 @@ - - + + diff --git a/Pilz.Updating.Administration/Properties/AssemblyInfo.cs b/Pilz.Updating.Administration/Properties/AssemblyInfo.cs index 210747f..afac49e 100644 --- a/Pilz.Updating.Administration/Properties/AssemblyInfo.cs +++ b/Pilz.Updating.Administration/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using global::System; -using global::System.Reflection; using global::System.Runtime.CompilerServices; using global::System.Runtime.InteropServices; [assembly: ComVisible(false)] diff --git a/Pilz.Updating.Administration/ProxyConfiguration.cs b/Pilz.Updating.Administration/ProxyConfiguration.cs index ec961e2..cc71aeb 100644 --- a/Pilz.Updating.Administration/ProxyConfiguration.cs +++ b/Pilz.Updating.Administration/ProxyConfiguration.cs @@ -1,18 +1,12 @@ using Newtonsoft.Json; using Pilz.Cryptography; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace Pilz.Updating.Administration +namespace Pilz.Updating.Administration; + +public class ProxyConfiguration { - public class ProxyConfiguration - { - public bool UseProxyAuth { get; set; } - public string Username { get; set; } - [JsonProperty("PasswordV3")] - public SecureString Password { get; set; } - } + public bool UseProxyAuth { get; set; } + public string Username { get; set; } + [JsonProperty("PasswordV3")] + public SecureString Password { get; set; } } diff --git a/Pilz.Updating.Administration/UpdateInstaller/PackageFileNameDefinations.cs b/Pilz.Updating.Administration/UpdateInstaller/PackageFileNameDefinations.cs index 5ac38f7..7b0ca7a 100644 --- a/Pilz.Updating.Administration/UpdateInstaller/PackageFileNameDefinations.cs +++ b/Pilz.Updating.Administration/UpdateInstaller/PackageFileNameDefinations.cs @@ -1,9 +1,8 @@ -namespace Pilz.Updating.UpdateInstaller +namespace Pilz.Updating.UpdateInstaller; + +public static class PackageFileNameDefinations { - public static class PackageFileNameDefinations - { - public const string ZIP_PACKAGE_FILENAME = "updatepackage.zip"; - public const string ZIP_UPDATE_INSTALLER_ADDONS_DIRECTORY = "installer_addons"; - public const string ZIP_APP_DATA_FILES_DIRECTORY = "appdata"; - } + public const string ZIP_PACKAGE_FILENAME = "updatepackage.zip"; + public const string ZIP_UPDATE_INSTALLER_ADDONS_DIRECTORY = "installer_addons"; + public const string ZIP_APP_DATA_FILES_DIRECTORY = "appdata"; } \ No newline at end of file diff --git a/Pilz.Updating.Administration/UpdateInstaller/UpdateInstallerAddOnNameDefinitions.cs b/Pilz.Updating.Administration/UpdateInstaller/UpdateInstallerAddOnNameDefinitions.cs index c8aacad..318107c 100644 --- a/Pilz.Updating.Administration/UpdateInstaller/UpdateInstallerAddOnNameDefinitions.cs +++ b/Pilz.Updating.Administration/UpdateInstaller/UpdateInstallerAddOnNameDefinitions.cs @@ -1,9 +1,8 @@ -namespace Pilz.Updating.UpdateInstaller +namespace Pilz.Updating.UpdateInstaller; + +public static partial class UpdateInstallerAddOnNameDefinitions { - public static partial class UpdateInstallerAddOnNameDefinitions - { - public const string UPDATE_INSTALLER_ADDON_NAMESPACE = "UpdateInstaller"; - public const string UPDATE_INSTALLER_ADDON_TYPE = "AddOn"; - public const string UPDATE_INSTALLER_ADDON_METHOD = "Main"; - } + public const string UPDATE_INSTALLER_ADDON_NAMESPACE = "UpdateInstaller"; + public const string UPDATE_INSTALLER_ADDON_TYPE = "AddOn"; + public const string UPDATE_INSTALLER_ADDON_METHOD = "Main"; } \ No newline at end of file diff --git a/Pilz.Updating.Administration/UpdateProject.cs b/Pilz.Updating.Administration/UpdateProject.cs index 2dd14ce..14d3644 100644 --- a/Pilz.Updating.Administration/UpdateProject.cs +++ b/Pilz.Updating.Administration/UpdateProject.cs @@ -1,31 +1,25 @@ using Newtonsoft.Json.Linq; using Pilz.Updating.Administration.Discord; -using System; -using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace Pilz.Updating.Administration +namespace Pilz.Updating.Administration; + +public class UpdateProject { - public class UpdateProject - { - public UpdateServerConfig UpdateServerConfig { get; } = new UpdateServerConfig(); - public DiscordBotConfig DiscordBotConfig { get; } = new DiscordBotConfig(); - public ProxyConfiguration ProxyConfig { get; } = new ProxyConfiguration(); - - public static UpdateProject Load(string filePath) - { - if (File.Exists(filePath)) - return JObject.Parse(File.ReadAllText(filePath)).ToObject(); - else - return new UpdateProject(); - } + public UpdateServerConfig UpdateServerConfig { get; } = new UpdateServerConfig(); + public DiscordBotConfig DiscordBotConfig { get; } = new DiscordBotConfig(); + public ProxyConfiguration ProxyConfig { get; } = new ProxyConfiguration(); - public void Save(string filePath) - { - File.WriteAllText(filePath, JObject.FromObject(this).ToString()); - } + public static UpdateProject Load(string filePath) + { + if (File.Exists(filePath)) + return JObject.Parse(File.ReadAllText(filePath)).ToObject(); + else + return new UpdateProject(); + } + + public void Save(string filePath) + { + File.WriteAllText(filePath, JObject.FromObject(this).ToString()); } } diff --git a/Pilz.Updating.Administration/UpdateServerConfig.cs b/Pilz.Updating.Administration/UpdateServerConfig.cs index cdc3462..bbcded0 100644 --- a/Pilz.Updating.Administration/UpdateServerConfig.cs +++ b/Pilz.Updating.Administration/UpdateServerConfig.cs @@ -1,22 +1,16 @@ using Newtonsoft.Json; using Pilz.Cryptography; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace Pilz.Updating.Administration +namespace Pilz.Updating.Administration; + +public class UpdateServerConfig { - public class UpdateServerConfig - { - public bool UseProxyForWebDAV { get; set; } = false; - public string ServerAdress { get; set; } - public string PublicPackageBaseURL { get; set; } - public string UpdateInfoFilename { get; set; } - public string Username { get; set; } + public bool UseProxyForWebDAV { get; set; } = false; + public string ServerAdress { get; set; } + public string PublicPackageBaseURL { get; set; } + public string UpdateInfoFilename { get; set; } + public string Username { get; set; } - [JsonProperty("PasswordV3")] - public SecureString Password { get; set; } - } + [JsonProperty("PasswordV3")] + public SecureString Password { get; set; } } diff --git a/Pilz.Updating.Administration/UpdateServerManager.cs b/Pilz.Updating.Administration/UpdateServerManager.cs index df355c5..5c76192 100644 --- a/Pilz.Updating.Administration/UpdateServerManager.cs +++ b/Pilz.Updating.Administration/UpdateServerManager.cs @@ -1,134 +1,99 @@ -using global::System.IO; -using global::Newtonsoft.Json.Linq; -using WebDav; -using System.Net; +using Microsoft.VisualBasic; +using Newtonsoft.Json.Linq; using System; -using System.Threading.Tasks; using System.Collections.Generic; +using System.IO; using System.Linq; +using System.Net; +using System.Threading.Tasks; +using WebDav; using static Microsoft.VisualBasic.CompilerServices.LikeOperator; -using Microsoft.VisualBasic; -namespace Pilz.Updating.Administration +namespace Pilz.Updating.Administration; + +public class UpdateServerManager { - public class UpdateServerManager + private const string PKG_SEARCHTEXT = "pkg*.*.*.*.zip"; + private const string PKG_FILENAME_TEMPLATE = "pkg{0}{1}.zip"; + private const string PKG_FILENAME_ALPHADEFINITION = "a"; + private const string PKG_FILENAME_BETADEFINITION = "b"; + private const string PKG_FILENAME_RCDEFINITION = "rc"; + private const string PKG_FILENAME_RELEASEDEFINITION = "r"; + + private WebDavClient client; + public UpdateInfo UpdateInfo { get; private set; } + public UpdateServerConfig Config { get; private set; } + public bool IsReady { get; private set; } + + public UpdateServerManager(UpdateServerConfig config) { - private const string PKG_SEARCHTEXT = "pkg*.*.*.*.zip"; - private const string PKG_FILENAME_TEMPLATE = "pkg{0}{1}.zip"; - private const string PKG_FILENAME_ALPHADEFINITION = "a"; - private const string PKG_FILENAME_BETADEFINITION = "b"; - private const string PKG_FILENAME_RCDEFINITION = "rc"; - private const string PKG_FILENAME_RELEASEDEFINITION = "r"; + GenerateClient(config); + NewInfo(); + } - private WebDavClient client; - public UpdateInfo UpdateInfo { get; private set; } - public UpdateServerConfig Config { get; private set; } - public bool IsReady { get; private set; } + public bool GenerateClient(UpdateServerConfig config) + { + bool success; - public UpdateServerManager(UpdateServerConfig config) + try { - GenerateClient(config); - NewInfo(); + // Create client params + var clientparams = new WebDavClientParams() + { + BaseAddress = new Uri(config.ServerAdress), + Credentials = new NetworkCredential(config.Username, config.Password), + UseProxy = false + }; + + // Create client + client = new WebDavClient(clientparams); + + // Remember config + Config = config; + + success = true; + } + catch (Exception) + { + success = false; + Config = null; + client = null; } - public bool GenerateClient(UpdateServerConfig config) + return success; + } + + public async Task LoadInfoFromServer() + { + bool success; + + try { - bool success; + var response = await client.GetProcessedFile(Config.UpdateInfoFilename); - try + if (response.IsSuccessful) { - // Create client params - var clientparams = new WebDavClientParams() - { - BaseAddress = new Uri(config.ServerAdress), - Credentials = new NetworkCredential(config.Username, config.Password), - UseProxy = false - }; - - // Create client - client = new WebDavClient(clientparams); - - // Remember config - Config = config; - - success = true; - } - catch (Exception) - { - success = false; - Config = null; - client = null; + var sr = new StreamReader(response.Stream); + var raw = await sr.ReadToEndAsync(); + sr.Close(); + UpdateInfo = JObject.Parse(raw).ToObject(); } - return success; + success = true; + } + catch (Exception) + { + success = false; } - public async Task LoadInfoFromServer() - { - bool success; + return success; + } - try - { - var response = await client.GetProcessedFile(Config.UpdateInfoFilename); + public async Task SaveInfoToServer() + { + bool success; - if (response.IsSuccessful) - { - var sr = new StreamReader(response.Stream); - var raw = await sr.ReadToEndAsync(); - sr.Close(); - UpdateInfo = JObject.Parse(raw).ToObject(); - } - - success = true; - } - catch (Exception) - { - success = false; - } - - return success; - } - - public async Task SaveInfoToServer() - { - bool success; - - try - { - // Remove configs of non-existing packages - await ClearUpdateInfo(); - - // Update Packagelinks - UpdatePackageLinks(); - - // Write - var raw = UpdateInfo.ToString(); - var ms = new MemoryStream(); - var sw = new StreamWriter(ms); - await sw.WriteAsync(raw); - await sw.FlushAsync(); - - // Upload - ms.Position = 0; - await client.PutFile(Config.UpdateInfoFilename, ms); - - ms.Close(); - success = true; - } - catch (Exception) - { - success = false; - } - - return success; - } - - public void LoadInfoFromFile(string filePath) - { - UpdateInfo = JObject.Parse(File.ReadAllText(filePath)).ToObject(); - } - - public async Task SaveInfoToFile(string filePath) + try { // Remove configs of non-existing packages await ClearUpdateInfo(); @@ -137,269 +102,302 @@ namespace Pilz.Updating.Administration UpdatePackageLinks(); // Write - File.WriteAllText(filePath, UpdateInfo.ToString()); - } - - public void NewInfo() - { - UpdateInfo = new UpdateInfo(); - } - - private async Task ClearUpdateInfo() - { - var pkgs = await GetUpdatePackagesList(); - var infosToRemove = new List(); - - // Find non-existing packages - foreach (var info in UpdateInfo.Packages) - { - if (!pkgs.Where((n) => n == info.Version).Any()) - { - infosToRemove.Add(info); - } - } - - // Remove found packages - foreach (var info in infosToRemove) - UpdateInfo.Packages.Remove(info); - } - - private void UpdatePackageLinks() - { - foreach (var info in UpdateInfo.Packages) - UpdatePackageLink(info); - } - - private void UpdatePackageLink(UpdatePackageInfo info) - { - info.Packagelink = Config.PublicPackageBaseURL + BuildPackageFilename(info.Version); - } - - public async Task> GetUpdatePackagesList() - { - var pkgs = new List(); - var response = await client.Propfind(string.Empty); - - if (response.IsSuccessful) - { - foreach (var resource in response.Resources) - { - var fileName = Path.GetFileName(resource.Uri); - if (!string.IsNullOrEmpty(fileName) && fileName.ToLower() != Config.UpdateInfoFilename && LikeString(fileName, "pkg*.*.*.*.zip", CompareMethod.Text)) - { - var appVersion = new ApplicationVersion(); - bool allowAdd = true; - - fileName = Path.GetFileNameWithoutExtension(fileName); - fileName = fileName.Substring(3); - - // Get alpha/beta/rc value - { - int indexAlpha, indexBeta, indexRC, indexRelease; - indexAlpha = fileName.IndexOf(PKG_FILENAME_ALPHADEFINITION); - indexBeta = fileName.IndexOf(PKG_FILENAME_BETADEFINITION); - indexRC = fileName.IndexOf(PKG_FILENAME_RCDEFINITION); - indexRelease = fileName.IndexOf(PKG_FILENAME_RELEASEDEFINITION); - - int indexDef; - string pkgFilenameDef; - if (indexAlpha > -1) - { - indexDef = indexAlpha; - pkgFilenameDef = PKG_FILENAME_ALPHADEFINITION; - } - else if (indexBeta > -1) - { - indexDef = indexBeta; - pkgFilenameDef = PKG_FILENAME_BETADEFINITION; - } - else if (indexRC > -1) - { - indexDef = indexRC; - pkgFilenameDef = PKG_FILENAME_RCDEFINITION; - } - else if (indexRelease > -1) - { - indexDef = indexRelease; - pkgFilenameDef = PKG_FILENAME_RELEASEDEFINITION; - } - else - { - indexDef = -1; - pkgFilenameDef = null; - } - - if (indexDef > -1) - { - // Get def from filename - var def = fileName.Substring(indexDef); - fileName = fileName.Remove(indexDef); - - // Get channel - switch (pkgFilenameDef) - { - case PKG_FILENAME_ALPHADEFINITION: - appVersion.Channel = Channels.Alpha; - break; - case PKG_FILENAME_BETADEFINITION: - appVersion.Channel = Channels.Beta; - break; - case PKG_FILENAME_RCDEFINITION: - appVersion.Channel = Channels.PreRelease; - break; - case PKG_FILENAME_RELEASEDEFINITION: - appVersion.Channel = Channels.Stable; - break; - } - - // Get build - var defBuild = def.Substring(pkgFilenameDef.Length); - appVersion.Build = Convert.ToInt32(defBuild); - } - else - { - // Set to default - appVersion.Build = 1; - appVersion.Channel = Channels.Stable; - } - } - - // Get version - if (Version.TryParse(fileName, out Version version)) - appVersion.Version = version; - else - allowAdd = false; - - if (allowAdd) - pkgs.Add(appVersion); - } - } - } - - return pkgs; - } - - public async Task DeletePackage(ApplicationVersion version) - { - var fileName = BuildPackageFilename(version); - var response = await client.Delete(fileName); - return response.IsSuccessful; - } - - public async Task UploadPackage(string filePath, ApplicationVersion version) - { - bool success; - var fileName = BuildPackageFilename(version); + var raw = UpdateInfo.ToString(); + var ms = new MemoryStream(); + var sw = new StreamWriter(ms); + await sw.WriteAsync(raw); + await sw.FlushAsync(); // Upload - var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read); - var response = await client.PutFile(fileName, fs); - fs.Close(); - success = response.IsSuccessful; + ms.Position = 0; + await client.PutFile(Config.UpdateInfoFilename, ms); - // Generate public downloadlink - if (success) + ms.Close(); + success = true; + } + catch (Exception) + { + success = false; + } + + return success; + } + + public void LoadInfoFromFile(string filePath) + { + UpdateInfo = JObject.Parse(File.ReadAllText(filePath)).ToObject(); + } + + public async Task SaveInfoToFile(string filePath) + { + // Remove configs of non-existing packages + await ClearUpdateInfo(); + + // Update Packagelinks + UpdatePackageLinks(); + + // Write + File.WriteAllText(filePath, UpdateInfo.ToString()); + } + + public void NewInfo() + { + UpdateInfo = new UpdateInfo(); + } + + private async Task ClearUpdateInfo() + { + var pkgs = await GetUpdatePackagesList(); + var infosToRemove = new List(); + + // Find non-existing packages + foreach (var info in UpdateInfo.Packages) + { + if (!pkgs.Where((n) => n == info.Version).Any()) { - var pkgInfo = GetOrCreateUpdatePackageInfo(version); - pkgInfo.Packagelink = Config.PublicPackageBaseURL + fileName; - } - - return success; - } - - private string BuildPackageFilename(ApplicationVersion version) - { - // Build channel/build definition of filename - string def = string.Empty; - switch (version.Channel) - { - case Channels.Alpha: - def = PKG_FILENAME_ALPHADEFINITION + version.Build; - break; - case Channels.Stable: - if (version.Build != 1) - def = PKG_FILENAME_RELEASEDEFINITION + version.Build; - break; - case Channels.PreRelease: - def = PKG_FILENAME_RCDEFINITION + version.Build; - break; - case Channels.Beta: - def = PKG_FILENAME_BETADEFINITION + version.Build; - break; - } - - // Build filename - var fileName = string.Format(PKG_FILENAME_TEMPLATE, version.Version, def); - - return fileName; - } - - private UpdatePackageInfo GetOrCreateUpdatePackageInfo(ApplicationVersion version) - { - var info = GetUpdatePackageInfo(version); - - if (info == null) - info = CreateUpdatePackageInfo(version); - - return info; - } - - public UpdatePackageInfo GetUpdatePackageInfo(ApplicationVersion version) - { - return UpdateInfo.Packages.FirstOrDefault((n) => n.Version == version); - } - - private UpdatePackageInfo CreateUpdatePackageInfo(ApplicationVersion version) - { - var info = new UpdatePackageInfo() - { - Version = version - }; - UpdateInfo.Packages.Add(info); - return info; - } - - public (string name, string description, UpdateNotesContentType descriptionType) GetPackageDescription(ApplicationVersion version) - { - var pkg = GetUpdatePackageInfo(version); - if (pkg is object) - return (pkg.Name, pkg.Notes.Content, pkg.Notes.ContentType); - else - return default; - } - - public void SetPackageDescription(ApplicationVersion version, string name, string description, UpdateNotesContentType descriptionType) - { - var pkg = GetOrCreateUpdatePackageInfo(version); - if (pkg is object) - { - pkg.Name = name; - pkg.Notes.Content = description; - pkg.Notes.ContentType = descriptionType; + infosToRemove.Add(info); } } - public async Task ChangePackageVersion(ApplicationVersion currentVersion, ApplicationVersion newVersion) + // Remove found packages + foreach (var info in infosToRemove) + UpdateInfo.Packages.Remove(info); + } + + private void UpdatePackageLinks() + { + foreach (var info in UpdateInfo.Packages) + UpdatePackageLink(info); + } + + private void UpdatePackageLink(UpdatePackageInfo info) + { + info.Packagelink = Config.PublicPackageBaseURL + BuildPackageFilename(info.Version); + } + + public async Task> GetUpdatePackagesList() + { + var pkgs = new List(); + var response = await client.Propfind(string.Empty); + + if (response.IsSuccessful) { - bool success = false; - - // Get file names - var currentFilename = BuildPackageFilename(currentVersion); - var newFilename = BuildPackageFilename(newVersion); - - // Move - var response = await client.Move(currentFilename, newFilename); - - // Change package info version, if exists - if (response.IsSuccessful) + foreach (var resource in response.Resources) { - var pkg = GetUpdatePackageInfo(currentVersion); - if (pkg is object) - pkg.Version = newVersion; - success = true; - } + var fileName = Path.GetFileName(resource.Uri); + if (!string.IsNullOrEmpty(fileName) && fileName.ToLower() != Config.UpdateInfoFilename && LikeString(fileName, "pkg*.*.*.*.zip", CompareMethod.Text)) + { + var appVersion = new ApplicationVersion(); + bool allowAdd = true; - return success; + fileName = Path.GetFileNameWithoutExtension(fileName); + fileName = fileName.Substring(3); + + // Get alpha/beta/rc value + { + int indexAlpha, indexBeta, indexRC, indexRelease; + indexAlpha = fileName.IndexOf(PKG_FILENAME_ALPHADEFINITION); + indexBeta = fileName.IndexOf(PKG_FILENAME_BETADEFINITION); + indexRC = fileName.IndexOf(PKG_FILENAME_RCDEFINITION); + indexRelease = fileName.IndexOf(PKG_FILENAME_RELEASEDEFINITION); + + int indexDef; + string pkgFilenameDef; + if (indexAlpha > -1) + { + indexDef = indexAlpha; + pkgFilenameDef = PKG_FILENAME_ALPHADEFINITION; + } + else if (indexBeta > -1) + { + indexDef = indexBeta; + pkgFilenameDef = PKG_FILENAME_BETADEFINITION; + } + else if (indexRC > -1) + { + indexDef = indexRC; + pkgFilenameDef = PKG_FILENAME_RCDEFINITION; + } + else if (indexRelease > -1) + { + indexDef = indexRelease; + pkgFilenameDef = PKG_FILENAME_RELEASEDEFINITION; + } + else + { + indexDef = -1; + pkgFilenameDef = null; + } + + if (indexDef > -1) + { + // Get def from filename + var def = fileName.Substring(indexDef); + fileName = fileName.Remove(indexDef); + + // Get channel + switch (pkgFilenameDef) + { + case PKG_FILENAME_ALPHADEFINITION: + appVersion.Channel = Channels.Alpha; + break; + case PKG_FILENAME_BETADEFINITION: + appVersion.Channel = Channels.Beta; + break; + case PKG_FILENAME_RCDEFINITION: + appVersion.Channel = Channels.PreRelease; + break; + case PKG_FILENAME_RELEASEDEFINITION: + appVersion.Channel = Channels.Stable; + break; + } + + // Get build + var defBuild = def.Substring(pkgFilenameDef.Length); + appVersion.Build = Convert.ToInt32(defBuild); + } + else + { + // Set to default + appVersion.Build = 1; + appVersion.Channel = Channels.Stable; + } + } + + // Get version + if (Version.TryParse(fileName, out Version version)) + appVersion.Version = version; + else + allowAdd = false; + + if (allowAdd) + pkgs.Add(appVersion); + } + } + } + + return pkgs; + } + + public async Task DeletePackage(ApplicationVersion version) + { + var fileName = BuildPackageFilename(version); + var response = await client.Delete(fileName); + return response.IsSuccessful; + } + + public async Task UploadPackage(string filePath, ApplicationVersion version) + { + bool success; + var fileName = BuildPackageFilename(version); + + // Upload + var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read); + var response = await client.PutFile(fileName, fs); + fs.Close(); + success = response.IsSuccessful; + + // Generate public downloadlink + if (success) + { + var pkgInfo = GetOrCreateUpdatePackageInfo(version); + pkgInfo.Packagelink = Config.PublicPackageBaseURL + fileName; + } + + return success; + } + + private string BuildPackageFilename(ApplicationVersion version) + { + // Build channel/build definition of filename + string def = string.Empty; + switch (version.Channel) + { + case Channels.Alpha: + def = PKG_FILENAME_ALPHADEFINITION + version.Build; + break; + case Channels.Stable: + if (version.Build != 1) + def = PKG_FILENAME_RELEASEDEFINITION + version.Build; + break; + case Channels.PreRelease: + def = PKG_FILENAME_RCDEFINITION + version.Build; + break; + case Channels.Beta: + def = PKG_FILENAME_BETADEFINITION + version.Build; + break; + } + + // Build filename + var fileName = string.Format(PKG_FILENAME_TEMPLATE, version.Version, def); + + return fileName; + } + + private UpdatePackageInfo GetOrCreateUpdatePackageInfo(ApplicationVersion version) + { + var info = GetUpdatePackageInfo(version); + + info ??= CreateUpdatePackageInfo(version); + + return info; + } + + public UpdatePackageInfo GetUpdatePackageInfo(ApplicationVersion version) + { + return UpdateInfo.Packages.FirstOrDefault((n) => n.Version == version); + } + + private UpdatePackageInfo CreateUpdatePackageInfo(ApplicationVersion version) + { + var info = new UpdatePackageInfo() + { + Version = version + }; + UpdateInfo.Packages.Add(info); + return info; + } + + public (string name, string description, UpdateNotesContentType descriptionType) GetPackageDescription(ApplicationVersion version) + { + var pkg = GetUpdatePackageInfo(version); + if (pkg is object) + return (pkg.Name, pkg.Notes.Content, pkg.Notes.ContentType); + else + return default; + } + + public void SetPackageDescription(ApplicationVersion version, string name, string description, UpdateNotesContentType descriptionType) + { + var pkg = GetOrCreateUpdatePackageInfo(version); + if (pkg is object) + { + pkg.Name = name; + pkg.Notes.Content = description; + pkg.Notes.ContentType = descriptionType; } } + + public async Task ChangePackageVersion(ApplicationVersion currentVersion, ApplicationVersion newVersion) + { + bool success = false; + + // Get file names + var currentFilename = BuildPackageFilename(currentVersion); + var newFilename = BuildPackageFilename(newVersion); + + // Move + var response = await client.Move(currentFilename, newFilename); + + // Change package info version, if exists + if (response.IsSuccessful) + { + var pkg = GetUpdatePackageInfo(currentVersion); + if (pkg is object) + pkg.Version = newVersion; + success = true; + } + + return success; + } } \ No newline at end of file diff --git a/Pilz.Updating.Client.GUI/My Project/Application.Designer.cs b/Pilz.Updating.Client.GUI/My Project/Application.Designer.cs deleted file mode 100644 index 2be760e..0000000 --- a/Pilz.Updating.Client.GUI/My Project/Application.Designer.cs +++ /dev/null @@ -1,11 +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. -// -// ------------------------------------------------------------------------------ - - diff --git a/Pilz.Updating.Client.GUI/My Project/Application.myapp b/Pilz.Updating.Client.GUI/My Project/Application.myapp deleted file mode 100644 index 1243847..0000000 --- a/Pilz.Updating.Client.GUI/My Project/Application.myapp +++ /dev/null @@ -1,11 +0,0 @@ - - - true - Form1 - false - 0 - true - 0 - 0 - true - diff --git a/Pilz.Updating.Client.GUI/My Project/AssemblyInfo.cs b/Pilz.Updating.Client.GUI/My Project/AssemblyInfo.cs deleted file mode 100644 index 8d23a86..0000000 --- a/Pilz.Updating.Client.GUI/My Project/AssemblyInfo.cs +++ /dev/null @@ -1,8 +0,0 @@ -using global::System; -using global::System.Reflection; -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("f26b0b17-862f-42e2-afd5-340ef6761192")] - diff --git a/Pilz.Updating.Client.GUI/My Project/MyNamespace.Static.1.Designer.cs b/Pilz.Updating.Client.GUI/My Project/MyNamespace.Static.1.Designer.cs deleted file mode 100644 index f631b76..0000000 --- a/Pilz.Updating.Client.GUI/My Project/MyNamespace.Static.1.Designer.cs +++ /dev/null @@ -1,192 +0,0 @@ -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Diagnostics; -using Microsoft.VisualBasic; - -/* TODO ERROR: Skipped IfDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia */ - /* TODO ERROR: Skipped IfDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped ElifDirectiveTrivia */ - /* TODO ERROR: Skipped DefineDirectiveTrivia *//* TODO ERROR: Skipped DefineDirectiveTrivia *//* TODO ERROR: Skipped DefineDirectiveTrivia *//* TODO ERROR: Skipped DefineDirectiveTrivia */ - /* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia */ - /* TODO ERROR: Skipped IfDirectiveTrivia */ -namespace Pilz.Updating.Client.GUI.My -{ - - /* TODO ERROR: Skipped IfDirectiveTrivia */ - [System.CodeDom.Compiler.GeneratedCode("MyTemplate", "11.0.0.0")] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - - /* TODO ERROR: Skipped IfDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped ElifDirectiveTrivia */ - internal partial class MyApplication : Microsoft.VisualBasic.ApplicationServices.ApplicationBase - { - /* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia */ - } - - /* TODO ERROR: Skipped EndIfDirectiveTrivia */ - /* TODO ERROR: Skipped IfDirectiveTrivia */ - [System.CodeDom.Compiler.GeneratedCode("MyTemplate", "11.0.0.0")] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - - /* TODO ERROR: Skipped IfDirectiveTrivia */ - internal partial class MyComputer : Microsoft.VisualBasic.Devices.Computer - { - /* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia */ - [DebuggerHidden()] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public MyComputer() : base() - { - } - } - /* TODO ERROR: Skipped EndIfDirectiveTrivia */ - [HideModuleName()] - [System.CodeDom.Compiler.GeneratedCode("MyTemplate", "11.0.0.0")] - internal static class MyProject - { - - /* TODO ERROR: Skipped IfDirectiveTrivia */ - [System.ComponentModel.Design.HelpKeyword("My.Computer")] - internal static MyComputer Computer - { - [DebuggerHidden()] - get - { - return m_ComputerObjectProvider.GetInstance; - } - } - - private readonly static ThreadSafeObjectProvider m_ComputerObjectProvider = new ThreadSafeObjectProvider(); - /* TODO ERROR: Skipped EndIfDirectiveTrivia */ - /* TODO ERROR: Skipped IfDirectiveTrivia */ - [System.ComponentModel.Design.HelpKeyword("My.Application")] - internal static MyApplication Application - { - [DebuggerHidden()] - get - { - return m_AppObjectProvider.GetInstance; - } - } - - private readonly static ThreadSafeObjectProvider m_AppObjectProvider = new ThreadSafeObjectProvider(); - /* TODO ERROR: Skipped EndIfDirectiveTrivia */ - /* TODO ERROR: Skipped IfDirectiveTrivia */ - [System.ComponentModel.Design.HelpKeyword("My.User")] - internal static Microsoft.VisualBasic.ApplicationServices.User User - { - [DebuggerHidden()] - get - { - return m_UserObjectProvider.GetInstance; - } - } - - private readonly static ThreadSafeObjectProvider m_UserObjectProvider = new ThreadSafeObjectProvider(); - /* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia */ - /* TODO ERROR: Skipped IfDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia */ - /* TODO ERROR: Skipped IfDirectiveTrivia */ - [System.ComponentModel.Design.HelpKeyword("My.WebServices")] - internal static MyWebServices WebServices - { - [DebuggerHidden()] - get - { - return m_MyWebServicesObjectProvider.GetInstance; - } - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [MyGroupCollection("System.Web.Services.Protocols.SoapHttpClientProtocol", "Create__Instance__", "Dispose__Instance__", "")] - internal sealed class MyWebServices - { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [DebuggerHidden()] - public override bool Equals(object o) - { - return base.Equals(o); - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [DebuggerHidden()] - public override int GetHashCode() - { - return base.GetHashCode(); - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [DebuggerHidden()] - internal new Type GetType() - { - return typeof(MyWebServices); - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [DebuggerHidden()] - public override string ToString() - { - return base.ToString(); - } - - [DebuggerHidden()] - private static T Create__Instance__(T instance) where T : new() - { - if (instance == null) - { - return new T(); - } - else - { - return instance; - } - } - - [DebuggerHidden()] - private void Dispose__Instance__(ref T instance) - { - instance = default; - } - - [DebuggerHidden()] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public MyWebServices() : base() - { - } - } - - private readonly static ThreadSafeObjectProvider m_MyWebServicesObjectProvider = new ThreadSafeObjectProvider(); - /* TODO ERROR: Skipped EndIfDirectiveTrivia */ - /* TODO ERROR: Skipped IfDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia */ - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [System.Runtime.InteropServices.ComVisible(false)] - internal sealed class ThreadSafeObjectProvider where T : new() - { - internal T GetInstance - { - /* TODO ERROR: Skipped IfDirectiveTrivia */ - [DebuggerHidden()] - get - { - var Value = m_Context.Value; - if (Value == null) - { - Value = new T(); - m_Context.Value = Value; - } - - return Value; - } - /* TODO ERROR: Skipped ElseDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia */ - } - - [DebuggerHidden()] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public ThreadSafeObjectProvider() : base() - { - } - - /* TODO ERROR: Skipped IfDirectiveTrivia */ - private readonly Microsoft.VisualBasic.MyServices.Internal.ContextValue m_Context = new Microsoft.VisualBasic.MyServices.Internal.ContextValue(); - /* TODO ERROR: Skipped ElseDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia */ - } - } -} -/* TODO ERROR: Skipped EndIfDirectiveTrivia */ diff --git a/Pilz.Updating.Client.GUI/My Project/MyNamespace.Static.2.Designer.cs b/Pilz.Updating.Client.GUI/My Project/MyNamespace.Static.2.Designer.cs deleted file mode 100644 index 530cb48..0000000 --- a/Pilz.Updating.Client.GUI/My Project/MyNamespace.Static.2.Designer.cs +++ /dev/null @@ -1,253 +0,0 @@ -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -// See Compiler::LoadXmlSolutionExtension -using System.Collections; -using System.Collections.Generic; -using System.Data; -using System.Diagnostics; -using System.Linq; -using System.Xml.Linq; -using Microsoft.VisualBasic; -using Microsoft.VisualBasic.CompilerServices; - -namespace Pilz.Updating.Client.GUI.My -{ - [Embedded()] - [DebuggerNonUserCode()] - [System.Runtime.CompilerServices.CompilerGenerated()] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - internal sealed class InternalXmlHelper - { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - private InternalXmlHelper() - { - } - - public static string get_Value(IEnumerable source) - { - foreach (XElement item in source) - return item.Value; - return null; - } - - public static void set_Value(IEnumerable source, string value) - { - foreach (XElement item in source) - { - item.Value = value; - break; - } - } - - public static string get_AttributeValue(IEnumerable source, XName name) - { - foreach (XElement item in source) - return Conversions.ToString(item.Attribute(name)); - return null; - } - - public static void set_AttributeValue(IEnumerable source, XName name, string value) - { - foreach (XElement item in source) - { - item.SetAttributeValue(name, value); - break; - } - } - - public static string get_AttributeValue(XElement source, XName name) - { - return Conversions.ToString(source.Attribute(name)); - } - - public static void set_AttributeValue(XElement source, XName name, string value) - { - source.SetAttributeValue(name, value); - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static XAttribute CreateAttribute(XName name, object value) - { - if (value is null) - { - return null; - } - - return new XAttribute(name, value); - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static XAttribute CreateNamespaceAttribute(XName name, XNamespace ns) - { - var a = new XAttribute(name, ns.NamespaceName); - a.AddAnnotation(ns); - return a; - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static object RemoveNamespaceAttributes(string[] inScopePrefixes, XNamespace[] inScopeNs, List attributes, object obj) - { - if (obj is object) - { - XElement elem = obj as XElement; - if (elem is object) - { - return RemoveNamespaceAttributes(inScopePrefixes, inScopeNs, attributes, elem); - } - else - { - IEnumerable elems = obj as IEnumerable; - if (elems is object) - { - return RemoveNamespaceAttributes(inScopePrefixes, inScopeNs, attributes, elems); - } - } - } - - return obj; - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static IEnumerable RemoveNamespaceAttributes(string[] inScopePrefixes, XNamespace[] inScopeNs, List attributes, IEnumerable obj) - { - if (obj is object) - { - IEnumerable elems = obj as IEnumerable; - if (elems is object) - { - return elems.Select(new RemoveNamespaceAttributesClosure(inScopePrefixes, inScopeNs, attributes).ProcessXElement); - } - else - { - return obj.Cast().Select(new RemoveNamespaceAttributesClosure(inScopePrefixes, inScopeNs, attributes).ProcessObject); - } - } - - return obj; - } - - [DebuggerNonUserCode()] - [System.Runtime.CompilerServices.CompilerGenerated()] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - private sealed class RemoveNamespaceAttributesClosure - { - private readonly string[] m_inScopePrefixes; - private readonly XNamespace[] m_inScopeNs; - private readonly List m_attributes; - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - internal RemoveNamespaceAttributesClosure(string[] inScopePrefixes, XNamespace[] inScopeNs, List attributes) - { - m_inScopePrefixes = inScopePrefixes; - m_inScopeNs = inScopeNs; - m_attributes = attributes; - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - internal XElement ProcessXElement(XElement elem) - { - return RemoveNamespaceAttributes(m_inScopePrefixes, m_inScopeNs, m_attributes, elem); - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - internal object ProcessObject(object obj) - { - XElement elem = obj as XElement; - if (elem is object) - { - return RemoveNamespaceAttributes(m_inScopePrefixes, m_inScopeNs, m_attributes, elem); - } - else - { - return obj; - } - } - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static XElement RemoveNamespaceAttributes(string[] inScopePrefixes, XNamespace[] inScopeNs, List attributes, XElement e) - { - if (e is object) - { - var a = e.FirstAttribute; - while (a is object) - { - var nextA = a.NextAttribute; - if (a.IsNamespaceDeclaration) - { - var ns = a.Annotation(); - string prefix = a.Name.LocalName; - if (ns is object) - { - if (inScopePrefixes is object && inScopeNs is object) - { - int lastIndex = inScopePrefixes.Length - 1; - for (int i = 0, loopTo = lastIndex; i <= loopTo; i++) - { - string currentInScopePrefix = inScopePrefixes[i]; - var currentInScopeNs = inScopeNs[i]; - if (prefix.Equals(currentInScopePrefix)) - { - if (ns == currentInScopeNs) - { - // prefix and namespace match. Remove the unneeded ns attribute - a.Remove(); - } - - // prefix is in scope but refers to something else. Leave the ns attribute. - a = null; - break; - } - } - } - - if (a is object) - { - // Prefix is not in scope - // Now check whether it's going to be in scope because it is in the attributes list - - if (attributes is object) - { - int lastIndex = attributes.Count - 1; - for (int i = 0, loopTo1 = lastIndex; i <= loopTo1; i++) - { - var currentA = attributes[i]; - string currentInScopePrefix = currentA.Name.LocalName; - var currentInScopeNs = currentA.Annotation(); - if (currentInScopeNs is object) - { - if (prefix.Equals(currentInScopePrefix)) - { - if (ns == currentInScopeNs) - { - // prefix and namespace match. Remove the unneeded ns attribute - a.Remove(); - } - - // prefix is in scope but refers to something else. Leave the ns attribute. - a = null; - break; - } - } - } - } - - if (a is object) - { - // Prefix is definitely not in scope - a.Remove(); - // namespace is not defined either. Add this attributes list - attributes.Add(a); - } - } - } - } - - a = nextA; - } - } - - return e; - } - } -} \ No newline at end of file diff --git a/Pilz.Updating.Client.GUI/My Project/MyNamespace.Static.3.Designer.cs b/Pilz.Updating.Client.GUI/My Project/MyNamespace.Static.3.Designer.cs deleted file mode 100644 index b2b5044..0000000 --- a/Pilz.Updating.Client.GUI/My Project/MyNamespace.Static.3.Designer.cs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; - -namespace Microsoft.VisualBasic -{ - [Embedded()] - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Module | AttributeTargets.Assembly, Inherited = false)] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [System.Runtime.CompilerServices.CompilerGenerated()] - internal sealed class Embedded : Attribute - { - } -} \ No newline at end of file diff --git a/Pilz.Updating.Client.GUI/My Project/Resources.resx b/Pilz.Updating.Client.GUI/My Project/Resources.resx deleted file mode 100644 index af7dbeb..0000000 --- a/Pilz.Updating.Client.GUI/My Project/Resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/Pilz.Updating.Client.GUI/My Project/Settings.Designer.cs b/Pilz.Updating.Client.GUI/My Project/Settings.Designer.cs deleted file mode 100644 index 5d932e9..0000000 --- a/Pilz.Updating.Client.GUI/My Project/Settings.Designer.cs +++ /dev/null @@ -1,52 +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. -// -// ------------------------------------------------------------------------------ - -using System.Diagnostics; -using Microsoft.VisualBasic; - -namespace Pilz.Updating.Client.GUI.My -{ - [System.Runtime.CompilerServices.CompilerGenerated()] - [System.CodeDom.Compiler.GeneratedCode("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)] - internal sealed partial class MySettings : System.Configuration.ApplicationSettingsBase - { - private static MySettings defaultInstance = (MySettings)Synchronized(new MySettings()); - - /* TODO ERROR: Skipped RegionDirectiveTrivia *//* TODO ERROR: Skipped IfDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia *//* TODO ERROR: Skipped EndRegionDirectiveTrivia */ - public static MySettings Default - { - get - { - - /* TODO ERROR: Skipped IfDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia */ - return defaultInstance; - } - } - } -} - -namespace Pilz.Updating.Client.GUI.My -{ - [HideModuleName()] - [DebuggerNonUserCode()] - [System.Runtime.CompilerServices.CompilerGenerated()] - internal static class MySettingsProperty - { - [System.ComponentModel.Design.HelpKeyword("My.Settings")] - internal static MySettings Settings - { - get - { - return MySettings.Default; - } - } - } -} \ No newline at end of file diff --git a/Pilz.Updating.Client.GUI/My Project/Settings.settings b/Pilz.Updating.Client.GUI/My Project/Settings.settings deleted file mode 100644 index 85b890b..0000000 --- a/Pilz.Updating.Client.GUI/My Project/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/Pilz.Updating.Client.GUI/Pilz.Updating.Client.GUI.csproj b/Pilz.Updating.Client.GUI/Pilz.Updating.Client.GUI.csproj index fa941d6..4991d80 100644 --- a/Pilz.Updating.Client.GUI/Pilz.Updating.Client.GUI.csproj +++ b/Pilz.Updating.Client.GUI/Pilz.Updating.Client.GUI.csproj @@ -1,8 +1,7 @@  - SM64_ROM_Manager.Updating.Client.GUI - net6.0-windows;net8.0-windows + net8.0-windows true $(DefaultItemExcludes);$(ProjectDir)**\*.vb latest @@ -38,7 +37,6 @@ TRACE - True 2.0.0 @@ -46,9 +44,6 @@ - - 2023.1.117 - @@ -83,20 +78,11 @@ UpdatesAvailableDialog.cs Form - - True - Application.myapp - True True Resources.resx - - True - Settings.settings - True - True True @@ -137,17 +123,6 @@ UpdatingClientGuiLangRes.Designer.cs - - - MyApplicationCodeGenerator - Application.Designer.cs - - - SettingsSingleFileGenerator - SM64_ROM_Manager.Updating.Client.GUI.My - Settings.Designer.cs - - @@ -155,8 +130,10 @@ - + + + diff --git a/Pilz.Updating.Client.GUI/SimpleActionDialog.cs b/Pilz.Updating.Client.GUI/SimpleActionDialog.cs index d9a7152..8a7e964 100644 --- a/Pilz.Updating.Client.GUI/SimpleActionDialog.cs +++ b/Pilz.Updating.Client.GUI/SimpleActionDialog.cs @@ -1,29 +1,28 @@ -namespace Pilz.Updating.Client.GUI +namespace Pilz.Updating.Client.GUI; + +public partial class SimpleActionDialog { - public partial class SimpleActionDialog + public SimpleActionDialog() { - public SimpleActionDialog() - { - InitializeComponent(); - SetCurrentState(UpdateStatus.Waiting); - } + InitializeComponent(); + SetCurrentState(UpdateStatus.Waiting); + } - public void SetCurrentState(UpdateStatus curAction) + public void SetCurrentState(UpdateStatus curAction) + { + string progressText = curAction switch { - string progressText = curAction switch - { - UpdateStatus.Waiting => UpdatingClientGuiLangRes.SimpleActions_Waiting, - UpdateStatus.Searching => UpdatingClientGuiLangRes.SimpleActions_Searching, - UpdateStatus.DownloadingPackage => UpdatingClientGuiLangRes.SimpleActions_DownloadingPackage, - UpdateStatus.DownloadingInstaller => UpdatingClientGuiLangRes.SimpleActions_DownloadingInstaller, - UpdateStatus.StartingInstaller => UpdatingClientGuiLangRes.SimpleActions_StartingInstaller, - _ => string.Empty, - }; + UpdateStatus.Waiting => UpdatingClientGuiLangRes.SimpleActions_Waiting, + UpdateStatus.Searching => UpdatingClientGuiLangRes.SimpleActions_Searching, + UpdateStatus.DownloadingPackage => UpdatingClientGuiLangRes.SimpleActions_DownloadingPackage, + UpdateStatus.DownloadingInstaller => UpdatingClientGuiLangRes.SimpleActions_DownloadingInstaller, + UpdateStatus.StartingInstaller => UpdatingClientGuiLangRes.SimpleActions_StartingInstaller, + _ => string.Empty, + }; - radProgressBar1.Visible = false; - radWaitingBar1.Text = progressText; - radWaitingBar1.BringToFront(); - radWaitingBar1.StartWaiting(); - } + radProgressBar1.Visible = false; + radWaitingBar1.Text = progressText; + radWaitingBar1.BringToFront(); + radWaitingBar1.StartWaiting(); } } \ No newline at end of file diff --git a/Pilz.Updating.Client.GUI/UpdateClientGUI.cs b/Pilz.Updating.Client.GUI/UpdateClientGUI.cs index eb31fa3..ec05e5b 100644 --- a/Pilz.Updating.Client.GUI/UpdateClientGUI.cs +++ b/Pilz.Updating.Client.GUI/UpdateClientGUI.cs @@ -1,146 +1,144 @@ -using System.ComponentModel; -using System.Drawing; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Windows.Forms; -using Microsoft.VisualBasic.CompilerServices; +using Microsoft.VisualBasic.CompilerServices; using System; -using Telerik.WinControls; +using System.ComponentModel; +using System.Drawing; +using System.Runtime.CompilerServices; using System.Threading.Tasks; +using System.Windows.Forms; +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 UpdateClient _UpdateClient; + + private UpdateClient UpdateClient { - - // F i e l d s - - private Form parentForm; - private UpdateClient _UpdateClient; - - private UpdateClient UpdateClient + [MethodImpl(MethodImplOptions.Synchronized)] + get { - [MethodImpl(MethodImplOptions.Synchronized)] - get + return _UpdateClient; + } + + [MethodImpl(MethodImplOptions.Synchronized)] + set + { + if (_UpdateClient != null) { - return _UpdateClient; + + // U p d a t e C l i e n t - E v e n t s + + _UpdateClient.UpdateStatusChanged -= MyUpdateClient_UpdateStatusChanged; + _UpdateClient.DownloadingUpdate -= MyUpdateClient_DownloadingUpdate; + _UpdateClient.InstallingUpdate -= MyUpdateClient_InstallingUpdate; + _UpdateClient.UpdateInstallerStarted -= MyUpdateClient_FinishWork; + _UpdateClient.NoUpdatesFound -= MyUpdateClient_NoUpdatesFound; } - [MethodImpl(MethodImplOptions.Synchronized)] - set + _UpdateClient = value; + if (_UpdateClient != null) { - if (_UpdateClient != null) - { - - // U p d a t e C l i e n t - E v e n t s - - _UpdateClient.UpdateStatusChanged -= MyUpdateClient_UpdateStatusChanged; - _UpdateClient.DownloadingUpdate -= MyUpdateClient_DownloadingUpdate; - _UpdateClient.InstallingUpdate -= MyUpdateClient_InstallingUpdate; - _UpdateClient.UpdateInstallerStarted -= MyUpdateClient_FinishWork; - _UpdateClient.NoUpdatesFound -= MyUpdateClient_NoUpdatesFound; - } - - _UpdateClient = value; - if (_UpdateClient != null) - { - _UpdateClient.UpdateStatusChanged += MyUpdateClient_UpdateStatusChanged; - _UpdateClient.DownloadingUpdate += MyUpdateClient_DownloadingUpdate; - _UpdateClient.InstallingUpdate += MyUpdateClient_InstallingUpdate; - _UpdateClient.UpdateInstallerStarted += MyUpdateClient_FinishWork; - _UpdateClient.NoUpdatesFound += MyUpdateClient_NoUpdatesFound; - } - } - } - - private SimpleActionDialog curProgressDialog = null; - - // P r o p e r t i e s - - public bool UseHiddenSearch { get; set; } = false; - - private static Image MyAppIcon => Icon.ExtractAssociatedIcon(IO.Extensions.GetExecutablePath()).ToBitmap(); - - // C o n s t r u c t o r s - - public UpdateClientGUI(UpdateClient updateClient) - { - UpdateClient = updateClient; - } - - // F e a t u r e s - - public async Task UpdateInteractive(Form parentForm) - { - this.parentForm = parentForm; - await UpdateClient.UpdateInteractive(); - } - - private void EndUpdating() - { - curProgressDialog?.Invoke(new Action(() => curProgressDialog.Close())); - UpdateClient = null; - } - - private void MyUpdateClient_UpdateStatusChanged(UpdateStatus newStatus) - { - bool useGui = false; - if (!(newStatus == UpdateStatus.Searching && UseHiddenSearch)) - { - useGui = true; - } - - if (useGui && curProgressDialog is null) - { - parentForm.Invoke(new Action(() => - { - curProgressDialog = new SimpleActionDialog(); - curProgressDialog.SetCurrentState(UpdateStatus.Waiting); - curProgressDialog.Show(parentForm); - })); - } - - curProgressDialog?.Invoke(new Action(() => curProgressDialog.SetCurrentState(newStatus))); - } - - private void MyUpdateClient_DownloadingUpdate(UpdatePackageInfo pkg, CancelEventArgs e) - { - curProgressDialog?.Invoke(new Action(() => curProgressDialog.Hide())); - var dres = default(DialogResult); - parentForm.Invoke(new Action(() => - { - var dialog = new UpdatesAvailableDialog(MyAppIcon, UpdateClient.CurrentVersion.Version.ToString(), UpdateClient.CurrentVersion.Channel.ToString(), Conversions.ToString(UpdateClient.CurrentVersion.Build), pkg.Version.Version.ToString(), pkg.Version.Channel.ToString(), Conversions.ToString(pkg.Version.Build), pkg.Notes, UpdateClient.InstallAsAdmin); - dres = dialog.ShowDialog(parentForm); - })); - if (dres != DialogResult.OK) - { - e.Cancel = true; - EndUpdating(); - } - else - { - e.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); + _UpdateClient.UpdateStatusChanged += MyUpdateClient_UpdateStatusChanged; + _UpdateClient.DownloadingUpdate += MyUpdateClient_DownloadingUpdate; + _UpdateClient.InstallingUpdate += MyUpdateClient_InstallingUpdate; + _UpdateClient.UpdateInstallerStarted += MyUpdateClient_FinishWork; + _UpdateClient.NoUpdatesFound += MyUpdateClient_NoUpdatesFound; } } } + + private SimpleActionDialog curProgressDialog = null; + + // P r o p e r t i e s + + public bool UseHiddenSearch { get; set; } = false; + + private static Image MyAppIcon => Icon.ExtractAssociatedIcon(IO.Extensions.GetExecutablePath()).ToBitmap(); + + // C o n s t r u c t o r s + + public UpdateClientGUI(UpdateClient updateClient) + { + UpdateClient = updateClient; + } + + // F e a t u r e s + + public async Task UpdateInteractive(Form parentForm) + { + this.parentForm = parentForm; + await UpdateClient.UpdateInteractive(); + } + + private void EndUpdating() + { + curProgressDialog?.Invoke(new Action(() => curProgressDialog.Close())); + UpdateClient = null; + } + + private void MyUpdateClient_UpdateStatusChanged(UpdateStatus newStatus) + { + bool useGui = false; + if (!(newStatus == UpdateStatus.Searching && UseHiddenSearch)) + { + useGui = true; + } + + if (useGui && curProgressDialog is null) + { + parentForm.Invoke(new Action(() => + { + curProgressDialog = new SimpleActionDialog(); + curProgressDialog.SetCurrentState(UpdateStatus.Waiting); + curProgressDialog.Show(parentForm); + })); + } + + curProgressDialog?.Invoke(new Action(() => curProgressDialog.SetCurrentState(newStatus))); + } + + private void MyUpdateClient_DownloadingUpdate(UpdatePackageInfo pkg, CancelEventArgs e) + { + curProgressDialog?.Invoke(new Action(() => curProgressDialog.Hide())); + var dres = default(DialogResult); + parentForm.Invoke(new Action(() => + { + var dialog = new UpdatesAvailableDialog(MyAppIcon, UpdateClient.CurrentVersion.Version.ToString(), UpdateClient.CurrentVersion.Channel.ToString(), Conversions.ToString(UpdateClient.CurrentVersion.Build), pkg.Version.Version.ToString(), pkg.Version.Channel.ToString(), Conversions.ToString(pkg.Version.Build), pkg.Notes, UpdateClient.InstallAsAdmin); + dres = dialog.ShowDialog(parentForm); + })); + if (dres != DialogResult.OK) + { + e.Cancel = true; + EndUpdating(); + } + else + { + e.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); + } + } } \ No newline at end of file diff --git a/Pilz.Updating.Client.GUI/UpdatesAvailableDialog.cs b/Pilz.Updating.Client.GUI/UpdatesAvailableDialog.cs index 754f1e2..836f08f 100644 --- a/Pilz.Updating.Client.GUI/UpdatesAvailableDialog.cs +++ b/Pilz.Updating.Client.GUI/UpdatesAvailableDialog.cs @@ -1,57 +1,55 @@ -using System.Drawing; +using Pilz.Updating.GUIBase; +using System.Drawing; using System.Windows.Forms; -using Pilz.Updating.GUIBase; -using Telerik.WinControls; using Telerik.WinControls.UI; -namespace Pilz.Updating.Client.GUI +namespace Pilz.Updating.Client.GUI; + +internal partial class UpdatesAvailableDialog { - internal partial class UpdatesAvailableDialog + public UpdatesAvailableDialog(Image appIcon, string curVersion, string curChannel, string curBuild, string newVersion, string newChannel, string newBuild, UpdateNotes updateNotes, bool installAsAdmin) { - public UpdatesAvailableDialog(Image appIcon, string curVersion, string curChannel, string curBuild, string newVersion, string newChannel, string newBuild, UpdateNotes updateNotes, bool installAsAdmin) + InitializeComponent(); + + if (installAsAdmin) + radButton_Install.Image = BaseFeatures.GetUacShieldImage(); + + radPictureBox1.Image = appIcon ?? Icon.ToBitmap(); + radLabel_CurrentVersion.Text = curVersion; + radLabel_CurrentVersionChannel.Text = curChannel; + radLabel_CurrentVersionBuild.Text = curBuild; + radLabel_AvailableVersion.Text = newVersion; + radLabel_AvailableVersionChannel.Text = newChannel; + radLabel_AvailableVersionBuild.Text = newBuild; + + // Update Notes + Control updateNotesControl = null; + switch (updateNotes.ContentType) { - InitializeComponent(); - - if (installAsAdmin) - radButton_Install.Image = BaseFeatures.GetUacShieldImage(); - - radPictureBox1.Image = appIcon ?? Icon.ToBitmap(); - radLabel_CurrentVersion.Text = curVersion; - radLabel_CurrentVersionChannel.Text = curChannel; - radLabel_CurrentVersionBuild.Text = curBuild; - radLabel_AvailableVersion.Text = newVersion; - radLabel_AvailableVersionChannel.Text = newChannel; - radLabel_AvailableVersionBuild.Text = newBuild; - - // Update Notes - Control updateNotesControl = null; - switch (updateNotes.ContentType) - { - case UpdateNotesContentType.PlainText: - var newUpdateNotesControl = new RadRichTextEditor - { - Text = updateNotes.Content - }; - updateNotesControl = newUpdateNotesControl; - break; - case UpdateNotesContentType.Markdown: - updateNotesControl = new Westermo.HtmlRenderer.WinForms.HtmlPanel - { - Text = Markdig.Markdown.ToHtml(updateNotes.Content) - }; - break; - case UpdateNotesContentType.HTML: - updateNotesControl = new Westermo.HtmlRenderer.WinForms.HtmlPanel - { - Text = updateNotes.Content - }; - break; - } - if (updateNotesControl is not null) - { - updateNotesControl.Dock = DockStyle.Fill; - panel_ChangelogPanel.Controls.Add(updateNotesControl); - } + case UpdateNotesContentType.PlainText: + var newUpdateNotesControl = new RadRichTextEditor + { + Text = updateNotes.Content + }; + updateNotesControl = newUpdateNotesControl; + break; + case UpdateNotesContentType.Markdown: + updateNotesControl = new Westermo.HtmlRenderer.WinForms.HtmlPanel + { + Text = Markdig.Markdown.ToHtml(updateNotes.Content) + }; + break; + case UpdateNotesContentType.HTML: + updateNotesControl = new Westermo.HtmlRenderer.WinForms.HtmlPanel + { + Text = updateNotes.Content + }; + break; + } + if (updateNotesControl is not null) + { + updateNotesControl.Dock = DockStyle.Fill; + panel_ChangelogPanel.Controls.Add(updateNotesControl); } } } \ No newline at end of file diff --git a/Pilz.Updating.Client/Pilz.Updating.Client.csproj b/Pilz.Updating.Client/Pilz.Updating.Client.csproj index a5bc543..135479d 100644 --- a/Pilz.Updating.Client/Pilz.Updating.Client.csproj +++ b/Pilz.Updating.Client/Pilz.Updating.Client.csproj @@ -1,7 +1,7 @@  Pilz.Updating - net6.0-windows;net8.0-windows + net8.0-windows $(DefaultItemExcludes);$(ProjectDir)**\*.vb latest Pilz.Updating.Client @@ -11,7 +11,6 @@ Pilz.Updating.Client.xml true 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022,CS1591,CS0660,CS0661,CS0436 - true true @@ -37,7 +36,6 @@ TRACE;RelMono - True 2.0.0 diff --git a/Pilz.Updating.Client/Properties/AssemblyInfo.cs b/Pilz.Updating.Client/Properties/AssemblyInfo.cs index ac80aa6..df9add3 100644 --- a/Pilz.Updating.Client/Properties/AssemblyInfo.cs +++ b/Pilz.Updating.Client/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using global::System; -using global::System.Reflection; using global::System.Runtime.InteropServices; [assembly: ComVisible(false)] diff --git a/Pilz.Updating.Client/UpdateClient.cs b/Pilz.Updating.Client/UpdateClient.cs index 782e2d0..c94e5f9 100644 --- a/Pilz.Updating.Client/UpdateClient.cs +++ b/Pilz.Updating.Client/UpdateClient.cs @@ -1,267 +1,261 @@ -using System; +using Microsoft.VisualBasic.CompilerServices; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; -using System.Drawing; using System.IO; using System.IO.Compression; -using System.IO.Pipes; using System.Linq; -using System.Net; using System.Net.Http; -using System.Reflection; using System.Threading.Tasks; -using Microsoft.VisualBasic.CompilerServices; -using Pilz.Updating.UpdateInstaller; -namespace Pilz.Updating +namespace Pilz.Updating; + +public class UpdateClient { - public class UpdateClient + + // 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(); + + // 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; } + public ApplicationVersion CurrentVersion { get; private set; } + public Channels MinimumChannel { get; private set; } + 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; + + // C o n s t r u c t o r s + + public UpdateClient(string updateUrl, ApplicationVersion currentVersion, Channels minimumChannel) { + UpdateUrl = updateUrl; + CurrentVersion = currentVersion; + MinimumChannel = (Channels)Math.Max((int)minimumChannel, (int)currentVersion.Channel); + } - // E b v e n t s + // E v e n t M e t h o d s - public event UpdateStatusChangedEventHandler UpdateStatusChanged; + private bool RaiseDownloadingUpdate(UpdatePackageInfo pkg) + { + var e = new CancelEventArgs(false); + DownloadingUpdate?.Invoke(pkg, e); + return e.Cancel; + } - public delegate void UpdateStatusChangedEventHandler(UpdateStatus newStatus); + private bool RaiseInstallingUpdate(UpdatePackageInfo pkg) + { + var e = new CancelEventArgs(true); + InstallingUpdate?.Invoke(pkg, e); + return e.Cancel; + } - public event DownloadingUpdateEventHandler DownloadingUpdate; + // U p d a t e R o u t i n e s - public delegate void DownloadingUpdateEventHandler(UpdatePackageInfo pkg, CancelEventArgs e); + public async Task UpdateInteractive() + { + var latestVersion = await CheckForUpdate(); + if (latestVersion is null) + NoUpdatesFound?.Invoke(); + else + await UpdateInteractive(latestVersion); + } - 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(); - - // F i e l d s - - private readonly Dictionary dicPackagePaths = new Dictionary(); - 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; } - public ApplicationVersion CurrentVersion { get; private set; } - public Channels MinimumChannel { get; private set; } - 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; - - // C o n s t r u c t o r s - - public UpdateClient(string updateUrl, ApplicationVersion currentVersion, Channels minimumChannel) + public async Task UpdateInteractive(UpdatePackageInfo package) + { + if (!RaiseDownloadingUpdate(package) && await DownloadPackageAsync(package)) { - UpdateUrl = updateUrl; - CurrentVersion = currentVersion; - MinimumChannel = (Channels)Math.Max((int)minimumChannel, (int)currentVersion.Channel); + if (!RaiseInstallingUpdate(package)) + await InstallPackage(package); } + } - // E v e n t M e t h o d s + public void RaiseUpdateStatusChanged(UpdateStatus newStatus) + { + UpdateStatusChanged?.Invoke(newStatus); + } - private bool RaiseDownloadingUpdate(UpdatePackageInfo pkg) + // F e a t u r e s + + public async Task GetUpdateInfo() + { + string str = await WebClient.GetStringAsync(UpdateUrl); + var info = UpdateInfo.Parse(str); + return info; + } + + public async Task CheckForUpdate() + { + RaiseUpdateStatusChanged(UpdateStatus.Searching); + UpdateInfo = await GetUpdateInfo(); + if (UpdateInfo is not null) + return CheckForUpdate(UpdateInfo); + else + return null; + } + + public UpdatePackageInfo CheckForUpdate(UpdateInfo updateInfo) + { + UpdatePackageInfo foundPkgInfo = null; + var latestVersion = CurrentVersion; + RaiseUpdateStatusChanged(UpdateStatus.Searching); + foreach (UpdatePackageInfo pkgInfo in updateInfo.Packages) { - var e = new CancelEventArgs(false); - DownloadingUpdate?.Invoke(pkg, e); - return e.Cancel; - } - - private bool RaiseInstallingUpdate(UpdatePackageInfo pkg) - { - var e = new CancelEventArgs(true); - InstallingUpdate?.Invoke(pkg, e); - return e.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 - await UpdateInteractive(latestVersion); - } - - public async Task UpdateInteractive(UpdatePackageInfo package) - { - if (!RaiseDownloadingUpdate(package) && await DownloadPackageAsync(package)) + if (pkgInfo.Version.Channel <= MinimumChannel && pkgInfo.Version > latestVersion) { - if (!RaiseInstallingUpdate(package)) - await InstallPackage(package); + foundPkgInfo = pkgInfo; + latestVersion = pkgInfo.Version; } } - public void RaiseUpdateStatusChanged(UpdateStatus newStatus) + UpdatePackageInfo = foundPkgInfo; + return foundPkgInfo; + } + + public async Task DownloadPackageAsync(UpdatePackageInfo package) + { + curDownloadingStatus = UpdateStatus.DownloadingPackage; + RaiseUpdateStatusChanged(curDownloadingStatus); + string dirPath = Path.Combine(MyPaths.GetMyAppDataPath(), Conversions.ToString(package.GetHashCode())); + string zipPath = Path.Combine(dirPath, PackageFileNameDefinations.ZIP_PACKAGE_FILENAME); + var dir = new DirectoryInfo(dirPath); + try { - UpdateStatusChanged?.Invoke(newStatus); + // Ensure existing and empty directory for the Zip File + if (dir.Exists) + dir.Delete(true); + + dir.Create(); + + // Download zip package + using var zipFile = new FileStream(zipPath, FileMode.Create, FileAccess.ReadWrite); + using var zipStream = await WebClient.GetStreamAsync(package.Packagelink); + await zipStream.CopyToAsync(zipFile); + + // Remember path to package directory + dicPackagePaths.Add(package, dirPath); + } + catch (Exception) + { + return false; } - // F e a t u r e s + return true; + } - public async Task GetUpdateInfo() + private async Task DownloadUpdateInstaller() + { + 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)) { - string str = await WebClient.GetStringAsync(UpdateUrl); - var info = UpdateInfo.Parse(str); - return info; + using var installerZipStream = await WebClient.GetStreamAsync(UpdateInfo.UpdateInstallerLink); + await installerZipStream.CopyToAsync(installerZipFile); } - public async Task CheckForUpdate() + // Extract update installer + var installerExtractPath = installerDirPath.CreateSubdirectory("extracted"); + ZipFile.ExtractToDirectory(installerZipPath, installerExtractPath.FullName); + File.Delete(installerZipPath); + + // Get UpdateInstaller.exe file + return installerExtractPath.EnumerateFiles("*.exe").FirstOrDefault(); + } + + private void StartUpdateInstaller(string packagePath, string installerPath) + { + RaiseUpdateStatusChanged(UpdateStatus.StartingInstaller); + + // Create update settings + var myAppPath = IO.Extensions.GetExecutablePath(); + var updateConfig = new UpdateInstallerConfig { - RaiseUpdateStatusChanged(UpdateStatus.Searching); - UpdateInfo = await GetUpdateInfo(); - if (UpdateInfo is not null) - return CheckForUpdate(UpdateInfo); - else - return null; - } + 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 + }; - public UpdatePackageInfo CheckForUpdate(UpdateInfo updateInfo) + // Start UpdateInstaller + var procStartInfo = new ProcessStartInfo { - UpdatePackageInfo foundPkgInfo = null; - var latestVersion = CurrentVersion; - RaiseUpdateStatusChanged(UpdateStatus.Searching); - foreach (UpdatePackageInfo pkgInfo in updateInfo.Packages) - { - if (pkgInfo.Version.Channel <= MinimumChannel && pkgInfo.Version > latestVersion) - { - foundPkgInfo = pkgInfo; - latestVersion = pkgInfo.Version; - } - } + FileName = installerPath, + Arguments = updateConfig.ToString(), + UseShellExecute = false, + Verb = InstallAsAdmin ? "runas" : string.Empty + }; + Process.Start(procStartInfo); + UpdateInstallerStarted?.Invoke(); + } - UpdatePackageInfo = foundPkgInfo; - return foundPkgInfo; - } - - public async Task DownloadPackageAsync(UpdatePackageInfo package) + public async Task InstallPackage(UpdatePackageInfo package) + { + if (dicPackagePaths.TryGetValue(package, out var packagePath)) { - curDownloadingStatus = UpdateStatus.DownloadingPackage; - RaiseUpdateStatusChanged(curDownloadingStatus); - string dirPath = Path.Combine(MyPaths.GetMyAppDataPath(), Conversions.ToString(package.GetHashCode())); - string zipPath = Path.Combine(dirPath, PackageFileNameDefinations.ZIP_PACKAGE_FILENAME); - var dir = new DirectoryInfo(dirPath); - try - { - // Ensure existing and empty directory for the Zip File - if (dir.Exists) - dir.Delete(true); + // Download update installer + var installerPath = await DownloadUpdateInstaller(); - dir.Create(); + // Start update installer + StartUpdateInstaller(packagePath, installerPath.FullName); - // Download zip package - using var zipFile = new FileStream(zipPath, FileMode.Create, FileAccess.ReadWrite); - using var zipStream = await WebClient.GetStreamAsync(package.Packagelink); - await zipStream.CopyToAsync(zipFile); - - // Remember path to package directory - dicPackagePaths.Add(package, dirPath); - } - catch (Exception) - { - return false; - } + // Close Host Application + if (AutoCloseHostApplication) + Environment.Exit(Environment.ExitCode); return true; } - private async Task DownloadUpdateInstaller() - { - 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)) - { - using var installerZipStream = await WebClient.GetStreamAsync(UpdateInfo.UpdateInstallerLink); - await installerZipStream.CopyToAsync(installerZipFile); - } - - // Extract update installer - var installerExtractPath = installerDirPath.CreateSubdirectory("extracted"); - ZipFile.ExtractToDirectory(installerZipPath, installerExtractPath.FullName); - File.Delete(installerZipPath); - - // Get UpdateInstaller.exe file - return installerExtractPath.EnumerateFiles("*.exe").FirstOrDefault(); - } - - private void StartUpdateInstaller(string packagePath, string installerPath) - { - 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 false; } } \ No newline at end of file diff --git a/Pilz.Updating.Client/UpdateStatus.cs b/Pilz.Updating.Client/UpdateStatus.cs index 2327749..ea1601b 100644 --- a/Pilz.Updating.Client/UpdateStatus.cs +++ b/Pilz.Updating.Client/UpdateStatus.cs @@ -1,11 +1,10 @@ -namespace Pilz.Updating +namespace Pilz.Updating; + +public enum UpdateStatus { - public enum UpdateStatus - { - Waiting, - Searching, - DownloadingPackage, - DownloadingInstaller, - StartingInstaller - } + Waiting, + Searching, + DownloadingPackage, + DownloadingInstaller, + StartingInstaller } \ No newline at end of file diff --git a/Pilz.Updating.GUIBase/BaseFeatures.cs b/Pilz.Updating.GUIBase/BaseFeatures.cs index d5d4e79..fd4ac81 100644 --- a/Pilz.Updating.GUIBase/BaseFeatures.cs +++ b/Pilz.Updating.GUIBase/BaseFeatures.cs @@ -1,113 +1,114 @@ -using System; -using global::System.Drawing; -using global::System.Runtime.InteropServices; -using global::System.Windows.Forms; +using System.Drawing; +using System.Runtime.InteropServices; +using System; +using System.Windows.Forms; -namespace Pilz.Updating.GUIBase +namespace Pilz.Updating.GUIBase; + +internal static class BaseFeatures { - internal static class BaseFeatures + [DllImport("user32")] + private static extern uint SendMessage(IntPtr hWnd, uint msg, uint wParam, uint lParam); + + private const int BCM_FIRST = 0x1600; // Normal button + private const int BCM_SETSHIELD = BCM_FIRST + 0xC; // Elevated button + + public static void AddShieldToButton(Button b) { - [DllImport("user32")] - private static extern uint SendMessage(IntPtr hWnd, uint msg, uint wParam, uint lParam); + b.FlatStyle = FlatStyle.System; + SendMessage(b.Handle, BCM_SETSHIELD, 0, 0xFFFFFFFFU); + } - private const int BCM_FIRST = 0x1600; // Normal button - private const int BCM_SETSHIELD = BCM_FIRST + 0xC; // Elevated button + // Return a bitmap containing the UAC shield. + private static Bitmap shield_bm = null; - public static void AddShieldToButton(Button b) + public static Bitmap GetUacShieldImage() + { + if (shield_bm is object) { - b.FlatStyle = FlatStyle.System; - SendMessage(b.Handle, BCM_SETSHIELD, 0, 0xFFFFFFFFU); - } - - // Return a bitmap containing the UAC shield. - private static Bitmap shield_bm = null; - - public static Bitmap GetUacShieldImage() - { - if (shield_bm is object) - { - return shield_bm; - } - - const int WID = 50; - const int HGT = 50; - const int MARGIN = 4; - - // Make the button. For some reason, it must - // have text or the UAC shield won't appear. - var btn = new Button(); - btn.Text = " "; - btn.Size = new Size(WID, HGT); - AddShieldToButton(btn); - - // Draw the button onto a bitmap. - var bm = new Bitmap(WID, HGT); - btn.Refresh(); - btn.DrawToBitmap(bm, new Rectangle(0, 0, WID, HGT)); - - // Find the part containing the shield. - int min_x = WID; - int max_x = 0; - int min_y = HGT; - int max_y = 0; - - // Fill on the left. - int y = MARGIN; - while (y < HGT - MARGIN) - { - // Get the leftmost pixel's color. - var target_color = bm.GetPixel(MARGIN, y); - - // Fill in with this color as long as we see the target. - int x = MARGIN; - while (x < WID - MARGIN) - { - // See if this pixel is part of the shield. - if (bm.GetPixel(x, y).Equals(target_color)) - { - // It's not part of the shield. - // Clear the pixel. - bm.SetPixel(x, y, Color.Transparent); - } - else - { - // It's part of the shield. - if (min_y > y) - { - min_y = y; - } - - if (min_x > x) - { - min_x = x; - } - - if (max_y < y) - { - max_y = y; - } - - if (max_x < x) - { - max_x = x; - } - } - - x += 1; - } - - y += 1; - } - - // Clip out the shield part. - int shield_wid = max_x - min_x + 1; - int shield_hgt = max_y - min_y + 1; - shield_bm = new Bitmap(shield_wid, shield_hgt); - var shield_gr = Graphics.FromImage(shield_bm); - shield_gr.DrawImage(bm, 0, 0, new Rectangle(min_x, min_y, shield_wid, shield_hgt), GraphicsUnit.Pixel); - - // Return the shield. return shield_bm; } + + const int WID = 50; + const int HGT = 50; + const int MARGIN = 4; + + // Make the button. For some reason, it must + // have text or the UAC shield won't appear. + var btn = new Button + { + Text = " ", + Size = new Size(WID, HGT) + }; + AddShieldToButton(btn); + + // Draw the button onto a bitmap. + var bm = new Bitmap(WID, HGT); + btn.Refresh(); + btn.DrawToBitmap(bm, new Rectangle(0, 0, WID, HGT)); + + // Find the part containing the shield. + int min_x = WID; + int max_x = 0; + int min_y = HGT; + int max_y = 0; + + // Fill on the left. + int y = MARGIN; + while (y < HGT - MARGIN) + { + // Get the leftmost pixel's color. + var target_color = bm.GetPixel(MARGIN, y); + + // Fill in with this color as long as we see the target. + int x = MARGIN; + while (x < WID - MARGIN) + { + // See if this pixel is part of the shield. + if (bm.GetPixel(x, y).Equals(target_color)) + { + // It's not part of the shield. + // Clear the pixel. + bm.SetPixel(x, y, Color.Transparent); + } + else + { + // It's part of the shield. + if (min_y > y) + { + min_y = y; + } + + if (min_x > x) + { + min_x = x; + } + + if (max_y < y) + { + max_y = y; + } + + if (max_x < x) + { + max_x = x; + } + } + + x += 1; + } + + y += 1; + } + + // Clip out the shield part. + int shield_wid = max_x - min_x + 1; + int shield_hgt = max_y - min_y + 1; + shield_bm = new Bitmap(shield_wid, shield_hgt); + var shield_gr = Graphics.FromImage(shield_bm); + shield_gr.DrawImage(bm, 0, 0, new Rectangle(min_x, min_y, shield_wid, shield_hgt), GraphicsUnit.Pixel); + + // Return the shield. + return shield_bm; } } \ No newline at end of file diff --git a/Pilz.Updating.GUIBase/My Project/Application.Designer.cs b/Pilz.Updating.GUIBase/My Project/Application.Designer.cs deleted file mode 100644 index 5e9e2a0..0000000 --- a/Pilz.Updating.GUIBase/My Project/Application.Designer.cs +++ /dev/null @@ -1,11 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - - diff --git a/Pilz.Updating.GUIBase/My Project/Application.myapp b/Pilz.Updating.GUIBase/My Project/Application.myapp deleted file mode 100644 index 758895d..0000000 --- a/Pilz.Updating.GUIBase/My Project/Application.myapp +++ /dev/null @@ -1,10 +0,0 @@ - - - false - false - 0 - true - 0 - 1 - true - diff --git a/Pilz.Updating.GUIBase/My Project/MyNamespace.Static.1.Designer.cs b/Pilz.Updating.GUIBase/My Project/MyNamespace.Static.1.Designer.cs deleted file mode 100644 index 4652276..0000000 --- a/Pilz.Updating.GUIBase/My Project/MyNamespace.Static.1.Designer.cs +++ /dev/null @@ -1,192 +0,0 @@ -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Diagnostics; -using Microsoft.VisualBasic; - -/* TODO ERROR: Skipped IfDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia */ -/* TODO ERROR: Skipped IfDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped ElifDirectiveTrivia */ -/* TODO ERROR: Skipped DefineDirectiveTrivia *//* TODO ERROR: Skipped DefineDirectiveTrivia *//* TODO ERROR: Skipped DefineDirectiveTrivia *//* TODO ERROR: Skipped DefineDirectiveTrivia */ -/* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia */ -/* TODO ERROR: Skipped IfDirectiveTrivia */ -namespace Pilz.Updating.GUIBase.My -{ - - /* TODO ERROR: Skipped IfDirectiveTrivia */ - [System.CodeDom.Compiler.GeneratedCode("MyTemplate", "11.0.0.0")] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - - /* TODO ERROR: Skipped IfDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped ElifDirectiveTrivia */ - internal partial class MyApplication : Microsoft.VisualBasic.ApplicationServices.ApplicationBase - { - /* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia */ - } - - /* TODO ERROR: Skipped EndIfDirectiveTrivia */ - /* TODO ERROR: Skipped IfDirectiveTrivia */ - [System.CodeDom.Compiler.GeneratedCode("MyTemplate", "11.0.0.0")] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - - /* TODO ERROR: Skipped IfDirectiveTrivia */ - internal partial class MyComputer : Microsoft.VisualBasic.Devices.Computer - { - /* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia */ - [DebuggerHidden()] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public MyComputer() : base() - { - } - } - /* TODO ERROR: Skipped EndIfDirectiveTrivia */ - [HideModuleName()] - [System.CodeDom.Compiler.GeneratedCode("MyTemplate", "11.0.0.0")] - internal static class MyProject - { - - /* TODO ERROR: Skipped IfDirectiveTrivia */ - [System.ComponentModel.Design.HelpKeyword("My.Computer")] - internal static MyComputer Computer - { - [DebuggerHidden()] - get - { - return m_ComputerObjectProvider.GetInstance; - } - } - - private readonly static ThreadSafeObjectProvider m_ComputerObjectProvider = new ThreadSafeObjectProvider(); - /* TODO ERROR: Skipped EndIfDirectiveTrivia */ - /* TODO ERROR: Skipped IfDirectiveTrivia */ - [System.ComponentModel.Design.HelpKeyword("My.Application")] - internal static MyApplication Application - { - [DebuggerHidden()] - get - { - return m_AppObjectProvider.GetInstance; - } - } - - private readonly static ThreadSafeObjectProvider m_AppObjectProvider = new ThreadSafeObjectProvider(); - /* TODO ERROR: Skipped EndIfDirectiveTrivia */ - /* TODO ERROR: Skipped IfDirectiveTrivia */ - [System.ComponentModel.Design.HelpKeyword("My.User")] - internal static Microsoft.VisualBasic.ApplicationServices.User User - { - [DebuggerHidden()] - get - { - return m_UserObjectProvider.GetInstance; - } - } - - private readonly static ThreadSafeObjectProvider m_UserObjectProvider = new ThreadSafeObjectProvider(); - /* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia */ - /* TODO ERROR: Skipped IfDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia */ - /* TODO ERROR: Skipped IfDirectiveTrivia */ - [System.ComponentModel.Design.HelpKeyword("My.WebServices")] - internal static MyWebServices WebServices - { - [DebuggerHidden()] - get - { - return m_MyWebServicesObjectProvider.GetInstance; - } - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [MyGroupCollection("System.Web.Services.Protocols.SoapHttpClientProtocol", "Create__Instance__", "Dispose__Instance__", "")] - internal sealed class MyWebServices - { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [DebuggerHidden()] - public override bool Equals(object o) - { - return base.Equals(o); - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [DebuggerHidden()] - public override int GetHashCode() - { - return base.GetHashCode(); - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [DebuggerHidden()] - internal new Type GetType() - { - return typeof(MyWebServices); - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [DebuggerHidden()] - public override string ToString() - { - return base.ToString(); - } - - [DebuggerHidden()] - private static T Create__Instance__(T instance) where T : new() - { - if (instance == null) - { - return new T(); - } - else - { - return instance; - } - } - - [DebuggerHidden()] - private void Dispose__Instance__(ref T instance) - { - instance = default; - } - - [DebuggerHidden()] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public MyWebServices() : base() - { - } - } - - private readonly static ThreadSafeObjectProvider m_MyWebServicesObjectProvider = new ThreadSafeObjectProvider(); - /* TODO ERROR: Skipped EndIfDirectiveTrivia */ - /* TODO ERROR: Skipped IfDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia */ - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [System.Runtime.InteropServices.ComVisible(false)] - internal sealed class ThreadSafeObjectProvider where T : new() - { - internal T GetInstance - { - /* TODO ERROR: Skipped IfDirectiveTrivia */ - [DebuggerHidden()] - get - { - var Value = m_Context.Value; - if (Value == null) - { - Value = new T(); - m_Context.Value = Value; - } - - return Value; - } - /* TODO ERROR: Skipped ElseDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia */ - } - - [DebuggerHidden()] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public ThreadSafeObjectProvider() : base() - { - } - - /* TODO ERROR: Skipped IfDirectiveTrivia */ - private readonly Microsoft.VisualBasic.MyServices.Internal.ContextValue m_Context = new Microsoft.VisualBasic.MyServices.Internal.ContextValue(); - /* TODO ERROR: Skipped ElseDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia */ - } - } -} -/* TODO ERROR: Skipped EndIfDirectiveTrivia */ diff --git a/Pilz.Updating.GUIBase/My Project/MyNamespace.Static.2.Designer.cs b/Pilz.Updating.GUIBase/My Project/MyNamespace.Static.2.Designer.cs deleted file mode 100644 index 916d0c8..0000000 --- a/Pilz.Updating.GUIBase/My Project/MyNamespace.Static.2.Designer.cs +++ /dev/null @@ -1,253 +0,0 @@ -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -// See Compiler::LoadXmlSolutionExtension -using System.Collections; -using System.Collections.Generic; -using System.Data; -using System.Diagnostics; -using System.Linq; -using System.Xml.Linq; -using Microsoft.VisualBasic; -using Microsoft.VisualBasic.CompilerServices; - -namespace Pilz.Updating.GUIBase.My -{ - [Embedded()] - [DebuggerNonUserCode()] - [System.Runtime.CompilerServices.CompilerGenerated()] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - internal sealed class InternalXmlHelper - { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - private InternalXmlHelper() - { - } - - public static string get_Value(IEnumerable source) - { - foreach (XElement item in source) - return item.Value; - return null; - } - - public static void set_Value(IEnumerable source, string value) - { - foreach (XElement item in source) - { - item.Value = value; - break; - } - } - - public static string get_AttributeValue(IEnumerable source, XName name) - { - foreach (XElement item in source) - return Conversions.ToString(item.Attribute(name)); - return null; - } - - public static void set_AttributeValue(IEnumerable source, XName name, string value) - { - foreach (XElement item in source) - { - item.SetAttributeValue(name, value); - break; - } - } - - public static string get_AttributeValue(XElement source, XName name) - { - return Conversions.ToString(source.Attribute(name)); - } - - public static void set_AttributeValue(XElement source, XName name, string value) - { - source.SetAttributeValue(name, value); - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static XAttribute CreateAttribute(XName name, object value) - { - if (value is null) - { - return null; - } - - return new XAttribute(name, value); - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static XAttribute CreateNamespaceAttribute(XName name, XNamespace ns) - { - var a = new XAttribute(name, ns.NamespaceName); - a.AddAnnotation(ns); - return a; - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static object RemoveNamespaceAttributes(string[] inScopePrefixes, XNamespace[] inScopeNs, List attributes, object obj) - { - if (obj is object) - { - XElement elem = obj as XElement; - if (elem is object) - { - return RemoveNamespaceAttributes(inScopePrefixes, inScopeNs, attributes, elem); - } - else - { - IEnumerable elems = obj as IEnumerable; - if (elems is object) - { - return RemoveNamespaceAttributes(inScopePrefixes, inScopeNs, attributes, elems); - } - } - } - - return obj; - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static IEnumerable RemoveNamespaceAttributes(string[] inScopePrefixes, XNamespace[] inScopeNs, List attributes, IEnumerable obj) - { - if (obj is object) - { - IEnumerable elems = obj as IEnumerable; - if (elems is object) - { - return elems.Select(new RemoveNamespaceAttributesClosure(inScopePrefixes, inScopeNs, attributes).ProcessXElement); - } - else - { - return obj.Cast().Select(new RemoveNamespaceAttributesClosure(inScopePrefixes, inScopeNs, attributes).ProcessObject); - } - } - - return obj; - } - - [DebuggerNonUserCode()] - [System.Runtime.CompilerServices.CompilerGenerated()] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - private sealed class RemoveNamespaceAttributesClosure - { - private readonly string[] m_inScopePrefixes; - private readonly XNamespace[] m_inScopeNs; - private readonly List m_attributes; - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - internal RemoveNamespaceAttributesClosure(string[] inScopePrefixes, XNamespace[] inScopeNs, List attributes) - { - m_inScopePrefixes = inScopePrefixes; - m_inScopeNs = inScopeNs; - m_attributes = attributes; - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - internal XElement ProcessXElement(XElement elem) - { - return RemoveNamespaceAttributes(m_inScopePrefixes, m_inScopeNs, m_attributes, elem); - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - internal object ProcessObject(object obj) - { - XElement elem = obj as XElement; - if (elem is object) - { - return RemoveNamespaceAttributes(m_inScopePrefixes, m_inScopeNs, m_attributes, elem); - } - else - { - return obj; - } - } - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static XElement RemoveNamespaceAttributes(string[] inScopePrefixes, XNamespace[] inScopeNs, List attributes, XElement e) - { - if (e is object) - { - var a = e.FirstAttribute; - while (a is object) - { - var nextA = a.NextAttribute; - if (a.IsNamespaceDeclaration) - { - var ns = a.Annotation(); - string prefix = a.Name.LocalName; - if (ns is object) - { - if (inScopePrefixes is object && inScopeNs is object) - { - int lastIndex = inScopePrefixes.Length - 1; - for (int i = 0, loopTo = lastIndex; i <= loopTo; i++) - { - string currentInScopePrefix = inScopePrefixes[i]; - var currentInScopeNs = inScopeNs[i]; - if (prefix.Equals(currentInScopePrefix)) - { - if (ns == currentInScopeNs) - { - // prefix and namespace match. Remove the unneeded ns attribute - a.Remove(); - } - - // prefix is in scope but refers to something else. Leave the ns attribute. - a = null; - break; - } - } - } - - if (a is object) - { - // Prefix is not in scope - // Now check whether it's going to be in scope because it is in the attributes list - - if (attributes is object) - { - int lastIndex = attributes.Count - 1; - for (int i = 0, loopTo1 = lastIndex; i <= loopTo1; i++) - { - var currentA = attributes[i]; - string currentInScopePrefix = currentA.Name.LocalName; - var currentInScopeNs = currentA.Annotation(); - if (currentInScopeNs is object) - { - if (prefix.Equals(currentInScopePrefix)) - { - if (ns == currentInScopeNs) - { - // prefix and namespace match. Remove the unneeded ns attribute - a.Remove(); - } - - // prefix is in scope but refers to something else. Leave the ns attribute. - a = null; - break; - } - } - } - } - - if (a is object) - { - // Prefix is definitely not in scope - a.Remove(); - // namespace is not defined either. Add this attributes list - attributes.Add(a); - } - } - } - } - - a = nextA; - } - } - - return e; - } - } -} \ No newline at end of file diff --git a/Pilz.Updating.GUIBase/My Project/MyNamespace.Static.3.Designer.cs b/Pilz.Updating.GUIBase/My Project/MyNamespace.Static.3.Designer.cs deleted file mode 100644 index b2b5044..0000000 --- a/Pilz.Updating.GUIBase/My Project/MyNamespace.Static.3.Designer.cs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; - -namespace Microsoft.VisualBasic -{ - [Embedded()] - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Module | AttributeTargets.Assembly, Inherited = false)] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [System.Runtime.CompilerServices.CompilerGenerated()] - internal sealed class Embedded : Attribute - { - } -} \ No newline at end of file diff --git a/Pilz.Updating.GUIBase/My Project/Resources.resx b/Pilz.Updating.GUIBase/My Project/Resources.resx deleted file mode 100644 index af7dbeb..0000000 --- a/Pilz.Updating.GUIBase/My Project/Resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/Pilz.Updating.GUIBase/Pilz.Updating.GUIBase.csproj b/Pilz.Updating.GUIBase/Pilz.Updating.GUIBase.csproj index 0d0fab1..2df9ca2 100644 --- a/Pilz.Updating.GUIBase/Pilz.Updating.GUIBase.csproj +++ b/Pilz.Updating.GUIBase/Pilz.Updating.GUIBase.csproj @@ -1,7 +1,7 @@  Pilz.Updating.GUIBase - net6.0-windows;net8.0-windows + net8.0-windows $(DefaultItemExcludes);$(ProjectDir)**\*.vb latest Pilz.Updating.GUIBase @@ -36,7 +36,6 @@ TRACE;RelMono - True 2.0.0 @@ -56,10 +55,6 @@ - - True - Application.myapp - True True @@ -80,10 +75,6 @@ - - MyApplicationCodeGenerator - Application.Designer.cs - SettingsSingleFileGenerator Pilz.Updating.GUIBase.My diff --git a/Pilz.Updating.GUIBase/Properties/AssemblyInfo.cs b/Pilz.Updating.GUIBase/Properties/AssemblyInfo.cs index 33b5898..63aa519 100644 --- a/Pilz.Updating.GUIBase/Properties/AssemblyInfo.cs +++ b/Pilz.Updating.GUIBase/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using global::System; -using global::System.Reflection; using global::System.Runtime.CompilerServices; using global::System.Runtime.InteropServices; [assembly: ComVisible(false)] diff --git a/Pilz.Updating.UpdateInstaller.Lib/Pilz.Updating.UpdateInstaller.Lib.csproj b/Pilz.Updating.UpdateInstaller.Lib/Pilz.Updating.UpdateInstaller.Lib.csproj index 52d672b..7f77189 100644 --- a/Pilz.Updating.UpdateInstaller.Lib/Pilz.Updating.UpdateInstaller.Lib.csproj +++ b/Pilz.Updating.UpdateInstaller.Lib/Pilz.Updating.UpdateInstaller.Lib.csproj @@ -1,14 +1,12 @@  - net6.0-windows;net8.0-windows + net8.0-windows enable enable - True - True 2.0.0 diff --git a/Pilz.Updating.UpdateInstaller.Lib/UpdateInstaller.cs b/Pilz.Updating.UpdateInstaller.Lib/UpdateInstaller.cs index dc39862..731c2d3 100644 --- a/Pilz.Updating.UpdateInstaller.Lib/UpdateInstaller.cs +++ b/Pilz.Updating.UpdateInstaller.Lib/UpdateInstaller.cs @@ -1,173 +1,167 @@ -using System; +using Microsoft.VisualBasic.CompilerServices; using System.Diagnostics; -using System.IO; using System.IO.Compression; -using System.Linq; -using System.Reflection; -using System.Threading.Tasks; -using Microsoft.VisualBasic.CompilerServices; -namespace Pilz.Updating.UpdateInstaller.Lib +namespace Pilz.Updating.UpdateInstaller.Lib; + +public class UpdateInstaller { - public class UpdateInstaller + // 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; } + + // C o n s t r c u t o r s + + public UpdateInstaller(UpdateInstallerConfig config) { - // E v e n t s + Configuration = config; + } - public delegate void UpdateInstallerEventHandler(object sender, UpdateInstallerEventArgs e); - public delegate void UpdateInstallerStepEventHandler(object sender, UpdateInstallerStepEventArgs e); - public delegate void StatusChangesEventHandler(object sender, UpdateInstallerStatusChangedEventArgs e); + // F e a t u r e s - public event StatusChangesEventHandler StatusChanges; - public event UpdateInstallerStepEventHandler OnStep; + private void ChangeStep(UpdateInstallerStep step, UpdateInstallerStepState state) + { + OnStep?.Invoke(this, new UpdateInstallerStepEventArgs(this, step, state)); + } - // F i e l d s + private void ChangeStatus(UpdateInstallerStatus newStatus) + { + StatusChanges?.Invoke(this, new UpdateInstallerStatusChangedEventArgs(newStatus)); + } - private string dataPath = string.Empty; - - // P r o p e r t i e s - - public UpdateInstallerConfig Configuration { get; private set; } - - // C o n s t r c u t o r s - - public UpdateInstaller(UpdateInstallerConfig config) + public void StartHostApplication() + { + if (!string.IsNullOrEmpty(Conversions.ToString(Configuration.RestartHostApplication)) && File.Exists(Configuration.HostApplicationProcessPath)) { - Configuration = 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 = Path.Combine(packagePath, PackageFileNameDefinations.ZIP_PACKAGE_FILENAME); - dataPath = Path.Combine(packagePath, Path.GetFileNameWithoutExtension(PackageFileNameDefinations.ZIP_PACKAGE_FILENAME)); - 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(Path.Combine(dataPath, PackageFileNameDefinations.ZIP_APP_DATA_FILES_DIRECTORY)); - 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)); - try - { - sFile.CopyTo(dFile.FullName, true); - } - 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); + 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 = Path.Combine(packagePath, PackageFileNameDefinations.ZIP_PACKAGE_FILENAME); + dataPath = Path.Combine(packagePath, Path.GetFileNameWithoutExtension(PackageFileNameDefinations.ZIP_PACKAGE_FILENAME)); + 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(Path.Combine(dataPath, PackageFileNameDefinations.ZIP_APP_DATA_FILES_DIRECTORY)); + 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)); + try + { + sFile.CopyTo(dFile.FullName, true); + } + 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 index 12b4274..8282c63 100644 --- a/Pilz.Updating.UpdateInstaller.Lib/UpdateInstallerEventArgs.cs +++ b/Pilz.Updating.UpdateInstaller.Lib/UpdateInstallerEventArgs.cs @@ -1,18 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +namespace Pilz.Updating.UpdateInstaller.Lib; -namespace Pilz.Updating.UpdateInstaller.Lib +public class UpdateInstallerEventArgs : EventArgs { - public class UpdateInstallerEventArgs : EventArgs - { - public UpdateInstaller UpdateInstaller { get; init; } + public UpdateInstaller UpdateInstaller { get; init; } - public UpdateInstallerEventArgs(UpdateInstaller updateInstaller) - { - UpdateInstaller = updateInstaller; - } + public UpdateInstallerEventArgs(UpdateInstaller updateInstaller) + { + UpdateInstaller = updateInstaller; } } diff --git a/Pilz.Updating.UpdateInstaller.Lib/UpdateInstallerStatus.cs b/Pilz.Updating.UpdateInstaller.Lib/UpdateInstallerStatus.cs index 841dae2..72217ae 100644 --- a/Pilz.Updating.UpdateInstaller.Lib/UpdateInstallerStatus.cs +++ b/Pilz.Updating.UpdateInstaller.Lib/UpdateInstallerStatus.cs @@ -1,12 +1,11 @@  -namespace Pilz.Updating.UpdateInstaller.Lib +namespace Pilz.Updating.UpdateInstaller.Lib; + +public enum UpdateInstallerStatus { - public enum UpdateInstallerStatus - { - Waiting, - Extracting, - CopyingFiles, - RemovingFiles, - Done - } + 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 index 5a35bf0..b037893 100644 --- a/Pilz.Updating.UpdateInstaller.Lib/UpdateInstallerStatusChangedEventArgs.cs +++ b/Pilz.Updating.UpdateInstaller.Lib/UpdateInstallerStatusChangedEventArgs.cs @@ -1,14 +1,11 @@ -using System; +namespace Pilz.Updating.UpdateInstaller.Lib; -namespace Pilz.Updating.UpdateInstaller.Lib +public class UpdateInstallerStatusChangedEventArgs : EventArgs { - public class UpdateInstallerStatusChangedEventArgs : EventArgs - { - public UpdateInstallerStatus NewStatus { get; private set; } + public UpdateInstallerStatus NewStatus { get; private set; } - public UpdateInstallerStatusChangedEventArgs(UpdateInstallerStatus newStatus) : base() - { - NewStatus = newStatus; - } + 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 index a8daf51..8ff2659 100644 --- a/Pilz.Updating.UpdateInstaller.Lib/UpdateInstallerStep.cs +++ b/Pilz.Updating.UpdateInstaller.Lib/UpdateInstallerStep.cs @@ -1,17 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +namespace Pilz.Updating.UpdateInstaller.Lib; -namespace Pilz.Updating.UpdateInstaller.Lib +public enum UpdateInstallerStep { - public enum UpdateInstallerStep - { - Startup, - ExtractPackage, - CopyFiles, - DeletePackage, - Finish - } + Startup, + ExtractPackage, + CopyFiles, + DeletePackage, + Finish } diff --git a/Pilz.Updating.UpdateInstaller.Lib/UpdateInstallerStepEventArgs.cs b/Pilz.Updating.UpdateInstaller.Lib/UpdateInstallerStepEventArgs.cs index 079780e..ae13184 100644 --- a/Pilz.Updating.UpdateInstaller.Lib/UpdateInstallerStepEventArgs.cs +++ b/Pilz.Updating.UpdateInstaller.Lib/UpdateInstallerStepEventArgs.cs @@ -1,20 +1,13 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +namespace Pilz.Updating.UpdateInstaller.Lib; -namespace Pilz.Updating.UpdateInstaller.Lib +public class UpdateInstallerStepEventArgs : UpdateInstallerEventArgs { - public class UpdateInstallerStepEventArgs : UpdateInstallerEventArgs - { - public UpdateInstallerStep Step { get; init; } - public UpdateInstallerStepState State { get; init; } + public UpdateInstallerStep Step { get; init; } + public UpdateInstallerStepState State { get; init; } - public UpdateInstallerStepEventArgs(UpdateInstaller updateInstaller, UpdateInstallerStep step, UpdateInstallerStepState state) : base(updateInstaller) - { - Step = step; - State = state; - } + 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 index 72a299d..e5390bf 100644 --- a/Pilz.Updating.UpdateInstaller.Lib/UpdateInstallerStepState.cs +++ b/Pilz.Updating.UpdateInstaller.Lib/UpdateInstallerStepState.cs @@ -1,15 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +namespace Pilz.Updating.UpdateInstaller.Lib; -namespace Pilz.Updating.UpdateInstaller.Lib +public enum UpdateInstallerStepState { - public enum UpdateInstallerStepState - { - Default, - PreEvent, - PostEvent - } + Default, + PreEvent, + PostEvent } diff --git a/Pilz.Updating.UpdateInstaller/General.cs b/Pilz.Updating.UpdateInstaller/General.cs index 5aa9b7f..2897f90 100644 --- a/Pilz.Updating.UpdateInstaller/General.cs +++ b/Pilz.Updating.UpdateInstaller/General.cs @@ -1,36 +1,32 @@ -using System.IO; -using System.Reflection; -using Pilz.Plugins; -using System.Configuration; -using Z.Reflection.Extensions; +using Pilz.Plugins; +using System.IO; -namespace Pilz.Updating.UpdateInstaller +namespace Pilz.Updating.UpdateInstaller; + +internal static class General { - internal static class General + private static string p = null; + + public static string MyAppPath { - private static string p = null; - - public static string MyAppPath + get { - get - { - if (string.IsNullOrEmpty(p)) - p = Path.GetDirectoryName(IO.Extensions.GetExecutablePath()); - return p; - } + if (string.IsNullOrEmpty(p)) + p = Path.GetDirectoryName(IO.Extensions.GetExecutablePath()); + return p; } + } - public static void LoadAddons(Lib.UpdateInstaller installer) + public static void LoadAddons(Lib.UpdateInstaller installer) + { + var pluginsPath = Path.Combine(MyAppPath, "AddOns"); + if (Directory.Exists(pluginsPath)) { - var pluginsPath = Path.Combine(MyAppPath, "AddOns"); - if (Directory.Exists(pluginsPath)) + foreach (var subdir in Directory.GetDirectories(pluginsPath, string.Empty, SearchOption.TopDirectoryOnly)) { - 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); - } + var pluginPath = Path.Combine(subdir, Path.GetFileName(subdir) + ".dll"); + if (File.Exists(pluginPath)) + PluginManager.Instance.LoadPlugin(pluginPath, installer); } } } diff --git a/Pilz.Updating.UpdateInstaller/Main.cs b/Pilz.Updating.UpdateInstaller/Main.cs index e1e475e..3313cea 100644 --- a/Pilz.Updating.UpdateInstaller/Main.cs +++ b/Pilz.Updating.UpdateInstaller/Main.cs @@ -1,149 +1,147 @@ -using System; +using Pilz.Updating.UpdateInstaller.Lib; +using System; using System.Drawing; using System.Linq; -using System.Runtime.CompilerServices; using System.Threading.Tasks; using System.Windows.Forms; using Telerik.WinControls; using Telerik.WinControls.Themes; -using Pilz.Updating.UpdateInstaller.Lib; -namespace Pilz.Updating.UpdateInstaller +namespace Pilz.Updating.UpdateInstaller; + +public partial class Main { - public partial class Main + // C o n s t r u c t o r s + + public Main() { - // C o n s t r u c t o r s + // G u i + this.Shown += Main_Shown; + this.FormClosed += Main_FormClosed; + this.FormClosing += Main_FormClosing; - public Main() + // Get arguments + var args = Environment.GetCommandLineArgs().Skip(1).ToArray(); + if (args.Length != 0) { - // G u i - this.Shown += Main_Shown; - this.FormClosed += Main_FormClosed; - this.FormClosing += Main_FormClosing; + // Load config + installer = new Lib.UpdateInstaller(UpdateInstallerConfig.Parse(args[0])); + General.LoadAddons(installer); - // Get arguments - var args = My.MyProject.Application.CommandLineArgs.ToArray(); - if (args.Any()) - { - // Load config - installer = new Lib.UpdateInstaller(UpdateInstallerConfig.Parse(args[0])); - General.LoadAddons(installer); + // Init Form + InitializeComponent(); - // Init Form - InitializeComponent(); + // Init Style + RadThemeComponentBase themeToUse = installer.Configuration.UIDarkMode ? new FluentDarkTheme() : new FluentTheme(); + ThemeResolutionService.ApplicationThemeName = themeToUse.ThemeName; - // 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; - // 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); + radLabel_Header.Text = $"{header}"; } - // F i e l d s + if (installer is null) + Environment.Exit(0); + } - private bool allowClose = false; - private readonly Lib.UpdateInstaller installer; + // F i e l d s - // F e a t u r e s + private bool allowClose = false; + private readonly Lib.UpdateInstaller installer; - private void SetStatus(UpdateInstallerStatus newStatus) + // F e a t u r e s + + private void SetStatus(UpdateInstallerStatus newStatus) + { + string newStatusText = string.Empty; + Image newStatusImage = null; + + switch (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(); - //} + 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; } - private async Task WaitforHostApp() + switch (newStatus) { - SetStatus(UpdateInstallerStatus.Waiting); - await Task.Run(() => installer.WaitForHostApplication()); + 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; } - private async void ExecuteUpdate() - { - await Task.Run(() => installer.InstallUpdate()); - allowClose = true; - Close(); - } + radLabel_Status.Text = newStatusText; + radLabel_Status.Image = newStatusImage; - private async void Main_Shown(object sender, EventArgs e) - { - radWaitingBar1.StartWaiting(); - await WaitforHostApp(); - ExecuteUpdate(); - } + //if (newStatus == UpdateInstallerStatus.Done) + //{ + // allowClose = true; + // Close(); + //} + } - private void Main_FormClosed(object sender, FormClosedEventArgs e) - { - installer.StartHostApplication(); - } + private async Task WaitforHostApp() + { + SetStatus(UpdateInstallerStatus.Waiting); + await Task.Run(() => installer.WaitForHostApplication()); + } - private void Main_FormClosing(object sender, FormClosingEventArgs e) - { - radWaitingBar1.StopWaiting(); - e.Cancel = !allowClose; - } + private async void ExecuteUpdate() + { + await Task.Run(() => installer.InstallUpdate()); + allowClose = true; + Close(); + } - private void Installer_StatusChanges(object sender, UpdateInstallerStatusChangedEventArgs e) - { - base.Invoke(new Action(() => SetStatus(e.NewStatus))); - } + 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/My Project/Application.Designer.cs b/Pilz.Updating.UpdateInstaller/My Project/Application.Designer.cs deleted file mode 100644 index d32f0c8..0000000 --- a/Pilz.Updating.UpdateInstaller/My Project/Application.Designer.cs +++ /dev/null @@ -1,38 +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. -// -// ------------------------------------------------------------------------------ - -using System.Diagnostics; - -namespace Pilz.Updating.UpdateInstaller.My -{ - - // HINWEIS: Diese Datei wird automatisch generiert und darf nicht direkt bearbeitet werden. Wenn Sie Änderungen vornehmen möchten - // oder in dieser Datei Buildfehler auftreten, wechseln Sie zum Projekt-Designer. - // (Wechseln Sie dazu zu den Projekteigenschaften, oder doppelklicken Sie auf den Knoten "Mein Projekt" im - // Projektmappen-Explorer). Nehmen Sie auf der Registerkarte "Anwendung" entsprechende Änderungen vor. - // - internal partial class MyApplication - { - [DebuggerStepThrough()] - public MyApplication() : base(Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows) - { - IsSingleInstance = false; - EnableVisualStyles = true; - SaveMySettingsOnExit = true; - ShutdownStyle = Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterAllFormsClose; - } - - [DebuggerStepThrough()] - protected override void OnCreateMainForm() - { - MainForm = MyProject.Forms.Main; - } - } -} \ No newline at end of file diff --git a/Pilz.Updating.UpdateInstaller/My Project/Application.myapp b/Pilz.Updating.UpdateInstaller/My Project/Application.myapp deleted file mode 100644 index e72aaaf..0000000 --- a/Pilz.Updating.UpdateInstaller/My Project/Application.myapp +++ /dev/null @@ -1,10 +0,0 @@ - - - true - Main - false - 1 - true - 0 - true - \ No newline at end of file diff --git a/Pilz.Updating.UpdateInstaller/My Project/MyNamespace.Dynamic.Designer.cs b/Pilz.Updating.UpdateInstaller/My Project/MyNamespace.Dynamic.Designer.cs deleted file mode 100644 index a5689cb..0000000 --- a/Pilz.Updating.UpdateInstaller/My Project/MyNamespace.Dynamic.Designer.cs +++ /dev/null @@ -1,35 +0,0 @@ -using global::System; -using global::System.ComponentModel; -using global::System.Diagnostics; - -namespace Pilz.Updating.UpdateInstaller.My -{ - internal static partial class MyProject - { - internal partial class MyForms - { - [EditorBrowsable(EditorBrowsableState.Never)] - public Main m_Main; - - public Main Main - { - [DebuggerHidden] - get - { - m_Main = MyForms.Create__Instance__(m_Main); - return m_Main; - } - - [DebuggerHidden] - set - { - if (value == m_Main) - return; - if (value is object) - throw new ArgumentException("Property can only be set to Nothing"); - Dispose__Instance__(ref m_Main); - } - } - } - } -} \ No newline at end of file diff --git a/Pilz.Updating.UpdateInstaller/My Project/MyNamespace.Static.1.Designer.cs b/Pilz.Updating.UpdateInstaller/My Project/MyNamespace.Static.1.Designer.cs deleted file mode 100644 index 6876b4d..0000000 --- a/Pilz.Updating.UpdateInstaller/My Project/MyNamespace.Static.1.Designer.cs +++ /dev/null @@ -1,305 +0,0 @@ -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Collections; -using System.Diagnostics; -using System.Windows.Forms; -using Microsoft.VisualBasic; - -/* TODO ERROR: Skipped IfDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia */ - /* TODO ERROR: Skipped IfDirectiveTrivia */ - /* TODO ERROR: Skipped DefineDirectiveTrivia *//* TODO ERROR: Skipped DefineDirectiveTrivia *//* TODO ERROR: Skipped DefineDirectiveTrivia *//* TODO ERROR: Skipped DefineDirectiveTrivia *//* TODO ERROR: Skipped DefineDirectiveTrivia */ - /* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia */ - /* TODO ERROR: Skipped IfDirectiveTrivia */ -namespace Pilz.Updating.UpdateInstaller.My -{ - - /* TODO ERROR: Skipped IfDirectiveTrivia */ - [System.CodeDom.Compiler.GeneratedCode("MyTemplate", "11.0.0.0")] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - - /* TODO ERROR: Skipped IfDirectiveTrivia */ - internal partial class MyApplication : Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase - { - /* TODO ERROR: Skipped IfDirectiveTrivia */ - [STAThread()] - [DebuggerHidden()] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)] - internal static void Main(string[] Args) - { - try - { - Application.SetCompatibleTextRenderingDefault(UseCompatibleTextRendering); - } - finally - { - } - - MyProject.Application.Run(Args); - } - /* TODO ERROR: Skipped EndIfDirectiveTrivia */ - /* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia */ - } - - /* TODO ERROR: Skipped EndIfDirectiveTrivia */ - /* TODO ERROR: Skipped IfDirectiveTrivia */ - [System.CodeDom.Compiler.GeneratedCode("MyTemplate", "11.0.0.0")] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - - /* TODO ERROR: Skipped IfDirectiveTrivia */ - internal partial class MyComputer : Microsoft.VisualBasic.Devices.Computer - { - /* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia */ - [DebuggerHidden()] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public MyComputer() : base() - { - } - } - /* TODO ERROR: Skipped EndIfDirectiveTrivia */ - [HideModuleName()] - [System.CodeDom.Compiler.GeneratedCode("MyTemplate", "11.0.0.0")] - internal static partial class MyProject - { - - /* TODO ERROR: Skipped IfDirectiveTrivia */ - [System.ComponentModel.Design.HelpKeyword("My.Computer")] - internal static MyComputer Computer - { - [DebuggerHidden()] - get - { - return m_ComputerObjectProvider.GetInstance; - } - } - - private readonly static ThreadSafeObjectProvider m_ComputerObjectProvider = new ThreadSafeObjectProvider(); - /* TODO ERROR: Skipped EndIfDirectiveTrivia */ - /* TODO ERROR: Skipped IfDirectiveTrivia */ - [System.ComponentModel.Design.HelpKeyword("My.Application")] - internal static MyApplication Application - { - [DebuggerHidden()] - get - { - return m_AppObjectProvider.GetInstance; - } - } - - private readonly static ThreadSafeObjectProvider m_AppObjectProvider = new ThreadSafeObjectProvider(); - /* TODO ERROR: Skipped EndIfDirectiveTrivia */ - /* TODO ERROR: Skipped IfDirectiveTrivia */ - [System.ComponentModel.Design.HelpKeyword("My.User")] - internal static Microsoft.VisualBasic.ApplicationServices.User User - { - [DebuggerHidden()] - get - { - return m_UserObjectProvider.GetInstance; - } - } - - private readonly static ThreadSafeObjectProvider m_UserObjectProvider = new ThreadSafeObjectProvider(); - /* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia */ - /* TODO ERROR: Skipped IfDirectiveTrivia */ - /* TODO ERROR: Skipped DefineDirectiveTrivia */ - [System.ComponentModel.Design.HelpKeyword("My.Forms")] - internal static MyForms Forms - { - [DebuggerHidden()] - get - { - return m_MyFormsObjectProvider.GetInstance; - } - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [MyGroupCollection("System.Windows.Forms.Form", "Create__Instance__", "Dispose__Instance__", "My.MyProject.Forms")] - internal sealed partial class MyForms - { - [DebuggerHidden()] - private static T Create__Instance__(T Instance) where T : Form, new() - { - if (Instance is null || Instance.IsDisposed) - { - if (m_FormBeingCreated is object) - { - if (m_FormBeingCreated.ContainsKey(typeof(T)) == true) - { - throw new InvalidOperationException(Microsoft.VisualBasic.CompilerServices.Utils.GetResourceString("WinForms_RecursiveFormCreate")); - } - } - else - { - m_FormBeingCreated = new Hashtable(); - } - - m_FormBeingCreated.Add(typeof(T), null); - try - { - return new T(); - } - catch (System.Reflection.TargetInvocationException ex) when (ex.InnerException is object) - { - string BetterMessage = Microsoft.VisualBasic.CompilerServices.Utils.GetResourceString("WinForms_SeeInnerException", ex.InnerException.Message); - throw new InvalidOperationException(BetterMessage, ex.InnerException); - } - finally - { - m_FormBeingCreated.Remove(typeof(T)); - } - } - else - { - return Instance; - } - } - - [DebuggerHidden()] - private void Dispose__Instance__(ref T instance) where T : Form - { - instance.Dispose(); - instance = null; - } - - [DebuggerHidden()] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public MyForms() : base() - { - } - - [ThreadStatic()] - private static Hashtable m_FormBeingCreated; - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public override bool Equals(object o) - { - return base.Equals(o); - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public override int GetHashCode() - { - return base.GetHashCode(); - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - internal new Type GetType() - { - return typeof(MyForms); - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public override string ToString() - { - return base.ToString(); - } - } - - private static ThreadSafeObjectProvider m_MyFormsObjectProvider = new ThreadSafeObjectProvider(); - - /* TODO ERROR: Skipped EndIfDirectiveTrivia */ - /* TODO ERROR: Skipped IfDirectiveTrivia */ - [System.ComponentModel.Design.HelpKeyword("My.WebServices")] - internal static MyWebServices WebServices - { - [DebuggerHidden()] - get - { - return m_MyWebServicesObjectProvider.GetInstance; - } - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [MyGroupCollection("System.Web.Services.Protocols.SoapHttpClientProtocol", "Create__Instance__", "Dispose__Instance__", "")] - internal sealed class MyWebServices - { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [DebuggerHidden()] - public override bool Equals(object o) - { - return base.Equals(o); - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [DebuggerHidden()] - public override int GetHashCode() - { - return base.GetHashCode(); - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [DebuggerHidden()] - internal new Type GetType() - { - return typeof(MyWebServices); - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [DebuggerHidden()] - public override string ToString() - { - return base.ToString(); - } - - [DebuggerHidden()] - private static T Create__Instance__(T instance) where T : new() - { - if (instance == null) - { - return new T(); - } - else - { - return instance; - } - } - - [DebuggerHidden()] - private void Dispose__Instance__(ref T instance) - { - instance = default; - } - - [DebuggerHidden()] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public MyWebServices() : base() - { - } - } - - private readonly static ThreadSafeObjectProvider m_MyWebServicesObjectProvider = new ThreadSafeObjectProvider(); - /* TODO ERROR: Skipped EndIfDirectiveTrivia */ - /* TODO ERROR: Skipped IfDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia */ - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [System.Runtime.InteropServices.ComVisible(false)] - internal sealed class ThreadSafeObjectProvider where T : new() - { - internal T GetInstance - { - /* TODO ERROR: Skipped IfDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped ElseDirectiveTrivia */ - [DebuggerHidden()] - get - { - if (m_ThreadStaticValue == null) - m_ThreadStaticValue = new T(); - return m_ThreadStaticValue; - } - /* TODO ERROR: Skipped EndIfDirectiveTrivia */ - } - - [DebuggerHidden()] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public ThreadSafeObjectProvider() : base() - { - } - - /* TODO ERROR: Skipped IfDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped ElseDirectiveTrivia */ - [System.Runtime.CompilerServices.CompilerGenerated()] - [ThreadStatic()] - private static T m_ThreadStaticValue; - /* TODO ERROR: Skipped EndIfDirectiveTrivia */ - } - } -} -/* TODO ERROR: Skipped EndIfDirectiveTrivia */ diff --git a/Pilz.Updating.UpdateInstaller/My Project/MyNamespace.Static.2.Designer.cs b/Pilz.Updating.UpdateInstaller/My Project/MyNamespace.Static.2.Designer.cs deleted file mode 100644 index 85a6e3a..0000000 --- a/Pilz.Updating.UpdateInstaller/My Project/MyNamespace.Static.2.Designer.cs +++ /dev/null @@ -1,253 +0,0 @@ -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -// See Compiler::LoadXmlSolutionExtension -using System.Collections; -using System.Collections.Generic; -using System.Data; -using System.Diagnostics; -using System.Linq; -using System.Xml.Linq; -using Microsoft.VisualBasic; -using Microsoft.VisualBasic.CompilerServices; - -namespace Pilz.Updating.UpdateInstaller.My -{ - [Embedded()] - [DebuggerNonUserCode()] - [System.Runtime.CompilerServices.CompilerGenerated()] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - internal sealed class InternalXmlHelper - { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - private InternalXmlHelper() - { - } - - public static string get_Value(IEnumerable source) - { - foreach (XElement item in source) - return item.Value; - return null; - } - - public static void set_Value(IEnumerable source, string value) - { - foreach (XElement item in source) - { - item.Value = value; - break; - } - } - - public static string get_AttributeValue(IEnumerable source, XName name) - { - foreach (XElement item in source) - return Conversions.ToString(item.Attribute(name)); - return null; - } - - public static void set_AttributeValue(IEnumerable source, XName name, string value) - { - foreach (XElement item in source) - { - item.SetAttributeValue(name, value); - break; - } - } - - public static string get_AttributeValue(XElement source, XName name) - { - return Conversions.ToString(source.Attribute(name)); - } - - public static void set_AttributeValue(XElement source, XName name, string value) - { - source.SetAttributeValue(name, value); - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static XAttribute CreateAttribute(XName name, object value) - { - if (value is null) - { - return null; - } - - return new XAttribute(name, value); - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static XAttribute CreateNamespaceAttribute(XName name, XNamespace ns) - { - var a = new XAttribute(name, ns.NamespaceName); - a.AddAnnotation(ns); - return a; - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static object RemoveNamespaceAttributes(string[] inScopePrefixes, XNamespace[] inScopeNs, List attributes, object obj) - { - if (obj is object) - { - XElement elem = obj as XElement; - if (elem is object) - { - return RemoveNamespaceAttributes(inScopePrefixes, inScopeNs, attributes, elem); - } - else - { - IEnumerable elems = obj as IEnumerable; - if (elems is object) - { - return RemoveNamespaceAttributes(inScopePrefixes, inScopeNs, attributes, elems); - } - } - } - - return obj; - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static IEnumerable RemoveNamespaceAttributes(string[] inScopePrefixes, XNamespace[] inScopeNs, List attributes, IEnumerable obj) - { - if (obj is object) - { - IEnumerable elems = obj as IEnumerable; - if (elems is object) - { - return elems.Select(new RemoveNamespaceAttributesClosure(inScopePrefixes, inScopeNs, attributes).ProcessXElement); - } - else - { - return obj.Cast().Select(new RemoveNamespaceAttributesClosure(inScopePrefixes, inScopeNs, attributes).ProcessObject); - } - } - - return obj; - } - - [DebuggerNonUserCode()] - [System.Runtime.CompilerServices.CompilerGenerated()] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - private sealed class RemoveNamespaceAttributesClosure - { - private readonly string[] m_inScopePrefixes; - private readonly XNamespace[] m_inScopeNs; - private readonly List m_attributes; - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - internal RemoveNamespaceAttributesClosure(string[] inScopePrefixes, XNamespace[] inScopeNs, List attributes) - { - m_inScopePrefixes = inScopePrefixes; - m_inScopeNs = inScopeNs; - m_attributes = attributes; - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - internal XElement ProcessXElement(XElement elem) - { - return RemoveNamespaceAttributes(m_inScopePrefixes, m_inScopeNs, m_attributes, elem); - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - internal object ProcessObject(object obj) - { - XElement elem = obj as XElement; - if (elem is object) - { - return RemoveNamespaceAttributes(m_inScopePrefixes, m_inScopeNs, m_attributes, elem); - } - else - { - return obj; - } - } - } - - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static XElement RemoveNamespaceAttributes(string[] inScopePrefixes, XNamespace[] inScopeNs, List attributes, XElement e) - { - if (e is object) - { - var a = e.FirstAttribute; - while (a is object) - { - var nextA = a.NextAttribute; - if (a.IsNamespaceDeclaration) - { - var ns = a.Annotation(); - string prefix = a.Name.LocalName; - if (ns is object) - { - if (inScopePrefixes is object && inScopeNs is object) - { - int lastIndex = inScopePrefixes.Length - 1; - for (int i = 0, loopTo = lastIndex; i <= loopTo; i++) - { - string currentInScopePrefix = inScopePrefixes[i]; - var currentInScopeNs = inScopeNs[i]; - if (prefix.Equals(currentInScopePrefix)) - { - if (ns == currentInScopeNs) - { - // prefix and namespace match. Remove the unneeded ns attribute - a.Remove(); - } - - // prefix is in scope but refers to something else. Leave the ns attribute. - a = null; - break; - } - } - } - - if (a is object) - { - // Prefix is not in scope - // Now check whether it's going to be in scope because it is in the attributes list - - if (attributes is object) - { - int lastIndex = attributes.Count - 1; - for (int i = 0, loopTo1 = lastIndex; i <= loopTo1; i++) - { - var currentA = attributes[i]; - string currentInScopePrefix = currentA.Name.LocalName; - var currentInScopeNs = currentA.Annotation(); - if (currentInScopeNs is object) - { - if (prefix.Equals(currentInScopePrefix)) - { - if (ns == currentInScopeNs) - { - // prefix and namespace match. Remove the unneeded ns attribute - a.Remove(); - } - - // prefix is in scope but refers to something else. Leave the ns attribute. - a = null; - break; - } - } - } - } - - if (a is object) - { - // Prefix is definitely not in scope - a.Remove(); - // namespace is not defined either. Add this attributes list - attributes.Add(a); - } - } - } - } - - a = nextA; - } - } - - return e; - } - } -} \ No newline at end of file diff --git a/Pilz.Updating.UpdateInstaller/My Project/MyNamespace.Static.3.Designer.cs b/Pilz.Updating.UpdateInstaller/My Project/MyNamespace.Static.3.Designer.cs deleted file mode 100644 index b2b5044..0000000 --- a/Pilz.Updating.UpdateInstaller/My Project/MyNamespace.Static.3.Designer.cs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; - -namespace Microsoft.VisualBasic -{ - [Embedded()] - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Module | AttributeTargets.Assembly, Inherited = false)] - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - [System.Runtime.CompilerServices.CompilerGenerated()] - internal sealed class Embedded : Attribute - { - } -} \ No newline at end of file diff --git a/Pilz.Updating.UpdateInstaller/My Project/Resources.resx b/Pilz.Updating.UpdateInstaller/My Project/Resources.resx deleted file mode 100644 index 1af7de1..0000000 --- a/Pilz.Updating.UpdateInstaller/My Project/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/MyIcons.Designer.cs b/Pilz.Updating.UpdateInstaller/MyIcons.Designer.cs index ea5063b..45a47f4 100644 --- a/Pilz.Updating.UpdateInstaller/MyIcons.Designer.cs +++ b/Pilz.Updating.UpdateInstaller/MyIcons.Designer.cs @@ -19,7 +19,7 @@ namespace Pilz.Updating.UpdateInstaller { // -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", "16.0.0.0")] + [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 { diff --git a/Pilz.Updating.UpdateInstaller/Pilz.Updating.UpdateInstaller.csproj b/Pilz.Updating.UpdateInstaller/Pilz.Updating.UpdateInstaller.csproj index 76e524c..cdef7be 100644 --- a/Pilz.Updating.UpdateInstaller/Pilz.Updating.UpdateInstaller.csproj +++ b/Pilz.Updating.UpdateInstaller/Pilz.Updating.UpdateInstaller.csproj @@ -1,60 +1,27 @@  WinExe - Pilz.Updating.UpdateInstaller.My.MyApplication - Pilz.Updating.UpdateInstaller WindowsForms - net8.0-windows + net8.0-windows true $(DefaultItemExcludes);$(ProjectDir)**\*.vb latest Pilz.Updating.UpdateInstaller Pilzinsel64 Pilz.Updating.UpdateInstaller - Copyright © Pilzinsel64 2019 - 2020 Pilz.Updating.UpdateInstaller.xml true 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022,CS1591 true true - - true - - - false - - - On - - - Binary - - - Off - - - On - - - icons8_software_installer.ico - - - true - MinimumRecommendedRules.ruleset - true - TRACE;RelMono - - + - - 2023.1.117 - @@ -76,10 +43,6 @@ Main.cs Form - - True - Application.myapp - True True @@ -132,10 +95,6 @@ - - MyApplicationCodeGenerator - Application.Designer.cs - SettingsSingleFileGenerator Pilz.Updating.UpdateInstaller.My @@ -152,11 +111,8 @@ + + - - - - - \ No newline at end of file diff --git a/Pilz.Updating.UpdateInstaller/Program.cs b/Pilz.Updating.UpdateInstaller/Program.cs new file mode 100644 index 0000000..8b153b2 --- /dev/null +++ b/Pilz.Updating.UpdateInstaller/Program.cs @@ -0,0 +1,14 @@ +using System.Windows.Forms; + +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 index 967b6d4..5778bea 100644 --- a/Pilz.Updating.UpdateInstaller/Properties/AssemblyInfo.cs +++ b/Pilz.Updating.UpdateInstaller/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using global::System; -using global::System.Reflection; using global::System.Runtime.InteropServices; [assembly: ComVisible(false)] diff --git a/Pilz.Updating.UpdateInstaller/Properties/Resources.Designer.cs b/Pilz.Updating.UpdateInstaller/Properties/Resources.Designer.cs index ce482c9..edb29c2 100644 --- a/Pilz.Updating.UpdateInstaller/Properties/Resources.Designer.cs +++ b/Pilz.Updating.UpdateInstaller/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace Pilz.Updating.UpdateInstaller.My.Resources { // -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", "16.0.0.0")] + [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 { diff --git a/Pilz.Updating.UpdateInstaller/UpdateInstallerGuiLangRes.Designer.cs b/Pilz.Updating.UpdateInstaller/UpdateInstallerGuiLangRes.Designer.cs index 1720a79..97ccb12 100644 --- a/Pilz.Updating.UpdateInstaller/UpdateInstallerGuiLangRes.Designer.cs +++ b/Pilz.Updating.UpdateInstaller/UpdateInstallerGuiLangRes.Designer.cs @@ -19,7 +19,7 @@ namespace Pilz.Updating.UpdateInstaller.My.Resources { // -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", "16.0.0.0")] + [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 { diff --git a/Pilz.Updating/ApplicationVersion.cs b/Pilz.Updating/ApplicationVersion.cs index b92be32..5d07f7a 100644 --- a/Pilz.Updating/ApplicationVersion.cs +++ b/Pilz.Updating/ApplicationVersion.cs @@ -1,73 +1,72 @@ using Newtonsoft.Json; using System; -namespace Pilz.Updating +namespace Pilz.Updating; + +public class ApplicationVersion { - public class ApplicationVersion + + // P r o p e r t i e s + + [JsonConverter(typeof(Newtonsoft.Json.Converters.VersionConverter))] + public Version Version { get; set; } + public int Build { get; set; } + [JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + public Channels Channel { get; set; } + + // C o n s t r u c t o r s + + public ApplicationVersion() : this(new Version("1.0.0.0")) { + } - // P r o p e r t i e s + public ApplicationVersion(Version version) : this(version, 1, Channels.Stable) + { + } - [JsonConverter(typeof(Newtonsoft.Json.Converters.VersionConverter))] - public Version Version { get; set; } - public int Build { get; set; } - [JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] - public Channels Channel { get; set; } + public ApplicationVersion(Version version, int build, Channels channel) + { + Version = version; + Build = build; + Channel = channel; + } - // C o n s t r u c t o r s + // F e a t u r e s - public ApplicationVersion() : this(new Version("1.0.0.0")) - { - } + public override string ToString() + { + return $"{Version.ToString()} {Channel.ToString()} {Build}"; + } - public ApplicationVersion(Version version) : this(version, 1, Channels.Stable) - { - } + // O p e r a t o r s - public ApplicationVersion(Version version, int build, Channels channel) - { - Version = version; - Build = build; - Channel = channel; - } + 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)); + } - // F e a t u r e 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 override string ToString() - { - return $"{Version.ToString()} {Channel.ToString()} {Build}"; - } + public static bool operator ==(ApplicationVersion a, ApplicationVersion b) + { + return a.Version == b.Version && a.Channel == b.Channel && a.Build == b.Build; + } - // O p e r a t o r s + 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.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 == b || a > b; + } - 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; - } + public static bool operator <=(ApplicationVersion a, ApplicationVersion b) + { + return a == b || a < b; } } \ No newline at end of file diff --git a/Pilz.Updating/Channels.cs b/Pilz.Updating/Channels.cs index fb2d76f..6ca3a09 100644 --- a/Pilz.Updating/Channels.cs +++ b/Pilz.Updating/Channels.cs @@ -1,11 +1,10 @@  -namespace Pilz.Updating +namespace Pilz.Updating; + +public enum Channels { - public enum Channels - { - Stable, - PreRelease, - Beta, - Alpha - } + Stable, + PreRelease, + Beta, + Alpha } \ No newline at end of file diff --git a/Pilz.Updating/MyPaths.cs b/Pilz.Updating/MyPaths.cs index bd91ab6..86b7ca2 100644 --- a/Pilz.Updating/MyPaths.cs +++ b/Pilz.Updating/MyPaths.cs @@ -1,24 +1,23 @@ -using System; -using global::System.IO; +using global::System.IO; +using System; -namespace Pilz.Updating +namespace Pilz.Updating; + +internal static class MyPaths { - internal static class MyPaths + private static string p = string.Empty; + + public static string GetMyAppDataPath() { - private static string p = string.Empty; - - public static string GetMyAppDataPath() + if (string.IsNullOrEmpty(p)) { - if (string.IsNullOrEmpty(p)) + p = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "PilzUpdater"); + if (!Directory.Exists(p)) { - p = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "PilzUpdater"); - if (!Directory.Exists(p)) - { - Directory.CreateDirectory(p); - } + Directory.CreateDirectory(p); } - - return p; } + + return p; } } \ No newline at end of file diff --git a/Pilz.Updating/Pilz.Updating.csproj b/Pilz.Updating/Pilz.Updating.csproj index ae79de3..2ea4a2a 100644 --- a/Pilz.Updating/Pilz.Updating.csproj +++ b/Pilz.Updating/Pilz.Updating.csproj @@ -1,7 +1,7 @@  Pilz.Updating - net6.0-windows;net8.0-windows + net8.0-windows $(DefaultItemExcludes);$(ProjectDir)**\*.vb latest Pilz.Updating @@ -11,7 +11,6 @@ Pilz.Updating.xml true 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022,CS1591,CS0660,CS0661 - true true @@ -37,7 +36,6 @@ TRACE;RelMono - True 2.0.0 diff --git a/Pilz.Updating/Properties/AssemblyInfo.cs b/Pilz.Updating/Properties/AssemblyInfo.cs index 3b808a0..2ae65cf 100644 --- a/Pilz.Updating/Properties/AssemblyInfo.cs +++ b/Pilz.Updating/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using global::System; -using global::System.Reflection; using global::System.Runtime.CompilerServices; using global::System.Runtime.InteropServices; [assembly: ComVisible(false)] diff --git a/Pilz.Updating/UpdateInfo.cs b/Pilz.Updating/UpdateInfo.cs index 2a2da3b..ceeef41 100644 --- a/Pilz.Updating/UpdateInfo.cs +++ b/Pilz.Updating/UpdateInfo.cs @@ -1,21 +1,20 @@ -using System.Collections.Generic; -using global::Newtonsoft.Json.Linq; +using global::Newtonsoft.Json.Linq; +using System.Collections.Generic; -namespace Pilz.Updating +namespace Pilz.Updating; + +public class UpdateInfo { - public class UpdateInfo + public string UpdateInstallerLink { get; set; } + public List Packages { get; set; } = []; + + public static UpdateInfo Parse(string str) { - public string UpdateInstallerLink { get; set; } - public List Packages { get; set; } = new List(); + return JObject.Parse(str).ToObject(); + } - public static UpdateInfo Parse(string str) - { - return JObject.Parse(str).ToObject(); - } - - public override string ToString() - { - return JObject.FromObject(this).ToString(); - } + public override string ToString() + { + return JObject.FromObject(this).ToString(); } } \ No newline at end of file diff --git a/Pilz.Updating/UpdateInstaller/UpdateInstallerConfig.cs b/Pilz.Updating/UpdateInstaller/UpdateInstallerConfig.cs index e450d59..7725f54 100644 --- a/Pilz.Updating/UpdateInstaller/UpdateInstallerConfig.cs +++ b/Pilz.Updating/UpdateInstaller/UpdateInstallerConfig.cs @@ -1,31 +1,29 @@ -using System; -using global::System.Drawing; -using global::Newtonsoft.Json.Linq; +using global::Newtonsoft.Json.Linq; +using System; -namespace Pilz.Updating.UpdateInstaller +namespace Pilz.Updating.UpdateInstaller; + +public class UpdateInstallerConfig { - 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) { - 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; } + return JObject.Parse(System.Text.Encoding.Default.GetString(Convert.FromBase64String(str))).ToObject(); + } - public static UpdateInstallerConfig Parse(string str) - { - return JObject.Parse(System.Text.Encoding.Default.GetString(Convert.FromBase64String(str))).ToObject(); - } - - public override string ToString() - { - return Convert.ToBase64String(System.Text.Encoding.Default.GetBytes(JObject.FromObject(this).ToString())); - } + public override string ToString() + { + return Convert.ToBase64String(System.Text.Encoding.Default.GetBytes(JObject.FromObject(this).ToString())); } } \ No newline at end of file diff --git a/Pilz.Updating/UpdateNotes.cs b/Pilz.Updating/UpdateNotes.cs index e8fd1da..9211d59 100644 --- a/Pilz.Updating/UpdateNotes.cs +++ b/Pilz.Updating/UpdateNotes.cs @@ -1,16 +1,10 @@ using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace Pilz.Updating +namespace Pilz.Updating; + +public class UpdateNotes { - public class UpdateNotes - { - public string Content { get; set; } - [JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] - public UpdateNotesContentType ContentType { get; set; } = UpdateNotesContentType.PlainText; - } + public string Content { get; set; } + [JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + public UpdateNotesContentType ContentType { get; set; } = UpdateNotesContentType.PlainText; } diff --git a/Pilz.Updating/UpdateNotesContentType.cs b/Pilz.Updating/UpdateNotesContentType.cs index 281efa6..9ac1156 100644 --- a/Pilz.Updating/UpdateNotesContentType.cs +++ b/Pilz.Updating/UpdateNotesContentType.cs @@ -1,15 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +namespace Pilz.Updating; -namespace Pilz.Updating +public enum UpdateNotesContentType { - public enum UpdateNotesContentType - { - PlainText, - Markdown, - HTML - } + PlainText, + Markdown, + HTML } diff --git a/Pilz.Updating/UpdatePackageInfo.cs b/Pilz.Updating/UpdatePackageInfo.cs index f84c75f..98f4dbf 100644 --- a/Pilz.Updating/UpdatePackageInfo.cs +++ b/Pilz.Updating/UpdatePackageInfo.cs @@ -1,23 +1,22 @@  using Newtonsoft.Json; -namespace Pilz.Updating -{ - public class UpdatePackageInfo - { - public string Name { get; set; } - public ApplicationVersion Version { get; set; } - public UpdateNotes Notes { get; } = new UpdateNotes(); - public string Packagelink { get; set; } +namespace Pilz.Updating; - [JsonProperty] - private string Changelog +public class UpdatePackageInfo +{ + public string Name { get; set; } + public ApplicationVersion Version { get; set; } + public UpdateNotes Notes { get; } = new UpdateNotes(); + public string Packagelink { get; set; } + + [JsonProperty] + private string Changelog + { + set { - set - { - Notes.Content = value; - Notes.ContentType = UpdateNotesContentType.PlainText; - } + Notes.Content = value; + Notes.ContentType = UpdateNotesContentType.PlainText; } } } \ No newline at end of file diff --git a/Pilz.Updating_Report.htm b/Pilz.Updating_Report.htm deleted file mode 100644 index c602fb7..0000000 --- a/Pilz.Updating_Report.htm +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - - Telerik UI for WinForms Upgrade Wizard Log - - - - -
- - - - - - - - - - - - - - - -
- -
- Processed: 0 - Succeeded: 0 - Info: 0 - Warnings: 0 - Failed: 0 -
-
 ProjectTitleDetailsResult
-
- -