Change Opacity when the form is Deactivated

This commit is contained in:
OmrSi 2020-10-10 12:04:27 +03:00
parent f805ec48c2
commit 4c1dcd6c77
2 changed files with 16 additions and 0 deletions

View File

@ -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();

View File

@ -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;
}
}
}
}