public async Task VerifyFocusProperty() { SystemWindow systemWindow = new SystemWindow(300, 200) { BackgroundColor = RGBA_Bytes.Black, }; var editField = new TextEditWidget(pixelWidth: 200) { HAnchor = HAnchor.ParentCenter, VAnchor = VAnchor.ParentCenter, }; systemWindow.AddChild(editField); AutomationTest testToRun = (testRunner) => { UiThread.RunOnIdle(editField.Focus); testRunner.Delay(() => editField.ContainsFocus, 3); Assert.IsTrue(editField.ContainsFocus, "Focused property should be true after invoking Focus method"); return(Task.FromResult(0)); }; await AutomationRunner.ShowWindowAndExecuteTests(systemWindow, testToRun, 10); }
public async Task VerifyFocusProperty() { var systemWindow = new SystemWindow(300, 200) { BackgroundColor = Color.Black, }; var editField = new TextEditWidget(pixelWidth: 200) { HAnchor = HAnchor.Center, VAnchor = VAnchor.Center, }; systemWindow.AddChild(editField); Task TestToRun(AutomationRunner testRunner) { UiThread.RunOnIdle(editField.Focus); testRunner.WaitFor(() => editField.ContainsFocus); //if (!editField.ContainsFocus) { System.Diagnostics.Debugger.Launch(); System.Diagnostics.Debugger.Break(); } // NOTE: Okay. During parallel testing, it seems that the avalanche of windows causes test UIs to lose control focus and get confused. Assert.IsTrue(editField.ContainsFocus, "Focused property should be true after invoking Focus method"); return(Task.CompletedTask); } await AutomationRunner.ShowWindowAndExecuteTests(systemWindow, TestToRun); }
public async Task VerifyFocusMakesTextWidgetEditable() { TextEditWidget editField = null; var systemWindow = new SystemWindow(300, 200) { BackgroundColor = Color.Black, }; Task TestToRun(AutomationRunner testRunner) { UiThread.RunOnIdle(editField.Focus); testRunner.Type("Test Text"); testRunner.Delay(1); Assert.IsTrue(editField.Text == "Test Text", "validate text is typed"); return(Task.CompletedTask); } editField = new TextEditWidget(pixelWidth: 200) { HAnchor = HAnchor.Center, VAnchor = VAnchor.Center, }; systemWindow.AddChild(editField); await AutomationRunner.ShowWindowAndExecuteTests(systemWindow, TestToRun); }
public async Task VerifyFocusMakesTextWidgetEditable() { TextEditWidget editField = null; SystemWindow systemWindow = new SystemWindow(300, 200) { BackgroundColor = RGBA_Bytes.Black, }; AutomationTest testToRun = (testRunner) => { UiThread.RunOnIdle(editField.Focus); testRunner.Type("Test Text"); testRunner.Wait(1); Assert.IsTrue(editField.Text == "Test Text", "validate text is typed"); return(Task.FromResult(0)); }; editField = new TextEditWidget(pixelWidth: 200) { HAnchor = HAnchor.ParentCenter, VAnchor = VAnchor.ParentCenter, }; systemWindow.AddChild(editField); await AutomationRunner.ShowWindowAndExecuteTests(systemWindow, testToRun, 10); }
public void TextWidgetVisibleTest() { GuiWidget rectangleWidget = new GuiWidget(100, 50); TextEditWidget itemToAdd = new TextEditWidget("test Item", 10, 10); rectangleWidget.AddChild(itemToAdd); rectangleWidget.DoubleBuffer = true; rectangleWidget.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White); rectangleWidget.OnDraw(rectangleWidget.BackBuffer.NewGraphics2D()); ImageBuffer textOnly = new ImageBuffer(75, 20, 32, new BlenderBGRA()); textOnly.NewGraphics2D().Clear(RGBA_Bytes.White); #if true TypeFacePrinter stringPrinter = new TypeFacePrinter("test Item", 12); IVertexSource offsetText = new VertexSourceApplyTransform(stringPrinter, Affine.NewTranslation(1, -stringPrinter.LocalBounds.Bottom)); textOnly.NewGraphics2D().Render(offsetText, RGBA_Bytes.Black); #else textOnly.NewGraphics2D().DrawString("test Item", 1, 1); #endif if (saveImagesForDebug) { ImageTgaIO.Save(rectangleWidget.BackBuffer, "-rectangleWidget.tga"); //ImageTgaIO.Save(itemToAdd.Children[0].BackBuffer, "-internalTextWidget.tga"); ImageTgaIO.Save(textOnly, "-textOnly.tga"); } Assert.IsTrue(rectangleWidget.BackBuffer.FindLeastSquaresMatch(textOnly, 1), "TextWidgets need to be drawing."); rectangleWidget.Close(); }
public void ScrollingToEndShowsEnd() { GuiWidget container = new GuiWidget(); container.DoubleBuffer = true; container.LocalBounds = new RectangleDouble(0, 0, 110, 30); TextEditWidget editField1 = new TextEditWidget("This is a nice long text string", 0, 0, pixelWidth: 100); container.AddChild(editField1); TextWidget firstWordText = new TextWidget("This"); RectangleDouble bounds = firstWordText.LocalBounds; bounds.Offset(bounds.Left, bounds.Bottom); firstWordText.LocalBounds = bounds; firstWordText.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White); firstWordText.OnDraw(firstWordText.BackBuffer.NewGraphics2D()); TextWidget lastWordText = new TextWidget("string"); bounds = lastWordText.LocalBounds; bounds.Offset(bounds.Left, bounds.Bottom); lastWordText.LocalBounds = bounds; lastWordText.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White); lastWordText.OnDraw(lastWordText.BackBuffer.NewGraphics2D()); container.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White); container.BackgroundColor = RGBA_Bytes.White; container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 1, 1, 0)); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, 1, 1, 0)); Assert.IsTrue(editField1.ContainsFocus == true); container.OnDraw(container.BackBuffer.NewGraphics2D()); OutputImage(firstWordText.BackBuffer, "Control - Left.tga"); OutputImage(lastWordText.BackBuffer, "Control - Right.tga"); OutputImage(container.BackBuffer, "Test - Start.tga"); Vector2 bestPosition; double bestLeastSquares; container.BackBuffer.FindLeastSquaresMatch(firstWordText.BackBuffer, out bestPosition, out bestLeastSquares); Assert.IsTrue(bestLeastSquares < 2000000); container.BackBuffer.FindLeastSquaresMatch(lastWordText.BackBuffer, out bestPosition, out bestLeastSquares); Assert.IsTrue(bestLeastSquares > 2000000); SendKeyDown(Keys.End, container); container.OnDraw(container.BackBuffer.NewGraphics2D()); OutputImage(container.BackBuffer, "Test - Scrolled.tga"); container.BackBuffer.FindLeastSquaresMatch(firstWordText.BackBuffer, out bestPosition, out bestLeastSquares); Assert.IsTrue(bestLeastSquares > 2000000); container.BackBuffer.FindLeastSquaresMatch(lastWordText.BackBuffer, out bestPosition, out bestLeastSquares); Assert.IsTrue(bestLeastSquares < 2000000); container.Close(); }
public void TextEditGetsFocusTests() { var container = new GuiWidget { Name = "container", LocalBounds = new RectangleDouble(0, 0, 200, 200) }; var editField1 = new TextEditWidget("", 0, 0, pixelWidth: 160) { Name = "editField1" }; container.AddChild(editField1); var editField2 = new TextEditWidget("", 0, 20, pixelWidth: 160) { Name = "editField2" }; container.AddChild(editField2); // select no edit field Assert.IsTrue(editField1.Text == ""); SendKey(Keys.D, 'a', container); Assert.IsTrue(editField1.Text == ""); Assert.IsTrue(editField2.Text == ""); // select edit field 1 container.OnMouseMove(new MouseEventArgs(MouseButtons.Left, 1, 1, 1, 0)); // we move into the widget to make sure we have separate focus and enter events. Assert.IsTrue(editField1.ContainsFocus == false); Assert.IsTrue(editField1.Focused == false); container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 1, 1, 0)); Assert.IsTrue(editField1.ContainsFocus == true); Assert.IsTrue(editField1.Focused == false, "The internal text widget must be focused."); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 1, 1, 0)); Assert.IsTrue(editField1.ContainsFocus == true); Assert.IsTrue(editField1.Focused == false); SendKey(Keys.B, 'b', container); Assert.IsTrue(editField1.Text == "b", "It should have b a in it."); container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 150, 1, 0)); Assert.IsTrue(editField1.ContainsFocus == true); Assert.IsTrue(editField1.Focused == false, "The internal text widget must be focused."); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 150, 1, 0)); Assert.IsTrue(editField1.ContainsFocus == true); Assert.IsTrue(editField1.Focused == false); SendKey(Keys.D, 'c', container); Assert.IsTrue(editField1.Text == "bc", "It should have b a in it."); // select edit field 2 container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 1, 21, 0)); Assert.IsTrue(editField2.ContainsFocus == true); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 1, 21, 0)); SendKey(Keys.D, 'd', container); Assert.IsTrue(editField1.Text == "bc", "It should have a bc in it."); Assert.IsTrue(editField2.Text == "d", "It should have d in it."); container.Close(); }
public void TextEditingSpecialKeysWork() { var container = new GuiWidget { DoubleBuffer = true, LocalBounds = new RectangleDouble(0, 0, 200, 200) }; var textEdit = new TextEditWidget("some starting text"); container.AddChild(textEdit); container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 1, textEdit.Height - 1, 0)); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 1, textEdit.Height - 1, 0)); Assert.IsTrue(textEdit.CharIndexToInsertBefore == 0); Assert.IsTrue(textEdit.TopLeftOffset.Y == 0); Assert.IsTrue(textEdit.Text == "some starting text"); // this is to select some text SendKey(Keys.Shift | Keys.Control | Keys.Right, ' ', container); Assert.IsTrue(textEdit.Selection == "some "); Assert.IsTrue(textEdit.Text == "some starting text"); // this is to prove that we don't loose the selection when pressing Control SendKeyDown(Keys.Control, container); Assert.IsTrue(textEdit.Selection == "some "); Assert.IsTrue(textEdit.Text == "some starting text"); // this is to prove that we don't loose the selection when pressing Shift SendKeyDown(Keys.Shift, container); Assert.IsTrue(textEdit.Text == "some starting text"); Assert.IsTrue(textEdit.Selection == "some "); SendKeyDown(Keys.Right, container); Assert.IsTrue(textEdit.Selection == ""); SendKey(Keys.Shift | Keys.Control | Keys.Left, ' ', container); Assert.IsTrue(textEdit.Selection == "some "); SendKey(Keys.Delete, ' ', container); Assert.IsTrue(textEdit.Text == "starting text"); SendKey(Keys.Shift | Keys.Control | Keys.Right, ' ', container); Assert.IsTrue(textEdit.Selection == "starting "); #if !__ANDROID__ // if this fails add // GuiHalWidget.SetClipboardFunctions(System.Windows.Forms.Clipboard.GetText, System.Windows.Forms.Clipboard.SetText, System.Windows.Forms.Clipboard.ContainsText); // before you call the unit tests Clipboard.SetSystemClipboard(new WindowsFormsClipboard()); SendKey(Keys.Control | Keys.C, 'c', container); Assert.IsTrue(textEdit.Selection == "starting "); Assert.IsTrue(textEdit.Text == "starting text"); SendKeyDown(Keys.Right, container); // move to the right SendKey(Keys.Control | Keys.V, 'v', container); Assert.IsTrue(textEdit.Text == "starting starting text"); #endif container.Close(); }
public void TextSelectionWithShiftClick() { const string fullText = "This is a text"; var container = new GuiWidget(200, 200); var editField1 = new TextEditWidget(fullText, pixelWidth: 100); container.AddChild(editField1); // select all from left to right with shift click container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 1, 0, 0)); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, 1, 0, 0)); Assert.AreEqual(0, editField1.CharIndexToInsertBefore); Assert.AreEqual("", editField1.Selection); Keyboard.SetKeyDownState(Keys.Shift, true); container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 100, 0, 0)); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, 100, 0, 0)); Keyboard.SetKeyDownState(Keys.Shift, false); Assert.AreEqual(fullText.Length, editField1.CharIndexToInsertBefore); Assert.AreEqual(fullText, editField1.Selection, "It should select full text"); // select all from right to left with shift click container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 100, 0, 0)); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, 100, 0, 0)); Assert.AreEqual(fullText.Length, editField1.CharIndexToInsertBefore); Assert.AreEqual("", editField1.Selection); Keyboard.SetKeyDownState(Keys.Shift, true); container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 1, 0, 0)); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, 1, 0, 0)); Keyboard.SetKeyDownState(Keys.Shift, false); Assert.AreEqual(0, editField1.CharIndexToInsertBefore); Assert.AreEqual(fullText, editField1.Selection, "It should select full text"); // select parts of the text with shift click container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 1, 0, 0)); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, 1, 0, 0)); SendKey(Keys.Control | Keys.Right, ' ', container); SendKey(Keys.Control | Keys.Right, ' ', container); Assert.AreEqual("This is ".Length, editField1.CharIndexToInsertBefore); Assert.AreEqual("", editField1.Selection); Keyboard.SetKeyDownState(Keys.Shift, true); container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 100, 0, 0)); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, 100, 0, 0)); Keyboard.SetKeyDownState(Keys.Shift, false); Assert.AreEqual(fullText.Length, editField1.CharIndexToInsertBefore); Assert.AreEqual("a text", editField1.Selection, "It should select second part of the text"); Keyboard.SetKeyDownState(Keys.Shift, true); container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 1, 0, 0)); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, 1, 0, 0)); Keyboard.SetKeyDownState(Keys.Shift, false); Assert.AreEqual(0, editField1.CharIndexToInsertBefore); Assert.AreEqual("This is ", editField1.Selection, "It should select first part of the text"); container.Close(); }
public void TextEditTextSelectionTests() { var container = new GuiWidget { LocalBounds = new RectangleDouble(0, 0, 200, 200) }; var editField1 = new TextEditWidget("", 0, 0, pixelWidth: 51); container.AddChild(editField1); // select the control and type something in it container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0)); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, 0, 0, 0)); SendKey(Keys.A, 'a', container); Assert.IsTrue(editField1.Text == "a", "It should have a in it."); // select the beginning again and type something else in it container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0)); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, 0, 0, 0)); SendKey(Keys.B, 'b', container); Assert.IsTrue(editField1.Text == "ba", "It should have ba in it."); // select the ba and delete them container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0)); container.OnMouseMove(new MouseEventArgs(MouseButtons.Left, 0, 15, 0, 0)); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, 15, 0, 0)); SendKey(Keys.Back, ' ', container); Assert.IsTrue(editField1.Text == "", "It should have nothing in it."); // select the other way editField1.Text = "ab"; Assert.IsTrue(editField1.Text == "ab", "It should have ab in it."); container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 15, 0, 0)); container.OnMouseMove(new MouseEventArgs(MouseButtons.Left, 0, 0, 0, 0)); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, 0, 0, 0)); SendKey(Keys.Back, ' ', container); Assert.IsTrue(editField1.Text == "", "It should have nothing in it."); // select the other way but start far to the right editField1.Text = "abc"; Assert.IsTrue(editField1.Text == "abc", "It should have abc in it."); container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 30, 0, 0)); container.OnMouseMove(new MouseEventArgs(MouseButtons.Left, 0, 0, 0, 0)); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, 0, 0, 0)); SendKey(Keys.Back, ' ', container); Assert.IsTrue(editField1.Text == "", "It should have nothing in it."); container.Close(); }
public void AddThenDeleteCausesNoVisualChange() { var container = new GuiWidget { DoubleBuffer = true, LocalBounds = new RectangleDouble(0, 0, 200, 200) }; var editField1 = new TextEditWidget("Test", 10, 10, pixelWidth: 50); container.AddChild(editField1); container.BackBuffer.NewGraphics2D().Clear(Color.White); container.OnDraw(container.BackBuffer.NewGraphics2D()); var beforeEditImage = new ImageBuffer(container.BackBuffer); RectangleDouble beforeLocalBounds = editField1.LocalBounds; Vector2 beforeOrigin = editField1.OriginRelativeParent; OutputImage(beforeEditImage, "z text un-edited.tga"); container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 10, 10, 0)); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 10, 10, 0)); Assert.IsTrue(editField1.ContainsFocus == true); SendKey(Keys.B, 'b', container); Assert.IsTrue(editField1.Text == "bTest", "It should have b a in it."); RectangleDouble afterBLocalBounds = editField1.LocalBounds; Assert.IsTrue(beforeLocalBounds.Bottom == afterBLocalBounds.Bottom && beforeLocalBounds.Top == afterBLocalBounds.Top); SendKey(Keys.Back, ' ', container); Assert.IsTrue(editField1.Text == "Test", "It should not have b a in it."); RectangleDouble afterLocalBounds = editField1.LocalBounds; Vector2 afterOrigin = editField1.OriginRelativeParent; Assert.IsTrue(beforeLocalBounds == afterLocalBounds); Assert.IsTrue(beforeOrigin == afterOrigin); // click off it so the cursor is not in it. container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 1, 1, 0)); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 1, 1, 0)); Assert.IsTrue(editField1.Focused == false); container.BackBuffer.NewGraphics2D().Clear(Color.White); container.OnDraw(container.BackBuffer.NewGraphics2D()); OutputImage(container.BackBuffer, "z text edited.tga"); Assert.IsTrue(container.BackBuffer == beforeEditImage); }
public void TextEditTextSelectionTests() { GuiWidget container = new GuiWidget(); container.LocalBounds = new RectangleDouble(0, 0, 200, 200); TextEditWidget editField1 = new TextEditWidget("", 0, 0, pixelWidth: 51); container.AddChild(editField1); // select the conrol and type something in it container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0)); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, 0, 0, 0)); SendKey(Keys.A, 'a', container); Assert.IsTrue(editField1.Text == "a", "It should have a in it."); // select the begining again and type something else in it container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0)); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, 0, 0, 0)); SendKey(Keys.B, 'b', container); Assert.IsTrue(editField1.Text == "ba", "It should have ba in it."); // select the ba and delete them container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0)); container.OnMouseMove(new MouseEventArgs(MouseButtons.Left, 0, 15, 0, 0)); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, 15, 0, 0)); SendKey(Keys.Back, ' ', container); Assert.IsTrue(editField1.Text == "", "It should have nothing in it."); // select the other way editField1.Text = "ab"; Assert.IsTrue(editField1.Text == "ab", "It should have ab in it."); container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 15, 0, 0)); container.OnMouseMove(new MouseEventArgs(MouseButtons.Left, 0, 0, 0, 0)); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, 0, 0, 0)); SendKey(Keys.Back, ' ', container); Assert.IsTrue(editField1.Text == "", "It should have nothing in it."); // select the other way but start far to the right editField1.Text = "abc"; Assert.IsTrue(editField1.Text == "abc", "It should have abc in it."); container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 30, 0, 0)); container.OnMouseMove(new MouseEventArgs(MouseButtons.Left, 0, 0, 0, 0)); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, 0, 0, 0)); SendKey(Keys.Back, ' ', container); Assert.IsTrue(editField1.Text == "", "It should have nothing in it."); container.Close(); }
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) { 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); }; RemoveChild(noContentFieldDescription); AddChild(noContentFieldDescription); }
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 = "", TypeFace typeFace = null) { Padding = new BorderDouble(3); actuallTextEditWidget = new TextEditWidget(text, x, y, pointSize, pixelWidth, pixelHeight, multiLine, tabIndex: tabIndex, typeFace: typeFace); 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(); }
public void SelectAllOnFocusCanStillClickAfterSelection() { TextEditWidget editField = null; SystemWindow systemWindow = new SystemWindow(300, 200) { BackgroundColor = RGBA_Bytes.Black, }; Action <AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) => { editField.SelectAllOnFocus = true; AutomationRunner testRunner = new AutomationRunner(); testRunner.Wait(1); resultsHarness.AddTestResult(testRunner.ClickByName(editField.Name, 1)); editField.SelectAllOnFocus = true; testRunner.Type("123"); resultsHarness.AddTestResult(editField.Text == "123", "on enter we have selected all and replaced the text"); resultsHarness.AddTestResult(testRunner.ClickByName(editField.Name, 1)); testRunner.Type("123"); resultsHarness.AddTestResult(editField.Text == "123123", "we already have the contol selected so don't select all again."); systemWindow.CloseOnIdle(); }; editField = new TextEditWidget(pixelWidth: 200) { Name = "editField", Text = "Some Text", HAnchor = HAnchor.ParentCenter, VAnchor = VAnchor.ParentCenter, }; systemWindow.AddChild(editField); AutomationTesterHarness testHarness = AutomationTesterHarness.ShowWindowAndExectueTests(systemWindow, testToRun, 15); Assert.IsTrue(testHarness.AllTestsPassed); Assert.IsTrue(testHarness.TestCount == 4); // make sure we can all our tests }
public async Task SelectAllOnFocusCanStillClickAfterSelection() { var editField = new TextEditWidget(pixelWidth: 200) { Name = "editField", Text = "Some Text", HAnchor = HAnchor.Center, VAnchor = VAnchor.Center, }; var systemWindow = new SystemWindow(300, 200) { BackgroundColor = Color.Gray, }; systemWindow.AddChild(editField); Task TestToRun(AutomationRunner testRunner) { editField.SelectAllOnFocus = true; testRunner.Delay(1); testRunner.ClickByName(editField.Name); editField.SelectAllOnFocus = true; testRunner.Type("123"); Assert.AreEqual("123", editField.Text, "Text input on newly focused control should replace selection"); testRunner.ClickByName(editField.Name); //testRunner.WaitFor(() => editField.ContainsFocus); testRunner.Type("123"); //testRunner.WaitFor(() => "123123" == editField.Text, maxSeconds: 60); // NOTE: Used to get intermittent failures here. These issues might have been sorted out now. Assert.AreEqual("123123", editField.Text, "Text should be appended if control is focused and has already received input"); return(Task.CompletedTask); } await AutomationRunner.ShowWindowAndExecuteTests(systemWindow, TestToRun); }
public async Task SelectAllOnFocusCanStillClickAfterSelection() { var editField = new TextEditWidget(pixelWidth: 200) { Name = "editField", Text = "Some Text", HAnchor = HAnchor.ParentCenter, VAnchor = VAnchor.ParentCenter, }; var systemWindow = new SystemWindow(300, 200) { BackgroundColor = RGBA_Bytes.Gray, }; systemWindow.AddChild(editField); AutomationTest testToRun = (testRunner) => { editField.SelectAllOnFocus = true; testRunner.Wait(1); testRunner.ClickByName(editField.Name, 1); editField.SelectAllOnFocus = true; testRunner.Type("123"); Assert.AreEqual("123", editField.Text, "Text input on newly focused control should replace selection"); testRunner.ClickByName(editField.Name, 1); testRunner.Wait(.2); testRunner.Type("123"); Assert.AreEqual("123123", editField.Text, "Text should be appended if control is focused and has already received input"); return(Task.FromResult(0)); }; await AutomationRunner.ShowWindowAndExecuteTests(systemWindow, testToRun, 15); }
public async Task SelectAllOnFocusCanStillClickAfterSelection() { var editField = new TextEditWidget(pixelWidth: 200) { Name = "editField", Text = "Some Text", HAnchor = HAnchor.Center, VAnchor = VAnchor.Center, }; var systemWindow = new SystemWindow(300, 200) { BackgroundColor = Color.Gray, }; systemWindow.AddChild(editField); Task TestToRun(AutomationRunner testRunner) { editField.SelectAllOnFocus = true; testRunner.Delay(1); testRunner.ClickByName(editField.Name); editField.SelectAllOnFocus = true; testRunner.Type("123"); Assert.AreEqual("123", editField.Text, "Text input on newly focused control should replace selection"); testRunner.ClickByName(editField.Name); testRunner.Delay(.2); testRunner.Type("123"); Assert.AreEqual("123123", editField.Text, "Text should be appended if control is focused and has already received input"); return(Task.CompletedTask); } await AutomationRunner.ShowWindowAndExecuteTests(systemWindow, TestToRun); }
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 = "", TypeFace typeFace = null) { this.Padding = new BorderDouble(3); this.BackgroundColor = Color.White; this.HAnchor = HAnchor.Fit; this.VAnchor = VAnchor.Fit; this.Border = 1; this.ActualTextEditWidget = new TextEditWidget(text, x, y, pointSize, pixelWidth, pixelHeight, multiLine, tabIndex: tabIndex, typeFace: typeFace) { VAnchor = VAnchor.Bottom }; this.ActualTextEditWidget.MinimumSize = new Vector2(Math.Max(ActualTextEditWidget.MinimumSize.X, pixelWidth), Math.Max(ActualTextEditWidget.MinimumSize.Y, pixelHeight)); this.AddChild(this.ActualTextEditWidget); this.AddChild(noContentFieldDescription = new TextWidget(messageWhenEmptyAndNotSelected, textColor: Color.Gray) { VAnchor = VAnchor.Top, AutoExpandBoundsToText = true }); SetNoContentFieldDescriptionVisibility(); }
public void VerifyFocusMakesTextWidgetEditable() { TextEditWidget editField = null; SystemWindow systemWindow = new SystemWindow(300, 200) { BackgroundColor = RGBA_Bytes.Black, }; bool firstDraw = true; Stopwatch testDiedTimer = Stopwatch.StartNew(); Action <AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) => { UiThread.RunOnIdle(editField.Focus); AutomationRunner testRunner = new AutomationRunner(); testRunner.Wait(1); // Now do the actions specific to this test. (replace this for new tests) testRunner.Type("Test Text"); resultsHarness.AddTestResult(editField.Text == "Test Text", "validate text is typed"); systemWindow.CloseOnIdle(); }; editField = new TextEditWidget(pixelWidth: 200) { HAnchor = HAnchor.ParentCenter, VAnchor = VAnchor.ParentCenter, }; systemWindow.AddChild(editField); AutomationTesterHarness testHarness = AutomationTesterHarness.ShowWindowAndExectueTests(systemWindow, testToRun, 10); Assert.IsTrue(testHarness.AllTestsPassed); Assert.IsTrue(testHarness.TestCount == 1); // make sure we can all our tests }
private static void ShowFileDialog(Action <string> dialogClosedHandler) { var systemWindow = new SystemWindow(600, 200) { Title = "TestAutomation File Input", BackgroundColor = Color.DarkGray }; var warningLabel = new TextWidget("This dialog should not appear outside of automation tests.\nNotify technical support if visible", pointSize: 15, textColor: Color.Pink) { Margin = new BorderDouble(20), VAnchor = VAnchor.Top, HAnchor = HAnchor.Stretch }; systemWindow.AddChild(warningLabel); var fileNameInput = new TextEditWidget(pixelWidth: 400) { VAnchor = VAnchor.Center, HAnchor = HAnchor.Stretch, Margin = new BorderDouble(30, 15), Name = "Automation Dialog TextEdit" }; fileNameInput.EnterPressed += (s, e) => systemWindow.CloseOnIdle(); systemWindow.AddChild(fileNameInput); systemWindow.Load += (s, e) => fileNameInput.Focus(); systemWindow.Closed += (s, e) => { dialogClosedHandler(fileNameInput.Text); }; systemWindow.ShowAsSystemWindow(); }
public MHTextEditWidget(string text, ThemeConfig theme, double pixelWidth = 0, double pixelHeight = 0, bool multiLine = false, int tabIndex = 0, string messageWhenEmptyAndNotSelected = "", TypeFace typeFace = null) { this.Padding = new BorderDouble(3); this.HAnchor = HAnchor.Fit; this.VAnchor = VAnchor.Fit; this.Border = 1; this.theme = theme; this.ActualTextEditWidget = new TextEditWidget(text, 0, 0, theme.DefaultFontSize, pixelWidth, pixelHeight, multiLine, tabIndex: tabIndex, typeFace: typeFace) { VAnchor = VAnchor.Bottom, BackgroundColor = Color.Transparent }; var internalWidget = this.ActualTextEditWidget.InternalTextEditWidget; internalWidget.TextColor = theme.EditFieldColors.Inactive.TextColor; internalWidget.FocusChanged += (s, e) => { internalWidget.TextColor = (internalWidget.Focused) ? theme.EditFieldColors.Focused.TextColor : theme.EditFieldColors.Inactive.TextColor; noContentFieldDescription.TextColor = (internalWidget.Focused) ? theme.EditFieldColors.Focused.TextColor : theme.EditFieldColors.Inactive.TextColor; }; this.ActualTextEditWidget.InternalTextEditWidget.BackgroundColor = Color.Transparent; this.ActualTextEditWidget.MinimumSize = new Vector2(Math.Max(ActualTextEditWidget.MinimumSize.X, pixelWidth), Math.Max(ActualTextEditWidget.MinimumSize.Y, pixelHeight)); this.AddChild(this.ActualTextEditWidget); this.AddChild(noContentFieldDescription = new TextWidget(messageWhenEmptyAndNotSelected, textColor: Color.Gray) { VAnchor = VAnchor.Top, AutoExpandBoundsToText = true }); SetNoContentFieldDescriptionVisibility(); }
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 hidden letters) this.RemoveChild(noContentFieldDescription); passwordCoverText = new TextEditWidget(text, x, y, pointSize, pixelWidth, pixelHeight, multiLine) { Selectable = false, HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Bottom }; passwordCoverText.MinimumSize = new Vector2(Math.Max(passwordCoverText.MinimumSize.X, pixelWidth), Math.Max(passwordCoverText.MinimumSize.Y, pixelHeight)); this.AddChild(passwordCoverText); this.ActualTextEditWidget.TextChanged += (sender, e) => { passwordCoverText.Text = new string('●', this.ActualTextEditWidget.Text.Length); }; // put in back in after the hidden text noContentFieldDescription.ClearRemovedFlag(); this.AddChild(noContentFieldDescription); }
public MainWindow() : base(1000, 1000) { //new BoxPrimitive(8, 20, 10); //rootUnion.Add(new Translate(new BoxPrimitive(10, 10, 20), 5, 10, 5)); //rootUnion.Add(new Box(8, 20, 10)); ////rootUnion.Add(new Cylinder(10, 40)); //rootUnion.Add(new Translate(new Sphere(radius: 30), 15, 20, 40)); //not implemented //var testUnion = new Translate(new Box(10, 10, 20) - new Box(8, 20, 10), 5, 5, 5); //new Difference( //rootUnion.Add(new LinearExtrude(new double[] { 1.1, 2.2, 3.3, 6.3 }, 7)); //not implemented //rootUnion.Add(testUnion); //rootUnion.Box(8, 20, 40); SuspendLayout(); varticalSplitter = new Splitter(); varticalSplitter.SplitterDistance = 700; // panel 1 stuff #region TextSide textSide = new FlowLayoutWidget(FlowDirection.TopToBottom); objectEditorView = new GuiWidget(); objectEditorList = new FlowLayoutWidget(); objectEditorList.AddChild(new TextEditWidget("Text in box")); objectEditorView.AddChild(objectEditorList); objectEditorView.BackgroundColor = RGBA_Bytes.LightGray; //matterScriptEditor.LocalBounds = new RectangleDouble(0, 0, 200, 300); textSide.AddChild(objectEditorView); var code = new StringBuilder(); code.AppendLine("var rootUnion = new MatterHackers.Csg.Operations.Union(\"root\");"); code.AppendLine("//rootUnion.Add(new LinearExtrude(new double[] { 1.1, 2.2, 3.3, 6.3 }, 7));"); code.AppendLine("rootUnion.Add(new Translate(new Cylinder(10, 40), 5, 10, 5));"); code.AppendLine("rootUnion.Add(new BoxPrimitive(8, 20, 10));"); code.AppendLine("for (int i = 0; i != 10; i++)"); code.AppendLine("{"); code.AppendLine(" rootUnion.Add(new Translate(new BoxPrimitive(18, i, 14), 10 * i, 10+i, 10+i*i));"); code.AppendLine("}"); code.AppendLine("return rootUnion;"); //code.AppendLine("MatterHackers.PolygonMesh.Mesh mesh = new MatterHackers.PolygonMesh.Mesh();"); //code.AppendLine("var v0 = mesh.CreateVertex(new Vector3(1, 0, 1)); // V0"); //code.AppendLine("var v1 = mesh.CreateVertex(new Vector3(1, 0, -1)); // V1"); //code.AppendLine("var v2 = mesh.CreateVertex(new Vector3(-1, 0, -1)); // V2"); //code.AppendLine("var v3 = mesh.CreateVertex(new Vector3(-1, 0, 1)); // V3"); //code.AppendLine("var v4 = mesh.CreateVertex(new Vector3(0, 1, 0)); // V4"); //code.AppendLine("mesh.CreateFace(new Vertex[] { v0, v1, v2, v3 });"); //code.AppendLine("mesh.CreateFace(new Vertex[] { v3, v0, v4 });"); //code.AppendLine("mesh.CreateFace(new Vertex[] { v0, v1, v4 });"); //code.AppendLine("mesh.CreateFace(new Vertex[] { v1, v2, v4 });"); //code.AppendLine("mesh.CreateFace(new Vertex[] { v2, v3, v4 });"); //code.AppendLine("RenderMeshToGl.Render(mesh, new RGBA_Floats(.3, .8, 7)); "); textEdit = new TextEditWidget(code.ToString().Replace('\r', '\n')); // textEdit.BackgroundColor = RGBA_Bytes.Yellow; textEdit.TextChanged += Hello_TextChanged; textEdit.Multiline = true; // hello.Text = code.ToString(); textSide.AddChild(textEdit); outputEdit = new TextEditWidget("Hello world!") { Multiline = true }; outputEdit.AnchorAll(); textSide.AddChild(outputEdit); textSide.AnchorAll(); textEdit.AnchorAll(); objectEditorList.AnchorAll(); textSide.BoundsChanged += textSide_BoundsChanged; #region Buttons FlowLayoutWidget topButtonBar = new FlowLayoutWidget(); Button load = new Button("Load OpenSharpCAD Script"); load.Click += loadMatterScript_Click; topButtonBar.AddChild(load); Button save = new Button("Save OpenSharpCAD Script"); save.Click += SaveMatterScript_Click; topButtonBar.AddChild(save); outputScad = new Button("Output SCAD"); outputScad.Click += outputScad_Click; topButtonBar.AddChild(outputScad); textSide.AddChild(topButtonBar); FlowLayoutWidget bottomButtonBar = new FlowLayoutWidget(); //Button loadStl = new Button("Load STL"); //loadStl.Click += LoadStl_Click; //bottomButtonBar.AddChild(loadStl); textSide.AddChild(bottomButtonBar); #endregion #endregion // pannel 2 stuff FlowLayoutWidget renderSide = new FlowLayoutWidget(FlowDirection.TopToBottom); renderSide.AnchorAll(); trackBallWidget = new TrackballTumbleWidget(); trackBallWidget.DrawGlContent += glLightedView_DrawGlContent; trackBallWidget.TrackBallController.Scale = 0.05; renderSide.AddChild(trackBallWidget); varticalSplitter.Panel2.AddChild(renderSide); varticalSplitter.Panel1.AddChild(textSide); ResumeLayout(); AnchorAll(); varticalSplitter.AnchorAll(); textSide.AnchorAll(); trackBallWidget.AnchorAll(); AddChild(varticalSplitter); BackgroundColor = RGBA_Bytes.White; Compile(); }
public override void OnLoad(EventArgs args) { TextEditWidget.Focus(); base.OnLoad(args); }
public void TextChangedEventsTests() { GuiWidget container = new GuiWidget(); container.Name = "container"; container.LocalBounds = new RectangleDouble(0, 0, 200, 200); TextEditWidget editField1 = new TextEditWidget("", 0, 0, pixelWidth: 20); editField1.Name = "editField1"; Assert.IsTrue(editField1.BoundsRelativeToParent.Top < 40, "We make this assumption in the code below, so make sure it's true."); bool textField1EditComplete = false; editField1.EditComplete += (sender, e) => { textField1EditComplete = true; }; bool textField1LostFocus = false; editField1.LostFocus += (sender, e) => { textField1LostFocus = true; }; bool textField1GotFocus = false; editField1.GotFocus += (sender, e) => { textField1GotFocus = true; }; container.AddChild(editField1); TextEditWidget editField2 = new TextEditWidget("", 0, 40, pixelWidth: 20); editField2.Name = "editField2"; container.AddChild(editField2); // mouse select on the control when it contains nothing container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 1, 1, 0)); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, 1, 1, 0)); Assert.IsTrue(textField1GotFocus); Assert.IsFalse(textField1EditComplete); SendKey(Keys.B, 'b', container); Assert.IsTrue(editField1.Text == "b"); Assert.IsFalse(textField1EditComplete, "We do not change with each keystroke."); SendKey(Keys.Enter, '\n', container); Assert.IsTrue(textField1EditComplete, "Enter must send a EditComplete if changed."); textField1EditComplete = false; SendKey(Keys.A, 'a', container); Assert.IsTrue(editField1.Text == "ba"); Assert.IsFalse(textField1EditComplete, "We do not change with each keystroke."); Assert.IsFalse(textField1LostFocus); textField1GotFocus = false; container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 1, 41, 0)); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, 1, 1, 0)); SendKey(Keys.E, 'e', container); Assert.IsTrue(textField1LostFocus); Assert.IsTrue(textField1EditComplete, "Loosing focus should send a text changed."); Assert.IsTrue(editField1.Text == "ba"); Assert.IsTrue(editField2.Text == "e"); textField1EditComplete = false; textField1LostFocus = false; container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 1, 1, 0)); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, 1, 1, 0)); Assert.IsFalse(textField1LostFocus); Assert.IsFalse(textField1EditComplete); container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 1, 41, 0)); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, 1, 1, 0)); Assert.IsTrue(textField1LostFocus); Assert.IsFalse(textField1EditComplete, "The text did not change even though we lost focus we should not call textChanged."); container.Close(); }
public void TextEditGetsFocusTests() { GuiWidget container = new GuiWidget(); container.Name = "container"; container.LocalBounds = new RectangleDouble(0, 0, 200, 200); TextEditWidget editField1 = new TextEditWidget("", 0, 0, pixelWidth: 160); editField1.Name = "editField1"; container.AddChild(editField1); TextEditWidget editField2 = new TextEditWidget("", 0, 20, pixelWidth: 160); editField2.Name = "editField2"; container.AddChild(editField2); // select no edit field Assert.IsTrue(editField1.Text == ""); SendKey(Keys.D, 'a', container); Assert.IsTrue(editField1.Text == ""); Assert.IsTrue(editField2.Text == ""); // select edit field 1 container.OnMouseMove(new MouseEventArgs(MouseButtons.Left, 1, 1, 1, 0)); // we move into the widget to make sure we have seprated focus and enter events. Assert.IsTrue(editField1.ContainsFocus == false); Assert.IsTrue(editField1.Focused == false); container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 1, 1, 0)); Assert.IsTrue(editField1.ContainsFocus == true); Assert.IsTrue(editField1.Focused == false, "The internal text widget must be focused."); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 1, 1, 0)); Assert.IsTrue(editField1.ContainsFocus == true); Assert.IsTrue(editField1.Focused == false); SendKey(Keys.B, 'b', container); Assert.IsTrue(editField1.Text == "b", "It should have b a in it."); container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 150, 1, 0)); Assert.IsTrue(editField1.ContainsFocus == true); Assert.IsTrue(editField1.Focused == false, "The internal text widget must be focused."); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 150, 1, 0)); Assert.IsTrue(editField1.ContainsFocus == true); Assert.IsTrue(editField1.Focused == false); SendKey(Keys.D, 'c', container); Assert.IsTrue(editField1.Text == "bc", "It should have b a in it."); // select edit field 2 container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 1, 21, 0)); Assert.IsTrue(editField2.ContainsFocus == true); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 1, 21, 0)); SendKey(Keys.D, 'd', container); Assert.IsTrue(editField1.Text == "bc", "It should have a bc in it."); Assert.IsTrue(editField2.Text == "d", "It should have d in it."); container.Close(); }
public void AddThenDeleteCausesNoVisualChange() { GuiWidget container = new GuiWidget(); container.DoubleBuffer = true; container.LocalBounds = new RectangleDouble(0, 0, 200, 200); TextEditWidget editField1 = new TextEditWidget("Test", 10, 10, pixelWidth: 50); container.AddChild(editField1); container.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White); container.OnDraw(container.BackBuffer.NewGraphics2D()); ImageBuffer beforeEditImage = new ImageBuffer(container.BackBuffer); RectangleDouble beforeLocalBounds = editField1.LocalBounds; Vector2 beforeOrigin = editField1.OriginRelativeParent; OutputImage(beforeEditImage, "z text un-edited.tga"); container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 10, 10, 0)); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 10, 10, 0)); Assert.IsTrue(editField1.ContainsFocus == true); SendKey(Keys.B, 'b', container); Assert.IsTrue(editField1.Text == "bTest", "It should have b a in it."); RectangleDouble afterBLocalBounds = editField1.LocalBounds; Assert.IsTrue(beforeLocalBounds.Bottom == afterBLocalBounds.Bottom && beforeLocalBounds.Top == afterBLocalBounds.Top); SendKey(Keys.Back, ' ', container); Assert.IsTrue(editField1.Text == "Test", "It should not have b a in it."); RectangleDouble afterLocalBounds = editField1.LocalBounds; Vector2 afterOrigin = editField1.OriginRelativeParent; Assert.IsTrue(beforeLocalBounds == afterLocalBounds); Assert.IsTrue(beforeOrigin == afterOrigin); // click off it so the cursor is not in it. container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 1, 1, 0)); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 1, 1, 0)); Assert.IsTrue(editField1.Focused == false); container.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White); container.OnDraw(container.BackBuffer.NewGraphics2D()); OutputImage(container.BackBuffer, "z text edited.tga"); Assert.IsTrue(container.BackBuffer == beforeEditImage); }
public void TextWidgetVisibleTest() { { GuiWidget rectangleWidget = new GuiWidget(100, 50); TextWidget itemToAdd = new TextWidget("test Item", 10, 10); rectangleWidget.AddChild(itemToAdd); rectangleWidget.DoubleBuffer = true; rectangleWidget.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White); rectangleWidget.OnDraw(rectangleWidget.BackBuffer.NewGraphics2D()); ImageBuffer textOnly = new ImageBuffer(75, 20, 32, new BlenderBGRA()); textOnly.NewGraphics2D().Clear(RGBA_Bytes.White); textOnly.NewGraphics2D().DrawString("test Item", 1, 1); if (saveImagesForDebug) { ImageTgaIO.Save(rectangleWidget.BackBuffer, "-rectangleWidget.tga"); //ImageTgaIO.Save(itemToAdd.Children[0].BackBuffer, "-internalTextWidget.tga"); ImageTgaIO.Save(textOnly, "-textOnly.tga"); } Assert.IsTrue(rectangleWidget.BackBuffer.FindLeastSquaresMatch(textOnly, 1), "TextWidgets need to be drawing."); rectangleWidget.Close(); } { GuiWidget rectangleWidget = new GuiWidget(100, 50); TextEditWidget itemToAdd = new TextEditWidget("test Item", 10, 10); rectangleWidget.AddChild(itemToAdd); rectangleWidget.DoubleBuffer = true; rectangleWidget.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White); rectangleWidget.OnDraw(rectangleWidget.BackBuffer.NewGraphics2D()); ImageBuffer textOnly = new ImageBuffer(75, 20, 32, new BlenderBGRA()); textOnly.NewGraphics2D().Clear(RGBA_Bytes.White); TypeFacePrinter stringPrinter = new TypeFacePrinter("test Item", 12); IVertexSource offsetText = new VertexSourceApplyTransform(stringPrinter, Affine.NewTranslation(1, -stringPrinter.LocalBounds.Bottom)); textOnly.NewGraphics2D().Render(offsetText, RGBA_Bytes.Black); if (saveImagesForDebug) { ImageTgaIO.Save(rectangleWidget.BackBuffer, "-rectangleWidget.tga"); //ImageTgaIO.Save(itemToAdd.Children[0].BackBuffer, "-internalTextWidget.tga"); ImageTgaIO.Save(textOnly, "-textOnly.tga"); } Assert.IsTrue(rectangleWidget.BackBuffer.FindLeastSquaresMatch(textOnly, 1), "TextWidgets need to be drawing."); rectangleWidget.Close(); } }
public void SelectAllOnFocusCanStillClickAfterSelection() { TextEditWidget editField = null; SystemWindow systemWindow = new SystemWindow(300, 200) { BackgroundColor = RGBA_Bytes.Black, }; Action<AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) => { editField.SelectAllOnFocus = true; AutomationRunner testRunner = new AutomationRunner(); testRunner.Wait(1); resultsHarness.AddTestResult(testRunner.ClickByName(editField.Name, 1)); editField.SelectAllOnFocus = true; testRunner.Type("123"); resultsHarness.AddTestResult(editField.Text == "123", "on enter we have selected all and replaced the text"); resultsHarness.AddTestResult(testRunner.ClickByName(editField.Name, 1)); testRunner.Type("123"); resultsHarness.AddTestResult(editField.Text == "123123", "we already have the contol selected so don't select all again."); systemWindow.CloseOnIdle(); }; editField = new TextEditWidget(pixelWidth: 200) { Name = "editField", Text = "Some Text", HAnchor = HAnchor.ParentCenter, VAnchor = VAnchor.ParentCenter, }; systemWindow.AddChild(editField); AutomationTesterHarness testHarness = AutomationTesterHarness.ShowWindowAndExectueTests(systemWindow, testToRun, 15); Assert.IsTrue(testHarness.AllTestsPassed); Assert.IsTrue(testHarness.TestCount == 4); // make sure we can all our tests }
public void TextChangedEventsTests() { var container = new GuiWidget { Name = "container", LocalBounds = new RectangleDouble(0, 0, 200, 200) }; var editField1 = new TextEditWidget("", 0, 0, pixelWidth: 20) { Name = "editField1" }; Assert.IsTrue(editField1.BoundsRelativeToParent.Top < 40, "We make this assumption in the code below, so make sure it's true."); bool textField1EditComplete = false; editField1.EditComplete += (sender, e) => { textField1EditComplete = true; }; bool textField1LostFocus = false; bool textField1GotFocus = false; editField1.ContainsFocusChanged += (sender, e) => { if ((sender as GuiWidget) != null && (sender as GuiWidget).ContainsFocus) { textField1GotFocus = true; } else { textField1LostFocus = true; } }; container.AddChild(editField1); var editField2 = new TextEditWidget("", 0, 40, pixelWidth: 20) { Name = "editField2" }; container.AddChild(editField2); // mouse select on the control when it contains nothing container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 1, 1, 0)); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, 1, 1, 0)); Assert.IsTrue(textField1GotFocus); Assert.IsFalse(textField1EditComplete); SendKey(Keys.B, 'b', container); Assert.IsTrue(editField1.Text == "b"); Assert.IsFalse(textField1EditComplete, "We do not change with each keystroke."); SendKey(Keys.Enter, '\n', container); Assert.IsTrue(textField1EditComplete, "Enter must send a EditComplete if changed."); textField1EditComplete = false; SendKey(Keys.A, 'a', container); Assert.IsTrue(editField1.Text == "ba"); Assert.IsFalse(textField1EditComplete, "We do not change with each keystroke."); Assert.IsFalse(textField1LostFocus); textField1GotFocus = false; container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 1, 41, 0)); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, 1, 1, 0)); SendKey(Keys.E, 'e', container); Assert.IsTrue(textField1LostFocus); Assert.IsTrue(textField1EditComplete, "Loosing focus should send a text changed."); Assert.IsTrue(editField1.Text == "ba"); Assert.IsTrue(editField2.Text == "e"); textField1EditComplete = false; textField1LostFocus = false; container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 1, 1, 0)); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, 1, 1, 0)); Assert.IsFalse(textField1LostFocus); Assert.IsFalse(textField1EditComplete); container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 1, 41, 0)); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, 1, 1, 0)); Assert.IsTrue(textField1LostFocus); Assert.IsFalse(textField1EditComplete, "The text did not change even though we lost focus we should not call textChanged."); container.Close(); }
public void TextEditingSpecialKeysWork() { { GuiWidget container = new GuiWidget(); container.DoubleBuffer = true; container.LocalBounds = new RectangleDouble(0, 0, 200, 200); TextEditWidget textEdit = new TextEditWidget("some starting text"); container.AddChild(textEdit); container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 1, textEdit.Height - 1, 0)); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 1, textEdit.Height - 1, 0)); Assert.IsTrue(textEdit.CharIndexToInsertBefore == 0); Assert.IsTrue(textEdit.TopLeftOffset.y == 0); Assert.IsTrue(textEdit.Text == "some starting text"); // this is to select some text SendKey(Keys.Shift | Keys.Control | Keys.Right, ' ', container); Assert.IsTrue(textEdit.Selection == "some "); Assert.IsTrue(textEdit.Text == "some starting text"); // this is to prove that we don't loose the selection when pressing Control SendKeyDown(Keys.Control, container); Assert.IsTrue(textEdit.Selection == "some "); Assert.IsTrue(textEdit.Text == "some starting text"); // this is to prove that we don't loose the selection when pressing Shift SendKeyDown(Keys.Shift, container); Assert.IsTrue(textEdit.Text == "some starting text"); Assert.IsTrue(textEdit.Selection == "some "); SendKeyDown(Keys.Right, container); Assert.IsTrue(textEdit.Selection == ""); SendKey(Keys.Shift | Keys.Control | Keys.Left, ' ', container); Assert.IsTrue(textEdit.Selection == "some "); SendKey(Keys.Delete, ' ', container); Assert.IsTrue(textEdit.Text == "starting text"); SendKey(Keys.Shift | Keys.Control | Keys.Right, ' ', container); Assert.IsTrue(textEdit.Selection == "starting "); #if(!__ANDROID__) // if this fails add // GuiHalWidget.SetClipboardFunctions(System.Windows.Forms.Clipboard.GetText, System.Windows.Forms.Clipboard.SetText, System.Windows.Forms.Clipboard.ContainsText); // before you call the unit tests Clipboard.SetSystemClipboard(new WindowsFormsClipboard()); SendKey(Keys.Control | Keys.C, 'c', container); Assert.IsTrue(textEdit.Selection == "starting "); Assert.IsTrue(textEdit.Text == "starting text"); SendKeyDown(Keys.Right, container); // move to the right SendKey(Keys.Control | Keys.V, 'v', container); Assert.IsTrue(textEdit.Text == "starting starting text"); #endif container.Close(); } }
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; }
private GuiWidget CreateSettingInfoUIControls(OrganizerSettingsData settingData, double minSettingNameWidth) { GuiWidget container = new GuiWidget(); FlowLayoutWidget leftToRightLayout = new FlowLayoutWidget(); bool addQualityOverlay = false; bool addMaterialOverlay = false; RGBA_Bytes qualityOverlayColor = new RGBA_Bytes(255, 255, 0, 40); RGBA_Bytes materialOverlayColor = new RGBA_Bytes(255, 127, 0, 40); if (ActiveSliceSettings.Instance.Contains(settingData.SlicerConfigName)) { int intEditWidth = 60; int doubleEditWidth = 60; int vectorXYEditWidth = 60; int multiLineEditHeight = 60; string sliceSettingValue = ActiveSliceSettings.Instance.GetActiveValue(settingData.SlicerConfigName); leftToRightLayout.Margin = new BorderDouble(0, 2); leftToRightLayout.Padding = new BorderDouble(3); leftToRightLayout.HAnchor = Agg.UI.HAnchor.ParentLeftRight; if (settingData.DataEditType != OrganizerSettingsData.DataEditTypes.MULTI_LINE_TEXT) { string convertedNewLines = settingData.PresentationName.Replace("\\n ", "\n"); convertedNewLines = convertedNewLines.Replace("\\n", "\n"); convertedNewLines = LocalizedString.Get(convertedNewLines); TextWidget settingName = new TextWidget(convertedNewLines); settingName.TextColor = ActiveTheme.Instance.PrimaryTextColor; if (ActiveSliceSettings.Instance.SettingExistsInLayer(settingData.SlicerConfigName, 3)) { addMaterialOverlay = true; } else if (ActiveSliceSettings.Instance.SettingExistsInLayer(settingData.SlicerConfigName, 2)) { addQualityOverlay = true; } settingName.Width = minSettingNameWidth; //settingName.MinimumSize = new Vector2(minSettingNameWidth, settingName.MinimumSize.y); leftToRightLayout.AddChild(settingName); } switch (settingData.DataEditType) { case OrganizerSettingsData.DataEditTypes.INT: { int currentValue = 0; int.TryParse(sliceSettingValue, out currentValue); MHNumberEdit intEditWidget = new MHNumberEdit(currentValue, pixelWidth: intEditWidth, tabIndex: tabIndexForItem++); intEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((NumberEdit)sender).Value.ToString()); }; leftToRightLayout.AddChild(intEditWidget); leftToRightLayout.AddChild(getSettingInfoData(settingData)); } break; case OrganizerSettingsData.DataEditTypes.DOUBLE: { double currentValue = 0; double.TryParse(sliceSettingValue, out currentValue); MHNumberEdit doubleEditWidget = new MHNumberEdit(currentValue, allowNegatives: true, allowDecimals: true, pixelWidth: doubleEditWidth, tabIndex: tabIndexForItem++); doubleEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((NumberEdit)sender).Value.ToString()); }; leftToRightLayout.AddChild(doubleEditWidget); leftToRightLayout.AddChild(getSettingInfoData(settingData)); } break; case OrganizerSettingsData.DataEditTypes.POSITIVE_DOUBLE: { double currentValue = 0; double.TryParse(sliceSettingValue, out currentValue); MHNumberEdit doubleEditWidget = new MHNumberEdit(currentValue, allowDecimals: true, pixelWidth: doubleEditWidth, tabIndex: tabIndexForItem++); doubleEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((NumberEdit)sender).Value.ToString()); }; leftToRightLayout.AddChild(doubleEditWidget); leftToRightLayout.AddChild(getSettingInfoData(settingData)); } break; case OrganizerSettingsData.DataEditTypes.OFFSET: { double currentValue = 0; double.TryParse(sliceSettingValue, out currentValue); MHNumberEdit doubleEditWidget = new MHNumberEdit(currentValue, allowDecimals: true, allowNegatives: true, pixelWidth: doubleEditWidth, tabIndex: tabIndexForItem++); doubleEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((NumberEdit)sender).Value.ToString()); }; leftToRightLayout.AddChild(doubleEditWidget); leftToRightLayout.AddChild(getSettingInfoData(settingData)); } break; case OrganizerSettingsData.DataEditTypes.DOUBLE_OR_PERCENT: { MHTextEditWidget stringEdit = new MHTextEditWidget(sliceSettingValue, pixelWidth: 60, tabIndex: tabIndexForItem++); stringEdit.ActualTextEditWidget.EditComplete += (sender, e) => { TextEditWidget textEditWidget = (TextEditWidget)sender; string text = textEditWidget.Text; text = text.Trim(); bool isPercent = text.Contains("%"); if (isPercent) { text = text.Substring(0, text.IndexOf("%")); } double result; double.TryParse(text, out result); text = result.ToString(); if (isPercent) { text += "%"; } textEditWidget.Text = text; SaveSetting(settingData.SlicerConfigName, textEditWidget.Text); }; leftToRightLayout.AddChild(stringEdit); leftToRightLayout.AddChild(getSettingInfoData(settingData)); } break; case OrganizerSettingsData.DataEditTypes.CHECK_BOX: { CheckBox checkBoxWidget = new CheckBox(""); checkBoxWidget.VAnchor = Agg.UI.VAnchor.ParentBottom; checkBoxWidget.TextColor = ActiveTheme.Instance.PrimaryTextColor; checkBoxWidget.Checked = (sliceSettingValue == "1"); checkBoxWidget.CheckedStateChanged += (sender, e) => { if (((CheckBox)sender).Checked) { SaveSetting(settingData.SlicerConfigName, "1"); } else { SaveSetting(settingData.SlicerConfigName, "0"); } }; leftToRightLayout.AddChild(checkBoxWidget); } break; case OrganizerSettingsData.DataEditTypes.STRING: { MHTextEditWidget stringEdit = new MHTextEditWidget(sliceSettingValue, pixelWidth: 120, tabIndex: tabIndexForItem++); stringEdit.ActualTextEditWidget.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((TextEditWidget)sender).Text); }; leftToRightLayout.AddChild(stringEdit); } break; case OrganizerSettingsData.DataEditTypes.MULTI_LINE_TEXT: { string convertedNewLines = sliceSettingValue.Replace("\\n", "\n"); MHTextEditWidget stringEdit = new MHTextEditWidget(convertedNewLines, pixelWidth: 320, pixelHeight: multiLineEditHeight, multiLine: true, tabIndex: tabIndexForItem++); stringEdit.ActualTextEditWidget.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((TextEditWidget)sender).Text.Replace("\n", "\\n")); }; leftToRightLayout.AddChild(stringEdit); } break; case OrganizerSettingsData.DataEditTypes.LIST: { StyledDropDownList selectableOptions = new StyledDropDownList("None", maxHeight: 200); selectableOptions.Margin = new BorderDouble(); string[] listItems = settingData.ExtraSettings.Split(','); foreach (string listItem in listItems) { MenuItem newItem = selectableOptions.AddItem(listItem); if (newItem.Text == sliceSettingValue) { selectableOptions.SelectedLabel = sliceSettingValue; } newItem.Selected += (sender, e) => { MenuItem menuItem = ((MenuItem)sender); SaveSetting(settingData.SlicerConfigName, menuItem.Text); }; } leftToRightLayout.AddChild(selectableOptions); } break; case OrganizerSettingsData.DataEditTypes.VECTOR2: { string[] xyValueStrings = sliceSettingValue.Split(','); if (xyValueStrings.Length != 2) { xyValueStrings = new string[] { "0", "0" }; } double currentXValue = 0; double.TryParse(xyValueStrings[0], out currentXValue); MHNumberEdit xEditWidget = new MHNumberEdit(currentXValue, allowDecimals: true, pixelWidth: vectorXYEditWidth, tabIndex: tabIndexForItem++); double currentYValue = 0; double.TryParse(xyValueStrings[1], out currentYValue); MHNumberEdit yEditWidget = new MHNumberEdit(currentYValue, allowDecimals: true, pixelWidth: vectorXYEditWidth, tabIndex: tabIndexForItem++); { xEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, xEditWidget.ActuallNumberEdit.Value.ToString() + "," + yEditWidget.ActuallNumberEdit.Value.ToString()); }; leftToRightLayout.AddChild(xEditWidget); TextWidget xText = new TextWidget("x"); xText.TextColor = ActiveTheme.Instance.PrimaryTextColor; xText.Margin = new BorderDouble(5, 0); leftToRightLayout.AddChild(xText); } { yEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, xEditWidget.ActuallNumberEdit.Value.ToString() + "," + yEditWidget.ActuallNumberEdit.Value.ToString()); }; leftToRightLayout.AddChild(yEditWidget); TextWidget yText = new TextWidget("y"); yText.TextColor = ActiveTheme.Instance.PrimaryTextColor; yText.Margin = new BorderDouble(5, 0); leftToRightLayout.AddChild(yText); } } break; case OrganizerSettingsData.DataEditTypes.OFFSET2: { string[] xyValueStrings = sliceSettingValue.Split('x'); if (xyValueStrings.Length != 2) { xyValueStrings = new string[] { "0", "0" }; } double currentXValue = 0; double.TryParse(xyValueStrings[0], out currentXValue); MHNumberEdit xEditWidget = new MHNumberEdit(currentXValue, allowDecimals: true, allowNegatives: true, pixelWidth: vectorXYEditWidth, tabIndex: tabIndexForItem++); double currentYValue = 0; double.TryParse(xyValueStrings[1], out currentYValue); MHNumberEdit yEditWidget = new MHNumberEdit(currentYValue, allowDecimals: true, allowNegatives: true, pixelWidth: vectorXYEditWidth, tabIndex: tabIndexForItem++); { xEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, xEditWidget.ActuallNumberEdit.Value.ToString() + "x" + yEditWidget.ActuallNumberEdit.Value.ToString()); }; leftToRightLayout.AddChild(xEditWidget); TextWidget xText = new TextWidget("x"); xText.TextColor = ActiveTheme.Instance.PrimaryTextColor; xText.Margin = new BorderDouble(5, 0); leftToRightLayout.AddChild(xText); } { yEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, xEditWidget.ActuallNumberEdit.Value.ToString() + "x" + yEditWidget.ActuallNumberEdit.Value.ToString()); }; leftToRightLayout.AddChild(yEditWidget); TextWidget yText = new TextWidget("y"); yText.TextColor = ActiveTheme.Instance.PrimaryTextColor; yText.Margin = new BorderDouble(5, 0); leftToRightLayout.AddChild(yText); } } break; default: TextWidget missingSetting = new TextWidget(String.Format("Missing the setting for '{0}'.", settingData.DataEditType.ToString())); missingSetting.TextColor = ActiveTheme.Instance.PrimaryTextColor; missingSetting.BackgroundColor = RGBA_Bytes.Red; leftToRightLayout.AddChild(missingSetting); break; } } else // the setting we think we are adding is not in the config.ini it may have been depricated { TextWidget settingName = new TextWidget(String.Format("Setting '{0}' not found in config.ini", settingData.SlicerConfigName)); settingName.TextColor = ActiveTheme.Instance.PrimaryTextColor; settingName.MinimumSize = new Vector2(minSettingNameWidth, settingName.MinimumSize.y); leftToRightLayout.AddChild(settingName); leftToRightLayout.BackgroundColor = RGBA_Bytes.Red; } container.HAnchor = HAnchor.ParentLeftRight; container.VAnchor = VAnchor.FitToChildren; container.AddChild(leftToRightLayout); if (addQualityOverlay || addMaterialOverlay) { SettingPresetOverlay overlay = new SettingPresetOverlay(); overlay.HAnchor = HAnchor.ParentLeftRight; overlay.VAnchor = Agg.UI.VAnchor.ParentBottomTop; SettingPresetClick clickToEdit = new SettingPresetClick(); clickToEdit.HAnchor = HAnchor.ParentLeftRight; clickToEdit.VAnchor = Agg.UI.VAnchor.ParentBottomTop; clickToEdit.Visible = false; Button editButton = buttonFactory.Generate("Edit Preset".Localize().ToUpper()); editButton.HAnchor = Agg.UI.HAnchor.ParentCenter; editButton.VAnchor = Agg.UI.VAnchor.ParentCenter; clickToEdit.AddChild(editButton); if (addQualityOverlay) { overlay.OverlayColor = qualityOverlayColor; clickToEdit.OverlayColor = qualityOverlayColor; editButton.Click += (sender, e) => { if (ApplicationWidget.Instance.EditSlicePresetsWindow == null) { ApplicationWidget.Instance.EditSlicePresetsWindow = new SlicePresetsWindow(ReloadOptions, "Quality", "quality", false, ActivePrinterProfile.Instance.ActiveQualitySettingsID); ApplicationWidget.Instance.EditSlicePresetsWindow.Closed += (popupWindowSender, popupWindowSenderE) => { ApplicationWidget.Instance.EditSlicePresetsWindow = null; }; } else { ApplicationWidget.Instance.EditSlicePresetsWindow.ChangeToSlicePresetFromID(ActivePrinterProfile.Instance.ActiveQualitySettingsID); ApplicationWidget.Instance.EditSlicePresetsWindow.BringToFront(); } }; } else if (addMaterialOverlay) { overlay.OverlayColor = materialOverlayColor; clickToEdit.OverlayColor = materialOverlayColor; editButton.Click += (sender, e) => { if (ApplicationWidget.Instance.EditSlicePresetsWindow == null) { ApplicationWidget.Instance.EditSlicePresetsWindow = new SlicePresetsWindow(ReloadOptions, "Material", "material", false, ActivePrinterProfile.Instance.GetMaterialSetting(1)); ApplicationWidget.Instance.EditSlicePresetsWindow.Closed += (popupWindowSender, popupWindowSenderE) => { ApplicationWidget.Instance.EditSlicePresetsWindow = null; }; } else { ApplicationWidget.Instance.EditSlicePresetsWindow.ChangeToSlicePresetFromID(ActivePrinterProfile.Instance.GetMaterialSetting(1)); ApplicationWidget.Instance.EditSlicePresetsWindow.BringToFront(); } }; } container.MouseEnterBounds += (sender, e) => { UiThread.RunOnIdle((state) => { overlay.Visible = false; clickToEdit.Visible = true; }); }; container.MouseLeaveBounds += (sender, e) => { UiThread.RunOnIdle((state) => { overlay.Visible = true; clickToEdit.Visible = false; }); }; container.AddChild(overlay); container.AddChild(clickToEdit); } return(container); }
public void ScrollingToEndShowsEnd() { GuiWidget container = new GuiWidget(); container.DoubleBuffer = true; container.LocalBounds = new RectangleDouble(0, 0, 110, 30); TextEditWidget editField1 = new TextEditWidget("This is a nice long text string", 0, 0, pixelWidth: 100); container.AddChild(editField1); TextWidget firstWordText = new TextWidget("This"); RectangleDouble bounds = firstWordText.LocalBounds; bounds.Offset(bounds.Left, bounds.Bottom); firstWordText.LocalBounds = bounds; firstWordText.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White); firstWordText.OnDraw(firstWordText.BackBuffer.NewGraphics2D()); TextWidget lastWordText = new TextWidget("string"); bounds = lastWordText.LocalBounds; bounds.Offset(bounds.Left, bounds.Bottom); lastWordText.LocalBounds = bounds; lastWordText.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White); lastWordText.OnDraw(lastWordText.BackBuffer.NewGraphics2D()); container.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White); container.BackgroundColor = RGBA_Bytes.White; container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 1, 1, 0)); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, 1, 1, 0)); Assert.IsTrue(editField1.ContainsFocus == true); container.OnDraw(container.BackBuffer.NewGraphics2D()); OutputImage(firstWordText.BackBuffer, "Control - Left.tga"); OutputImage(lastWordText.BackBuffer, "Control - Right.tga"); OutputImage(container.BackBuffer, "Test - Start.tga"); Vector2 bestPosition; double bestLeastSquares; container.BackBuffer.FindLeastSquaresMatch(firstWordText.BackBuffer, out bestPosition, out bestLeastSquares); Assert.IsTrue(bestLeastSquares < 2000000); container.BackBuffer.FindLeastSquaresMatch(lastWordText.BackBuffer, out bestPosition, out bestLeastSquares); Assert.IsTrue(bestLeastSquares > 2000000); SendKeyDown(Keys.End, container); container.OnDraw(container.BackBuffer.NewGraphics2D()); OutputImage(container.BackBuffer, "Test - Scrolled.tga"); container.BackBuffer.FindLeastSquaresMatch(firstWordText.BackBuffer, out bestPosition, out bestLeastSquares); Assert.IsTrue(bestLeastSquares > 2000000); container.BackBuffer.FindLeastSquaresMatch(lastWordText.BackBuffer, out bestPosition, out bestLeastSquares); Assert.IsTrue(bestLeastSquares < 2000000); container.Close(); }
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); }
public void TestVAnchorCenter() { FlowLayoutWidget searchPanel = new FlowLayoutWidget(); searchPanel.BackgroundColor = new RGBA_Bytes(180, 180, 180); searchPanel.HAnchor = HAnchor.ParentLeftRight; searchPanel.Padding = new BorderDouble(3, 3); { TextEditWidget searchInput = new TextEditWidget("Test"); searchInput.Margin = new BorderDouble(6, 0); searchInput.HAnchor = HAnchor.ParentLeftRight; searchInput.VAnchor = VAnchor.ParentCenter; Button searchButton = new Button("Search"); searchButton.Margin = new BorderDouble(right: 9); searchPanel.AddChild(searchInput); Assert.IsTrue(searchInput.BoundsRelativeToParent.Bottom - searchPanel.BoundsRelativeToParent.Bottom == searchPanel.BoundsRelativeToParent.Top - searchInput.BoundsRelativeToParent.Top); searchPanel.AddChild(searchButton); Assert.IsTrue(searchInput.BoundsRelativeToParent.Bottom - searchPanel.BoundsRelativeToParent.Bottom == searchPanel.BoundsRelativeToParent.Top - searchInput.BoundsRelativeToParent.Top); } searchPanel.Close(); }
public void VerifyFocusMakesTextWidgetEditable() { TextEditWidget editField = null; SystemWindow systemWindow = new SystemWindow(300, 200) { BackgroundColor = RGBA_Bytes.Black, }; bool firstDraw = true; Stopwatch testDiedTimer = Stopwatch.StartNew(); Action<AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) => { UiThread.RunOnIdle(editField.Focus); AutomationRunner testRunner = new AutomationRunner(); testRunner.Wait(1); // Now do the actions specific to this test. (replace this for new tests) testRunner.Type("Test Text"); resultsHarness.AddTestResult(editField.Text == "Test Text", "validate text is typed"); systemWindow.CloseOnIdle(); }; editField = new TextEditWidget(pixelWidth: 200) { HAnchor = HAnchor.ParentCenter, VAnchor = VAnchor.ParentCenter, }; systemWindow.AddChild(editField); AutomationTesterHarness testHarness = AutomationTesterHarness.ShowWindowAndExectueTests(systemWindow, testToRun, 10); Assert.IsTrue(testHarness.AllTestsPassed); Assert.IsTrue(testHarness.TestCount == 1); // make sure we can all our tests }
private FlowLayoutWidget GetSettingsRow(OrganizerSettingsData settingData, string sliceSettingValue = null) { FlowLayoutWidget container = new FlowLayoutWidget(); container.HAnchor = HAnchor.ParentLeftRight; double minSettingNameWidth = 400; if (ActiveSliceSettings.Instance.Contains(settingData.SlicerConfigName)) { int intEditWidth = 60; int doubleEditWidth = 60; int vectorXYEditWidth = 60; int multiLineEditHeight = 60; //Get the current value as a default value if (sliceSettingValue == null) { sliceSettingValue = ActiveSliceSettings.Instance.GetActiveValue(settingData.SlicerConfigName); } //Get the presentation name from the SettingNameLookup TextWidget settingName = new TextWidget(SettingNameLookup[settingData.SlicerConfigName], pointSize: 10); settingName.AutoExpandBoundsToText = false; settingName.EllipsisIfClipped = true; settingName.TextColor = ActiveTheme.Instance.PrimaryTextColor; settingName.VAnchor = Agg.UI.VAnchor.ParentCenter; settingName.MinimumSize = new Vector2(minSettingNameWidth, settingName.Height); settingName.Width = minSettingNameWidth; container.AddChild(settingName); switch (settingData.DataEditType) { case OrganizerSettingsData.DataEditTypes.INT: { int currentValue = 0; int.TryParse(sliceSettingValue, out currentValue); MHNumberEdit intEditWidget = new MHNumberEdit(currentValue, pixelWidth: intEditWidth, tabIndex: tabIndexForItem++); intEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((NumberEdit)sender).Value.ToString()); }; container.AddChild(intEditWidget); container.AddChild(getSettingInfoData(settingData)); } break; case OrganizerSettingsData.DataEditTypes.DOUBLE: { double currentValue = 0; double.TryParse(sliceSettingValue, out currentValue); MHNumberEdit doubleEditWidget = new MHNumberEdit(currentValue, allowNegatives: true, allowDecimals: true, pixelWidth: doubleEditWidth, tabIndex: tabIndexForItem++); doubleEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((NumberEdit)sender).Value.ToString()); }; container.AddChild(doubleEditWidget); container.AddChild(getSettingInfoData(settingData)); } break; case OrganizerSettingsData.DataEditTypes.POSITIVE_DOUBLE: { double currentValue = 0; double.TryParse(sliceSettingValue, out currentValue); MHNumberEdit doubleEditWidget = new MHNumberEdit(currentValue, allowDecimals: true, pixelWidth: doubleEditWidth, tabIndex: tabIndexForItem++); doubleEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((NumberEdit)sender).Value.ToString()); }; container.AddChild(doubleEditWidget); container.AddChild(getSettingInfoData(settingData)); } break; case OrganizerSettingsData.DataEditTypes.OFFSET: { double currentValue = 0; double.TryParse(sliceSettingValue, out currentValue); MHNumberEdit doubleEditWidget = new MHNumberEdit(currentValue, allowDecimals: true, allowNegatives: true, pixelWidth: doubleEditWidth, tabIndex: tabIndexForItem++); doubleEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((NumberEdit)sender).Value.ToString()); }; container.AddChild(doubleEditWidget); container.AddChild(getSettingInfoData(settingData)); } break; case OrganizerSettingsData.DataEditTypes.DOUBLE_OR_PERCENT: { MHTextEditWidget stringEdit = new MHTextEditWidget(sliceSettingValue, pixelWidth: 60, tabIndex: tabIndexForItem++); stringEdit.ActualTextEditWidget.EditComplete += (sender, e) => { TextEditWidget textEditWidget = (TextEditWidget)sender; string text = textEditWidget.Text; text = text.Trim(); bool isPercent = text.Contains("%"); if (isPercent) { text = text.Substring(0, text.IndexOf("%")); } double result; double.TryParse(text, out result); text = result.ToString(); if (isPercent) { text += "%"; } textEditWidget.Text = text; SaveSetting(settingData.SlicerConfigName, textEditWidget.Text); }; container.AddChild(stringEdit); container.AddChild(getSettingInfoData(settingData)); } break; case OrganizerSettingsData.DataEditTypes.CHECK_BOX: { CheckBox checkBoxWidget = new CheckBox(""); checkBoxWidget.VAnchor = Agg.UI.VAnchor.ParentBottom; checkBoxWidget.TextColor = ActiveTheme.Instance.PrimaryTextColor; checkBoxWidget.Checked = (sliceSettingValue == "1"); checkBoxWidget.CheckedStateChanged += (sender, e) => { if (((CheckBox)sender).Checked) { SaveSetting(settingData.SlicerConfigName, "1"); } else { SaveSetting(settingData.SlicerConfigName, "0"); } }; container.AddChild(checkBoxWidget); } break; case OrganizerSettingsData.DataEditTypes.STRING: { MHTextEditWidget stringEdit = new MHTextEditWidget(sliceSettingValue, pixelWidth: 120, tabIndex: tabIndexForItem++); stringEdit.ActualTextEditWidget.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((TextEditWidget)sender).Text); }; container.AddChild(stringEdit); } break; case OrganizerSettingsData.DataEditTypes.MULTI_LINE_TEXT: { string convertedNewLines = sliceSettingValue.Replace("\\n", "\n"); MHTextEditWidget stringEdit = new MHTextEditWidget(convertedNewLines, pointSize: 10, pixelWidth: 280, pixelHeight: multiLineEditHeight, multiLine: true, tabIndex: tabIndexForItem++); stringEdit.ActualTextEditWidget.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((TextEditWidget)sender).Text.Replace("\n", "\\n")); }; container.AddChild(stringEdit); } break; case OrganizerSettingsData.DataEditTypes.LIST: { StyledDropDownList selectableOptions = new StyledDropDownList("None", Direction.Down); selectableOptions.Margin = new BorderDouble(); string[] listItems = settingData.ExtraSettings.Split(','); foreach (string listItem in listItems) { MenuItem newItem = selectableOptions.AddItem(listItem); if (newItem.Text == sliceSettingValue) { selectableOptions.SelectedLabel = sliceSettingValue; } newItem.Selected += (sender, e) => { MenuItem menuItem = ((MenuItem)sender); SaveSetting(settingData.SlicerConfigName, menuItem.Text); }; } container.AddChild(selectableOptions); } break; case OrganizerSettingsData.DataEditTypes.VECTOR2: { string[] xyValueStrings = sliceSettingValue.Split(','); if (xyValueStrings.Length != 2) { xyValueStrings = new string[] { "0", "0" }; } double currentXValue = 0; double.TryParse(xyValueStrings[0], out currentXValue); MHNumberEdit xEditWidget = new MHNumberEdit(currentXValue, allowDecimals: true, pixelWidth: vectorXYEditWidth, tabIndex: tabIndexForItem++); double currentYValue = 0; double.TryParse(xyValueStrings[1], out currentYValue); MHNumberEdit yEditWidget = new MHNumberEdit(currentYValue, allowDecimals: true, pixelWidth: vectorXYEditWidth, tabIndex: tabIndexForItem++); { xEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, xEditWidget.ActuallNumberEdit.Value.ToString() + "," + yEditWidget.ActuallNumberEdit.Value.ToString()); }; container.AddChild(xEditWidget); TextWidget xText = new TextWidget("x"); xText.TextColor = ActiveTheme.Instance.PrimaryTextColor; xText.Margin = new BorderDouble(5, 0); container.AddChild(xText); } { yEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, xEditWidget.ActuallNumberEdit.Value.ToString() + "," + yEditWidget.ActuallNumberEdit.Value.ToString()); }; container.AddChild(yEditWidget); TextWidget yText = new TextWidget("y"); yText.TextColor = ActiveTheme.Instance.PrimaryTextColor; yText.Margin = new BorderDouble(5, 0); container.AddChild(yText); } } break; case OrganizerSettingsData.DataEditTypes.OFFSET2: { string[] xyValueStrings = sliceSettingValue.Split('x'); if (xyValueStrings.Length != 2) { xyValueStrings = new string[] { "0", "0" }; } double currentXValue = 0; double.TryParse(xyValueStrings[0], out currentXValue); MHNumberEdit xEditWidget = new MHNumberEdit(currentXValue, allowDecimals: true, allowNegatives: true, pixelWidth: vectorXYEditWidth, tabIndex: tabIndexForItem++); double currentYValue = 0; double.TryParse(xyValueStrings[1], out currentYValue); MHNumberEdit yEditWidget = new MHNumberEdit(currentYValue, allowDecimals: true, allowNegatives: true, pixelWidth: vectorXYEditWidth, tabIndex: tabIndexForItem++); { xEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, xEditWidget.ActuallNumberEdit.Value.ToString() + "x" + yEditWidget.ActuallNumberEdit.Value.ToString()); }; container.AddChild(xEditWidget); TextWidget xText = new TextWidget("x"); xText.TextColor = ActiveTheme.Instance.PrimaryTextColor; xText.Margin = new BorderDouble(5, 0); container.AddChild(xText); } { yEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, xEditWidget.ActuallNumberEdit.Value.ToString() + "x" + yEditWidget.ActuallNumberEdit.Value.ToString()); }; container.AddChild(yEditWidget); TextWidget yText = new TextWidget("y"); yText.TextColor = ActiveTheme.Instance.PrimaryTextColor; yText.Margin = new BorderDouble(5, 0); container.AddChild(yText); } } break; default: TextWidget missingSetting = new TextWidget(String.Format("Missing the setting for '{0}'.", settingData.DataEditType.ToString())); missingSetting.TextColor = ActiveTheme.Instance.PrimaryTextColor; missingSetting.BackgroundColor = RGBA_Bytes.Red; container.AddChild(missingSetting); break; } } else // the setting we think we are adding is not in the config.ini it may have been depricated { TextWidget settingName = new TextWidget(String.Format("Setting '{0}' not found in config.ini", settingData.SlicerConfigName)); settingName.TextColor = ActiveTheme.Instance.PrimaryTextColor; settingName.MinimumSize = new Vector2(minSettingNameWidth, settingName.MinimumSize.y); container.AddChild(settingName); container.BackgroundColor = RGBA_Bytes.Red; } container.AddChild(new HorizontalSpacer()); Button removeLink = linkButtonFactory.Generate("remove"); removeLink.Click += (sender, e) => { RemoveSetting(settingData.SlicerConfigName); }; removeLink.VAnchor = Agg.UI.VAnchor.ParentCenter; container.AddChild(removeLink); return(container); }
public MatterCadGuiWidget() { //rootUnion.Add(DemoProjects.PowerSupply()); //works but cutout is not working rootUnion.Add(SimplePartTester.Assembly()); //rootUnion.Add(new BoxPrimitive(8, 20, 10)); //rootUnion.Add(new LinearExtrude(new double[] { 1.1, 2.2, 3.3, 6.3 }, 7)); //rootUnion.Add( // new Difference (new Translate(new Cylinder(10, 40), 5, 10, 5), new Translate(new BoxPrimitive(10, 10, 20,"test",true), 5, 20, 5))); SuspendLayout(); verticleSpliter = new Splitter(); // pannel 1 stuff textSide = new FlowLayoutWidget(FlowDirection.TopToBottom); objectEditorView = new GuiWidget(300, 500); objectEditorList = new FlowLayoutWidget(); textEdit = new TextEditWidget("test", 300, 400); textEdit.HAnchor = HAnchor.ParentLeftRight; // textEdit.MinimumSize = new Vector2(Math.Max(textEdit.MinimumSize.x, pixelWidth), Math.Max(textEdit.MinimumSize.y, pixelHeight)); textEdit.VAnchor = VAnchor.ParentBottomTop; textEdit.Multiline = true; textEdit.BackgroundColor = RGBA_Bytes.Yellow; // objectEditorList.AddChild(textEdit);//CsgEditorBase.CreateEditorForCsg(rootUnion)); // objectEditorView.AddChild(objectEditorList); // objectEditorView.BackgroundColor = RGBA_Bytes.Orange; // objectEditorView.Text = "Hello World!"; objectEditorView.LocalBounds = new RectangleDouble(0, 0, 200, 300); textSide.LocalBounds = new RectangleDouble(0, 0, 200, 300); // objectEditorView.DebugShowBounds = true; textSide.AddChild(textEdit); textSide.BoundsChanged += new EventHandler(textSide_BoundsChanged); FlowLayoutWidget topButtonBar = new FlowLayoutWidget(); Button loadMatterScript = new Button("Load Matter Script"); loadMatterScript.Click += loadMatterScript_Click; topButtonBar.AddChild(loadMatterScript); outputScad = new Button("Output SCAD"); outputScad.Click += OutputScad_Click; topButtonBar.AddChild(outputScad); textSide.AddChild(topButtonBar); FlowLayoutWidget bottomButtonBar = new FlowLayoutWidget(); Button loadStl = new Button("Load STL"); loadStl.Click += LoadStl_Click; bottomButtonBar.AddChild(loadStl); textSide.AddChild(bottomButtonBar); // // pannel 2 stuff FlowLayoutWidget renderSide = new FlowLayoutWidget(FlowDirection.TopToBottom); renderSide.AnchorAll(); trackBallWidget = new TrackballTumbleWidget(); trackBallWidget.DrawGlContent += new EventHandler(glLightedView_DrawGlContent); renderSide.AddChild(trackBallWidget); verticleSpliter.Panel2.AddChild(renderSide); verticleSpliter.Panel1.AddChild(textSide); ResumeLayout(); objectEditorView.AnchorAll(); AnchorAll(); verticleSpliter.AnchorAll(); textSide.AnchorAll(); trackBallWidget.AnchorAll(); AddChild(verticleSpliter); BackgroundColor = RGBA_Bytes.White; }