public InlineEditControl(string defaultSizeString = "-0000.00", Agg.Font.Justification justification = Agg.Font.Justification.Left) { base.Visible = false; double pointSize = 12; numberDisplay = new TextWidget(defaultSizeString, 0, 0, pointSize, justification: justification) { Visible = false, VAnchor = VAnchor.Bottom, HAnchor = HAnchor.Left, Text = "0", }; AddChild(numberDisplay); numberEdit = new NumberEdit(0, 50, 50, pointSize, pixelWidth: numberDisplay.Width, allowNegatives: true, allowDecimals: true) { Visible = false, VAnchor = VAnchor.Bottom, HAnchor = HAnchor.Left, SelectAllOnFocus = true, }; numberEdit.InternalNumberEdit.TextChanged += (s, e) => { numberDisplay.Text = GetDisplayString == null ? "None" : GetDisplayString.Invoke(Value); base.OnTextChanged(e); }; numberEdit.InternalNumberEdit.MaxDecimalsPlaces = 2; numberEdit.EditComplete += (s, e) => { EditComplete?.Invoke(this, e); timeSinceMouseUp.Restart(); numberEdit.Visible = false; numberDisplay.Visible = true; }; AddChild(numberEdit); VAnchor = VAnchor.Fit; HAnchor = HAnchor.Fit; var runningInterval = UiThread.SetInterval(HideIfApplicable, .1); this.Closed += (s, e) => runningInterval.Continue = false; }
public InlineEditControl(string defaultSizeString = "-0000.00") { theme = AppContext.Theme; base.Visible = false; double pointSize = 10; this.Padding = new BorderDouble(3); numberDisplay = new TextWidget(defaultSizeString, 0, 0, pointSize, justification: Agg.Font.Justification.Center, textColor: theme.TextColor) { Visible = false, VAnchor = VAnchor.Bottom, HAnchor = HAnchor.Left, Text = "0", AutoExpandBoundsToText = true, }; this.BeforeDraw += (s, e) => { if (s is GuiWidget widget) { var test = true; if (test) { // return; } var bounds = widget.LocalBounds; e.Graphics2D.Render(new RoundedRect(bounds, 3 * GuiWidget.DeviceScale), theme.BackgroundColor.WithAlpha(200)); } }; AddChild(numberDisplay); numberEdit = new MHNumberEdit(0, theme, pixelWidth: numberDisplay.Width, allowNegatives: true, allowDecimals: true) { Visible = false, VAnchor = VAnchor.Bottom, HAnchor = HAnchor.Left, SelectAllOnFocus = true, }; numberEdit.ActuallNumberEdit.InternalNumberEdit.TextChanged += (s, e) => { numberDisplay.Text = GetDisplayString == null ? "None" : GetDisplayString.Invoke(Value); this.OnTextChanged(e); }; numberEdit.ActuallNumberEdit.InternalNumberEdit.MaxDecimalsPlaces = 2; numberEdit.ActuallNumberEdit.EditComplete += (s, e) => { EditComplete?.Invoke(this, e); timeSinceMouseUp.Restart(); numberEdit.Visible = false; numberDisplay.Visible = true; }; AddChild(numberEdit); VAnchor = VAnchor.Fit; HAnchor = HAnchor.Fit; runningInterval = UiThread.SetInterval(HideIfApplicable, .1); }