From 61b13599dc70c7eee0660ad99c0e07b404a2c166 Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Thu, 1 Sep 2022 20:23:19 +0200 Subject: [PATCH] Update COLEditor to only return `DialogResult.OK` once saved --- PCK-Studio/Forms/Editor/COLEditor.Designer.cs | 1 - PCK-Studio/Forms/Editor/COLEditor.cs | 10 +++------- PCK-Studio/MainForm.cs | 3 ++- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/PCK-Studio/Forms/Editor/COLEditor.Designer.cs b/PCK-Studio/Forms/Editor/COLEditor.Designer.cs index ea3d7a2a..eb5110c1 100644 --- a/PCK-Studio/Forms/Editor/COLEditor.Designer.cs +++ b/PCK-Studio/Forms/Editor/COLEditor.Designer.cs @@ -290,7 +290,6 @@ namespace PckStudio.Forms.Editor this.Name = "COLEditor"; this.Style = MetroFramework.MetroColorStyle.Silver; this.Theme = MetroFramework.MetroThemeStyle.Dark; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.COLEditor_FormClosing); this.metroPanel1.ResumeLayout(false); this.metroPanel1.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.blueUpDown)).EndInit(); diff --git a/PCK-Studio/Forms/Editor/COLEditor.cs b/PCK-Studio/Forms/Editor/COLEditor.cs index d3ac2e99..b91546a7 100644 --- a/PCK-Studio/Forms/Editor/COLEditor.cs +++ b/PCK-Studio/Forms/Editor/COLEditor.cs @@ -82,7 +82,8 @@ namespace PckStudio.Forms.Editor COLFileWriter.Write(stream, colurfile); _file.SetData(stream.ToArray()); } - } + DialogResult = DialogResult.OK; + } static byte[] StringToByteArrayFastest(string hex) { @@ -101,7 +102,7 @@ namespace PckStudio.Forms.Editor static int GetHexVal(char hex) { - int val = (int)hex; + int val = hex; return val - (val < 58 ? 48 : (val < 97 ? 55 : 87)); } @@ -219,10 +220,5 @@ namespace PckStudio.Forms.Editor } colorPick.Dispose(); } - - private void COLEditor_FormClosing(object sender, FormClosingEventArgs e) - { - DialogResult = DialogResult.OK; - } } } diff --git a/PCK-Studio/MainForm.cs b/PCK-Studio/MainForm.cs index f7469d72..76852e2a 100644 --- a/PCK-Studio/MainForm.cs +++ b/PCK-Studio/MainForm.cs @@ -2714,7 +2714,8 @@ namespace PckStudio file.filepath == "colours.col") // .col file { using COLEditor diag = new COLEditor(file); - diag.ShowDialog(this); + if (diag.ShowDialog(this) == DialogResult.OK) + saved = false; } }