diff --git a/UVtools.GUI/App.config b/UVtools.GUI/App.config index dfdb215..1c42fb5 100644 --- a/UVtools.GUI/App.config +++ b/UVtools.GUI/App.config @@ -220,6 +220,9 @@ True + + False + False diff --git a/UVtools.GUI/Forms/FrmSettings.Designer.cs b/UVtools.GUI/Forms/FrmSettings.Designer.cs index c2b2d5f..53dc6bd 100644 --- a/UVtools.GUI/Forms/FrmSettings.Designer.cs +++ b/UVtools.GUI/Forms/FrmSettings.Designer.cs @@ -173,6 +173,7 @@ this.cbLayerRepairLayersIslands = new System.Windows.Forms.CheckBox(); this.panel1 = new System.Windows.Forms.Panel(); this.toolTip = new System.Windows.Forms.ToolTip(this.components); + this.cbCloseEditOnApply = new System.Windows.Forms.CheckBox(); this.groupBox3.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.nmResinTrapBinaryThreshold)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nmResinTrapMaximumPixelBrightnessToDrain)).BeginInit(); @@ -1698,6 +1699,7 @@ // // tabPage4 // + this.tabPage4.Controls.Add(this.cbCloseEditOnApply); this.tabPage4.Controls.Add(this.groupBox10); this.tabPage4.Controls.Add(this.cbPartialUpdateIslandsOnEditing); this.tabPage4.Location = new System.Drawing.Point(4, 27); @@ -2055,6 +2057,17 @@ this.toolTip.ToolTipIcon = System.Windows.Forms.ToolTipIcon.Info; this.toolTip.ToolTipTitle = "Information"; // + // cbCloseEditOnApply + // + this.cbCloseEditOnApply.AutoSize = true; + this.cbCloseEditOnApply.Location = new System.Drawing.Point(11, 213); + this.cbCloseEditOnApply.Name = "cbCloseEditOnApply"; + this.cbCloseEditOnApply.Size = new System.Drawing.Size(322, 22); + this.cbCloseEditOnApply.TabIndex = 25; + this.cbCloseEditOnApply.Text = "Close pixel editor after operations are applied"; + this.toolTip.SetToolTip(this.cbCloseEditOnApply, "Automatically close pixel editor after applying changes"); + this.cbCloseEditOnApply.UseVisualStyleBackColor = true; + // // FrmSettings // this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F); @@ -2266,5 +2279,6 @@ private System.Windows.Forms.Label label23; private System.Windows.Forms.Button btnPixelEditorAddPixelColor; private System.Windows.Forms.Button btnPixelEditorAddPixelHLColor; + private System.Windows.Forms.CheckBox cbCloseEditOnApply; } } diff --git a/UVtools.GUI/Forms/FrmSettings.cs b/UVtools.GUI/Forms/FrmSettings.cs index 9dc5d40..41e5b52 100644 --- a/UVtools.GUI/Forms/FrmSettings.cs +++ b/UVtools.GUI/Forms/FrmSettings.cs @@ -113,6 +113,7 @@ namespace UVtools.GUI.Forms btnPixelEditorDrainHoleColor.BackColor = Settings.Default.PixelEditorDrainHoleColor; btnPixelEditorDrainHoleHLColor.BackColor = Settings.Default.PixelEditorDrainHoleHLColor; cbPartialUpdateIslandsOnEditing.Checked = Settings.Default.PartialUpdateIslandsOnEditing; + cbCloseEditOnApply.Checked = Settings.Default.CloseEditOnApply; // Layer Repair nmLayerRepairDefaultClosingIterations.Value = Settings.Default.LayerRepairDefaultClosingIterations; @@ -293,6 +294,7 @@ namespace UVtools.GUI.Forms Settings.Default.PixelEditorSupportHLColor = btnPixelEditorSupportHLColor.BackColor; Settings.Default.PixelEditorDrainHoleHLColor = btnPixelEditorDrainHoleHLColor.BackColor; Settings.Default.PartialUpdateIslandsOnEditing = cbPartialUpdateIslandsOnEditing.Checked; + Settings.Default.CloseEditOnApply = cbCloseEditOnApply.Checked; // Layer Repair Settings.Default.LayerRepairDefaultClosingIterations = (byte) nmLayerRepairDefaultClosingIterations.Value; diff --git a/UVtools.GUI/FrmMain.cs b/UVtools.GUI/FrmMain.cs index 37bbaf6..b32301f 100644 --- a/UVtools.GUI/FrmMain.cs +++ b/UVtools.GUI/FrmMain.cs @@ -4276,10 +4276,27 @@ namespace UVtools.GUI } return; } - var result = MessageBox.Show( - "There are unsaved changes on image editor, do you want to apply modifications?", - "Unsaved changes on image editor", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); + var result = DialogResult.None; + + if (exitEditor) { + result = MessageBox.Show( + "There are edit operations that have not been applied. " + + "Would you like to apply all operations before closing the editor?", + "Closing image editor", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); + } + else + { + + result = MessageBox.Show( + "Are you sure you want to apply all operations?", + "Apply image editor changes?", MessageBoxButtons.YesNo, MessageBoxIcon.Question); + + // For the "apply" case, We aren't exiting the editor, so map "No" to "Cancel" here + // in order to prevent pixel history from being cleared. + result = result == DialogResult.No ? DialogResult.Cancel : DialogResult.Yes; + } + if (result == DialogResult.Cancel) { btnLayerImagePixelEdit.Checked = true; @@ -4341,8 +4358,9 @@ namespace UVtools.GUI } } - if (exitEditor) + if (exitEditor || (Settings.Default.CloseEditOnApply && result == DialogResult.Yes)) { + btnLayerImagePixelEdit.Checked = false; tabControlLeft.SelectedTab = ControlLeftLastTab; tabControlLeft.TabPages.Remove(tabPagePixelEditor); } diff --git a/UVtools.GUI/Properties/Settings.Designer.cs b/UVtools.GUI/Properties/Settings.Designer.cs index 58297ff..ee21d1f 100644 --- a/UVtools.GUI/Properties/Settings.Designer.cs +++ b/UVtools.GUI/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace UVtools.GUI.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.6.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.7.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); @@ -779,6 +779,18 @@ namespace UVtools.GUI.Properties { } } + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool CloseEditOnApply { + get { + return ((bool)(this["CloseEditOnApply"])); + } + set { + this["CloseEditOnApply"] = value; + } + } + [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("False")] diff --git a/UVtools.GUI/Properties/Settings.settings b/UVtools.GUI/Properties/Settings.settings index 1ca1da1..62a76c1 100644 --- a/UVtools.GUI/Properties/Settings.settings +++ b/UVtools.GUI/Properties/Settings.settings @@ -191,6 +191,9 @@ True + + False + False