private static void ShowFileDialog(Action <string> dialogClosedHandler) { var systemWindow = new SystemWindow(600, 200) { Title = "TestAutomation File Input", BackgroundColor = RGBA_Bytes.DarkGray }; var warningLabel = new TextWidget("This dialog should not appear outside of automation tests.\nNotify technical support if visible", pointSize: 15, textColor: RGBA_Bytes.Pink) { Margin = new BorderDouble(20), VAnchor = VAnchor.ParentTop, HAnchor = HAnchor.ParentLeftRight }; systemWindow.AddChild(warningLabel); var fileNameInput = new TextEditWidget(pixelWidth: 400) { VAnchor = VAnchor.ParentCenter, HAnchor = HAnchor.ParentLeftRight, Margin = new BorderDouble(30, 15) }; fileNameInput.EnterPressed += (s, e) => systemWindow.CloseOnIdle(); systemWindow.AddChild(fileNameInput); systemWindow.Load += (s, e) => fileNameInput.Focus(); systemWindow.Closed += (s, e) => { dialogClosedHandler(fileNameInput.Text); }; systemWindow.ShowAsSystemWindow(); }
private void DoShowSoftwareKeyboard(object sender, EventArgs e) { CheckMouseCaptureStates(); hadFocusWidget = sender as TextEditWidget; // if we are not currently hooked up if (contentOffsetHolder == null || contentOffsetHolder.Children.Count == 0) { content.Invalidated += content_Invalidated; RemoveChild(content); contentOffsetHolder = new GuiWidget(Width, Height); contentOffsetHolder.AddChild(content); // remember where we were oldVAnchor = content.VAnchor; oldOrigin = content.OriginRelativeParent; if (hadFocusWidget != null) { // test if the text widget is visible RectangleDouble textWidgetScreenBounds = TextWidgetScreenBounds(); int topOfKeyboard = (int)keyboard.LocalBounds.Height; if (textWidgetScreenBounds.Bottom < topOfKeyboard) { // make sure the screen is not resizing vertically content.VAnchor = VAnchor.AbsolutePosition; // move the screen up so we can see the bottom of the text widget content.OriginRelativeParent = new Vector2(0, topOfKeyboard - textWidgetScreenBounds.Bottom + 3); } } } if (keyboard != null && !keyboard.Visible) { MouseEventArgs upMouseEvent = e as MouseEventArgs; if (lastMouseDownEvent != null) { // The onfocus that put us here had a mouse down event that we want to unwind if using our soft keybeard. CheckMouseCaptureStates(); content.OnMouseUp(lastMouseDownEvent); CheckMouseCaptureStates(); } keyboard.SetFocusWidget(hadFocusWidget); CheckMouseCaptureStates(); keyboard.Visible = true; CheckMouseCaptureStates(); } CheckMouseCaptureStates(); KeyboardActive = true; }
private void MoveContentBackDown(object sender, EventArgs e) { if (hadFocusWidget != null) { content.VAnchor = oldVAnchor; content.OriginRelativeParent = oldOrigin; IsActive = false; // Clear focus so that future clicks into the original control will fire focus events that restore the keyboard view hadFocusWidget.Unfocus(); hadFocusWidget = null; } }
public MHTextEditWidget(string text = "", double x = 0, double y = 0, double pointSize = 12, double pixelWidth = 0, double pixelHeight = 0, bool multiLine = false, int tabIndex = 0, string messageWhenEmptyAndNotSelected = "") { Padding = new BorderDouble(3); actuallTextEditWidget = new TextEditWidget(text, x, y, pointSize, pixelWidth, pixelHeight, multiLine, tabIndex: tabIndex); actuallTextEditWidget.HAnchor = Agg.UI.HAnchor.ParentLeftRight; actuallTextEditWidget.MinimumSize = new Vector2(Math.Max(actuallTextEditWidget.MinimumSize.x, pixelWidth), Math.Max(actuallTextEditWidget.MinimumSize.y, pixelHeight)); actuallTextEditWidget.VAnchor = Agg.UI.VAnchor.ParentBottom; AddChild(actuallTextEditWidget); BackgroundColor = RGBA_Bytes.White; HAnchor = HAnchor.FitToChildren; VAnchor = VAnchor.FitToChildren; noContentFieldDescription = new TextWidget(messageWhenEmptyAndNotSelected, textColor: RGBA_Bytes.Gray); noContentFieldDescription.VAnchor = VAnchor.ParentBottom; noContentFieldDescription.AutoExpandBoundsToText = true; AddChild(noContentFieldDescription); SetNoContentFieldDescriptionVisibility(); }
private void EnsureEditControlIsVisible(object sender, EventArgs e) { hadFocusWidget = sender as TextEditWidget; // remember where we were oldVAnchor = content.VAnchor; oldOrigin = content.OriginRelativeParent; // test if the text widget is visible RectangleDouble textWidgetScreenBounds = TextWidgetScreenBounds(); int topOfKeyboard = deviceKeyboardHeight; if (textWidgetScreenBounds.Bottom < topOfKeyboard) { // make sure the screen is not resizing vertically content.VAnchor = VAnchor.AbsolutePosition; // move the screen up so we can see the bottom of the text widget content.OriginRelativeParent = new Vector2(0, topOfKeyboard - textWidgetScreenBounds.Bottom + 10); } }
public void SetFocusWidget(TextEditWidget hadFocusWidget) { this.hadFocusWidget = hadFocusWidget; }
private void MoveContentBackDown(object sender, EventArgs e) { if (hadFocusWidget != null) { content.VAnchor = oldVAnchor; content.OriginRelativeParent = oldOrigin; // Clear focus so that future clicks into the original control will fire focus events that restore the keyboard view hadFocusWidget.Unfocus(); hadFocusWidget = null; } }
private void EnsureEditControlIsVisible(object sender, EventArgs e) { hadFocusWidget = sender as TextEditWidget; // remember where we were oldVAnchor = content.VAnchor; oldOrigin = content.OriginRelativeParent; // test if the text widget is visible RectangleDouble textWidgetScreenBounds = TextWidgetScreenBounds(); int topOfKeyboard = KeyboardHeight; if (textWidgetScreenBounds.Bottom < topOfKeyboard) { // make sure the screen is not resizing vertically content.VAnchor = VAnchor.AbsolutePosition; // move the screen up so we can see the bottom of the text widget content.OriginRelativeParent = new Vector2(0, topOfKeyboard - textWidgetScreenBounds.Bottom + 10); } }
private void DoShowSoftwareKeyboard(object sender, EventArgs e) { CheckMouseCaptureStates(); hadFocusWidget = sender as TextEditWidget; // if we are not currently hooked up if (contentOffsetHolder == null || contentOffsetHolder.Children.Count == 0) { content.Invalidated += content_Invalidated; RemoveChild(content); contentOffsetHolder = new GuiWidget(Width, Height); contentOffsetHolder.AddChild(content); // remember where we were oldVAnchor = content.VAnchor; oldOrigin = content.OriginRelativeParent; if (hadFocusWidget != null) { // test if the text widget is visible RectangleDouble textWidgetScreenBounds = TextWidgetScreenBounds(); int topOfKeyboard = (int)keyboard.LocalBounds.Height; if (textWidgetScreenBounds.Bottom < topOfKeyboard) { // make sure the screen is not resizing vertically content.VAnchor = VAnchor.AbsolutePosition; // move the screen up so we can see the bottom of the text widget content.OriginRelativeParent = new Vector2(0, topOfKeyboard - textWidgetScreenBounds.Bottom + 3); } } } if (keyboard != null && !keyboard.Visible) { MouseEventArgs upMouseEvent = e as MouseEventArgs; if (lastMouseDownEvent != null) { // The onfocus that put us here had a mouse down event that we want to unwind if using our soft keybeard. CheckMouseCaptureStates(); content.OnMouseUp(lastMouseDownEvent); CheckMouseCaptureStates(); } keyboard.SetFocusWidget(hadFocusWidget); CheckMouseCaptureStates(); keyboard.Visible = true; CheckMouseCaptureStates(); } CheckMouseCaptureStates(); }
public MHPasswordTextEditWidget(string text = "", double x = 0, double y = 0, double pointSize = 12, double pixelWidth = 0, double pixelHeight = 0, bool multiLine = false, int tabIndex = 0, string messageWhenEmptyAndNotSelected = "") : base(text, x, y, pointSize, pixelWidth, pixelHeight, multiLine, tabIndex, messageWhenEmptyAndNotSelected) { // remove this so that we can have other content first (the hiden letters) RemoveChild(noContentFieldDescription); passwordCoverText = new TextEditWidget(text, x, y, pointSize, pixelWidth, pixelHeight, multiLine); passwordCoverText.Selectable = false; passwordCoverText.HAnchor = Agg.UI.HAnchor.ParentLeftRight; passwordCoverText.MinimumSize = new Vector2(Math.Max(passwordCoverText.MinimumSize.x, pixelWidth), Math.Max(passwordCoverText.MinimumSize.y, pixelHeight)); passwordCoverText.VAnchor = Agg.UI.VAnchor.ParentBottom; AddChild(passwordCoverText); actuallTextEditWidget.TextChanged += (sender, e) => { passwordCoverText.Text = new string('●', actuallTextEditWidget.Text.Length); }; // put in back in after the hidden text noContentFieldDescription.ClearRemovedFlag(); AddChild(noContentFieldDescription); }
public TextEditPage() : base("Text Edit Widget") { FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); BackgroundColor = new RGBA_Bytes(210, 210, 255); topToBottom.Padding = new BorderDouble(20); topToBottom.AddChild(new TextWidget("testing underline jpqy", underline: true)); topToBottom.AddChild(new TextWidget("testing1\ntest2\ntest3")); topToBottom.AddChild(new TextWidget("this is some multiline\ntext\nwith centering", justification: Justification.Center)); int tabIndex = 0; #if true InternalTextEditWidget internalMultiLine = new InternalTextEditWidget("line1\nline2\nline3", 12, true, tabIndex++); //InternalTextEditWidget internalMultiLine = new InternalTextEditWidget("Line 1 - Multi Line Text Control\nLine 2 - Multi Line Text Control\nLine 3 - Multi Line Text Control\n", 12, true); topToBottom.AddChild(internalMultiLine); #endif // show some masking for passwords { FlowLayoutWidget leftToRight = new FlowLayoutWidget(); leftToRight.Margin = new BorderDouble(3); TextEditWidget passwordeTextEdit = new TextEditWidget("Password", tabIndex: tabIndex++); //passwordeTextEdit.InternalTextEditWidget.MaskCharacter = '*'; passwordeTextEdit.Margin = new BorderDouble(4, 0); leftToRight.AddChild(passwordeTextEdit); TextWidget description = new TextWidget("Content:"); leftToRight.AddChild(description); TextWidget passwordContent = new TextWidget("Password"); leftToRight.AddChild(passwordContent); passwordeTextEdit.TextChanged += (sender, e) => { passwordContent.Text = passwordeTextEdit.Text; }; topToBottom.AddChild(leftToRight); } TextEditWidget singleLineTextEdit = new TextEditWidget("Single Line Edit Text Control", tabIndex: tabIndex++); topToBottom.AddChild(singleLineTextEdit); TextEditWidget multiLineTextConrol = new TextEditWidget("Line 1 - Multi Line Text Control\nLine 2 - Multi Line Text Control\nLine 3 - Multi Line Text Control\n", tabIndex: tabIndex++); multiLineTextConrol.Multiline = true; topToBottom.AddChild(multiLineTextConrol); TextEditWidget longTextWidget = new TextEditWidget("This is some really long text.", pixelWidth: 100, tabIndex: tabIndex++); topToBottom.AddChild(longTextWidget); topToBottom.AddChild(new TextWidget("Integer Text Control:")); topToBottom.AddChild(new NumberEdit(512102416, tabIndex: tabIndex++)); topToBottom.AddChild(new TextWidget("Floating Point Text Control:")); topToBottom.AddChild(new NumberEdit(512102416, allowNegatives: true, allowDecimals: true, tabIndex: tabIndex++)); TextWidget paddingAdjustText = new TextWidget("Padding: 0"); paddingAdjustText.AutoExpandBoundsToText = true; topToBottom.AddChild(paddingAdjustText); TextEditWidget paddingAdjustTextEdit = new TextEditWidget("Edit With Padding", tabIndex: tabIndex++); GuiWidget paddingAroundTextEdit = new GuiWidget(100, 16); topToBottom.AddChild(paddingAroundTextEdit); paddingAroundTextEdit.AddChild(paddingAdjustTextEdit); paddingAdjustText.SetBoundsToEncloseChildren(); //AddChild(new TextEditWidget("Multiline Edit Text Widget line 1\nline 2\nline 3", 200, 400, 200, 80, multiLine: true)); AddChild(topToBottom); foreach (GuiWidget child in topToBottom.Children) { //child.Padding = new BorderDouble(4); child.HAnchor = UI.HAnchor.ParentCenter; child.BackgroundColor = RGBA_Bytes.White; //child.Margin = new BorderDouble(3); if (child is TextWidget) { child.BackgroundColor = new RGBA_Bytes(255, 200, 200); } } Slider textPaddingSlider = new Slider(new Vector2(), 200, 0, 10); topToBottom.AddChild(textPaddingSlider); textPaddingSlider.ValueChanged += (sender, e) => { double padding = ((Slider)sender).Value; paddingAdjustText.Padding = new BorderDouble(padding); paddingAroundTextEdit.Padding = new BorderDouble(padding); paddingAroundTextEdit.SetBoundsToEncloseChildren(); ((Slider)sender).Parent.SetBoundsToEncloseChildren(); }; topToBottom.HAnchor = UI.HAnchor.ParentCenter; topToBottom.VAnchor = UI.VAnchor.ParentCenter; }
public MatterCadWidget() { SuspendLayout(); verticleSpliter = new Splitter(); { // pannel 1 stuff textSide = new FlowLayoutWidget(FlowDirection.TopToBottom); { matterScriptEditor = new TextEditWidget("", pixelWidth: 300, pixelHeight: 500, multiLine: true); matterScriptEditor.ShowBounds = true; //matterScriptEditor.LocalBounds = new rect_d(0, 0, 200, 300); textSide.AddChild(matterScriptEditor); textSide.Resize += new ResizeEventHandler(textSide_Resize); FlowLayoutWidget buttonBar = new FlowLayoutWidget(); { Button loadFile = new Button("Load Matter Script"); loadFile.Click += new ButtonBase.ButtonEventHandler(loadFile_Click); buttonBar.AddChild(loadFile); runMatterScript = new Button("Run Matter Script"); runMatterScript.Click += new ButtonBase.ButtonEventHandler(runMatterScript_Click); buttonBar.AddChild(runMatterScript); outputScad = new Button("Output SCAD"); outputScad.Click += new ButtonBase.ButtonEventHandler(outputScad_Click); buttonBar.AddChild(outputScad); } textSide.AddChild(buttonBar); } // pannel 2 stuff FlowLayoutWidget rightStuff = new FlowLayoutWidget(FlowDirection.TopToBottom); { previewWindowRayTrace = new PreviewWindowRayTrace(); rightStuff.AddChild(previewWindowRayTrace); previewWindowGL = new PreviewWindowGL(); previewWindowGL.DrawGlContent += new PreviewWindowGL.DrawGlContentEventHandler(glLightedView_DrawGlContent); rightStuff.AddChild(previewWindowGL); FlowLayoutWidget radioButtons = new FlowLayoutWidget(); { RadioButton rayTrace = new RadioButton("Ray Trace"); radioButtons.AddChild(rayTrace); RadioButton openGL = new RadioButton("OpenGL"); radioButtons.AddChild(openGL); rayTrace.CheckedStateChanged += new RadioButton.CheckedStateChangedEventHandler(rayTrace_CheckedStateChanged); openGL.CheckedStateChanged += new RadioButton.CheckedStateChangedEventHandler(openGL_CheckedStateChanged); //rayTrace.Checked = true; openGL.Checked = true; } rightStuff.AddChild(radioButtons); } verticleSpliter.Panel2.AddChild(rightStuff); verticleSpliter.Panel1.AddChild(textSide); } ResumeLayout(); AddChild(verticleSpliter); }