From 98415aaa81800d35ace5f4d16fcc74c914694e3b Mon Sep 17 00:00:00 2001 From: Robin Date: Wed, 25 Jan 2017 17:33:21 +0100 Subject: [PATCH] BUG-2102: Fixing an issue when a second ColorDialog is opened. --- Greenshot/Controls/ColorButton.cs | 6 ++++-- Greenshot/Controls/ToolStripColorButton.cs | 6 ++++-- Greenshot/Forms/ColorDialog.cs | 8 +------- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Greenshot/Controls/ColorButton.cs b/Greenshot/Controls/ColorButton.cs index d37fbf1c9..a08f0afab 100644 --- a/Greenshot/Controls/ColorButton.cs +++ b/Greenshot/Controls/ColorButton.cs @@ -68,8 +68,10 @@ namespace Greenshot.Controls { } private void ColorButtonClick(object sender, EventArgs e) { - ColorDialog colorDialog = ColorDialog.GetInstance(); - colorDialog.Color = SelectedColor; + var colorDialog = new ColorDialog + { + Color = SelectedColor + }; // Using the parent to make sure the dialog doesn't show on another window colorDialog.ShowDialog(Parent.Parent); if (colorDialog.DialogResult == DialogResult.Cancel) diff --git a/Greenshot/Controls/ToolStripColorButton.cs b/Greenshot/Controls/ToolStripColorButton.cs index ac4fcd736..8f5acd7d9 100644 --- a/Greenshot/Controls/ToolStripColorButton.cs +++ b/Greenshot/Controls/ToolStripColorButton.cs @@ -66,8 +66,10 @@ namespace Greenshot.Controls { } private void ColorButtonClick(object sender, EventArgs e) { - ColorDialog colorDialog = ColorDialog.GetInstance(); - colorDialog.Color = SelectedColor; + var colorDialog = new ColorDialog + { + Color = SelectedColor + }; // Using the parent to make sure the dialog doesn't show on another window colorDialog.ShowDialog(Parent.Parent); if (colorDialog.DialogResult == DialogResult.Cancel) diff --git a/Greenshot/Forms/ColorDialog.cs b/Greenshot/Forms/ColorDialog.cs index 5cfbf187d..5799e0351 100644 --- a/Greenshot/Forms/ColorDialog.cs +++ b/Greenshot/Forms/ColorDialog.cs @@ -34,10 +34,9 @@ namespace Greenshot { /// Description of ColorDialog. /// public partial class ColorDialog : BaseForm { - private static ColorDialog _uniqueInstance; private static readonly EditorConfiguration EditorConfig = IniConfig.GetIniSection(); - private ColorDialog() { + public ColorDialog() { SuspendLayout(); InitializeComponent(); SuspendLayout(); @@ -47,11 +46,6 @@ namespace Greenshot { UpdateRecentColorsButtonRow(); } - public static ColorDialog GetInstance() - { - return _uniqueInstance ?? (_uniqueInstance = new ColorDialog()); - } - private readonly List