From 4c1dcd6c77c5f0716a92944005e741d6da1aa746 Mon Sep 17 00:00:00 2001 From: OmrSi Date: Sat, 10 Oct 2020 12:04:27 +0300 Subject: [PATCH] Change Opacity when the form is Deactivated --- src/Forms/MeasurementConverter.Designer.cs | 2 ++ src/Forms/MeasurementConverter.cs | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/Forms/MeasurementConverter.Designer.cs b/src/Forms/MeasurementConverter.Designer.cs index d0f4be8d4..71e27b4d1 100644 --- a/src/Forms/MeasurementConverter.Designer.cs +++ b/src/Forms/MeasurementConverter.Designer.cs @@ -179,6 +179,8 @@ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Measurement converter"; this.Activated += new System.EventHandler(this.MeasurementConverter_Activated); + this.Deactivate += new System.EventHandler(this.MeasurementConverter_Deactivate); + this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.MeasurementConverter_FormClosed); this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.MeasurementConverter_KeyDown); this.ResumeLayout(false); this.PerformLayout(); diff --git a/src/Forms/MeasurementConverter.cs b/src/Forms/MeasurementConverter.cs index f0c54b53b..aba512f2d 100644 --- a/src/Forms/MeasurementConverter.cs +++ b/src/Forms/MeasurementConverter.cs @@ -4877,6 +4877,7 @@ namespace Nikse.SubtitleEdit.Forms private void MeasurementConverter_Activated(object sender, EventArgs e) { + this.Opacity = 1; if (double.TryParse(Input, out _)) { textBoxInput.Text = Input; @@ -4886,5 +4887,18 @@ namespace Nikse.SubtitleEdit.Forms textBoxInput.Text = "1"; } } + + private void MeasurementConverter_FormClosed(object sender, FormClosedEventArgs e) + { + DialogResult = DialogResult.Cancel; + } + + private void MeasurementConverter_Deactivate(object sender, EventArgs e) + { + if (DialogResult != DialogResult.Cancel) + { + this.Opacity = 0.5; + } + } } }