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/Destinations/FileDestination.cs b/Greenshot/Destinations/FileDestination.cs index d3f1a2cb4..daada3f41 100644 --- a/Greenshot/Destinations/FileDestination.cs +++ b/Greenshot/Destinations/FileDestination.cs @@ -115,6 +115,7 @@ namespace Greenshot.Destinations { pattern = "greenshot ${capturetime}"; } string filename = FilenameHelper.GetFilenameFromPattern(pattern, CoreConfig.OutputFileFormat, captureDetails); + CoreConfig.ValidateAndCorrectOutputFilePath(); string filepath = FilenameHelper.FillVariables(CoreConfig.OutputFilePath, false); try { fullPath = Path.Combine(filepath, filename); diff --git a/Greenshot/Drawing/Fields/FieldAggregator.cs b/Greenshot/Drawing/Fields/FieldAggregator.cs index cbf5377d7..3eb2f8bac 100644 --- a/Greenshot/Drawing/Fields/FieldAggregator.cs +++ b/Greenshot/Drawing/Fields/FieldAggregator.cs @@ -27,6 +27,7 @@ using Greenshot.Plugin.Drawing; using GreenshotPlugin.Interfaces.Drawing; using System.Collections.Generic; using System.ComponentModel; +using System.Linq; namespace Greenshot.Drawing.Fields { @@ -203,7 +204,7 @@ namespace Greenshot.Drawing.Fields { return; } - foreach (var drawableContainer1 in _boundContainers) + foreach (var drawableContainer1 in _boundContainers.ToList()) { var drawableContainer = (DrawableContainer) drawableContainer1; if (!drawableContainer.HasField(field.FieldType)) diff --git a/Greenshot/Drawing/SpeechbubbleContainer.cs b/Greenshot/Drawing/SpeechbubbleContainer.cs index f90643ae9..0cdfb91c1 100644 --- a/Greenshot/Drawing/SpeechbubbleContainer.cs +++ b/Greenshot/Drawing/SpeechbubbleContainer.cs @@ -56,9 +56,10 @@ namespace Greenshot.Drawing /// /// Restore the target gripper /// - /// - protected override void OnDeserialized(StreamingContext context) + /// StreamingContext + protected override void OnDeserialized(StreamingContext streamingContext) { + base.OnDeserialized(streamingContext); InitAdorner(Color.Green, _storedTargetGripperLocation); } #endregion @@ -303,7 +304,6 @@ namespace Greenshot.Drawing tail.Dispose(); // Draw the text - UpdateFormat(); DrawText(graphics, rect, lineThickness, lineColor, shadow, StringFormat, Text, Font); } diff --git a/Greenshot/Drawing/TextContainer.cs b/Greenshot/Drawing/TextContainer.cs index 2761bfe9c..0c72b464b 100644 --- a/Greenshot/Drawing/TextContainer.cs +++ b/Greenshot/Drawing/TextContainer.cs @@ -272,8 +272,11 @@ namespace Greenshot.Drawing _parent.Controls.Add(_textBox); } EnsureTextBoxContrast(); - _textBox.Show(); - _textBox.Focus(); + if (_textBox != null) + { + _textBox.Show(); + _textBox.Focus(); + } } /// @@ -281,6 +284,10 @@ namespace Greenshot.Drawing /// private void EnsureTextBoxContrast() { + if (_textBox == null) + { + return; + } Color lc = GetFieldValueAsColor(FieldType.LINE_COLOR); if (lc.R > 203 && lc.G > 203 && lc.B > 203) { @@ -295,7 +302,7 @@ namespace Greenshot.Drawing private void HideTextBox() { _parent.Focus(); - _textBox.Hide(); + _textBox?.Hide(); _parent.KeysLocked = false; _parent.Controls.Remove(_textBox); } @@ -424,6 +431,10 @@ namespace Greenshot.Drawing /// private void UpdateTextBoxPosition() { + if (_textBox == null) + { + return; + } int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS); int lineWidth = (int)Math.Floor(lineThickness / 2d); 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