From 12be4f62157f914aa5dd2957849333b3f716f771 Mon Sep 17 00:00:00 2001 From: n00mkrad Date: Thu, 15 Jul 2021 18:50:20 +0200 Subject: [PATCH] Added button to reset config (in SettingsForm) --- Code/Flowframes.csproj | 1 + Code/Forms/SettingsForm.Designer.cs | 101 +++++++++++------- Code/Forms/SettingsForm.cs | 11 ++ Code/IO/Config.cs | 30 +++++- Code/Properties/Resources.Designer.cs | 10 ++ Code/Properties/Resources.resx | 31 +++--- .../baseline_restart_alt_white_48dp.png | Bin 0 -> 1040 bytes Media/baseline_restart_alt_white_48dp.png | Bin 0 -> 1040 bytes 8 files changed, 128 insertions(+), 56 deletions(-) create mode 100644 Code/Resources/baseline_restart_alt_white_48dp.png create mode 100644 Media/baseline_restart_alt_white_48dp.png diff --git a/Code/Flowframes.csproj b/Code/Flowframes.csproj index 0a590b5..c5a67d3 100644 --- a/Code/Flowframes.csproj +++ b/Code/Flowframes.csproj @@ -500,6 +500,7 @@ + diff --git a/Code/Forms/SettingsForm.Designer.cs b/Code/Forms/SettingsForm.Designer.cs index 37ee37a..e02612b 100644 --- a/Code/Forms/SettingsForm.Designer.cs +++ b/Code/Forms/SettingsForm.Designer.cs @@ -59,6 +59,10 @@ this.delLogsOnStartup = new System.Windows.Forms.CheckBox(); this.label11 = new System.Windows.Forms.Label(); this.tabListPage2 = new Cyotek.Windows.Forms.TabListPage(); + this.autoEncBlockPanel = new System.Windows.Forms.Panel(); + this.label70 = new System.Windows.Forms.Label(); + this.alwaysWaitForAutoEnc = new System.Windows.Forms.CheckBox(); + this.label58 = new System.Windows.Forms.Label(); this.pictureBox2 = new System.Windows.Forms.PictureBox(); this.label41 = new System.Windows.Forms.Label(); this.autoEncBackupMode = new System.Windows.Forms.ComboBox(); @@ -181,10 +185,7 @@ this.cmdDebugMode = new System.Windows.Forms.ComboBox(); this.titleLabel = new System.Windows.Forms.Label(); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); - this.alwaysWaitForAutoEnc = new System.Windows.Forms.CheckBox(); - this.label58 = new System.Windows.Forms.Label(); - this.label70 = new System.Windows.Forms.Label(); - this.autoEncBlockPanel = new System.Windows.Forms.Panel(); + this.resetBtn = new HTAlt.WinForms.HTButton(); this.settingsTabList.SuspendLayout(); this.generalTab.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.info1)).BeginInit(); @@ -597,6 +598,44 @@ this.tabListPage2.Size = new System.Drawing.Size(762, 419); this.tabListPage2.Text = "Interpolation"; // + // autoEncBlockPanel + // + this.autoEncBlockPanel.Location = new System.Drawing.Point(4, 330); + this.autoEncBlockPanel.Name = "autoEncBlockPanel"; + this.autoEncBlockPanel.Size = new System.Drawing.Size(755, 86); + this.autoEncBlockPanel.TabIndex = 94; + // + // label70 + // + this.label70.AutoSize = true; + this.label70.ForeColor = System.Drawing.Color.Silver; + this.label70.Location = new System.Drawing.Point(308, 390); + this.label70.Margin = new System.Windows.Forms.Padding(10, 10, 10, 7); + this.label70.Name = "label70"; + this.label70.Size = new System.Drawing.Size(443, 13); + this.label70.TabIndex = 93; + this.label70.Text = "Avoids filling up your hard drive by temporarily pausing interpolation if encodin" + + "g can\'t keep up"; + // + // alwaysWaitForAutoEnc + // + this.alwaysWaitForAutoEnc.AutoSize = true; + this.alwaysWaitForAutoEnc.Location = new System.Drawing.Point(280, 390); + this.alwaysWaitForAutoEnc.Name = "alwaysWaitForAutoEnc"; + this.alwaysWaitForAutoEnc.Size = new System.Drawing.Size(15, 14); + this.alwaysWaitForAutoEnc.TabIndex = 92; + this.alwaysWaitForAutoEnc.UseVisualStyleBackColor = true; + // + // label58 + // + this.label58.AutoSize = true; + this.label58.Location = new System.Drawing.Point(10, 390); + this.label58.Margin = new System.Windows.Forms.Padding(10, 10, 10, 7); + this.label58.Name = "label58"; + this.label58.Size = new System.Drawing.Size(229, 13); + this.label58.TabIndex = 91; + this.label58.Text = "Low Disk Space Mode (Wait For Auto-Encode)"; + // // pictureBox2 // this.pictureBox2.BackgroundImage = global::Flowframes.Properties.Resources.questmark_72px_bordeer; @@ -2134,43 +2173,23 @@ this.titleLabel.TabIndex = 1; this.titleLabel.Text = "Settings"; // - // alwaysWaitForAutoEnc + // resetBtn // - this.alwaysWaitForAutoEnc.AutoSize = true; - this.alwaysWaitForAutoEnc.Location = new System.Drawing.Point(280, 390); - this.alwaysWaitForAutoEnc.Name = "alwaysWaitForAutoEnc"; - this.alwaysWaitForAutoEnc.Size = new System.Drawing.Size(15, 14); - this.alwaysWaitForAutoEnc.TabIndex = 92; - this.alwaysWaitForAutoEnc.UseVisualStyleBackColor = true; - // - // label58 - // - this.label58.AutoSize = true; - this.label58.Location = new System.Drawing.Point(10, 390); - this.label58.Margin = new System.Windows.Forms.Padding(10, 10, 10, 7); - this.label58.Name = "label58"; - this.label58.Size = new System.Drawing.Size(229, 13); - this.label58.TabIndex = 91; - this.label58.Text = "Low Disk Space Mode (Wait For Auto-Encode)"; - // - // label70 - // - this.label70.AutoSize = true; - this.label70.ForeColor = System.Drawing.Color.Silver; - this.label70.Location = new System.Drawing.Point(308, 390); - this.label70.Margin = new System.Windows.Forms.Padding(10, 10, 10, 7); - this.label70.Name = "label70"; - this.label70.Size = new System.Drawing.Size(443, 13); - this.label70.TabIndex = 93; - this.label70.Text = "Avoids filling up your hard drive by temporarily pausing interpolation if encodin" + - "g can\'t keep up"; - // - // autoEncBlockPanel - // - this.autoEncBlockPanel.Location = new System.Drawing.Point(4, 330); - this.autoEncBlockPanel.Name = "autoEncBlockPanel"; - this.autoEncBlockPanel.Size = new System.Drawing.Size(755, 86); - this.autoEncBlockPanel.TabIndex = 94; + this.resetBtn.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48))))); + this.resetBtn.ButtonImage = global::Flowframes.Properties.Resources.baseline_restart_alt_white_48dp; + this.resetBtn.DrawImage = true; + this.resetBtn.FlatAppearance.BorderSize = 0; + this.resetBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.resetBtn.ForeColor = System.Drawing.Color.White; + this.resetBtn.ImageIndex = 0; + this.resetBtn.ImageSizeMode = HTAlt.WinForms.HTButton.ButtonImageSizeMode.Zoom; + this.resetBtn.Location = new System.Drawing.Point(889, 12); + this.resetBtn.Name = "resetBtn"; + this.resetBtn.Size = new System.Drawing.Size(40, 40); + this.resetBtn.TabIndex = 39; + this.toolTip1.SetToolTip(this.resetBtn, "Reset To Default"); + this.resetBtn.UseVisualStyleBackColor = false; + this.resetBtn.Click += new System.EventHandler(this.resetBtn_Click); // // SettingsForm // @@ -2178,6 +2197,7 @@ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(32)))), ((int)(((byte)(32)))), ((int)(((byte)(32))))); this.ClientSize = new System.Drawing.Size(944, 501); + this.Controls.Add(this.resetBtn); this.Controls.Add(this.titleLabel); this.Controls.Add(this.settingsTabList); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow; @@ -2374,5 +2394,6 @@ private System.Windows.Forms.CheckBox alwaysWaitForAutoEnc; private System.Windows.Forms.Label label58; private System.Windows.Forms.Panel autoEncBlockPanel; + private HTAlt.WinForms.HTButton resetBtn; } } \ No newline at end of file diff --git a/Code/Forms/SettingsForm.cs b/Code/Forms/SettingsForm.cs index 2c0e28d..166a8ad 100644 --- a/Code/Forms/SettingsForm.cs +++ b/Code/Forms/SettingsForm.cs @@ -248,5 +248,16 @@ namespace Flowframes.Forms { autoEncBlockPanel.Visible = autoEncMode.SelectedIndex == 0; } + + private async void resetBtn_Click(object sender, EventArgs e) + { + DialogResult dialog = MessageBox.Show($"Are you sure you want to reset the configuration?", "Are you sure?", MessageBoxButtons.YesNo); + + if (dialog == DialogResult.No) + return; + + await Config.Reset(3, this); + SettingsForm_Load(null, null); + } } } diff --git a/Code/IO/Config.cs b/Code/IO/Config.cs index 88bbd27..357ff95 100644 --- a/Code/IO/Config.cs +++ b/Code/IO/Config.cs @@ -1,8 +1,10 @@ -using Newtonsoft.Json; +using Flowframes.Forms; +using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Globalization; using System.IO; +using System.Threading.Tasks; namespace Flowframes.IO { @@ -18,6 +20,30 @@ namespace Flowframes.IO Reload(); } + public static async Task Reset(int retries = 3, SettingsForm settingsForm = null) + { + try + { + if (settingsForm != null) + settingsForm.Enabled = false; + + File.Delete(configPath); + await Task.Delay(100); + cachedValues.Clear(); + await Task.Delay(100); + + if (settingsForm != null) + settingsForm.Enabled = true; + } + catch(Exception e) + { + retries -= 1; + Logger.Log($"Failed to reset config: {e.Message}. Retrying ({retries} attempts left)."); + await Task.Delay(500); + await Reset(retries, settingsForm); + } + } + public static void Set(Key key, string value) { Set(key.ToString(), value); @@ -63,7 +89,7 @@ namespace Flowframes.IO } catch (Exception e) { - Logger.Log($"Failed to reload config! {e.Message}"); + Logger.Log($"Failed to reload config! {e.Message}", true); } } diff --git a/Code/Properties/Resources.Designer.cs b/Code/Properties/Resources.Designer.cs index 904daae..c5dab41 100644 --- a/Code/Properties/Resources.Designer.cs +++ b/Code/Properties/Resources.Designer.cs @@ -180,6 +180,16 @@ namespace Flowframes.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap baseline_restart_alt_white_48dp { + get { + object obj = ResourceManager.GetObject("baseline_restart_alt_white_48dp", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/Code/Properties/Resources.resx b/Code/Properties/Resources.resx index bb6b2e4..8fd0bc1 100644 --- a/Code/Properties/Resources.resx +++ b/Code/Properties/Resources.resx @@ -118,12 +118,12 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + ..\Resources\baseline_format_size_white_48dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\baseline_image_white_48dp-4x.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\baseline_list_alt_white_48dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Resources\baseline_queue_white_48dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -136,11 +136,17 @@ ..\Resources\paypal256px.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\baseline_system_update_alt_white_48dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\flowframesIcoNew-512px.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\baseline_system_update_alt_white_48dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\baseline_pause_white_48dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\baseline_create_white_18dp-semiTransparent.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\questmark-72px-bordeer.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -166,17 +172,14 @@ ..\Resources\devmode.bat;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 - - ..\Resources\baseline_wrap_text_white_48dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\baseline_pause_white_48dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\baseline_list_alt_white_48dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\baseline_image_white_48dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\baseline_create_white_18dp-semiTransparent.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\baseline_wrap_text_white_48dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\baseline_refresh_white_48dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -193,7 +196,7 @@ ..\Resources\baseline_image_white_48dp-4x-25pcAlpha.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\baseline_format_size_white_48dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\baseline_restart_alt_white_48dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a \ No newline at end of file diff --git a/Code/Resources/baseline_restart_alt_white_48dp.png b/Code/Resources/baseline_restart_alt_white_48dp.png new file mode 100644 index 0000000000000000000000000000000000000000..b7d32fc8ed18a81ec7d8b90dab3142a44119313c GIT binary patch literal 1040 zcmV+r1n>KaP)9LMp`-{}+Rp5=oqqKk+-d$5J!shbjZFll&6u#+b@RHB3W6LAQ-Q3HcuAceRd zPbN}PCk0O{kR%bb5-*$EdT_%IYVy1j74!T1|DR{m|L^Cs2mY^@3WY+UP>2Voc7_AB zFC34kUEz34?Fq+IYDYMpQTxI19JL!9hT01bkJ<^26txc=8PqOtWKw&;(bxnx`IT=u zz&5(I7~xpBD-6-A#RSKTyUJe5S`2W!tQv=?sMT=fF~d$0wHA(iF0odvg(IIi`qWxD z@){;lE8)l_@g_aIPd`D-(_kGT6WgYBcf#%M=$&r~*!zaHJ@O73^V> zY-1#fiO+e$DH9HlGSSI#9*|{N@zBTroHF4s)DY{rL6(mc2Wy$*c}|&dJV#B?#W~XE zSgY_zxP;Fs6OL!p6djC`c8Nrxv6HluY5>Pmnir#_eWI{f$uz$6bf_U5k7-_Xa1P%z z6@`Su_b0EbDIAYz0qEiezC#L!PHI^H(yMvlKnucp9$?idD-`zN8`gs0v_K5u+ow?Y z9cz-Z0;7`&tg8xx_4xKG0`}m0TOlxnRbz!BUlfw4Usyeg zh#st)%8MDSRf>pJSTo9tdsrn!L<#Gj^5Q;LNfA-Py05&bVO10n6|9=_;ucnqBBBTD zmhxg8Ym*{k6V|x$VhpQa5z&t|ro1?eRaHb(u?{OQwqi|?C=wDTu(m2Mx~XGrR3vP~ zs?)9fxP~>NNEpGorVu!WHA|-=pp#jwV+w&@d;^Mr0erm*gX>t+loc3drm?Oo6#DUf zp};tfuV0~1W)`c?W(CAMJj9x%tZ+Dj?>28J5LWUBz9R~WGE?||VwnPKDJO%p-?Ck3WY);nEwDS;o1Af%azXn0000< KMNUMnLSTYf!PwdW literal 0 HcmV?d00001 diff --git a/Media/baseline_restart_alt_white_48dp.png b/Media/baseline_restart_alt_white_48dp.png new file mode 100644 index 0000000000000000000000000000000000000000..b7d32fc8ed18a81ec7d8b90dab3142a44119313c GIT binary patch literal 1040 zcmV+r1n>KaP)9LMp`-{}+Rp5=oqqKk+-d$5J!shbjZFll&6u#+b@RHB3W6LAQ-Q3HcuAceRd zPbN}PCk0O{kR%bb5-*$EdT_%IYVy1j74!T1|DR{m|L^Cs2mY^@3WY+UP>2Voc7_AB zFC34kUEz34?Fq+IYDYMpQTxI19JL!9hT01bkJ<^26txc=8PqOtWKw&;(bxnx`IT=u zz&5(I7~xpBD-6-A#RSKTyUJe5S`2W!tQv=?sMT=fF~d$0wHA(iF0odvg(IIi`qWxD z@){;lE8)l_@g_aIPd`D-(_kGT6WgYBcf#%M=$&r~*!zaHJ@O73^V> zY-1#fiO+e$DH9HlGSSI#9*|{N@zBTroHF4s)DY{rL6(mc2Wy$*c}|&dJV#B?#W~XE zSgY_zxP;Fs6OL!p6djC`c8Nrxv6HluY5>Pmnir#_eWI{f$uz$6bf_U5k7-_Xa1P%z z6@`Su_b0EbDIAYz0qEiezC#L!PHI^H(yMvlKnucp9$?idD-`zN8`gs0v_K5u+ow?Y z9cz-Z0;7`&tg8xx_4xKG0`}m0TOlxnRbz!BUlfw4Usyeg zh#st)%8MDSRf>pJSTo9tdsrn!L<#Gj^5Q;LNfA-Py05&bVO10n6|9=_;ucnqBBBTD zmhxg8Ym*{k6V|x$VhpQa5z&t|ro1?eRaHb(u?{OQwqi|?C=wDTu(m2Mx~XGrR3vP~ zs?)9fxP~>NNEpGorVu!WHA|-=pp#jwV+w&@d;^Mr0erm*gX>t+loc3drm?Oo6#DUf zp};tfuV0~1W)`c?W(CAMJj9x%tZ+Dj?>28J5LWUBz9R~WGE?||VwnPKDJO%p-?Ck3WY);nEwDS;o1Af%azXn0000< KMNUMnLSTYf!PwdW literal 0 HcmV?d00001