From 5f4da6a291eff277c0f111a4bbccac46df892aef Mon Sep 17 00:00:00 2001 From: niksedk Date: Sun, 16 Jan 2022 21:47:35 +0100 Subject: [PATCH] Remember last four colors in color picker - thx Siamak :) --- src/libse/Common/Settings.cs | 27 +++++++++++++ src/ui/Forms/ColorChooser.cs | 78 ++++++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+) diff --git a/src/libse/Common/Settings.cs b/src/libse/Common/Settings.cs index d13acba7f..77ab2f3d0 100644 --- a/src/libse/Common/Settings.cs +++ b/src/libse/Common/Settings.cs @@ -1343,6 +1343,9 @@ $HorzAlign = Center public Color DarkThemeForeColor { get; set; } public Color DarkThemeBackColor { get; set; } public Color LastColorPickerColor { get; set; } + public Color LastColorPickerColor1 { get; set; } + public Color LastColorPickerColor2 { get; set; } + public Color LastColorPickerColor3 { get; set; } public bool UseDarkTheme { get; set; } public bool DarkThemeShowListViewGridLines { get; set; } public bool ShowBetaStuff { get; set; } @@ -1480,6 +1483,9 @@ $HorzAlign = Center DarkThemeForeColor = Color.FromArgb(155, 155, 155); DarkThemeBackColor = Color.FromArgb(30, 30, 30); LastColorPickerColor = Color.Yellow; + LastColorPickerColor1 = Color.Red; + LastColorPickerColor2 = Color.Green; + LastColorPickerColor3 = Color.Blue; UseDarkTheme = false; DarkThemeShowListViewGridLines = false; AutoSetVideoSmpteForTtml = true; @@ -4000,6 +4006,24 @@ $HorzAlign = Center settings.General.LastColorPickerColor = FromHtml(subNode.InnerText); } + subNode = node.SelectSingleNode("LastColorPickerColor1"); + if (subNode != null) + { + settings.General.LastColorPickerColor1 = FromHtml(subNode.InnerText); + } + + subNode = node.SelectSingleNode("LastColorPickerColor2"); + if (subNode != null) + { + settings.General.LastColorPickerColor2 = FromHtml(subNode.InnerText); + } + + subNode = node.SelectSingleNode("LastColorPickerColor3"); + if (subNode != null) + { + settings.General.LastColorPickerColor3 = FromHtml(subNode.InnerText); + } + subNode = node.SelectSingleNode("DarkThemeBackColor"); if (subNode != null) { @@ -9419,6 +9443,9 @@ $HorzAlign = Center textWriter.WriteElementString("SubtitleTextBoxMaxHeight", settings.General.SubtitleTextBoxMaxHeight.ToString(CultureInfo.InvariantCulture)); textWriter.WriteElementString("AllowLetterShortcutsInTextBox", settings.General.AllowLetterShortcutsInTextBox.ToString(CultureInfo.InvariantCulture)); textWriter.WriteElementString("LastColorPickerColor", ToHtml(settings.General.LastColorPickerColor)); + textWriter.WriteElementString("LastColorPickerColor1", ToHtml(settings.General.LastColorPickerColor1)); + textWriter.WriteElementString("LastColorPickerColor2", ToHtml(settings.General.LastColorPickerColor2)); + textWriter.WriteElementString("LastColorPickerColor3", ToHtml(settings.General.LastColorPickerColor3)); textWriter.WriteElementString("DarkThemeBackColor", settings.General.DarkThemeBackColor.ToArgb().ToString(CultureInfo.InvariantCulture)); textWriter.WriteElementString("DarkThemeForeColor", settings.General.DarkThemeForeColor.ToArgb().ToString(CultureInfo.InvariantCulture)); textWriter.WriteElementString("UseDarkTheme", settings.General.UseDarkTheme.ToString(CultureInfo.InvariantCulture)); diff --git a/src/ui/Forms/ColorChooser.cs b/src/ui/Forms/ColorChooser.cs index 1c6f75a45..d9d516e6a 100644 --- a/src/ui/Forms/ColorChooser.cs +++ b/src/ui/Forms/ColorChooser.cs @@ -60,6 +60,10 @@ namespace Nikse.SubtitleEdit.Forms private TrackBar _tbValue; private bool _showAlpha = true; private readonly Timer _hexCodeEditTimer; + private Panel panelC0; + private Panel panelC1; + private Panel panelC2; + private Panel panelC3; private bool _hexEditOn; public ColorChooser() @@ -83,6 +87,11 @@ namespace Nikse.SubtitleEdit.Forms CheckValidHexInput(); } }; + + panelC0.BackColor = Configuration.Settings.General.LastColorPickerColor; + panelC1.BackColor = Configuration.Settings.General.LastColorPickerColor1; + panelC2.BackColor = Configuration.Settings.General.LastColorPickerColor2; + panelC3.BackColor = Configuration.Settings.General.LastColorPickerColor3; } public bool ShowAlpha @@ -337,6 +346,10 @@ namespace Nikse.SubtitleEdit.Forms this._pnlSelectedColor = new System.Windows.Forms.Panel(); this._buttonCancel = new System.Windows.Forms.Button(); this._buttonOk = new System.Windows.Forms.Button(); + this.panelC0 = new System.Windows.Forms.Panel(); + this.panelC1 = new System.Windows.Forms.Panel(); + this.panelC2 = new System.Windows.Forms.Panel(); + this.panelC3 = new System.Windows.Forms.Panel(); this._flowLayoutPanel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this._tbRed)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this._tbGreen)).BeginInit(); @@ -679,10 +692,50 @@ namespace Nikse.SubtitleEdit.Forms this._buttonOk.UseVisualStyleBackColor = true; this._buttonOk.Click += new System.EventHandler(this.buttonOK_Click); // + // panelC0 + // + this.panelC0.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panelC0.Location = new System.Drawing.Point(295, 97); + this.panelC0.Name = "panelC0"; + this.panelC0.Size = new System.Drawing.Size(21, 20); + this.panelC0.TabIndex = 62; + this.panelC0.MouseClick += new System.Windows.Forms.MouseEventHandler(this.panelC0_MouseClick); + // + // panelC1 + // + this.panelC1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panelC1.Location = new System.Drawing.Point(322, 97); + this.panelC1.Name = "panelC1"; + this.panelC1.Size = new System.Drawing.Size(21, 20); + this.panelC1.TabIndex = 63; + this.panelC1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.panelC1_MouseClick); + // + // panelC2 + // + this.panelC2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panelC2.Location = new System.Drawing.Point(349, 97); + this.panelC2.Name = "panelC2"; + this.panelC2.Size = new System.Drawing.Size(21, 20); + this.panelC2.TabIndex = 63; + this.panelC2.MouseClick += new System.Windows.Forms.MouseEventHandler(this.panelC2_MouseClick); + // + // panelC3 + // + this.panelC3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panelC3.Location = new System.Drawing.Point(376, 97); + this.panelC3.Name = "panelC3"; + this.panelC3.Size = new System.Drawing.Size(21, 20); + this.panelC3.TabIndex = 64; + this.panelC3.MouseClick += new System.Windows.Forms.MouseEventHandler(this.panelC3_MouseClick); + // // ColorChooser // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(413, 441); + this.Controls.Add(this.panelC3); + this.Controls.Add(this.panelC2); + this.Controls.Add(this.panelC1); + this.Controls.Add(this.panelC0); this.Controls.Add(this._buttonCancel); this.Controls.Add(this._buttonOk); this.Controls.Add(this._label5); @@ -739,6 +792,11 @@ namespace Nikse.SubtitleEdit.Forms private void buttonOK_Click(object sender, EventArgs e) { + Configuration.Settings.General.LastColorPickerColor3 = Configuration.Settings.General.LastColorPickerColor2; + Configuration.Settings.General.LastColorPickerColor2 = Configuration.Settings.General.LastColorPickerColor1; + Configuration.Settings.General.LastColorPickerColor1 = Configuration.Settings.General.LastColorPickerColor; + Configuration.Settings.General.LastColorPickerColor = Color; + DialogResult = DialogResult.OK; } @@ -833,5 +891,25 @@ namespace Nikse.SubtitleEdit.Forms return true; } + + private void panelC0_MouseClick(object sender, MouseEventArgs e) + { + Color = panelC0.BackColor; + } + + private void panelC1_MouseClick(object sender, MouseEventArgs e) + { + Color = panelC1.BackColor; + } + + private void panelC2_MouseClick(object sender, MouseEventArgs e) + { + Color = panelC2.BackColor; + } + + private void panelC3_MouseClick(object sender, MouseEventArgs e) + { + Color = panelC3.BackColor; + } } }