public override void AddElements() { this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.TopToBottom); container.AnchorAll(); ApplicationMenuRow menuRow = new ApplicationMenuRow(); container.AddChild(menuRow); GuiWidget menuSeparator = new GuiWidget(); menuSeparator.BackgroundColor = new RGBA_Bytes(200, 200, 200); menuSeparator.Height = 2; menuSeparator.HAnchor = HAnchor.ParentLeftRight; menuSeparator.Margin = new BorderDouble(3, 6, 3, 3); container.AddChild(menuSeparator); widescreenPanel = new WidescreenPanel(); container.AddChild(widescreenPanel); this.AddChild(container); }
public override void CreateAndAddChildren() { this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; var container = new FlowLayoutWidget(FlowDirection.TopToBottom); container.AnchorAll(); if (!UserSettings.Instance.IsTouchScreen) { #if !__ANDROID__ // The application menu bar, which is suppressed on Android var menuRow = new ApplicationMenuRow(); container.AddChild(menuRow); #endif } var menuSeparator = new GuiWidget() { BackgroundColor = new RGBA_Bytes(200, 200, 200), Height = 2, HAnchor = HAnchor.ParentLeftRight, Margin = new BorderDouble(3, 6, 3, 3) }; container.AddChild(menuSeparator); widescreenPanel = new WidescreenPanel(); container.AddChild(widescreenPanel); using (new PerformanceTimer("ReloadAll", "AddChild")) { this.AddChild(container); } }
public PrintProgressBar() { MinimumSize = new Vector2(0, 24); HAnchor = HAnchor.ParentLeftRight; BackgroundColor = ActiveTheme.Instance.SecondaryAccentColor; Margin = new BorderDouble(0); FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.LeftToRight); container.AnchorAll(); container.Padding = new BorderDouble(6, 0); printTimeElapsed = new TextWidget("", pointSize: 11); printTimeElapsed.AutoExpandBoundsToText = true; printTimeElapsed.VAnchor = Agg.UI.VAnchor.ParentCenter; printTimeRemaining = new TextWidget("", pointSize: 11); printTimeRemaining.AutoExpandBoundsToText = true; printTimeRemaining.VAnchor = Agg.UI.VAnchor.ParentCenter; GuiWidget spacer = new GuiWidget(); spacer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; container.AddChild(printTimeElapsed); container.AddChild(spacer); container.AddChild(printTimeRemaining); AddChild(container); AddHandlers(); SetThemedColors(); UpdatePrintStatus(); UiThread.RunOnIdle(OnIdle); }
void LoadColumnTwo(object state = null) { ColumnTwo.CloseAndRemoveAllChildren(); double buildHeight = ActiveSliceSettings.Instance.BuildHeight; #if NEW_TWO_COLUMN_MODE PartPreviewContent partViewContent = new PartPreviewContent(PrinterConnectionAndCommunication.Instance.ActivePrintItem, true, View3DWidget.AutoRotate.Enabled, false); partViewContent.AnchorAll(); ColumnTwo.AddChild(partViewContent); #else part3DView = new View3DWidget(PrinterConnectionAndCommunication.Instance.ActivePrintItem, new Vector3(ActiveSliceSettings.Instance.BedSize, buildHeight), ActiveSliceSettings.Instance.BedCenter, ActiveSliceSettings.Instance.BedShape, View3DWidget.WindowType.Embeded, View3DWidget.AutoRotate.Enabled); part3DView.Margin = new BorderDouble(bottom: 4); part3DView.AnchorAll(); partGcodeView = new ViewGcodeBasic(PrinterConnectionAndCommunication.Instance.ActivePrintItem, new Vector3(ActiveSliceSettings.Instance.BedSize, buildHeight), ActiveSliceSettings.Instance.BedCenter, ActiveSliceSettings.Instance.BedShape, false); partGcodeView.AnchorAll(); ColumnTwo.AddChild(part3DView); ColumnTwo.AddChild(partGcodeView); #endif ColumnTwo.AnchorAll(); }
public override void AddElements() { Stopwatch timer = Stopwatch.StartNew(); timer.Start(); this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.TopToBottom); container.AnchorAll(); ApplicationMenuRow menuRow = new ApplicationMenuRow(); container.AddChild(menuRow); GuiWidget menuSeparator = new GuiWidget(); menuSeparator.BackgroundColor = new RGBA_Bytes(200, 200, 200); menuSeparator.Height = 2; menuSeparator.HAnchor = HAnchor.ParentLeftRight; menuSeparator.Margin = new BorderDouble(3, 6, 3, 3); container.AddChild(menuSeparator); Console.WriteLine("{0} ms 1".FormatWith(timer.ElapsedMilliseconds)); timer.Restart(); widescreenPanel = new WidescreenPanel(); container.AddChild(widescreenPanel); Console.WriteLine("{0} ms 2".FormatWith(timer.ElapsedMilliseconds)); timer.Restart(); Console.WriteLine("{0} ms 3".FormatWith(timer.ElapsedMilliseconds)); timer.Restart(); this.AddChild(container); Console.WriteLine("{0} ms 4".FormatWith(timer.ElapsedMilliseconds)); timer.Restart(); }
void loadMatterScript_Click(object sender, EventArgs mouseEvent) { OpenFileDialogParams openParams = new OpenFileDialogParams("MatterScript Files, c-sharp code|*.part;*.cs"); FileDialog.OpenFileDialog(openParams, (streamToLoadFrom) => { if (streamToLoadFrom != null) { SuspendLayout(); var loadedFileName = openParams.FileName; string extension = Path.GetExtension(openParams.FileName).ToUpper(CultureInfo.InvariantCulture); string text = File.ReadAllText(loadedFileName); StreamReader streamReader = new StreamReader(streamToLoadFrom.FileName); textEdit.Text = streamReader.ReadToEnd(); streamReader.Close(); varticalSplitter.SplitterDistance = varticalSplitter.SplitterDistance - 1; varticalSplitter.SplitterDistance = varticalSplitter.SplitterDistance + 1; ResumeLayout(); AnchorAll(); varticalSplitter.AnchorAll(); textSide.AnchorAll(); objectEditorView.Invalidate(); textSide.PerformLayout(); trackBallWidget.AnchorAll(); Invalidate(); } }); }
void LoadCompactView() { queueDataView = new QueueDataView(); ColumnOne.RemoveAllChildren(); ColumnOne.AddChild(new ActionBarPlus(queueDataView)); ColumnOne.AddChild(new CompactSlidePanel(queueDataView)); ColumnOne.AnchorAll(); }
public ButtonsPage() : base("Radio and Check Buttons") { FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); topToBottom.AddChild(new CheckBox("Simple Check Box")); CheckBoxViewStates fourStates = new CheckBoxViewStates(new TextWidget("normal"), new TextWidget("normal"), new TextWidget("switch n->p"), new TextWidget("pressed"), new TextWidget("pressed"), new TextWidget("switch p->n"), new TextWidget("disabled")); topToBottom.AddChild(new CheckBox(fourStates)); GuiWidget normalPressed = new TextWidget("0 4state"); normalPressed.BackgroundColor = RGBA_Bytes.Gray; GuiWidget downPressed = new TextWidget("1 4state"); downPressed.BackgroundColor = RGBA_Bytes.Gray; GuiWidget normalHover = new TextWidget("0 4state"); normalHover.BackgroundColor = RGBA_Bytes.Yellow; GuiWidget downHover = new TextWidget("1 4state"); downHover.BackgroundColor = RGBA_Bytes.Yellow; CheckBoxViewStates fourStates2 = new CheckBoxViewStates(new TextWidget("0 4state"), normalHover, normalPressed, new TextWidget("1 4state"), downHover, downPressed, new TextWidget("disabled")); topToBottom.AddChild(new CheckBox(fourStates2)); topToBottom.AddChild(new RadioButton("Simple Radio Button 1")); topToBottom.AddChild(new RadioButton("Simple Radio Button 2")); topToBottom.AddChild(new RadioButton(new RadioButtonViewText("Simple Radio Button 3"))); topToBottom.AddChild(new RadioButton(new RadioButtonViewStates(new TextWidget("O - unchecked"), new TextWidget("O - unchecked hover"), new TextWidget("O - checking"), new TextWidget("X - checked"), new TextWidget("disabled")))); groupBox = new GroupBox("Radio Group"); //groupBox.LocalBounds = new RectangleDouble(0, 0, 300, 150); groupBox.OriginRelativeParent = new Vector2(200, 350); FlowLayoutWidget topToBottomRadios = new FlowLayoutWidget(FlowDirection.TopToBottom); topToBottomRadios.AnchorAll(); topToBottomRadios.AddChild(new RadioButton("Simple Radio Button 1")); topToBottomRadios.AddChild(new RadioButton("Simple Radio Button 2")); topToBottomRadios.AddChild(new RadioButton("Simple Radio Button 3")); topToBottomRadios.SetBoundsToEncloseChildren(); groupBox.AddChild(topToBottomRadios); topToBottom.AddChild(groupBox); AddChild(topToBottom); topToBottom.VAnchor = UI.VAnchor.ParentTop; }
public SetupConnectionWidgetBase(ConnectionWindow windowController, GuiWidget containerWindowToClose, PrinterSetupStatus printerSetupStatus = null) : base(windowController, containerWindowToClose) { SetDisplayAttributes(); if (printerSetupStatus == null) { this.PrinterSetupStatus = new PrinterSetupStatus(); } else { this.PrinterSetupStatus = printerSetupStatus; } cancelButton = textImageButtonFactory.Generate(LocalizedString.Get("Cancel")); cancelButton.Click += new EventHandler(CancelButton_Click); //Create the main container GuiWidget mainContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); mainContainer.AnchorAll(); mainContainer.Padding = new BorderDouble(3, 5, 3, 5); mainContainer.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; //Create the header row for the widget headerRow = new FlowLayoutWidget(FlowDirection.LeftToRight); headerRow.Margin = new BorderDouble(0, 3, 0, 0); headerRow.Padding = new BorderDouble(0, 3, 0, 3); headerRow.HAnchor = HAnchor.ParentLeftRight; { string defaultHeaderTitle = LocalizedString.Get("3D Printer Setup"); headerLabel = new TextWidget(defaultHeaderTitle, pointSize: 14); headerLabel.AutoExpandBoundsToText = true; headerLabel.TextColor = this.defaultTextColor; headerRow.AddChild(headerLabel); } //Create the main control container contentRow = new FlowLayoutWidget(FlowDirection.TopToBottom); contentRow.Padding = new BorderDouble(5); contentRow.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; contentRow.HAnchor = HAnchor.ParentLeftRight; contentRow.VAnchor = VAnchor.ParentBottomTop; //Create the footer (button) container footerRow = new FlowLayoutWidget(FlowDirection.LeftToRight); footerRow.HAnchor = HAnchor.ParentLeft | HAnchor.ParentRight; footerRow.Margin = new BorderDouble(0, 3); mainContainer.AddChild(headerRow); mainContainer.AddChild(contentRow); mainContainer.AddChild(footerRow); this.AddChild(mainContainer); }
public SavePartsSheetFeedbackWindow(int totalParts, string firstPartName, RGBA_Bytes backgroundColor) : base(300, 500) { BackgroundColor = backgroundColor; Title = "MatterControl - Saving to Parts Sheet"; this.totalParts = totalParts; feedback.Padding = new BorderDouble(5, 5); feedback.AnchorAll(); AddChild(feedback); }
public MatterControlApplication(double width, double height) : base(width, height) { this.commandLineArgs = Environment.GetCommandLineArgs();; Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; //WriteTestGCodeFile(); if (File.Exists("RunUnitTests.txt")) { GuiHalWidget.SetClipboardFunctions(System.Windows.Forms.Clipboard.GetText, System.Windows.Forms.Clipboard.SetText, System.Windows.Forms.Clipboard.ContainsText); MatterHackers.Agg.Tests.UnitTests.Run(); MatterHackers.VectorMath.Tests.UnitTests.Run(); MatterHackers.Agg.UI.Tests.UnitTests.Run(); MatterHackers.PolygonMesh.UnitTests.UnitTests.Run(); // you can turn this on to debug some bounds issues //GuiWidget.DebugBoundsUnderMouse = true; } GuiWidget.DefaultEnforceIntegerBounds = true; FlowLayoutWidget allControls = new FlowLayoutWidget(FlowDirection.TopToBottom); allControls.AnchorAll(); this.AddChild(allControls); this.Padding = new BorderDouble(0); //To be re-enabled once native borders are turned off //allControls.AddChild(CreateMenues()); allControls.AddChild(new ActionBarPlus()); allControls.AddChild(MainSlidePanel.Instance); #if false // this is to test freeing gcodefile memory Button test = new Button("test"); test.Click += (sender, e) => { //MatterHackers.GCodeVisualizer.GCodeFile gcode = new GCodeVisualizer.GCodeFile(); //gcode.Load(@"C:\Users\lbrubaker\Downloads\drive assy.gcode"); SystemWindow window = new SystemWindow(100, 100); window.ShowAsSystemWindow(); }; allControls.AddChild(test); #endif this.AnchorAll(); UseOpenGL = true; Title = "MatterControl (beta)"; PrinterCommunication.Instance.Initialize(); UiThread.RunOnIdle(CheckOnPrinter); ShowAsSystemWindow(); }
public QueueControlsWidget() { SetDisplayAttributes(); textImageButtonFactory.normalTextColor = RGBA_Bytes.White; textImageButtonFactory.hoverTextColor = RGBA_Bytes.White; textImageButtonFactory.disabledTextColor = RGBA_Bytes.White; textImageButtonFactory.pressedTextColor = RGBA_Bytes.White; textImageButtonFactory.borderWidth = 0; FlowLayoutWidget allControls = new FlowLayoutWidget(FlowDirection.TopToBottom); { { // Ensure the form opens with no rows selected. //ActiveQueueList.Instance.ClearSelected(); allControls.AddChild(PrintQueueControl.Instance); } FlowLayoutWidget buttonPanel1 = new FlowLayoutWidget(); buttonPanel1.HAnchor = HAnchor.ParentLeftRight; buttonPanel1.Padding = new BorderDouble(0, 3); { Button addToQueueButton = textImageButtonFactory.Generate(new LocalizedString("Add").Translated, "icon_circle_plus.png"); buttonPanel1.AddChild(addToQueueButton); addToQueueButton.Margin = new BorderDouble(0, 0, 3, 0); addToQueueButton.Click += new ButtonBase.ButtonEventHandler(loadFile_Click); Button deleteAllFromQueueButton = textImageButtonFactory.Generate(new LocalizedString("Remove All").Translated); deleteAllFromQueueButton.Margin = new BorderDouble(3, 0); deleteAllFromQueueButton.Click += new ButtonBase.ButtonEventHandler(deleteAllFromQueueButton_Click); buttonPanel1.AddChild(deleteAllFromQueueButton); GuiWidget spacer1 = new GuiWidget(); spacer1.HAnchor = HAnchor.ParentLeftRight; buttonPanel1.AddChild(spacer1); GuiWidget spacer2 = new GuiWidget(); spacer2.HAnchor = HAnchor.ParentLeftRight; buttonPanel1.AddChild(spacer2); GuiWidget queueMenu = new PrintQueueMenu(); queueMenu.VAnchor = VAnchor.ParentTop; buttonPanel1.AddChild(queueMenu); } allControls.AddChild(buttonPanel1); } allControls.AnchorAll(); this.AddChild(allControls); }
public SavePartsSheetFeedbackWindow(int totalParts, string firstPartName, Color backgroundColor) : base(300, 500) { this.BackgroundColor = backgroundColor; this.Title = ApplicationController.Instance.ProductName + " - " + "Saving to Parts Sheet".Localize(); this.totalParts = totalParts; feedback = new FlowLayoutWidget(FlowDirection.TopToBottom); feedback.Padding = 5; feedback.AnchorAll(); this.AddChild(feedback); }
FlowLayoutWidget GetMiddleRow() { FlowLayoutWidget container = new FlowLayoutWidget(); container.HAnchor = HAnchor.ParentLeftRight; container.VAnchor = Agg.UI.VAnchor.ParentBottomTop; container.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; FlowLayoutWidget topBottomContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); topBottomContainer.AnchorAll(); FlowLayoutWidget addContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); addContainer.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; addContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; TextWidget errorMessage = new TextWidget("Oops! Please select a setting first.", pointSize: 10); errorMessage.TextColor = ActiveTheme.Instance.SecondaryAccentColor; errorMessageContainer = new FlowLayoutWidget(); errorMessageContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; errorMessageContainer.BackgroundColor = ActiveTheme.Instance.TransparentDarkOverlay; errorMessageContainer.Visible = false; errorMessageContainer.Padding = new BorderDouble(3); errorMessageContainer.AddChild(new HorizontalSpacer()); errorMessageContainer.AddChild(errorMessage); errorMessageContainer.AddChild(new HorizontalSpacer()); addSettingsContainer = new FlowLayoutWidget(); addSettingsContainer.Padding = new BorderDouble(3); addSettingsContainer.BackgroundColor = ActiveTheme.Instance.TransparentDarkOverlay; addSettingsContainer.HAnchor = HAnchor.ParentLeftRight; PopulateAddSettingRow(); addContainer.AddChild(addSettingsContainer); addContainer.AddChild(errorMessageContainer); settingsRowContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); settingsRowContainer.HAnchor = HAnchor.ParentLeftRight; settingsRowContainer.Padding = new BorderDouble(3); LoadSettingsRows(); topBottomContainer.AddChild(addContainer); topBottomContainer.AddChild(settingsRowContainer); container.AddChild(topBottomContainer); return(container); }
private void LoadColumnTwo() { ColumnTwo.CloseAndRemoveAllChildren(); PartPreviewContent partViewContent = new PartPreviewContent(PrinterConnectionAndCommunication.Instance.ActivePrintItem, View3DWidget.WindowMode.Embeded, View3DWidget.AutoRotate.Enabled); partViewContent.AnchorAll(); ColumnTwo.AddChild(partViewContent); ColumnTwo.AnchorAll(); }
void AddElements() { FlowLayoutWidget mainContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); mainContainer.Padding = new BorderDouble(3); mainContainer.AnchorAll(); mainContainer.AddChild(GetTopRow()); mainContainer.AddChild(GetMiddleRow()); mainContainer.AddChild(GetBottomRow()); this.AddChild(mainContainer); }
public ListBoxPage() : base("List Box Widget") { FlowLayoutWidget leftToRightLayout = new FlowLayoutWidget(); leftToRightLayout.AnchorAll(); { { leftListBox = new ListBox(new RectangleDouble(0, 0, 200, 300)); //leftListBox.BackgroundColor = RGBA_Bytes.Red; leftListBox.Name = "LeftListBox"; leftListBox.VAnchor = UI.VAnchor.ParentTop; //leftListBox.DebugShowBounds = true; leftListBox.Margin = new BorderDouble(15); leftToRightLayout.AddChild(leftListBox); for (int i = 0; i < 1; i++) { leftListBox.AddChild(new ListBoxTextItem("hand" + i.ToString() + ".stl", "c:\\development\\hand" + i.ToString() + ".stl")); } } if (true) { ListBox rightListBox = new ListBox(new RectangleDouble(0, 0, 200, 300)); rightListBox.VAnchor = UI.VAnchor.ParentTop; rightListBox.Margin = new BorderDouble(15); leftToRightLayout.AddChild(rightListBox); for (int i = 0; i < 30; i++) { switch (i % 3) { case 0: rightListBox.AddChild(new ListBoxTextItem("ListBoxTextItem" + i.ToString() + ".stl", "c:\\development\\hand" + i.ToString() + ".stl")); break; case 1: rightListBox.AddChild(new Button("Button" + i.ToString() + ".stl")); break; case 2: rightListBox.AddChild(new RadioButton("RadioButton" + i.ToString() + ".stl")); break; } } } } AddChild(leftToRightLayout); }
public SavePartsSheetFeedbackWindow(int totalParts, string firstPartName, RGBA_Bytes backgroundColor) : base(300, 500) { BackgroundColor = backgroundColor; string savePartSheetTitle = new LocalizedString("MatterControl").Translated; string savePartSheetTitleFull = new LocalizedString("Saving to Parts Sheet").Translated; Title = string.Format("{0} - {1}", savePartSheetTitle, savePartSheetTitleFull); this.totalParts = totalParts; feedback.Padding = new BorderDouble(5, 5); feedback.AnchorAll(); AddChild(feedback); }
public ExportToSdCardFeedbackWindow(int totalParts, string firstPartName, RGBA_Bytes backgroundColor) : base(300, 500) { BackgroundColor = backgroundColor; Title = "MatterControl - Exporting to Folder or SD Card".Localize(); this.totalParts = totalParts; feedback.Padding = new BorderDouble(5, 5); feedback.AnchorAll(); AddChild(feedback); nextLine = CreateNextLine(""); feedback.AddChild(nextLine); }
void LoadColumnTwo(object state = null) { ColumnTwo.RemoveAllChildren(); double buildHeight = ActiveSliceSettings.Instance.BuildHeight; part3DView = new View3DTransformPart(PrinterCommunication.Instance.ActivePrintItem, new Vector3(ActiveSliceSettings.Instance.BedSize, buildHeight), ActiveSliceSettings.Instance.BedShape, false); part3DView.Margin = new BorderDouble(bottom: 4); part3DView.AnchorAll(); partGcodeView = new GcodeViewBasic(PrinterCommunication.Instance.ActivePrintItem, ActiveSliceSettings.Instance.GetBedSize, ActiveSliceSettings.Instance.GetBedCenter, false); partGcodeView.AnchorAll(); ColumnTwo.AddChild(part3DView); ColumnTwo.AddChild(partGcodeView); ColumnTwo.AnchorAll(); }
public ExportToFolderFeedbackWindow(int totalParts, string firstPartName, RGBA_Bytes backgroundColor) : base(300, 500) { BackgroundColor = backgroundColor; string exportingToFolderTitle = LocalizedString.Get("MatterControl"); string exportingToFolderTitleFull = LocalizedString.Get("Exporting to Folder"); Title = string.Format("{0} - {1}", exportingToFolderTitle, exportingToFolderTitleFull); this.totalParts = totalParts; feedback.Padding = new BorderDouble(5, 5); feedback.AnchorAll(); AddChild(feedback); nextLine = CreateNextLine(""); feedback.AddChild(nextLine); }
public SetupConnectionWidgetBase(ConnectionWizard wizard) : base(wizard) { SetDisplayAttributes(); cancelButton = textImageButtonFactory.Generate("Cancel".Localize()); cancelButton.Name = "Setup Connection Cancel Button"; cancelButton.Click += CancelButton_Click; //Create the main container GuiWidget mainContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); mainContainer.AnchorAll(); mainContainer.Padding = new BorderDouble(3, 5, 3, 5); mainContainer.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; //Create the header row for the widget headerRow = new FlowLayoutWidget(FlowDirection.LeftToRight); headerRow.Margin = new BorderDouble(0, 3, 0, 0); headerRow.Padding = new BorderDouble(0, 3, 0, 3); headerRow.HAnchor = HAnchor.ParentLeftRight; { headerLabel = new TextWidget("3D Printer Setup".Localize(), pointSize: 14); headerLabel.AutoExpandBoundsToText = true; headerLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor; headerRow.AddChild(headerLabel); } //Create the main control container contentRow = new FlowLayoutWidget(FlowDirection.TopToBottom); contentRow.Padding = new BorderDouble(5); contentRow.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; contentRow.HAnchor = HAnchor.ParentLeftRight; contentRow.VAnchor = VAnchor.ParentBottomTop; //Create the footer (button) container footerRow = new FlowLayoutWidget(FlowDirection.LeftToRight); footerRow.HAnchor = HAnchor.ParentLeft | HAnchor.ParentRight; footerRow.Margin = new BorderDouble(0, 3); mainContainer.AddChild(headerRow); mainContainer.AddChild(contentRow); mainContainer.AddChild(footerRow); this.AddChild(mainContainer); }
public void TopToBottomContainerAppliesExpectedMarginToToggleView() { TestContext.CurrentContext.SetCompatibleWorkingDirectory(); int marginSize = 40; int dimensions = 300; GuiWidget outerContainer = new GuiWidget(dimensions, dimensions); FlowLayoutWidget topToBottomContainer = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, }; outerContainer.AddChild(topToBottomContainer); CheckBox toggleBox = new CheckBox("test"); toggleBox.HAnchor = HAnchor.Stretch; toggleBox.VAnchor = VAnchor.Stretch; toggleBox.Margin = new BorderDouble(marginSize); toggleBox.BackgroundColor = Color.Red; toggleBox.DebugShowBounds = true; topToBottomContainer.AddChild(toggleBox); topToBottomContainer.AnchorAll(); topToBottomContainer.PerformLayout(); outerContainer.DoubleBuffer = true; outerContainer.BackBuffer.NewGraphics2D().Clear(Color.White); outerContainer.OnDraw(outerContainer.NewGraphics2D()); // For troubleshooting or visual validation OutputImages(outerContainer, outerContainer); var bounds = toggleBox.BoundsRelativeToParent; Assert.IsTrue(bounds.Left == marginSize, "Left margin is incorrect"); Assert.IsTrue(bounds.Right == dimensions - marginSize, "Right margin is incorrect"); Assert.IsTrue(bounds.Top == dimensions - marginSize, "Top margin is incorrect"); Assert.IsTrue(bounds.Bottom == marginSize, "Bottom margin is incorrect"); }
public SlicePresetsWindow(PresetsContext presetsContext) : base(641, 481) { this.presetsContext = presetsContext; this.AlwaysOnTopOfMain = true; this.Title = LocalizedString.Get("Slice Presets Editor"); this.MinimumSize = new Vector2(640, 480); this.AnchorAll(); var linkButtonFactory = new LinkButtonFactory() { fontSize = 8, textColor = ActiveTheme.Instance.SecondaryAccentColor }; var buttonFactory = new TextImageButtonFactory() { normalTextColor = ActiveTheme.Instance.PrimaryTextColor, hoverTextColor = ActiveTheme.Instance.PrimaryTextColor, disabledTextColor = ActiveTheme.Instance.PrimaryTextColor, pressedTextColor = ActiveTheme.Instance.PrimaryTextColor, borderWidth = 0 }; FlowLayoutWidget mainContainer = new FlowLayoutWidget(FlowDirection.TopToBottom) { Padding = new BorderDouble(3) }; mainContainer.AnchorAll(); middleRow = new GuiWidget(); middleRow.AnchorAll(); middleRow.AddChild(CreateSliceSettingsWidget(presetsContext.PersistenceLayer)); mainContainer.AddChild(GetTopRow()); mainContainer.AddChild(middleRow); mainContainer.AddChild(GetBottomRow(buttonFactory)); this.AddChild(mainContainer); BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; }
public override void AddElements() { topIsHidden = false; this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.TopToBottom); container.AnchorAll(); TopContainer = new TopContainerWidget(); TopContainer.HAnchor = HAnchor.ParentLeftRight; ApplicationMenuRow menuRow = new ApplicationMenuRow(); #if !__ANDROID__ TopContainer.AddChild(menuRow); #endif menuSeparator = new GuiWidget(); menuSeparator.Height = 12; menuSeparator.HAnchor = HAnchor.ParentLeftRight; menuSeparator.MinimumSize = new Vector2(0, 12); menuSeparator.Visible = false; queueDataView = new QueueDataView(); TopContainer.AddChild(new ActionBarPlus(queueDataView)); TopContainer.SetOriginalHeight(); container.AddChild(TopContainer); progressBar = new PrintProgressBar(); container.AddChild(progressBar); container.AddChild(menuSeparator); compactTabView = new CompactTabView(queueDataView); BottomOverlay bottomOverlay = new BottomOverlay(); bottomOverlay.AddChild(compactTabView); container.AddChild(bottomOverlay); this.AddChild(container); }
public override void CreateAndAddChildren() { topIsHidden = false; this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.TopToBottom); container.AnchorAll(); TopContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); TopContainer.HAnchor = HAnchor.ParentLeftRight; if (!UserSettings.Instance.IsTouchScreen) { #if !__ANDROID__ // The application menu bar, which is suppressed on Android ApplicationMenuRow menuRow = new ApplicationMenuRow(); TopContainer.AddChild(menuRow); #endif } menuSeparator = new GuiWidget(); menuSeparator.Height = 12; menuSeparator.HAnchor = HAnchor.ParentLeftRight; menuSeparator.MinimumSize = new Vector2(0, 12); menuSeparator.Visible = false; queueDataView = new QueueDataView(); TopContainer.AddChild(new ActionBarPlus(queueDataView)); container.AddChild(TopContainer); progressBar = new PrintProgressBar(); container.AddChild(progressBar); container.AddChild(menuSeparator); touchscreenTabView = new TouchscreenTabView(queueDataView); container.AddChild(touchscreenTabView); this.AddChild(container); }
public FontHinter() { AnchorAll(); FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); topToBottom.AnchorAll(); pixelSizeSlider = new Slider(new Vector2(30, 30), 600 - 60); gammaSlider = new Slider(new Vector2(30, 70), 600 - 60); pixelSizeSlider.Text = "Pixel size={0:F3}"; pixelSizeSlider.SetRange(2, 20); pixelSizeSlider.NumTicks = 23; pixelSizeSlider.Value = 6; gammaSlider.Text = "Gamma={0:F3}"; gammaSlider.SetRange(0.0, 3.0); gammaSlider.Value = 1.0; topToBottom.AddChild(pixelSizeSlider); topToBottom.AddChild(gammaSlider); AddChild(topToBottom); }
public WizardControl() { Padding = new BorderDouble(10); textImageButtonFactory.normalTextColor = RGBA_Bytes.White; textImageButtonFactory.hoverTextColor = RGBA_Bytes.White; textImageButtonFactory.disabledTextColor = new RGBA_Bytes(200, 200, 200); textImageButtonFactory.disabledFillColor = new RGBA_Bytes(0, 0, 0, 0); textImageButtonFactory.pressedTextColor = RGBA_Bytes.White; AnchorAll(); BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; bottomToTopLayout = new FlowLayoutWidget(FlowDirection.BottomToTop); FlowLayoutWidget buttonBar = new FlowLayoutWidget(); textImageButtonFactory.FixedWidth = 60; backButton = textImageButtonFactory.Generate(new LocalizedString("Back").Translated, centerText: true); backButton.Click += new ButtonBase.ButtonEventHandler(back_Click); nextButton = textImageButtonFactory.Generate(new LocalizedString("Next").Translated, centerText: true); nextButton.Click += new ButtonBase.ButtonEventHandler(next_Click); doneButton = textImageButtonFactory.Generate(new LocalizedString("Done").Translated, centerText: true); doneButton.Click += new ButtonBase.ButtonEventHandler(done_Click); textImageButtonFactory.FixedWidth = 0; buttonBar.AddChild(backButton); buttonBar.AddChild(nextButton); buttonBar.AddChild(doneButton); bottomToTopLayout.AddChild(buttonBar); bottomToTopLayout.AnchorAll(); AddChild(bottomToTopLayout); }
public void NestedLayoutTopToBottomTest(BorderDouble controlPadding, BorderDouble buttonMargin) { GuiWidget containerControl = new GuiWidget(300, 200); containerControl.DoubleBuffer = true; containerControl.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White); { Button topButtonC = new Button("top button"); Button bottomButtonC = new Button("bottom wide button"); topButtonC.LocalBounds = new RectangleDouble(0, 0, bottomButtonC.LocalBounds.Width, 40); topButtonC.OriginRelativeParent = new Vector2(bottomButtonC.OriginRelativeParent.x + buttonMargin.Left, containerControl.Height - controlPadding.Top - topButtonC.Height - buttonMargin.Top); containerControl.AddChild(topButtonC); bottomButtonC.OriginRelativeParent = new Vector2(bottomButtonC.OriginRelativeParent.x + buttonMargin.Left, topButtonC.OriginRelativeParent.y - buttonMargin.Height - bottomButtonC.Height); containerControl.AddChild(bottomButtonC); } containerControl.OnDraw(containerControl.NewGraphics2D()); GuiWidget containerTest = new GuiWidget(300, 200); containerTest.DoubleBuffer = true; containerTest.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White); FlowLayoutWidget allButtons = new FlowLayoutWidget(FlowDirection.TopToBottom); allButtons.AnchorAll(); Button topButtonT; Button bottomButtonT; FlowLayoutWidget topButtonBar; FlowLayoutWidget bottomButtonBar; allButtons.Padding = controlPadding; { bottomButtonT = new Button("bottom wide button"); topButtonBar = new FlowLayoutWidget(); { topButtonT = new Button("top button"); topButtonT.LocalBounds = new RectangleDouble(0, 0, bottomButtonT.LocalBounds.Width, 40); topButtonT.Margin = buttonMargin; topButtonBar.AddChild(topButtonT); } allButtons.AddChild(topButtonBar); bottomButtonBar = new FlowLayoutWidget(); { bottomButtonT.Margin = buttonMargin; bottomButtonBar.AddChild(bottomButtonT); } allButtons.AddChild(bottomButtonBar); } containerTest.AddChild(allButtons); containerTest.OnDraw(containerTest.NewGraphics2D()); OutputImages(containerControl, containerTest); Assert.IsTrue(containerTest.BackBuffer != null, "When we set a guiWidget to DoubleBuffer it needs to create one."); Assert.IsTrue(containerTest.BackBuffer.Equals(containerControl.BackBuffer, 1), "The test should contain the same image as the control."); }
public void SingleItemVisibleTest() { { ListBox containerListBox = new ListBox(new RectangleDouble(0, 0, 100, 100)); ListBoxTextItem itemToAddToList = new ListBoxTextItem("test Item", "test data for item"); itemToAddToList.Name = "list item"; containerListBox.AddChild(itemToAddToList); containerListBox.DoubleBuffer = true; containerListBox.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White); containerListBox.OnDraw(containerListBox.BackBuffer.NewGraphics2D()); ImageBuffer textImage = new ImageBuffer(80, 16, 32, new BlenderBGRA()); textImage.NewGraphics2D().Clear(RGBA_Bytes.White); textImage.NewGraphics2D().DrawString("test Item", 1, 1); OutputImage(containerListBox.BackBuffer, "test.tga"); OutputImage(textImage, "control.tga"); double maxError = 20000000; Vector2 bestPosition; double leastSquares; containerListBox.BackBuffer.FindLeastSquaresMatch(textImage, out bestPosition, out leastSquares, maxError); Assert.IsTrue(leastSquares < maxError, "The list box need to be showing the item we added to it."); } { GuiWidget container = new GuiWidget(202, 302); container.DoubleBuffer = true; container.NewGraphics2D().Clear(RGBA_Bytes.White); FlowLayoutWidget leftToRightLayout = new FlowLayoutWidget(); leftToRightLayout.AnchorAll(); { { ListBox listBox = new ListBox(new RectangleDouble(0, 0, 200, 300)); //listBox.BackgroundColor = RGBA_Bytes.Red; listBox.Name = "listBox"; listBox.VAnchor = UI.VAnchor.ParentTop; listBox.ScrollArea.Margin = new BorderDouble(15); leftToRightLayout.AddChild(listBox); for (int i = 0; i < 1; i++) { ListBoxTextItem newItem = new ListBoxTextItem("hand" + i.ToString() + ".stl", "c:\\development\\hand" + i.ToString() + ".stl"); newItem.Name = "ListBoxItem" + i.ToString(); listBox.AddChild(newItem); } } } container.AddChild(leftToRightLayout); container.OnDraw(container.NewGraphics2D()); ImageBuffer textImage = new ImageBuffer(80, 16, 32, new BlenderBGRA()); textImage.NewGraphics2D().Clear(RGBA_Bytes.White); textImage.NewGraphics2D().DrawString("hand0.stl", 1, 1); OutputImage(container.BackBuffer, "control.tga"); OutputImage(textImage, "test.tga"); double maxError = 1000000; Vector2 bestPosition; double leastSquares; container.BackBuffer.FindLeastSquaresMatch(textImage, out bestPosition, out leastSquares, maxError); Assert.IsTrue(leastSquares < maxError, "The list box need to be showing the item we added to it."); } }
public void CreateWindowContent() { this.RemoveAllChildren(); TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory(); FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); topToBottom.Padding = new BorderDouble(3, 0, 3, 5); topToBottom.AnchorAll(); // Creates Header FlowLayoutWidget headerRow = new FlowLayoutWidget(FlowDirection.LeftToRight); headerRow.HAnchor = HAnchor.ParentLeftRight; headerRow.Margin = new BorderDouble(0, 3, 0, 0); headerRow.Padding = new BorderDouble(0, 3, 0, 3); BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; //Creates Text and adds into header { TextWidget elementHeader = new TextWidget("File export options:".Localize(), pointSize: 14); elementHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor; elementHeader.HAnchor = HAnchor.ParentLeftRight; elementHeader.VAnchor = Agg.UI.VAnchor.ParentBottom; headerRow.AddChild(elementHeader); topToBottom.AddChild(headerRow); } // Creates container in the middle of window FlowLayoutWidget middleRowContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); { middleRowContainer.HAnchor = HAnchor.ParentLeftRight; middleRowContainer.VAnchor = VAnchor.ParentBottomTop; middleRowContainer.Padding = new BorderDouble(5); middleRowContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; } if (!partIsGCode) { string exportStlText = LocalizedString.Get("Export as"); string exportStlTextFull = string.Format("{0} STL", exportStlText); Button exportAsStlButton = textImageButtonFactory.Generate(exportStlTextFull); exportAsStlButton.HAnchor = HAnchor.ParentLeft; exportAsStlButton.Cursor = Cursors.Hand; exportAsStlButton.Click += new EventHandler(exportSTL_Click); middleRowContainer.AddChild(exportAsStlButton); } if (!partIsGCode) { string exportAmfText = LocalizedString.Get("Export as"); string exportAmfTextFull = string.Format("{0} AMF", exportAmfText); Button exportAsAmfButton = textImageButtonFactory.Generate(exportAmfTextFull); exportAsAmfButton.HAnchor = HAnchor.ParentLeft; exportAsAmfButton.Cursor = Cursors.Hand; exportAsAmfButton.Click += new EventHandler(exportAMF_Click); middleRowContainer.AddChild(exportAsAmfButton); } bool showExportGCodeButton = ActiveSliceSettings.Instance != null || partIsGCode; if (showExportGCodeButton) { string exportGCodeTextFull = string.Format("{0} G-Code", "Export as".Localize()); Button exportGCode = textImageButtonFactory.Generate(exportGCodeTextFull); exportGCode.Name = "Export as GCode Button"; exportGCode.HAnchor = HAnchor.ParentLeft; exportGCode.Cursor = Cursors.Hand; exportGCode.Click += new EventHandler((object sender, EventArgs e) => { UiThread.RunOnIdle(ExportGCode_Click); }); middleRowContainer.AddChild(exportGCode); PluginFinder <ExportGcodePlugin> exportPluginFinder = new PluginFinder <ExportGcodePlugin>(); foreach (ExportGcodePlugin plugin in exportPluginFinder.Plugins) { //Create export button for each Plugin found string exportButtonText = plugin.GetButtonText().Localize(); Button exportButton = textImageButtonFactory.Generate(exportButtonText); exportButton.HAnchor = HAnchor.ParentLeft; exportButton.Cursor = Cursors.Hand; exportButton.Click += (object sender, EventArgs e) => { UiThread.RunOnIdle(() => { // Close the export window Close(); // Open a SaveFileDialog. If Save is clicked, slice the part if needed and pass the plugin the // path to the gcode file and the target save path FileDialog.SaveFileDialog( new SaveFileDialogParams(plugin.GetExtensionFilter()) { Title = "MatterControl: Export File", FileName = printItemWrapper.Name, ActionButtonLabel = "Export" }, (SaveFileDialogParams saveParam) => { string extension = Path.GetExtension(saveParam.FileName); if (extension == "") { saveParam.FileName += plugin.GetFileExtension(); } if (partIsGCode) { plugin.Generate(printItemWrapper.FileLocation, saveParam.FileName); } else { SlicingQueue.Instance.QueuePartForSlicing(printItemWrapper); printItemWrapper.SlicingDone += (printItem, eventArgs) => { PrintItemWrapper sliceItem = (PrintItemWrapper)printItem; if (File.Exists(sliceItem.GetGCodePathAndFileName())) { plugin.Generate(sliceItem.GetGCodePathAndFileName(), saveParam.FileName); } }; } }); }); }; // End exportButton Click handler middleRowContainer.AddChild(exportButton); } } middleRowContainer.AddChild(new VerticalSpacer()); // If print leveling is enabled then add in a check box 'Apply Leveling During Export' and default checked. if (showExportGCodeButton && ActiveSliceSettings.Instance.GetValue <bool>(SettingsKey.print_leveling_enabled)) { applyLeveling = new CheckBox(LocalizedString.Get(applyLevelingDuringExportString), ActiveTheme.Instance.PrimaryTextColor, 10); applyLeveling.Checked = true; applyLeveling.HAnchor = HAnchor.ParentLeft; applyLeveling.Cursor = Cursors.Hand; //applyLeveling.Margin = new BorderDouble(top: 10); middleRowContainer.AddChild(applyLeveling); } // TODO: make this work on the mac and then delete this if if (OsInformation.OperatingSystem == OSType.Windows || OsInformation.OperatingSystem == OSType.X11) { showInFolderAfterSave = new CheckBox(LocalizedString.Get("Show file in folder after save"), ActiveTheme.Instance.PrimaryTextColor, 10); showInFolderAfterSave.HAnchor = HAnchor.ParentLeft; showInFolderAfterSave.Cursor = Cursors.Hand; //showInFolderAfterSave.Margin = new BorderDouble(top: 10); middleRowContainer.AddChild(showInFolderAfterSave); } if (!showExportGCodeButton) { string noGCodeMessageTextBeg = LocalizedString.Get("Note"); string noGCodeMessageTextEnd = LocalizedString.Get("To enable GCode export, select a printer profile."); string noGCodeMessageTextFull = string.Format("{0}: {1}", noGCodeMessageTextBeg, noGCodeMessageTextEnd); TextWidget noGCodeMessage = new TextWidget(noGCodeMessageTextFull, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 10); noGCodeMessage.HAnchor = HAnchor.ParentLeft; middleRowContainer.AddChild(noGCodeMessage); } //Creates button container on the bottom of window FlowLayoutWidget buttonRow = new FlowLayoutWidget(FlowDirection.LeftToRight); { BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; buttonRow.HAnchor = HAnchor.ParentLeftRight; buttonRow.Padding = new BorderDouble(0, 3); } Button cancelButton = textImageButtonFactory.Generate("Cancel"); cancelButton.Name = "Export Item Window Cancel Button"; cancelButton.Cursor = Cursors.Hand; cancelButton.Click += (sender, e) => { CloseOnIdle(); }; buttonRow.AddChild(new HorizontalSpacer()); buttonRow.AddChild(cancelButton); topToBottom.AddChild(middleRowContainer); topToBottom.AddChild(buttonRow); this.AddChild(topToBottom); }
public EditManualMovementSpeedsWindow(string windowTitle, string movementSpeedsString, EventHandler functionToCallOnSave) : base(260, 300) { AlwaysOnTopOfMain = true; Title = LocalizedString.Get(windowTitle); FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); topToBottom.AnchorAll(); topToBottom.Padding = new BorderDouble(3, 0, 3, 5); FlowLayoutWidget headerRow = new FlowLayoutWidget(FlowDirection.LeftToRight); headerRow.HAnchor = HAnchor.ParentLeftRight; headerRow.Margin = new BorderDouble(0, 3, 0, 0); headerRow.Padding = new BorderDouble(0, 3, 0, 3); { string movementSpeedsLabel = LocalizedString.Get("Movement Speeds Presets".Localize()); TextWidget elementHeader = new TextWidget(string.Format("{0}:", movementSpeedsLabel), pointSize: 14); elementHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor; elementHeader.HAnchor = HAnchor.ParentLeftRight; elementHeader.VAnchor = Agg.UI.VAnchor.ParentBottom; headerRow.AddChild(elementHeader); } topToBottom.AddChild(headerRow); FlowLayoutWidget presetsFormContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); //ListBox printerListContainer = new ListBox(); { presetsFormContainer.HAnchor = HAnchor.ParentLeftRight; presetsFormContainer.VAnchor = VAnchor.ParentBottomTop; presetsFormContainer.Padding = new BorderDouble(3); presetsFormContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; } topToBottom.AddChild(presetsFormContainer); this.functionToCallOnSave = functionToCallOnSave; BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; double oldHeight = textImageButtonFactory.FixedHeight; textImageButtonFactory.FixedHeight = 30 * TextWidget.GlobalPointSizeScaleRatio; TextWidget tempTypeLabel = new TextWidget(windowTitle, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 10); tempTypeLabel.Margin = new BorderDouble(3); tempTypeLabel.HAnchor = HAnchor.ParentLeft; presetsFormContainer.AddChild(tempTypeLabel); FlowLayoutWidget leftRightLabels = new FlowLayoutWidget(); leftRightLabels.Padding = new BorderDouble(3, 6); leftRightLabels.HAnchor |= Agg.UI.HAnchor.ParentLeftRight; GuiWidget hLabelSpacer = new GuiWidget(); hLabelSpacer.HAnchor = HAnchor.ParentLeftRight; GuiWidget tempLabelContainer = new GuiWidget(); tempLabelContainer.Width = 76; tempLabelContainer.Height = 16; tempLabelContainer.Margin = new BorderDouble(3, 0); TextWidget tempLabel = new TextWidget(string.Format("mm / minute"), textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 10); tempLabel.HAnchor = HAnchor.ParentLeft; tempLabel.VAnchor = VAnchor.ParentCenter; tempLabelContainer.AddChild(tempLabel); leftRightLabels.AddChild(hLabelSpacer); leftRightLabels.AddChild(tempLabelContainer); presetsFormContainer.AddChild(leftRightLabels); // put in the movement edit controls string[] settingsArray = movementSpeedsString.Split(','); int preset_count = 1; int tab_index = 0; for (int i = 0; i < settingsArray.Count() - 1; i += 2) { FlowLayoutWidget leftRightEdit = new FlowLayoutWidget(); leftRightEdit.Padding = new BorderDouble(3); leftRightEdit.HAnchor |= Agg.UI.HAnchor.ParentLeftRight; TextWidget axisLabel; if (settingsArray[i].StartsWith("e")) { int extruderIndex = (int)double.Parse(settingsArray[i].Substring(1)) + 1; string extruderLabelTxt = LocalizedString.Get("Extruder"); axisLabel = new TextWidget(string.Format("{0} {1}", extruderLabelTxt, extruderIndex), textColor: ActiveTheme.Instance.PrimaryTextColor); } else { string axisLabelText = LocalizedString.Get("Axis"); axisLabel = new TextWidget(string.Format("{0} {1}", axisLabelText, settingsArray[i]), textColor: ActiveTheme.Instance.PrimaryTextColor); } axisLabel.VAnchor = VAnchor.ParentCenter; leftRightEdit.AddChild(axisLabel); GuiWidget hSpacer = new GuiWidget(); hSpacer.HAnchor = HAnchor.ParentLeftRight; leftRightEdit.AddChild(hSpacer); // we add this to the listWithValues to make sure we build the string correctly on save. TextWidget typeEdit = new TextWidget(settingsArray[i]); listWithValues.Add(typeEdit); double movementSpeed = 0; double.TryParse(settingsArray[i + 1], out movementSpeed); MHNumberEdit valueEdit = new MHNumberEdit(movementSpeed, minValue: 0, pixelWidth: 60, tabIndex: tab_index++); valueEdit.Margin = new BorderDouble(3); leftRightEdit.AddChild(valueEdit); listWithValues.Add(valueEdit); //leftRightEdit.AddChild(textImageButtonFactory.Generate("Delete")); presetsFormContainer.AddChild(leftRightEdit); preset_count += 1; } textImageButtonFactory.FixedHeight = oldHeight; ShowAsSystemWindow(); MinimumSize = new Vector2(260, 300); Button savePresetsButton = textImageButtonFactory.Generate(LocalizedString.Get("Save")); savePresetsButton.Click += new EventHandler(save_Click); Button cancelPresetsButton = textImageButtonFactory.Generate(LocalizedString.Get("Cancel")); cancelPresetsButton.Click += (sender, e) => { UiThread.RunOnIdle((state) => { Close(); }); }; FlowLayoutWidget buttonRow = new FlowLayoutWidget(); buttonRow.HAnchor = HAnchor.ParentLeftRight; buttonRow.Padding = new BorderDouble(0, 3); GuiWidget hButtonSpacer = new GuiWidget(); hButtonSpacer.HAnchor = HAnchor.ParentLeftRight; buttonRow.AddChild(savePresetsButton); buttonRow.AddChild(hButtonSpacer); buttonRow.AddChild(cancelPresetsButton); topToBottom.AddChild(buttonRow); AddChild(topToBottom); }
public void TopBottomWithAnchorBottomTopChildTest(BorderDouble controlPadding, BorderDouble buttonMargin) { double buttonSize = 40; GuiWidget containerControl = new GuiWidget(buttonSize * 3, buttonSize * 8); containerControl.Padding = controlPadding; containerControl.DoubleBuffer = true; RectangleDouble[] eightControlRectangles = new RectangleDouble[8]; RGBA_Bytes[] eightColors = new RGBA_Bytes[] { RGBA_Bytes.Red, RGBA_Bytes.Orange, RGBA_Bytes.Yellow, RGBA_Bytes.YellowGreen, RGBA_Bytes.Green, RGBA_Bytes.Blue, RGBA_Bytes.Indigo, RGBA_Bytes.Violet }; { double currentBottom = containerControl.Height - controlPadding.Top - buttonMargin.Top - buttonSize; double buttonWidthWithMargin = buttonSize + buttonMargin.Width; double scalledHeight = (containerControl.Height - controlPadding.Height - buttonMargin.Height * 8 - buttonSize * 2) / 6; // the bottom unsized rect eightControlRectangles[0] = new RectangleDouble( 0, currentBottom, buttonSize, currentBottom + buttonSize); // left anchor currentBottom -= scalledHeight + buttonMargin.Height; double leftAnchorX = controlPadding.Left + buttonMargin.Left; eightControlRectangles[1] = new RectangleDouble(leftAnchorX, currentBottom, leftAnchorX + buttonSize, currentBottom + scalledHeight); // center anchor double centerXOfContainer = controlPadding.Left + (containerControl.Width - controlPadding.Width) / 2; currentBottom -= scalledHeight + buttonMargin.Height; eightControlRectangles[2] = new RectangleDouble(centerXOfContainer - buttonWidthWithMargin / 2 + buttonMargin.Left, currentBottom, centerXOfContainer + buttonWidthWithMargin / 2 - buttonMargin.Right, currentBottom + scalledHeight); // right anchor double rightAnchorX = containerControl.Width - controlPadding.Right - buttonMargin.Right; currentBottom -= scalledHeight + buttonMargin.Height; eightControlRectangles[3] = new RectangleDouble(rightAnchorX - buttonSize, currentBottom, rightAnchorX, currentBottom + scalledHeight); // left center anchor currentBottom -= scalledHeight + buttonMargin.Height; eightControlRectangles[4] = new RectangleDouble(leftAnchorX, currentBottom, centerXOfContainer - buttonMargin.Right, currentBottom + scalledHeight); // center right anchor currentBottom -= scalledHeight + buttonMargin.Height; eightControlRectangles[5] = new RectangleDouble(centerXOfContainer + buttonMargin.Left, currentBottom, rightAnchorX, currentBottom + scalledHeight); // left right anchor currentBottom -= scalledHeight + buttonMargin.Height; eightControlRectangles[6] = new RectangleDouble(leftAnchorX, currentBottom, rightAnchorX, currentBottom + scalledHeight); // top anchor currentBottom -= buttonSize + buttonMargin.Height; eightControlRectangles[7] = new RectangleDouble(0, currentBottom, buttonSize, currentBottom + buttonSize); Graphics2D graphics = containerControl.NewGraphics2D(); for (int i = 0; i < 8; i++) { graphics.FillRectangle(eightControlRectangles[i], eightColors[i]); } } GuiWidget containerTest = new GuiWidget(containerControl.Width, containerControl.Height); FlowLayoutWidget bottomToTopFlowLayoutAll = new FlowLayoutWidget(FlowDirection.TopToBottom); containerTest.DoubleBuffer = true; { bottomToTopFlowLayoutAll.AnchorAll(); bottomToTopFlowLayoutAll.Padding = controlPadding; { GuiWidget top = new GuiWidget(buttonSize, buttonSize); top.BackgroundColor = RGBA_Bytes.Red; top.Margin = buttonMargin; bottomToTopFlowLayoutAll.AddChild(top); bottomToTopFlowLayoutAll.AddChild(CreateBottomToTopMiddleWidget(buttonMargin, buttonSize, HAnchor.ParentLeft, RGBA_Bytes.Orange)); bottomToTopFlowLayoutAll.AddChild(CreateBottomToTopMiddleWidget(buttonMargin, buttonSize, HAnchor.ParentCenter, RGBA_Bytes.Yellow)); bottomToTopFlowLayoutAll.AddChild(CreateBottomToTopMiddleWidget(buttonMargin, buttonSize, HAnchor.ParentRight, RGBA_Bytes.YellowGreen)); bottomToTopFlowLayoutAll.AddChild(CreateBottomToTopMiddleWidget(buttonMargin, buttonSize, HAnchor.ParentLeftCenter, RGBA_Bytes.Green)); bottomToTopFlowLayoutAll.AddChild(CreateBottomToTopMiddleWidget(buttonMargin, buttonSize, HAnchor.ParentCenterRight, RGBA_Bytes.Blue)); bottomToTopFlowLayoutAll.AddChild(CreateBottomToTopMiddleWidget(buttonMargin, buttonSize, HAnchor.ParentLeftRight, RGBA_Bytes.Indigo)); GuiWidget bottom = new GuiWidget(buttonSize, buttonSize); bottom.BackgroundColor = RGBA_Bytes.Violet; bottom.Margin = buttonMargin; bottomToTopFlowLayoutAll.AddChild(bottom); } containerTest.AddChild(bottomToTopFlowLayoutAll); } containerTest.OnDraw(containerTest.NewGraphics2D()); OutputImages(containerControl, containerTest); for (int i = 0; i < 8; i++) { Assert.IsTrue(eightControlRectangles[i].Equals(bottomToTopFlowLayoutAll.Children[i].BoundsRelativeToParent, .001)); } Assert.IsTrue(containerControl.BackBuffer != null, "When we set a guiWidget to DoubleBuffer it needs to create one."); // we use a least squares match because the erase background that is setting the widgets is integer pixel based and the fill rectangle is not. Assert.IsTrue(containerControl.BackBuffer.FindLeastSquaresMatch(containerTest.BackBuffer, 0), "The test and control need to match."); }
public void LeftRightWithAnchorLeftRightChildTest(BorderDouble controlPadding, BorderDouble buttonMargin) { double buttonSize = 40; GuiWidget containerControl = new GuiWidget(buttonSize * 8, buttonSize * 3); containerControl.Padding = controlPadding; containerControl.DoubleBuffer = true; RectangleDouble[] eightControlRectangles = new RectangleDouble[8]; RGBA_Bytes[] eightColors = new RGBA_Bytes[] { RGBA_Bytes.Red, RGBA_Bytes.Orange, RGBA_Bytes.Yellow, RGBA_Bytes.YellowGreen, RGBA_Bytes.Green, RGBA_Bytes.Blue, RGBA_Bytes.Indigo, RGBA_Bytes.Violet }; { double currentleft = controlPadding.Left + buttonMargin.Left; double buttonHeightWithMargin = buttonSize + buttonMargin.Height; double scalledWidth = (containerControl.Width - controlPadding.Width - buttonMargin.Width * 8 - buttonSize * 2) / 6; // the left unsized rect eightControlRectangles[0] = new RectangleDouble( currentleft, 0, currentleft + buttonSize, buttonSize); // a bottom anchor currentleft += buttonSize + buttonMargin.Width; double bottomAnchorY = controlPadding.Bottom + buttonMargin.Bottom; eightControlRectangles[1] = new RectangleDouble(currentleft, bottomAnchorY, currentleft + scalledWidth, bottomAnchorY + buttonSize); // center anchor double centerYOfContainer = controlPadding.Bottom + (containerControl.Height - controlPadding.Height) / 2; currentleft += scalledWidth + buttonMargin.Width; eightControlRectangles[2] = new RectangleDouble(currentleft, centerYOfContainer - buttonHeightWithMargin / 2 + buttonMargin.Bottom, currentleft + scalledWidth, centerYOfContainer + buttonHeightWithMargin / 2 - buttonMargin.Top); // top anchor double topAnchorY = containerControl.Height - controlPadding.Top - buttonMargin.Top; currentleft += scalledWidth + buttonMargin.Width; eightControlRectangles[3] = new RectangleDouble(currentleft, topAnchorY - buttonSize, currentleft + scalledWidth, topAnchorY); // bottom center anchor currentleft += scalledWidth + buttonMargin.Width; eightControlRectangles[4] = new RectangleDouble(currentleft, bottomAnchorY, currentleft + scalledWidth, centerYOfContainer - buttonMargin.Top); // center top anchor currentleft += scalledWidth + buttonMargin.Width; eightControlRectangles[5] = new RectangleDouble(currentleft, centerYOfContainer + buttonMargin.Bottom, currentleft + scalledWidth, topAnchorY); // bottom top anchor currentleft += scalledWidth + buttonMargin.Width; eightControlRectangles[6] = new RectangleDouble(currentleft, bottomAnchorY, currentleft + scalledWidth, topAnchorY); // right anchor currentleft += scalledWidth + buttonMargin.Width; eightControlRectangles[7] = new RectangleDouble(currentleft, 0, currentleft + buttonSize, buttonSize); Graphics2D graphics = containerControl.NewGraphics2D(); for (int i = 0; i < 8; i++) { graphics.FillRectangle(eightControlRectangles[i], eightColors[i]); } } GuiWidget containerTest = new GuiWidget(containerControl.Width, containerControl.Height); FlowLayoutWidget leftToRightFlowLayoutAll = new FlowLayoutWidget(FlowDirection.LeftToRight); containerTest.DoubleBuffer = true; { leftToRightFlowLayoutAll.AnchorAll(); leftToRightFlowLayoutAll.Padding = controlPadding; { GuiWidget left = new GuiWidget(buttonSize, buttonSize); left.BackgroundColor = RGBA_Bytes.Red; left.Margin = buttonMargin; leftToRightFlowLayoutAll.AddChild(left); leftToRightFlowLayoutAll.AddChild(CreateLeftToRightMiddleWidget(buttonMargin, buttonSize, VAnchor.ParentBottom, RGBA_Bytes.Orange)); leftToRightFlowLayoutAll.AddChild(CreateLeftToRightMiddleWidget(buttonMargin, buttonSize, VAnchor.ParentCenter, RGBA_Bytes.Yellow)); leftToRightFlowLayoutAll.AddChild(CreateLeftToRightMiddleWidget(buttonMargin, buttonSize, VAnchor.ParentTop, RGBA_Bytes.YellowGreen)); leftToRightFlowLayoutAll.AddChild(CreateLeftToRightMiddleWidget(buttonMargin, buttonSize, VAnchor.ParentBottomCenter, RGBA_Bytes.Green)); leftToRightFlowLayoutAll.AddChild(CreateLeftToRightMiddleWidget(buttonMargin, buttonSize, VAnchor.ParentCenterTop, RGBA_Bytes.Blue)); leftToRightFlowLayoutAll.AddChild(CreateLeftToRightMiddleWidget(buttonMargin, buttonSize, VAnchor.ParentBottomTop, RGBA_Bytes.Indigo)); GuiWidget right = new GuiWidget(buttonSize, buttonSize); right.BackgroundColor = RGBA_Bytes.Violet; right.Margin = buttonMargin; leftToRightFlowLayoutAll.AddChild(right); } containerTest.AddChild(leftToRightFlowLayoutAll); } containerTest.OnDraw(containerTest.NewGraphics2D()); OutputImages(containerControl, containerTest); for (int i = 0; i < 8; i++) { Assert.IsTrue(eightControlRectangles[i] == leftToRightFlowLayoutAll.Children[i].BoundsRelativeToParent); } Assert.IsTrue(containerControl.BackBuffer != null, "When we set a guiWidget to DoubleBuffer it needs to create one."); // we use a least squares match because the erase background that is setting the widgets is integer pixel based and the fill rectangle is not. Assert.IsTrue(containerControl.BackBuffer.FindLeastSquaresMatch(containerTest.BackBuffer, 0), "The test and control need to match."); }
public void NestedFlowWidgetsLeftToRightTest(BorderDouble controlPadding, BorderDouble buttonMargin) { GuiWidget containerControl = new GuiWidget(500, 300); containerControl.Padding = controlPadding; containerControl.DoubleBuffer = true; { Button buttonRight = new Button("buttonRight"); Button buttonLeft = new Button("buttonLeft"); buttonLeft.OriginRelativeParent = new VectorMath.Vector2(controlPadding.Left + buttonMargin.Left, buttonLeft.OriginRelativeParent.y); buttonRight.OriginRelativeParent = new VectorMath.Vector2(buttonLeft.BoundsRelativeToParent.Right + buttonMargin.Width, buttonRight.OriginRelativeParent.y); containerControl.AddChild(buttonRight); containerControl.AddChild(buttonLeft); containerControl.OnDraw(containerControl.NewGraphics2D()); } GuiWidget containerTest = new GuiWidget(500, 300); containerTest.DoubleBuffer = true; { FlowLayoutWidget leftToRightFlowLayoutAll = new FlowLayoutWidget(FlowDirection.LeftToRight); leftToRightFlowLayoutAll.AnchorAll(); leftToRightFlowLayoutAll.Padding = controlPadding; { FlowLayoutWidget leftToRightFlowLayoutLeft = new FlowLayoutWidget(FlowDirection.LeftToRight); Button buttonTop = new Button("buttonLeft"); buttonTop.Margin = buttonMargin; leftToRightFlowLayoutLeft.AddChild(buttonTop); leftToRightFlowLayoutLeft.SetBoundsToEncloseChildren(); leftToRightFlowLayoutAll.AddChild(leftToRightFlowLayoutLeft); } { FlowLayoutWidget leftToRightFlowLayoutRight = new FlowLayoutWidget(FlowDirection.LeftToRight); Button buttonBottom = new Button("buttonRight"); buttonBottom.Margin = buttonMargin; leftToRightFlowLayoutRight.AddChild(buttonBottom); leftToRightFlowLayoutRight.SetBoundsToEncloseChildren(); leftToRightFlowLayoutAll.AddChild(leftToRightFlowLayoutRight); } containerTest.AddChild(leftToRightFlowLayoutAll); } containerTest.OnDraw(containerTest.NewGraphics2D()); OutputImages(containerControl, containerTest); Assert.IsTrue(containerControl.BackBuffer != null, "When we set a guiWidget to DoubleBuffer it needs to create one."); Assert.IsTrue(containerControl.BackBuffer == containerTest.BackBuffer, "The Anchored widget should be in the correct place."); }
public void NestedFlowWidgetsRightToLeftTest(BorderDouble controlPadding, BorderDouble buttonMargin) { GuiWidget containerControl = new GuiWidget(500, 300); containerControl.Padding = controlPadding; containerControl.DoubleBuffer = true; { Button buttonRight = new Button("buttonRight"); Button buttonLeft = new Button("buttonLeft"); buttonRight.OriginRelativeParent = new VectorMath.Vector2(containerControl.LocalBounds.Right - controlPadding.Right - buttonMargin.Right - buttonRight.Width, buttonRight.OriginRelativeParent.y + controlPadding.Bottom + buttonMargin.Bottom); buttonLeft.OriginRelativeParent = new VectorMath.Vector2(buttonRight.BoundsRelativeToParent.Left - buttonMargin.Width - buttonLeft.Width, buttonLeft.OriginRelativeParent.y + controlPadding.Bottom + buttonMargin.Bottom); containerControl.AddChild(buttonRight); containerControl.AddChild(buttonLeft); containerControl.OnDraw(containerControl.NewGraphics2D()); } GuiWidget containerTest = new GuiWidget(500, 300); containerTest.DoubleBuffer = true; { FlowLayoutWidget rightToLeftFlowLayoutAll = new FlowLayoutWidget(FlowDirection.RightToLeft); rightToLeftFlowLayoutAll.AnchorAll(); rightToLeftFlowLayoutAll.Padding = controlPadding; { FlowLayoutWidget rightToLeftFlowLayoutRight = new FlowLayoutWidget(FlowDirection.RightToLeft); Button buttonRight = new Button("buttonRight"); buttonRight.Margin = buttonMargin; rightToLeftFlowLayoutRight.AddChild(buttonRight); rightToLeftFlowLayoutRight.SetBoundsToEncloseChildren(); rightToLeftFlowLayoutRight.VAnchor = VAnchor.ParentBottom; rightToLeftFlowLayoutAll.AddChild(rightToLeftFlowLayoutRight); } { FlowLayoutWidget rightToLeftFlowLayoutLeft = new FlowLayoutWidget(FlowDirection.RightToLeft); Button buttonLeft = new Button("buttonLeft"); buttonLeft.Margin = buttonMargin; rightToLeftFlowLayoutLeft.AddChild(buttonLeft); rightToLeftFlowLayoutLeft.SetBoundsToEncloseChildren(); rightToLeftFlowLayoutLeft.VAnchor = VAnchor.ParentBottom; rightToLeftFlowLayoutAll.AddChild(rightToLeftFlowLayoutLeft); } containerTest.AddChild(rightToLeftFlowLayoutAll); } containerTest.OnDraw(containerTest.NewGraphics2D()); OutputImages(containerControl, containerTest); Assert.IsTrue(containerControl.BackBuffer != null, "When we set a guiWidget to DoubleBuffer it needs to create one."); // we use a least squares match because the erase background that is setting the widgets is integer pixel based and the fill rectangle is not. Assert.IsTrue(containerControl.BackBuffer.FindLeastSquaresMatch(containerTest.BackBuffer, 50), "The test and control need to match."); Assert.IsTrue(containerControl.BackBuffer.Equals(containerTest.BackBuffer, 1), "The Anchored widget should be in the correct place."); }
public void NestedFlowWidgetsTopToBottomTest(BorderDouble controlPadding, BorderDouble buttonMargin) { GuiWidget containerControl = new GuiWidget(300, 500); containerControl.Padding = controlPadding; containerControl.DoubleBuffer = true; { Button buttonTop = new Button("buttonTop"); Button buttonBottom = new Button("buttonBottom"); buttonTop.OriginRelativeParent = new VectorMath.Vector2(buttonTop.OriginRelativeParent.x, containerControl.LocalBounds.Top - buttonMargin.Top - controlPadding.Top - buttonTop.Height); buttonBottom.OriginRelativeParent = new VectorMath.Vector2(buttonBottom.OriginRelativeParent.x, buttonTop.BoundsRelativeToParent.Bottom - buttonBottom.Height - buttonMargin.Height); containerControl.AddChild(buttonTop); containerControl.AddChild(buttonBottom); containerControl.OnDraw(containerControl.NewGraphics2D()); } GuiWidget containerTest = new GuiWidget(300, 500); containerTest.DoubleBuffer = true; { FlowLayoutWidget topToBottomFlowLayoutAll = new FlowLayoutWidget(FlowDirection.TopToBottom); topToBottomFlowLayoutAll.AnchorAll(); topToBottomFlowLayoutAll.Padding = controlPadding; { FlowLayoutWidget topToBottomFlowLayoutTop = new FlowLayoutWidget(FlowDirection.TopToBottom); Button buttonTop = new Button("buttonTop"); buttonTop.Margin = buttonMargin; topToBottomFlowLayoutTop.AddChild(buttonTop); topToBottomFlowLayoutTop.SetBoundsToEncloseChildren(); topToBottomFlowLayoutAll.AddChild(topToBottomFlowLayoutTop); } { FlowLayoutWidget topToBottomFlowLayoutBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); Button buttonBottom = new Button("buttonBottom"); buttonBottom.Margin = buttonMargin; topToBottomFlowLayoutBottom.AddChild(buttonBottom); topToBottomFlowLayoutBottom.SetBoundsToEncloseChildren(); topToBottomFlowLayoutAll.AddChild(topToBottomFlowLayoutBottom); } containerTest.AddChild(topToBottomFlowLayoutAll); } containerTest.OnDraw(containerTest.NewGraphics2D()); OutputImages(containerControl, containerTest); Assert.IsTrue(containerControl.BackBuffer != null, "When we set a guiWidget to DoubleBuffer it needs to create one."); Assert.IsTrue(containerControl.BackBuffer == containerTest.BackBuffer, "The Anchored widget should be in the correct place."); }
public void TopToBottomContainerAppliesExpectedMargin() { int marginSize = 40; int dimensions = 300; GuiWidget outerContainer = new GuiWidget(dimensions, dimensions); FlowLayoutWidget topToBottomContainer = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.ParentLeftRight, VAnchor = UI.VAnchor.ParentBottomTop, }; outerContainer.AddChild(topToBottomContainer); GuiWidget childWidget = new GuiWidget() { HAnchor = HAnchor.ParentLeftRight, VAnchor = VAnchor.ParentBottomTop, Margin = new BorderDouble(marginSize), BackgroundColor = RGBA_Bytes.Red, }; topToBottomContainer.AddChild(childWidget); topToBottomContainer.AnchorAll(); topToBottomContainer.PerformLayout(); outerContainer.DoubleBuffer = true; outerContainer.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White); outerContainer.OnDraw(outerContainer.NewGraphics2D()); // For troubleshooting or visual validation //saveImagesForDebug = true; //OutputImages(outerContainer, outerContainer); var bounds = childWidget.BoundsRelativeToParent; Assert.IsTrue(bounds.Left == marginSize, "Left margin is incorrect"); Assert.IsTrue(bounds.Right == dimensions - marginSize, "Right margin is incorrect"); Assert.IsTrue(bounds.Top == dimensions - marginSize, "Top margin is incorrect"); Assert.IsTrue(bounds.Bottom == marginSize, "Bottom margin is incorrect"); }
private void LeftToRightAnchorLeftBottomTest(BorderDouble controlPadding, BorderDouble buttonMargin) { GuiWidget containerControl = new GuiWidget(300, 200); containerControl.DoubleBuffer = true; Button controlButton1 = new Button("buttonLeft"); controlButton1.OriginRelativeParent = new VectorMath.Vector2(controlPadding.Left + buttonMargin.Left, controlButton1.OriginRelativeParent.y + controlPadding.Bottom + buttonMargin.Bottom); containerControl.AddChild(controlButton1); Button controlButton2 = new Button("buttonRight"); controlButton2.OriginRelativeParent = new VectorMath.Vector2(controlPadding.Left + buttonMargin.Width + buttonMargin.Left + controlButton1.Width, controlButton2.OriginRelativeParent.y + controlPadding.Bottom + buttonMargin.Bottom); containerControl.AddChild(controlButton2); containerControl.OnDraw(containerControl.NewGraphics2D()); GuiWidget containerTest = new GuiWidget(300, 200); FlowLayoutWidget flowLayout = new FlowLayoutWidget(FlowDirection.LeftToRight); flowLayout.AnchorAll(); flowLayout.Padding = controlPadding; containerTest.DoubleBuffer = true; Button testButton1 = new Button("buttonLeft"); testButton1.VAnchor = VAnchor.ParentBottom; testButton1.Margin = buttonMargin; flowLayout.AddChild(testButton1); Button testButton2 = new Button("buttonRight"); testButton2.VAnchor = VAnchor.ParentBottom; testButton2.Margin = buttonMargin; flowLayout.AddChild(testButton2); containerTest.AddChild(flowLayout); containerTest.OnDraw(containerTest.NewGraphics2D()); OutputImages(containerControl, containerTest); Assert.IsTrue(containerControl.BackBuffer != null, "When we set a guiWidget to DoubleBuffer it needs to create one."); Assert.IsTrue(containerControl.BackBuffer == containerTest.BackBuffer, "The Anchored widget should be in the correct place."); // make sure it can resize without breaking RectangleDouble bounds = containerTest.LocalBounds; RectangleDouble newBounds = bounds; newBounds.Right += 10; containerTest.LocalBounds = newBounds; Assert.IsTrue(containerControl.BackBuffer != containerTest.BackBuffer, "The Anchored widget should not be the same size."); containerTest.LocalBounds = bounds; containerTest.OnDraw(containerTest.NewGraphics2D()); OutputImages(containerControl, containerTest); Assert.IsTrue(containerControl.BackBuffer == containerTest.BackBuffer, "The Anchored widget should be in the correct place."); }
internal void EnsureCorrectMinimumSize() { { GuiWidget containerTest = new GuiWidget(640, 480); containerTest.DoubleBuffer = true; FlowLayoutWidget leftToRightLayout = new FlowLayoutWidget(FlowDirection.LeftToRight); containerTest.AddChild(leftToRightLayout); GuiWidget item1 = new GuiWidget(10, 11); GuiWidget item2 = new GuiWidget(20, 22); GuiWidget item3 = new GuiWidget(30, 33); item3.HAnchor = HAnchor.ParentLeftRight; leftToRightLayout.AddChild(item1); leftToRightLayout.AddChild(item2); leftToRightLayout.AddChild(item3); leftToRightLayout.AnchorAll(); containerTest.OnDraw(containerTest.NewGraphics2D()); Assert.IsTrue(leftToRightLayout.Width == 640); //Assert.IsTrue(leftToRightLayout.MinimumSize.x == 60); Assert.IsTrue(leftToRightLayout.Height == 480); //Assert.IsTrue(leftToRightLayout.MinimumSize.y == 33); Assert.IsTrue(item3.Width == 610); containerTest.OnDraw(containerTest.NewGraphics2D()); Assert.IsTrue(leftToRightLayout.Width == 640); //Assert.IsTrue(leftToRightLayout.MinimumSize.x == 60); Assert.IsTrue(leftToRightLayout.Height == 480); //Assert.IsTrue(leftToRightLayout.MinimumSize.y == 33); Assert.IsTrue(item3.Width == 610); containerTest.Width = 650; containerTest.OnDraw(containerTest.NewGraphics2D()); Assert.IsTrue(leftToRightLayout.Width == 650); //Assert.IsTrue(leftToRightLayout.MinimumSize.x == 60); Assert.IsTrue(leftToRightLayout.Height == 480); //Assert.IsTrue(leftToRightLayout.MinimumSize.y == 33); Assert.IsTrue(item3.Width == 620); containerTest.Width = 640; containerTest.OnDraw(containerTest.NewGraphics2D()); Assert.IsTrue(leftToRightLayout.Width == 640); //Assert.IsTrue(leftToRightLayout.MinimumSize.x == 60); Assert.IsTrue(leftToRightLayout.Height == 480); //Assert.IsTrue(leftToRightLayout.MinimumSize.y == 33); Assert.IsTrue(item3.Width == 610); } { GuiWidget containerTest = new GuiWidget(640, 480); containerTest.DoubleBuffer = true; FlowLayoutWidget leftToRightLayout = new FlowLayoutWidget(FlowDirection.TopToBottom); containerTest.AddChild(leftToRightLayout); GuiWidget item1 = new GuiWidget(10, 11); GuiWidget item2 = new GuiWidget(20, 22); GuiWidget item3 = new GuiWidget(30, 33); item3.VAnchor = VAnchor.ParentBottomTop; leftToRightLayout.AddChild(item1); leftToRightLayout.AddChild(item2); leftToRightLayout.AddChild(item3); leftToRightLayout.AnchorAll(); containerTest.OnDraw(containerTest.NewGraphics2D()); Assert.IsTrue(leftToRightLayout.Width == 640); //Assert.IsTrue(leftToRightLayout.MinimumSize.x == 30); Assert.IsTrue(leftToRightLayout.Height == 480); //Assert.IsTrue(leftToRightLayout.MinimumSize.y == 66); } }