Added button to reset config (in SettingsForm)

This commit is contained in:
n00mkrad 2021-07-15 18:50:20 +02:00
parent 8e05f3aa2a
commit 12be4f6215
8 changed files with 128 additions and 56 deletions

View File

@ -500,6 +500,7 @@
</ItemGroup>
<ItemGroup>
<Content Include="FlowframesLogo2021.ico" />
<None Include="Resources\baseline_restart_alt_white_48dp.png" />
<None Include="Resources\baseline_format_size_white_48dp.png" />
<None Include="Resources\baseline_wrap_text_white_48dp.png" />
<None Include="Resources\baseline_refresh_white_48dp.png" />

View File

@ -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;
}
}

View File

@ -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);
}
}
}

View File

@ -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);
}
}

View File

@ -180,6 +180,16 @@ namespace Flowframes.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
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));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>

View File

@ -118,12 +118,12 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="baseline_format_size_white_48dp" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\baseline_format_size_white_48dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="baseline_image_white_48dp-4x" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\baseline_image_white_48dp-4x.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="baseline_list_alt_white_48dp" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\baseline_list_alt_white_48dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="baseline_queue_white_48dp" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\baseline_queue_white_48dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
@ -136,11 +136,17 @@
<data name="paypal256px" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\paypal256px.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="baseline_system_update_alt_white_48dp" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\baseline_system_update_alt_white_48dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="flowframesIcoNew_512px" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\flowframesIcoNew-512px.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="baseline_system_update_alt_white_48dp" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\baseline_system_update_alt_white_48dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<data name="baseline_pause_white_48dp" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\baseline_pause_white_48dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="baseline_create_white_18dp-semiTransparent" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\baseline_create_white_18dp-semiTransparent.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="questmark-72px-bordeer" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\questmark-72px-bordeer.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
@ -166,17 +172,14 @@
<data name="devmode" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\devmode.bat;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
<data name="baseline_wrap_text_white_48dp" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\baseline_wrap_text_white_48dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="baseline_pause_white_48dp" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\baseline_pause_white_48dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<data name="baseline_list_alt_white_48dp" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\baseline_list_alt_white_48dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="baseline_image_white_48dp" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\baseline_image_white_48dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="baseline_create_white_18dp-semiTransparent" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\baseline_create_white_18dp-semiTransparent.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<data name="baseline_wrap_text_white_48dp" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\baseline_wrap_text_white_48dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="baseline_refresh_white_48dp" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\baseline_refresh_white_48dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
@ -193,7 +196,7 @@
<data name="baseline_image_white_48dp-4x-25pcAlpha" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\baseline_image_white_48dp-4x-25pcAlpha.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="baseline_format_size_white_48dp" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\baseline_format_size_white_48dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<data name="baseline_restart_alt_white_48dp" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\baseline_restart_alt_white_48dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB