diff --git a/TBF/Rig/Configs/ParamsProvider/ComponentCfgCtrl.cs b/TBF/Rig/Configs/ParamsProvider/ComponentCfgCtrl.cs index 212b52fb2..8260e498f 100644 --- a/TBF/Rig/Configs/ParamsProvider/ComponentCfgCtrl.cs +++ b/TBF/Rig/Configs/ParamsProvider/ComponentCfgCtrl.cs @@ -18,6 +18,11 @@ namespace TBF.Rig.Configs.ParamsProvider static readonly ILog log = LogManager.GetLogger(typeof(ComponentCfgCtrl)); static readonly string AkaPwd = "········"; + readonly ToolTip parameterNameToolTip; + Control parameterNameToolTipOwner; + string displayedParameterNameToolTip; + const int ParameterColumnTextPadding = 12; + static readonly string AkaPwd1 = "·"; /// One character only bool IsPassword(int i) { @@ -49,6 +54,22 @@ namespace TBF.Rig.Configs.ParamsProvider public ComponentCfgCtrl() { InitializeComponent(); + + parameterNameToolTip = new ToolTip + { + AutoPopDelay = 10000, + InitialDelay = 500, + ReshowDelay = 100, + ShowAlways = true + }; + + // Panel2 receives mouse events while the list is disabled (locked). + // The list receives them after the configuration is unlocked. + paramsListViewEx.MouseMove += ParameterNameToolTip_MouseMove; + paramsListViewEx.MouseLeave += ParameterNameToolTip_MouseLeave; + splitContainer1.Panel2.MouseMove += ParameterNameToolTip_MouseMove; + splitContainer1.Panel2.MouseLeave += ParameterNameToolTip_MouseLeave; + Disposed += (sender, args) => parameterNameToolTip.Dispose(); } /// @@ -141,6 +162,68 @@ namespace TBF.Rig.Configs.ParamsProvider } } + private void ParameterNameToolTip_MouseMove(object sender, MouseEventArgs e) + { + Control sourceControl = sender as Control; + if (sourceControl == null || paramsListViewEx.Columns.Count == 0) + { + HideParameterNameToolTip(); + return; + } + + var screenPoint = sourceControl.PointToScreen(e.Location); + var listPoint = paramsListViewEx.PointToClient(screenPoint); + if (!paramsListViewEx.ClientRectangle.Contains(listPoint)) + { + HideParameterNameToolTip(); + return; + } + + // Use a point in the first column so that hovering anywhere over + // the row also resolves the corresponding parameter item. + ListViewItem item = paramsListViewEx.GetItemAt(2, listPoint.Y); + string toolTipText = null; + if (item != null && item.SubItems.Count > 0) + { + string parameterName = item.SubItems[0].Text; + int availableWidth = Math.Max( + 0, + paramsListViewEx.Columns[0].Width - ParameterColumnTextPadding); + + if (TextRenderer.MeasureText(parameterName, paramsListViewEx.Font).Width > availableWidth) + toolTipText = parameterName; + } + + if (string.IsNullOrEmpty(toolTipText)) + { + HideParameterNameToolTip(); + return; + } + + if (parameterNameToolTipOwner == sourceControl && + displayedParameterNameToolTip == toolTipText) + return; + + HideParameterNameToolTip(); + parameterNameToolTipOwner = sourceControl; + displayedParameterNameToolTip = toolTipText; + parameterNameToolTip.SetToolTip(sourceControl, toolTipText); + } + + private void ParameterNameToolTip_MouseLeave(object sender, EventArgs e) + { + HideParameterNameToolTip(); + } + + private void HideParameterNameToolTip() + { + if (parameterNameToolTipOwner != null) + parameterNameToolTip.SetToolTip(parameterNameToolTipOwner, null); + + parameterNameToolTipOwner = null; + displayedParameterNameToolTip = null; + } + public void Unlock() { nameTextBox.Enabled = true; diff --git a/TBF/Rig/DataEntry/Uni/CycleBgEnForm.cs b/TBF/Rig/DataEntry/Uni/CycleBgEnForm.cs index 7bcd0e48a..354d30aa6 100644 --- a/TBF/Rig/DataEntry/Uni/CycleBgEnForm.cs +++ b/TBF/Rig/DataEntry/Uni/CycleBgEnForm.cs @@ -80,6 +80,8 @@ namespace TBF.Rig.DataEntry.Uni private System.Windows.Forms.Timer autoCloseTimer; private int autoCloseSecondsRemaining; private string okButtonTextBeforeAutoClose; + private bool showAutoCloseCountdown; + private const int AutoCloseCountdownDisplayThresholdSeconds = 3; private readonly IRegReader[] regReaders; @@ -1443,7 +1445,9 @@ namespace TBF.Rig.DataEntry.Uni StopAutoCloseCountdown(); okButtonTextBeforeAutoClose = okButton.Text; autoCloseSecondsRemaining = Math.Max(1, (int)Math.Ceiling(delayMs / 1000D)); - UpdateAutoCloseButtonText(); + showAutoCloseCountdown = autoCloseSecondsRemaining >= AutoCloseCountdownDisplayThresholdSeconds; + if (showAutoCloseCountdown) + UpdateAutoCloseButtonText(); autoCloseTimer = new System.Windows.Forms.Timer { Interval = 1000 }; autoCloseTimer.Tick += AutoCloseTimer_Tick; @@ -1467,6 +1471,9 @@ namespace TBF.Rig.DataEntry.Uni private void UpdateAutoCloseButtonText() { + if (!showAutoCloseCountdown) + return; + okButton.Text = string.Format("{0} ({1})", okButtonTextBeforeAutoClose, autoCloseSecondsRemaining); } @@ -1484,6 +1491,7 @@ namespace TBF.Rig.DataEntry.Uni okButton.Text = okButtonTextBeforeAutoClose; okButtonTextBeforeAutoClose = null; + showAutoCloseCountdown = false; autoCloseSecondsRemaining = 0; } } diff --git a/TBF/Rig/DataEntry/Uni/EntryFormCfg.cs b/TBF/Rig/DataEntry/Uni/EntryFormCfg.cs index ce6748c59..dc0a6a9bc 100644 --- a/TBF/Rig/DataEntry/Uni/EntryFormCfg.cs +++ b/TBF/Rig/DataEntry/Uni/EntryFormCfg.cs @@ -402,7 +402,7 @@ namespace TBF.Rig.DataEntry.Uni "Beginning: Show camera picture", "Beginning: Keys to close the form", "Beginning: Read Automatic Serial No from watermeter", //8 - "Beginning: Continue automatic after Read Serial No", //9 + "All: Auto-continue delay after automatic reading [s; <=0=off]", //9 "End: Show form",//8+2 "End: Form title", diff --git a/TBF/Rig/DataEntry/Uni/TestStartEndForm.cs b/TBF/Rig/DataEntry/Uni/TestStartEndForm.cs index 4959a1077..be237a343 100644 --- a/TBF/Rig/DataEntry/Uni/TestStartEndForm.cs +++ b/TBF/Rig/DataEntry/Uni/TestStartEndForm.cs @@ -130,6 +130,8 @@ namespace TBF.Rig.DataEntry.Uni private System.Windows.Forms.Timer autoCloseTimer; private int autoCloseSecondsRemaining; private string okButtonTextBeforeAutoClose; + private bool showAutoCloseCountdown; + private const int AutoCloseCountdownDisplayThresholdSeconds = 3; /// @@ -1783,7 +1785,9 @@ namespace TBF.Rig.DataEntry.Uni StopAutoCloseCountdown(); okButtonTextBeforeAutoClose = okButton.Text; autoCloseSecondsRemaining = Math.Max(1, (int)Math.Ceiling(delayMs / 1000D)); - UpdateAutoCloseButtonText(); + showAutoCloseCountdown = autoCloseSecondsRemaining >= AutoCloseCountdownDisplayThresholdSeconds; + if (showAutoCloseCountdown) + UpdateAutoCloseButtonText(); autoCloseTimer = new System.Windows.Forms.Timer { Interval = 1000 }; autoCloseTimer.Tick += AutoCloseTimer_Tick; @@ -1807,6 +1811,9 @@ namespace TBF.Rig.DataEntry.Uni private void UpdateAutoCloseButtonText() { + if (!showAutoCloseCountdown) + return; + okButton.Text = string.Format("{0} ({1})", okButtonTextBeforeAutoClose, autoCloseSecondsRemaining); } @@ -1824,6 +1831,7 @@ namespace TBF.Rig.DataEntry.Uni okButton.Text = okButtonTextBeforeAutoClose; okButtonTextBeforeAutoClose = null; + showAutoCloseCountdown = false; autoCloseSecondsRemaining = 0; } }