From 20169ffd8c2969076b8ef79100ed2381d93c924f Mon Sep 17 00:00:00 2001 From: niksedk Date: Thu, 17 Aug 2023 08:45:35 +0200 Subject: [PATCH] Some fixes for ASSA set layer --- src/ui/Controls/NikseUpDown.cs | 18 ++++++++++++++++++ src/ui/Forms/Assa/AssaTagTemplate.Designer.cs | 8 ++++---- src/ui/Forms/Assa/SetLayer.cs | 3 +++ src/ui/Forms/Main.cs | 2 ++ 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/ui/Controls/NikseUpDown.cs b/src/ui/Controls/NikseUpDown.cs index 62970fdf6..e4b90eb6c 100644 --- a/src/ui/Controls/NikseUpDown.cs +++ b/src/ui/Controls/NikseUpDown.cs @@ -13,6 +13,9 @@ namespace Nikse.SubtitleEdit.Controls // ReSharper disable once InconsistentNaming public event EventHandler ValueChanged; + // ReSharper disable once InconsistentNaming + public new event KeyEventHandler KeyDown; + private decimal _value; [Category("NikseUpDown"), Description("Gets or sets the default value in textBox"), RefreshProperties(RefreshProperties.Repaint)] @@ -230,6 +233,10 @@ namespace Nikse.SubtitleEdit.Controls AddValue(Increment); e.Handled = true; } + else + { + KeyDown?.Invoke(sender, e); + } }; _textBox.LostFocus += (sender, args) => { @@ -269,6 +276,17 @@ namespace Nikse.SubtitleEdit.Controls TabStop = false; } + protected override void OnGotFocus(EventArgs e) + { + if (_textBox != null) + { + _textBox.Focus(); + return; + } + + base.OnGotFocus(e); + } + private void _textBox_TextChanged(object sender, EventArgs e) { var text = _textBox.Text.Trim(); diff --git a/src/ui/Forms/Assa/AssaTagTemplate.Designer.cs b/src/ui/Forms/Assa/AssaTagTemplate.Designer.cs index 784f862eb..675540ef7 100644 --- a/src/ui/Forms/Assa/AssaTagTemplate.Designer.cs +++ b/src/ui/Forms/Assa/AssaTagTemplate.Designer.cs @@ -50,10 +50,10 @@ namespace Nikse.SubtitleEdit.Forms.Assa this.buttonAdd = new System.Windows.Forms.Button(); this.buttonRemoveAll = new System.Windows.Forms.Button(); this.buttonCopy = new System.Windows.Forms.Button(); - this.textBoxTag = new System.Windows.Forms.TextBox(); + this.textBoxTag = new Nikse.SubtitleEdit.Controls.NikseTextBox(); this.labelTag = new System.Windows.Forms.Label(); this.groupBoxTemplateItem = new System.Windows.Forms.GroupBox(); - this.textBoxHint = new System.Windows.Forms.TextBox(); + this.textBoxHint = new Nikse.SubtitleEdit.Controls.NikseTextBox(); this.labelHint = new System.Windows.Forms.Label(); this.contextMenuStripFile.SuspendLayout(); this.groupBoxTemplateItem.SuspendLayout(); @@ -346,10 +346,10 @@ namespace Nikse.SubtitleEdit.Forms.Assa private System.Windows.Forms.Button buttonAdd; private System.Windows.Forms.Button buttonRemoveAll; private System.Windows.Forms.Button buttonCopy; - private System.Windows.Forms.TextBox textBoxTag; + private Nikse.SubtitleEdit.Controls.NikseTextBox textBoxTag; private System.Windows.Forms.Label labelTag; private System.Windows.Forms.GroupBox groupBoxTemplateItem; - private System.Windows.Forms.TextBox textBoxHint; + private Nikse.SubtitleEdit.Controls.NikseTextBox textBoxHint; private System.Windows.Forms.Label labelHint; private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemRemoveAll; diff --git a/src/ui/Forms/Assa/SetLayer.cs b/src/ui/Forms/Assa/SetLayer.cs index fa59d6dea..0167eed06 100644 --- a/src/ui/Forms/Assa/SetLayer.cs +++ b/src/ui/Forms/Assa/SetLayer.cs @@ -1,6 +1,8 @@ using Nikse.SubtitleEdit.Logic; using System.Windows.Forms; using Nikse.SubtitleEdit.Core.Common; +using System.Threading; +using System; namespace Nikse.SubtitleEdit.Forms.Assa { @@ -50,6 +52,7 @@ namespace Nikse.SubtitleEdit.Forms.Assa private void SetLayer_Shown(object sender, System.EventArgs e) { numericUpDownLayer.Focus(); + SynchronizationContext.Current.Post(TimeSpan.FromMilliseconds(10), () => numericUpDownLayer.Focus()); } } } diff --git a/src/ui/Forms/Main.cs b/src/ui/Forms/Main.cs index 9ea059503..346451935 100644 --- a/src/ui/Forms/Main.cs +++ b/src/ui/Forms/Main.cs @@ -9612,6 +9612,8 @@ namespace Nikse.SubtitleEdit.Forms { _subtitle.Paragraphs[index].Layer = form.Layer; } + + numericUpDownLayer.Value = form.Layer; } } }