diff --git a/ShareX.HelpersLib/ShareXResources.cs b/ShareX.HelpersLib/ShareXResources.cs
index a3b1e1a1b..8742ae665 100644
--- a/ShareX.HelpersLib/ShareXResources.cs
+++ b/ShareX.HelpersLib/ShareXResources.cs
@@ -41,7 +41,19 @@ public static string UserAgent
}
}
- public static bool UseDarkTheme { get; set; }
+ private static bool useDarkTheme;
+
+ public static bool UseDarkTheme
+ {
+ get
+ {
+ return useDarkTheme && Theme != null;
+ }
+ set
+ {
+ useDarkTheme = value;
+ }
+ }
private static bool experimentalDarkTheme;
diff --git a/ShareX/Forms/ApplicationSettingsForm.Designer.cs b/ShareX/Forms/ApplicationSettingsForm.Designer.cs
index 084b09000..ba5fdc299 100644
--- a/ShareX/Forms/ApplicationSettingsForm.Designer.cs
+++ b/ShareX/Forms/ApplicationSettingsForm.Designer.cs
@@ -149,6 +149,8 @@ private void InitializeComponent()
this.tpAdvanced = new System.Windows.Forms.TabPage();
this.pgSettings = new System.Windows.Forms.PropertyGrid();
this.tttvMain = new ShareX.HelpersLib.TabToTreeView();
+ this.btnThemeAdd = new System.Windows.Forms.Button();
+ this.btnThemeRemove = new System.Windows.Forms.Button();
this.tcSettings.SuspendLayout();
this.tpGeneral.SuspendLayout();
this.tpTheme.SuspendLayout();
@@ -348,6 +350,8 @@ private void InitializeComponent()
//
// tpTheme
//
+ this.tpTheme.Controls.Add(this.btnThemeRemove);
+ this.tpTheme.Controls.Add(this.btnThemeAdd);
this.tpTheme.Controls.Add(this.cbThemes);
this.tpTheme.Controls.Add(this.cbExperimentalDarkTheme);
this.tpTheme.Controls.Add(this.btnApplyTheme);
@@ -363,6 +367,7 @@ private void InitializeComponent()
this.cbThemes.FormattingEnabled = true;
resources.ApplyResources(this.cbThemes, "cbThemes");
this.cbThemes.Name = "cbThemes";
+ this.cbThemes.SelectedIndexChanged += new System.EventHandler(this.CbThemes_SelectedIndexChanged);
//
// cbExperimentalDarkTheme
//
@@ -1095,6 +1100,20 @@ private void InitializeComponent()
this.tttvMain.TreeViewSize = 175;
this.tttvMain.TabChanged += new ShareX.HelpersLib.TabToTreeView.TabChangedEventHandler(this.tttvMain_TabChanged);
//
+ // btnThemeAdd
+ //
+ resources.ApplyResources(this.btnThemeAdd, "btnThemeAdd");
+ this.btnThemeAdd.Name = "btnThemeAdd";
+ this.btnThemeAdd.UseVisualStyleBackColor = true;
+ this.btnThemeAdd.Click += new System.EventHandler(this.BtnThemeAdd_Click);
+ //
+ // btnThemeRemove
+ //
+ resources.ApplyResources(this.btnThemeRemove, "btnThemeRemove");
+ this.btnThemeRemove.Name = "btnThemeRemove";
+ this.btnThemeRemove.UseVisualStyleBackColor = true;
+ this.btnThemeRemove.Click += new System.EventHandler(this.BtnThemeRemove_Click);
+ //
// ApplicationSettingsForm
//
resources.ApplyResources(this, "$this");
@@ -1274,5 +1293,7 @@ private void InitializeComponent()
private System.Windows.Forms.Button btnApplyTheme;
private System.Windows.Forms.PropertyGrid pgTheme;
private System.Windows.Forms.ComboBox cbThemes;
+ private System.Windows.Forms.Button btnThemeRemove;
+ private System.Windows.Forms.Button btnThemeAdd;
}
}
\ No newline at end of file
diff --git a/ShareX/Forms/ApplicationSettingsForm.cs b/ShareX/Forms/ApplicationSettingsForm.cs
index 440839470..12b8915b8 100644
--- a/ShareX/Forms/ApplicationSettingsForm.cs
+++ b/ShareX/Forms/ApplicationSettingsForm.cs
@@ -123,6 +123,7 @@ private void UpdateControls()
cbThemes.Items.AddRange(Program.Settings.Themes.ToArray());
cbThemes.SelectedIndex = Program.Settings.SelectedTheme;
pgTheme.SelectedObject = Program.Settings.Themes[Program.Settings.SelectedTheme];
+ UpdateThemeControls();
// Integration
#if WindowsStore
@@ -440,10 +441,73 @@ private void btnCheckDevBuild_Click(object sender, EventArgs e)
#region Theme
+ private void UpdateThemeControls()
+ {
+ cbThemes.Enabled = btnThemeRemove.Enabled = btnApplyTheme.Enabled = cbThemes.Items.Count > 0;
+ }
+
+ private void CbThemes_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ Program.Settings.SelectedTheme = cbThemes.SelectedIndex;
+
+ if (cbThemes.SelectedItem != null)
+ {
+ pgTheme.SelectedObject = cbThemes.SelectedItem.Copy();
+ }
+ else
+ {
+ pgTheme.SelectedObject = null;
+ }
+
+ UpdateThemeControls();
+ }
+
+ private void BtnThemeAdd_Click(object sender, EventArgs e)
+ {
+ ShareXTheme theme = new ShareXTheme();
+ theme.ApplyDarkColors();
+ Program.Settings.Themes.Add(theme);
+ cbThemes.Items.Add(theme);
+ int index = Program.Settings.Themes.Count - 1;
+ Program.Settings.SelectedTheme = index;
+ cbThemes.SelectedIndex = index;
+ UpdateThemeControls();
+ }
+
+ private void BtnThemeRemove_Click(object sender, EventArgs e)
+ {
+ int index = cbThemes.SelectedIndex;
+ if (index > -1)
+ {
+ Program.Settings.Themes.RemoveAt(index);
+ cbThemes.Items.RemoveAt(index);
+ if (Program.Settings.Themes.Count > 0)
+ {
+ index = 0;
+ }
+ else
+ {
+ index = -1;
+ }
+ Program.Settings.SelectedTheme = index;
+ cbThemes.SelectedIndex = index;
+ pgTheme.SelectedObject = cbThemes.SelectedItem;
+ UpdateThemeControls();
+ }
+ }
+
private void BtnApplyTheme_Click(object sender, EventArgs e)
{
- ShareXResources.ApplyTheme(this);
- Program.MainForm.UpdateTheme();
+ int index = cbThemes.SelectedIndex;
+ if (index > -1)
+ {
+ Program.Settings.SelectedTheme = index;
+ Program.Settings.Themes[index] = (ShareXTheme)pgTheme.SelectedObject;
+ cbThemes.Items[index] = Program.Settings.Themes[index];
+ UpdateThemeControls();
+ ShareXResources.ApplyTheme(this);
+ Program.MainForm.UpdateTheme();
+ }
}
#endregion
diff --git a/ShareX/Forms/ApplicationSettingsForm.resx b/ShareX/Forms/ApplicationSettingsForm.resx
index d7cb6be13..90ca60172 100644
--- a/ShareX/Forms/ApplicationSettingsForm.resx
+++ b/ShareX/Forms/ApplicationSettingsForm.resx
@@ -672,11 +672,59 @@
0
+
+ 296, 64
+
+
+ 80, 23
+
+
+ 23
+
+
+ Remove
+
+
+ btnThemeRemove
+
+
+ System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ tpTheme
+
+
+ 0
+
+
+ 208, 64
+
+
+ 80, 23
+
+
+ 22
+
+
+ Add
+
+
+ btnThemeAdd
+
+
+ System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ tpTheme
+
+
+ 1
+
16, 64
- 224, 21
+ 184, 21
21
@@ -691,7 +739,7 @@
tpTheme
- 0
+ 2
True
@@ -721,7 +769,7 @@
tpTheme
- 1
+ 3
NoControl
@@ -748,7 +796,7 @@
tpTheme
- 2
+ 4
False
@@ -772,7 +820,7 @@
tpTheme
- 3
+ 5
True
@@ -802,7 +850,7 @@
tpTheme
- 4
+ 6
4, 22