diff --git a/Pilz.Updating.Administration.GUI/DiscordBotSettingsWindow.Designer.cs b/Pilz.Updating.Administration.GUI/DiscordBotSettingsWindow.Designer.cs index 95fc106..f186fc7 100644 --- a/Pilz.Updating.Administration.GUI/DiscordBotSettingsWindow.Designer.cs +++ b/Pilz.Updating.Administration.GUI/DiscordBotSettingsWindow.Designer.cs @@ -30,6 +30,9 @@ namespace Pilz.Updating.Administration.GUI { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DiscordBotSettingsWindow)); this.panel1 = new System.Windows.Forms.Panel(); + this.radSeparator1 = new Telerik.WinControls.UI.RadSeparator(); + this.radLabel5 = new Telerik.WinControls.UI.RadLabel(); + this.radDropDownList_PresetChannel = new Telerik.WinControls.UI.RadDropDownList(); this.radTextBox_DefaultMessage = new Telerik.WinControls.UI.RadTextBox(); this.radLabel4 = new Telerik.WinControls.UI.RadLabel(); this.radTextBoxControl_BotToken = new Telerik.WinControls.UI.RadTextBoxControl(); @@ -41,6 +44,9 @@ namespace Pilz.Updating.Administration.GUI this.radButton_Okay = new Telerik.WinControls.UI.RadButton(); this.radLabel1 = new Telerik.WinControls.UI.RadLabel(); this.panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.radSeparator1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.radLabel5)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.radDropDownList_PresetChannel)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.radTextBox_DefaultMessage)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.radLabel4)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.radTextBoxControl_BotToken)).BeginInit(); @@ -57,6 +63,9 @@ namespace Pilz.Updating.Administration.GUI // panel1 // this.panel1.BackColor = System.Drawing.Color.Transparent; + this.panel1.Controls.Add(this.radSeparator1); + this.panel1.Controls.Add(this.radLabel5); + this.panel1.Controls.Add(this.radDropDownList_PresetChannel); this.panel1.Controls.Add(this.radTextBox_DefaultMessage); this.panel1.Controls.Add(this.radLabel4); this.panel1.Controls.Add(this.radTextBoxControl_BotToken); @@ -73,25 +82,50 @@ namespace Pilz.Updating.Administration.GUI this.panel1.Size = new System.Drawing.Size(736, 471); this.panel1.TabIndex = 0; // + // radSeparator1 + // + this.radSeparator1.Location = new System.Drawing.Point(3, 86); + this.radSeparator1.Name = "radSeparator1"; + this.radSeparator1.Size = new System.Drawing.Size(730, 4); + this.radSeparator1.TabIndex = 8; + // + // radLabel5 + // + this.radLabel5.Location = new System.Drawing.Point(3, 97); + this.radLabel5.Name = "radLabel5"; + this.radLabel5.Size = new System.Drawing.Size(86, 19); + this.radLabel5.TabIndex = 7; + this.radLabel5.Text = "Kanal-Vorlage:"; + // + // radDropDownList_PresetChannel + // + this.radDropDownList_PresetChannel.DropDownAnimationEnabled = true; + this.radDropDownList_PresetChannel.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDownList; + this.radDropDownList_PresetChannel.Location = new System.Drawing.Point(127, 96); + this.radDropDownList_PresetChannel.Name = "radDropDownList_PresetChannel"; + this.radDropDownList_PresetChannel.Size = new System.Drawing.Size(144, 22); + this.radDropDownList_PresetChannel.TabIndex = 1; + this.radDropDownList_PresetChannel.SelectedValueChanged += new System.EventHandler(this.radDropDownList_PresetChannel_SelectedValueChanged); + // // radTextBox_DefaultMessage // this.radTextBox_DefaultMessage.AcceptsReturn = true; this.radTextBox_DefaultMessage.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.radTextBox_DefaultMessage.Location = new System.Drawing.Point(127, 89); + this.radTextBox_DefaultMessage.Location = new System.Drawing.Point(127, 124); this.radTextBox_DefaultMessage.Multiline = true; this.radTextBox_DefaultMessage.Name = "radTextBox_DefaultMessage"; // // // this.radTextBox_DefaultMessage.RootElement.StretchVertically = true; - this.radTextBox_DefaultMessage.Size = new System.Drawing.Size(606, 349); + this.radTextBox_DefaultMessage.Size = new System.Drawing.Size(606, 314); this.radTextBox_DefaultMessage.TabIndex = 6; // // radLabel4 // - this.radLabel4.Location = new System.Drawing.Point(3, 89); + this.radLabel4.Location = new System.Drawing.Point(3, 126); this.radLabel4.Name = "radLabel4"; this.radLabel4.Size = new System.Drawing.Size(113, 19); this.radLabel4.TabIndex = 3; @@ -108,7 +142,7 @@ namespace Pilz.Updating.Administration.GUI // // radLabel3 // - this.radLabel3.Location = new System.Drawing.Point(3, 61); + this.radLabel3.Location = new System.Drawing.Point(3, 60); this.radLabel3.Name = "radLabel3"; this.radLabel3.Size = new System.Drawing.Size(124, 19); this.radLabel3.TabIndex = 2; @@ -118,7 +152,7 @@ namespace Pilz.Updating.Administration.GUI // this.radTextBoxControl_DefaultProgramName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.radTextBoxControl_DefaultProgramName.Location = new System.Drawing.Point(127, 59); + this.radTextBoxControl_DefaultProgramName.Location = new System.Drawing.Point(127, 58); this.radTextBoxControl_DefaultProgramName.Name = "radTextBoxControl_DefaultProgramName"; this.radTextBoxControl_DefaultProgramName.Size = new System.Drawing.Size(606, 22); this.radTextBoxControl_DefaultProgramName.TabIndex = 4; @@ -165,6 +199,7 @@ namespace Pilz.Updating.Administration.GUI this.radButton_Okay.Text = "Okay"; this.radButton_Okay.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft; this.radButton_Okay.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; + this.radButton_Okay.Click += new System.EventHandler(this.ButtonX_Okay_Click); // // radLabel1 // @@ -185,6 +220,9 @@ namespace Pilz.Updating.Administration.GUI this.Text = "Discord Bot-Einstellungen"; this.panel1.ResumeLayout(false); this.panel1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.radSeparator1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.radLabel5)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.radDropDownList_PresetChannel)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.radTextBox_DefaultMessage)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.radLabel4)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.radTextBoxControl_BotToken)).EndInit(); @@ -213,5 +251,8 @@ namespace Pilz.Updating.Administration.GUI private Telerik.WinControls.UI.RadButton radButton_Okay; private Telerik.WinControls.UI.RadLabel radLabel1; private Telerik.WinControls.UI.RadTextBox radTextBox_DefaultMessage; + private Telerik.WinControls.UI.RadDropDownList radDropDownList_PresetChannel; + private Telerik.WinControls.UI.RadSeparator radSeparator1; + private Telerik.WinControls.UI.RadLabel radLabel5; } } \ No newline at end of file diff --git a/Pilz.Updating.Administration.GUI/DiscordBotSettingsWindow.cs b/Pilz.Updating.Administration.GUI/DiscordBotSettingsWindow.cs index c021d8c..8810724 100644 --- a/Pilz.Updating.Administration.GUI/DiscordBotSettingsWindow.cs +++ b/Pilz.Updating.Administration.GUI/DiscordBotSettingsWindow.cs @@ -13,6 +13,8 @@ namespace Pilz.Updating.Administration.GUI public partial class DiscordBotSettingsWindow : RadForm { private readonly DiscordBotConfig config = null; + private Channels currentChannel = Channels.Stable; + private readonly bool hasInit = false; public DiscordBotSettingsWindow(DiscordBotConfig config) { @@ -20,18 +22,49 @@ namespace Pilz.Updating.Administration.GUI InitializeComponent(); + 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; - radTextBox_DefaultMessage.Text = config.DefaultUpdateMessage; + ShowDefaultMessage(); radToggleSwitch_UseProxy.Value = config.UseProxy; + + hasInit = true; + } + + private Channels GetCurrentChannel() + { + return radDropDownList_PresetChannel?.SelectedValue as Channels? ?? Channels.Stable; + } + + private void ShowDefaultMessage() + { + radTextBox_DefaultMessage.Text = config.DefaultUpdateMessages[currentChannel]; + } + + private void SaveDefaultMessage() + { + config.DefaultUpdateMessages[currentChannel] = radTextBox_DefaultMessage.Text.Trim(); } private void ButtonX_Okay_Click(object sender, EventArgs e) { - config.DefaultUpdateMessage = radTextBoxControl_BotToken.Text.Trim(); + SaveDefaultMessage(); config.DefaultAppName = radTextBoxControl_DefaultProgramName.Text.Trim(); - config.DiscordBotToken = radTextBox_DefaultMessage.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; + + ShowDefaultMessage(); + } } } \ No newline at end of file diff --git a/Pilz.Updating.Administration.GUI/DiscordPostDialog.cs b/Pilz.Updating.Administration.GUI/DiscordPostDialog.cs index b837418..33a367c 100644 --- a/Pilz.Updating.Administration.GUI/DiscordPostDialog.cs +++ b/Pilz.Updating.Administration.GUI/DiscordPostDialog.cs @@ -30,7 +30,7 @@ namespace Pilz.Updating.Administration.GUI InitializeComponent(); radTextBoxControl_ProgramName.Text = General.CurProject.DiscordBotConfig.DefaultAppName; - radTextBox_Message.Text = General.CurProject.DiscordBotConfig.DefaultUpdateMessage; + radTextBox_Message.Text = General.CurProject.DiscordBotConfig.DefaultUpdateMessages[package.Version.Channel]; LoadBgrTree(); } diff --git a/Pilz.Updating.Administration/Discord/DiscordBotConfig.cs b/Pilz.Updating.Administration/Discord/DiscordBotConfig.cs index 3c8b569..f24c5e4 100644 --- a/Pilz.Updating.Administration/Discord/DiscordBotConfig.cs +++ b/Pilz.Updating.Administration/Discord/DiscordBotConfig.cs @@ -1,4 +1,5 @@ -using System; +using Newtonsoft.Json; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -9,9 +10,25 @@ namespace Pilz.Updating.Administration.Discord public class DiscordBotConfig { public string DiscordBotToken { get; set; } = string.Empty; - public string DefaultUpdateMessage { 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 } + }; + + [JsonProperty, Obsolete] + private string DefaultUpdateMessage + { + set + { + foreach (var keys in DefaultUpdateMessages.Keys) + DefaultUpdateMessages[keys] = value; + } + } } }