Fix saving settings after cancel

This commit is contained in:
Vladimir
2024-05-26 22:33:32 +04:00
parent 34c6a66b0c
commit f28fc0126a
2 changed files with 20 additions and 9 deletions

View File

@@ -103,37 +103,29 @@
// //
// textDwhAvatarUrl // textDwhAvatarUrl
// //
this.textDwhAvatarUrl.DataBindings.Add(new System.Windows.Forms.Binding("Text", global::RelaunchProcess.Properties.Settings.Default, "dwhAvatarURL", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
this.textDwhAvatarUrl.Location = new System.Drawing.Point(9, 64); this.textDwhAvatarUrl.Location = new System.Drawing.Point(9, 64);
this.textDwhAvatarUrl.Name = "textDwhAvatarUrl"; this.textDwhAvatarUrl.Name = "textDwhAvatarUrl";
this.textDwhAvatarUrl.Size = new System.Drawing.Size(337, 20); this.textDwhAvatarUrl.Size = new System.Drawing.Size(337, 20);
this.textDwhAvatarUrl.TabIndex = 7; this.textDwhAvatarUrl.TabIndex = 7;
this.textDwhAvatarUrl.Text = global::RelaunchProcess.Properties.Settings.Default.dwhAvatarURL;
// //
// textDwhBotName // textDwhBotName
// //
this.textDwhBotName.DataBindings.Add(new System.Windows.Forms.Binding("Text", global::RelaunchProcess.Properties.Settings.Default, "dwhBotname", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
this.textDwhBotName.Location = new System.Drawing.Point(9, 25); this.textDwhBotName.Location = new System.Drawing.Point(9, 25);
this.textDwhBotName.MaxLength = 40; this.textDwhBotName.MaxLength = 40;
this.textDwhBotName.Name = "textDwhBotName"; this.textDwhBotName.Name = "textDwhBotName";
this.textDwhBotName.Size = new System.Drawing.Size(211, 20); this.textDwhBotName.Size = new System.Drawing.Size(211, 20);
this.textDwhBotName.TabIndex = 7; this.textDwhBotName.TabIndex = 7;
this.textDwhBotName.Text = global::RelaunchProcess.Properties.Settings.Default.dwhBotname;
// //
// textDwhURL // textDwhURL
// //
this.textDwhURL.DataBindings.Add(new System.Windows.Forms.Binding("Text", global::RelaunchProcess.Properties.Settings.Default, "dwhURL", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
this.textDwhURL.Location = new System.Drawing.Point(9, 103); this.textDwhURL.Location = new System.Drawing.Point(9, 103);
this.textDwhURL.Name = "textDwhURL"; this.textDwhURL.Name = "textDwhURL";
this.textDwhURL.Size = new System.Drawing.Size(337, 20); this.textDwhURL.Size = new System.Drawing.Size(337, 20);
this.textDwhURL.TabIndex = 3; this.textDwhURL.TabIndex = 3;
this.textDwhURL.Text = global::RelaunchProcess.Properties.Settings.Default.dwhURL;
// //
// chbxDiscordEnabled // chbxDiscordEnabled
// //
this.chbxDiscordEnabled.AutoSize = true; this.chbxDiscordEnabled.AutoSize = true;
this.chbxDiscordEnabled.Checked = global::RelaunchProcess.Properties.Settings.Default.dwhEnabled;
this.chbxDiscordEnabled.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::RelaunchProcess.Properties.Settings.Default, "dwhEnabled", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
this.chbxDiscordEnabled.Location = new System.Drawing.Point(9, 129); this.chbxDiscordEnabled.Location = new System.Drawing.Point(9, 129);
this.chbxDiscordEnabled.Name = "chbxDiscordEnabled"; this.chbxDiscordEnabled.Name = "chbxDiscordEnabled";
this.chbxDiscordEnabled.Size = new System.Drawing.Size(232, 17); this.chbxDiscordEnabled.Size = new System.Drawing.Size(232, 17);

View File

@@ -4,6 +4,7 @@ using System.ComponentModel;
using System.Data; using System.Data;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.Drawing.Printing;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@@ -17,6 +18,24 @@ namespace RelaunchProcess
public DiscordSettings() public DiscordSettings()
{ {
InitializeComponent(); InitializeComponent();
RestoreSettings();
}
private void RestoreSettings()
{
textDwhBotName.Text = Settings.Default.dwhBotname;
textDwhAvatarUrl.Text = Settings.Default.dwhAvatarURL;
textDwhURL.Text = Settings.Default.dwhURL;
chbxDiscordEnabled.Checked = Settings.Default.dwhEnabled;
}
private void SaveSettings()
{
Settings.Default.dwhBotname = textDwhBotName.Text;
Settings.Default.dwhAvatarURL = textDwhAvatarUrl.Text;
Settings.Default.dwhURL = textDwhURL.Text;
Settings.Default.dwhEnabled = chbxDiscordEnabled.Checked;
Settings.Default.Save();
} }
private void BtnCancel_Click(object sender, EventArgs e) private void BtnCancel_Click(object sender, EventArgs e)
@@ -35,7 +54,7 @@ namespace RelaunchProcess
{ {
chbxDiscordEnabled.Checked = false; chbxDiscordEnabled.Checked = false;
} }
Settings.Default.Save(); SaveSettings();
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
Close(); Close();
} }