Add StopEditing method to InlineEditControl

This commit is contained in:
John Lewin 2018-04-04 17:52:58 -07:00
parent db6044720d
commit be1cece4bf

View file

@ -98,26 +98,23 @@ namespace MatterHackers.MatterControl.CustomWidgets
public Func<bool> ForceHide { get; set; } public Func<bool> ForceHide { get; set; }
private Func<double, string> _GetDisplayString = (value) => "{0:0.0}".FormatWith(value); private Func<double, string> _getDisplayString = (value) => "{0:0.0}".FormatWith(value);
public Func<double, string> GetDisplayString public Func<double, string> GetDisplayString
{ {
get { return _GetDisplayString; } get => _getDisplayString;
set set
{ {
_GetDisplayString = value; _getDisplayString = value;
if (GetDisplayString != null) if (_getDisplayString != null)
{ {
numberDisplay.Text = GetDisplayString?.Invoke(Value); numberDisplay.Text = _getDisplayString?.Invoke(Value);
} }
} }
} }
public double Value public double Value
{ {
get get => numberEdit.Value;
{
return numberEdit.Value;
}
set set
{ {
if (!numberEdit.ContainsFocus if (!numberEdit.ContainsFocus
@ -146,13 +143,19 @@ namespace MatterHackers.MatterControl.CustomWidgets
if (base.Visible != value) if (base.Visible != value)
{ {
base.Visible = value; base.Visible = value;
numberEdit.Visible = false; this.StopEditing();
numberDisplay.Visible = true;
} }
} }
} }
public void StopEditing()
{
numberEdit.Visible = false;
numberDisplay.Visible = true;
}
protected double SecondsToShowNumberEdit { get; private set; } = 4; protected double SecondsToShowNumberEdit { get; private set; } = 4;
protected Stopwatch timeSinceMouseUp { get; private set; } = new Stopwatch(); protected Stopwatch timeSinceMouseUp { get; private set; } = new Stopwatch();
public override void OnDraw(Graphics2D graphics2D) public override void OnDraw(Graphics2D graphics2D)