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); }
public PrintProgressBar(bool widgetIsExtended = true) { 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.Printer.DrawFromHintedCache = true; printTimeElapsed.AutoExpandBoundsToText = true; printTimeElapsed.VAnchor = Agg.UI.VAnchor.ParentCenter; printTimeRemaining = new TextWidget("", pointSize: 11); printTimeRemaining.Printer.DrawFromHintedCache = true; 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); if (ActiveTheme.Instance.IsTouchScreen) { upImageBuffer = StaticData.Instance.LoadIcon("TouchScreen/arrow_up_32x24.png"); downImageBuffer = StaticData.Instance.LoadIcon("TouchScreen/arrow_down_32x24.png"); indicatorWidget = new ImageWidget(upImageBuffer); indicatorWidget.HAnchor = HAnchor.ParentCenter; indicatorWidget.VAnchor = VAnchor.ParentCenter; WidgetIsExtended = widgetIsExtended; GuiWidget indicatorOverlay = new GuiWidget(); indicatorOverlay.AnchorAll(); indicatorOverlay.AddChild(indicatorWidget); AddChild(indicatorOverlay); } ClickWidget clickOverlay = new ClickWidget(); clickOverlay.AnchorAll(); clickOverlay.Click += onProgressBarClick; AddChild(clickOverlay); AddHandlers(); SetThemedColors(); UpdatePrintStatus(); UiThread.RunOnIdle(OnIdle); }
public MeshViewerApplication(string meshFileToLoad = "") : base(800, 600) { BackgroundColor = RGBA_Bytes.White; MinimumSize = new VectorMath.Vector2(200, 200); Title = "MatterHackers MeshViewr"; UseOpenGL = true; FlowLayoutWidget mainContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); mainContainer.AnchorAll(); viewArea = new GuiWidget(); viewArea.AnchorAll(); Vector3 viewerVolume = new Vector3(200, 200, 200); double scale = 1; meshViewerWidget = new MeshViewerWidget(viewerVolume, scale, MeshViewerWidget.BedShape.Rectangular, "No Part Loaded"); meshViewerWidget.AnchorAll(); viewArea.AddChild(meshViewerWidget); mainContainer.AddChild(viewArea); FlowLayoutWidget buttonPanel = new FlowLayoutWidget(FlowDirection.LeftToRight); buttonPanel.HAnchor = HAnchor.ParentLeftRight; buttonPanel.Padding = new BorderDouble(3, 3); buttonPanel.BackgroundColor = RGBA_Bytes.DarkGray; if (meshFileToLoad != "") { meshViewerWidget.LoadMesh(meshFileToLoad); } else { openFileButton = new Button("Open 3D File", 0, 0); openFileButton.Click += new Button.ButtonEventHandler(openFileButton_ButtonClick); buttonPanel.AddChild(openFileButton); } bedCheckBox = new CheckBox("Bed"); bedCheckBox.Checked = true; buttonPanel.AddChild(bedCheckBox); wireframeCheckBox = new CheckBox("Wireframe"); buttonPanel.AddChild(wireframeCheckBox); GuiWidget leftRightSpacer = new GuiWidget(); leftRightSpacer.HAnchor = HAnchor.ParentLeftRight; buttonPanel.AddChild(leftRightSpacer); mainContainer.AddChild(buttonPanel); this.AddChild(mainContainer); this.AnchorAll(); AddHandlers(); }
public TemperatureWidgetBase(string textValue) : base(52 * TextWidget.GlobalPointSizeScaleRatio, 52 * TextWidget.GlobalPointSizeScaleRatio) { whiteButtonFactory.FixedHeight = 18 * TextWidget.GlobalPointSizeScaleRatio; whiteButtonFactory.fontSize = 7; whiteButtonFactory.normalFillColor = RGBA_Bytes.White; whiteButtonFactory.normalTextColor = RGBA_Bytes.DarkGray; FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.TopToBottom); container.AnchorAll(); this.BackgroundColor = new RGBA_Bytes(255, 255, 255, 200); this.Margin = new BorderDouble(0, 2) * TextWidget.GlobalPointSizeScaleRatio; GuiWidget labelContainer = new GuiWidget(); labelContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; labelContainer.Height = 18 * TextWidget.GlobalPointSizeScaleRatio; labelTextWidget = new TextWidget("", pointSize: 8); labelTextWidget.AutoExpandBoundsToText = true; labelTextWidget.HAnchor = HAnchor.ParentCenter; labelTextWidget.VAnchor = VAnchor.ParentCenter; labelTextWidget.TextColor = ActiveTheme.Instance.SecondaryAccentColor; labelTextWidget.Visible = false; labelContainer.AddChild(labelTextWidget); GuiWidget indicatorContainer = new GuiWidget(); indicatorContainer.AnchorAll(); indicatorTextWidget = new TextWidget(textValue, pointSize: 11); indicatorTextWidget.TextColor = ActiveTheme.Instance.PrimaryAccentColor; indicatorTextWidget.HAnchor = HAnchor.ParentCenter; indicatorTextWidget.VAnchor = VAnchor.ParentCenter; indicatorTextWidget.AutoExpandBoundsToText = true; indicatorContainer.AddChild(indicatorTextWidget); GuiWidget buttonContainer = new GuiWidget(); buttonContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; buttonContainer.Height = 18 * TextWidget.GlobalPointSizeScaleRatio; preheatButton = whiteButtonFactory.Generate("Preheat".Localize().ToUpper()); preheatButton.Cursor = Cursors.Hand; preheatButton.Visible = false; buttonContainer.AddChild(preheatButton); container.AddChild(labelContainer); container.AddChild(indicatorContainer); container.AddChild(buttonContainer); this.AddChild(container); ActiveTheme.Instance.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents); this.MouseEnterBounds += onEnterBounds; this.MouseLeaveBounds += onLeaveBounds; this.preheatButton.Click += onPreheatButtonClick; }
public SetupConnectionWidgetBase(ConnectionWindow windowController, GuiWidget containerWindowToClose, PrinterSetupStatus printerSetupStatus = null) : base(windowController, containerWindowToClose) { SetDisplayAttributes(); if (printerSetupStatus == null) { this.currentPrinterSetupStatus = new PrinterSetupStatus(); } else { this.currentPrinterSetupStatus = printerSetupStatus; } cancelButton = textImageButtonFactory.Generate(LocalizedString.Get("Cancel")); cancelButton.Name = "Setup Connection Cancel Button"; 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 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); }
private 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 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(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.ParentLeftRight, VAnchor = VAnchor.ParentBottomTop, }; outerContainer.AddChild(topToBottomContainer); CheckBox toggleBox = new CheckBox("test"); toggleBox.HAnchor = HAnchor.ParentLeftRight; toggleBox.VAnchor = VAnchor.ParentBottomTop; toggleBox.Margin = new BorderDouble(marginSize); toggleBox.BackgroundColor = RGBA_Bytes.Red; toggleBox.DebugShowBounds = true; topToBottomContainer.AddChild(toggleBox); topToBottomContainer.AnchorAll(); topToBottomContainer.PerformLayout(); outerContainer.DoubleBuffer = true; outerContainer.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.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 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); }
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 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 StyledMessageBox(Action<bool> callback, String message, string windowTitle, MessageType messageType, GuiWidget[] extraWidgetsToAdd, double width, double height, string yesOk, string no) : base(width, height) { if (UserSettings.Instance.IsTouchScreen) { extraTextScaling = 1.33333; } textImageButtonFactory.fontSize = extraTextScaling * textImageButtonFactory.fontSize; if (yesOk == "") { if (messageType == MessageType.OK) { yesOk = "Ok".Localize(); } else { yesOk = "Yes".Localize(); } } if (no == "") { no = "No".Localize(); } responseCallback = callback; unwrappedMessage = message; FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); topToBottom.AnchorAll(); if (UserSettings.Instance.IsTouchScreen) { topToBottom.Padding = new BorderDouble(12, 12, 13, 8); } else { topToBottom.Padding = new BorderDouble(3, 0, 3, 5); } // 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(windowTitle, pointSize: 14 * extraTextScaling); 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 middleRowContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); { middleRowContainer.HAnchor = HAnchor.ParentLeftRight; middleRowContainer.VAnchor = VAnchor.ParentBottomTop; // normally the padding for the middle container should be just (5) all around. The has extra top space middleRowContainer.Padding = new BorderDouble(5, 5, 5, 15); middleRowContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; } messageContainer = new TextWidget(message, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 12 * extraTextScaling); messageContainer.AutoExpandBoundsToText = true; messageContainer.HAnchor = Agg.UI.HAnchor.ParentLeft; middleRowContainer.AddChild(messageContainer); if (extraWidgetsToAdd != null) { foreach (GuiWidget widget in extraWidgetsToAdd) { middleRowContainer.AddChild(widget); } } topToBottom.AddChild(middleRowContainer); //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); } switch (messageType) { case MessageType.YES_NO: { Title = "MatterControl - " + "Please Confirm".Localize(); Button yesButton = textImageButtonFactory.Generate(yesOk, centerText: true); yesButton.Name = "Yes Button"; yesButton.Click += new EventHandler(okButton_Click); yesButton.Cursor = Cursors.Hand; buttonRow.AddChild(yesButton); buttonRow.AddChild(new HorizontalSpacer()); Button noButton = textImageButtonFactory.Generate(no, centerText: true); noButton.Name = "No Button"; noButton.Click += new EventHandler(noButton_Click); noButton.Cursor = Cursors.Hand; buttonRow.AddChild(noButton); } break; case MessageType.OK: { Title = "MatterControl - " + "Alert".Localize(); Button okButton = textImageButtonFactory.Generate(LocalizedString.Get("Ok"), centerText: true); okButton.Name = "Ok Button"; okButton.Cursor = Cursors.Hand; okButton.Click += new EventHandler(okButton_Click); buttonRow.AddChild(okButton); } break; default: throw new NotImplementedException(); } topToBottom.AddChild(buttonRow); this.AddChild(topToBottom); IsModal = true; AdjustTextWrap(); }
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.DoPrintLeveling) { 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); }
// private as you can't make one private OutputScrollWindow() : base(400, 300) { this.BackgroundColor = backgroundColor; this.Padding = new BorderDouble(5, 0); FlowLayoutWidget topLeftToRightLayout = new FlowLayoutWidget(); topLeftToRightLayout.AnchorAll(); { FlowLayoutWidget manualEntryTopToBottomLayout = new FlowLayoutWidget(FlowDirection.TopToBottom); manualEntryTopToBottomLayout.VAnchor |= Agg.UI.VAnchor.ParentTop; manualEntryTopToBottomLayout.Padding = new BorderDouble(top:8); { FlowLayoutWidget topBarControls = new FlowLayoutWidget(FlowDirection.LeftToRight); topBarControls.HAnchor |= HAnchor.ParentLeft; string filterOutputChkTxt = LocalizedString.Get("Filter Output"); filterOutput = new CheckBox(filterOutputChkTxt); filterOutput.Margin = new BorderDouble(5, 5, 5, 2); filterOutput.Checked = false; filterOutput.TextColor = this.textColor; filterOutput.CheckedStateChanged += new CheckBox.CheckedStateChangedEventHandler(SetCorrectFilterOutputBehavior); filterOutput.VAnchor = Agg.UI.VAnchor.ParentBottom; topBarControls.AddChild(filterOutput); string autoUpperCaseChkTxt = LocalizedString.Get("Auto Uppercase"); autoUppercase = new CheckBox(autoUpperCaseChkTxt); autoUppercase.Margin = new BorderDouble(5, 5, 5, 2); autoUppercase.Checked = true; autoUppercase.TextColor = this.textColor; autoUppercase.VAnchor = Agg.UI.VAnchor.ParentBottom; topBarControls.AddChild(autoUppercase); manualEntryTopToBottomLayout.AddChild(topBarControls); } { outputScrollWidget = new OutputScroll(); //outputScrollWidget.Height = 100; outputScrollWidget.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; outputScrollWidget.TextColor = ActiveTheme.Instance.PrimaryTextColor; outputScrollWidget.HAnchor = HAnchor.ParentLeftRight; outputScrollWidget.VAnchor = VAnchor.ParentBottomTop; outputScrollWidget.Margin = new BorderDouble(0,5); outputScrollWidget.Padding = new BorderDouble(3, 0); manualEntryTopToBottomLayout.AddChild(outputScrollWidget); } FlowLayoutWidget manualEntryLayout = new FlowLayoutWidget(FlowDirection.LeftToRight); manualEntryLayout.BackgroundColor = this.backgroundColor; manualEntryLayout.HAnchor = HAnchor.ParentLeftRight; { manualCommandTextEdit = new MHTextEditWidget(""); //manualCommandTextEdit.BackgroundColor = RGBA_Bytes.White; manualCommandTextEdit.Margin = new BorderDouble(right: 3); manualCommandTextEdit.HAnchor = HAnchor.ParentLeftRight; manualCommandTextEdit.VAnchor = VAnchor.ParentBottom; manualCommandTextEdit.ActualTextEditWidget.EnterPressed += new KeyEventHandler(manualCommandTextEdit_EnterPressed); manualCommandTextEdit.ActualTextEditWidget.KeyDown += new KeyEventHandler(manualCommandTextEdit_KeyDown); manualEntryLayout.AddChild(manualCommandTextEdit); } manualEntryTopToBottomLayout.AddChild(manualEntryLayout); Button clearConsoleButton = controlButtonFactory.Generate(LocalizedString.Get("Clear")); clearConsoleButton.Margin = new BorderDouble(0); clearConsoleButton.Click += (sender, e) => { outputScrollWidget.Clear(); }; Button closeButton = controlButtonFactory.Generate(LocalizedString.Get("Close")); closeButton.Click += (sender, e) => { UiThread.RunOnIdle(CloseWindow); }; sendCommand = controlButtonFactory.Generate(LocalizedString.Get("Send")); sendCommand.Click += new ButtonBase.ButtonEventHandler(sendManualCommandToPrinter_Click); FlowLayoutWidget bottomRowContainer = new FlowLayoutWidget(); bottomRowContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; bottomRowContainer.Margin = new BorderDouble(0, 3); bottomRowContainer.AddChild(sendCommand); bottomRowContainer.AddChild(clearConsoleButton); bottomRowContainer.AddChild(new HorizontalSpacer()); bottomRowContainer.AddChild(closeButton); manualEntryTopToBottomLayout.AddChild(bottomRowContainer); manualEntryTopToBottomLayout.AnchorAll(); topLeftToRightLayout.AddChild(manualEntryTopToBottomLayout); } AddHandlers(); AddChild(topLeftToRightLayout); SetCorrectFilterOutputBehavior(this, null); this.AnchorAll(); Title = LocalizedString.Get("MatterControl - Terminal"); this.ShowAsSystemWindow(); MinimumSize = new Vector2(Width, Height); }
public TerminalWidget(bool showInWindow) { this.BackgroundColor = backgroundColor; this.Padding = new BorderDouble(5, 0); FlowLayoutWidget topLeftToRightLayout = new FlowLayoutWidget(); topLeftToRightLayout.AnchorAll(); { FlowLayoutWidget manualEntryTopToBottomLayout = new FlowLayoutWidget(FlowDirection.TopToBottom); manualEntryTopToBottomLayout.VAnchor |= Agg.UI.VAnchor.ParentTop; manualEntryTopToBottomLayout.Padding = new BorderDouble(top: 8); { FlowLayoutWidget topBarControls = new FlowLayoutWidget(FlowDirection.LeftToRight); topBarControls.HAnchor |= HAnchor.ParentLeft; { string filterOutputChkTxt = LocalizedString.Get("Filter Output"); filterOutput = new CheckBox(filterOutputChkTxt); filterOutput.Margin = new BorderDouble(5, 5, 5, 2); filterOutput.TextColor = this.textColor; filterOutput.CheckedStateChanged += (object sender, EventArgs e) => { if (filterOutput.Checked) { textScrollWidget.SetLineStartFilter(new string[] { "<-wait", "<-ok", "->M105", "<-T" }); } else { textScrollWidget.SetLineStartFilter(null); } UserSettings.Instance.Fields.SetBool(TerminalFilterOutputKey, filterOutput.Checked); }; filterOutput.VAnchor = Agg.UI.VAnchor.ParentBottom; topBarControls.AddChild(filterOutput); } { string autoUpperCaseChkTxt = LocalizedString.Get("Auto Uppercase"); autoUppercase = new CheckBox(autoUpperCaseChkTxt); autoUppercase.Margin = new BorderDouble(5, 5, 5, 2); autoUppercase.Checked = UserSettings.Instance.Fields.GetBool(TerminalAutoUppercaseKey, true); autoUppercase.TextColor = this.textColor; autoUppercase.VAnchor = Agg.UI.VAnchor.ParentBottom; topBarControls.AddChild(autoUppercase); autoUppercase.CheckedStateChanged += (sender, e) => { UserSettings.Instance.Fields.SetBool(TerminalAutoUppercaseKey, autoUppercase.Checked); }; manualEntryTopToBottomLayout.AddChild(topBarControls); } } { FlowLayoutWidget leftToRight = new FlowLayoutWidget(); leftToRight.AnchorAll(); textScrollWidget = new TextScrollWidget(PrinterOutputCache.Instance.PrinterLines); //outputScrollWidget.Height = 100; textScrollWidget.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; textScrollWidget.TextColor = ActiveTheme.Instance.PrimaryTextColor; textScrollWidget.HAnchor = HAnchor.ParentLeftRight; textScrollWidget.VAnchor = VAnchor.ParentBottomTop; textScrollWidget.Margin = new BorderDouble(0, 5); textScrollWidget.Padding = new BorderDouble(3, 0); leftToRight.AddChild(textScrollWidget); TextScrollBar textScrollBar = new TextScrollBar(textScrollWidget, 15); leftToRight.AddChild(textScrollBar); manualEntryTopToBottomLayout.AddChild(leftToRight); } FlowLayoutWidget manualEntryLayout = new FlowLayoutWidget(FlowDirection.LeftToRight); manualEntryLayout.BackgroundColor = this.backgroundColor; manualEntryLayout.HAnchor = HAnchor.ParentLeftRight; { manualCommandTextEdit = new MHTextEditWidget(""); //manualCommandTextEdit.BackgroundColor = RGBA_Bytes.White; manualCommandTextEdit.Margin = new BorderDouble(right: 3); manualCommandTextEdit.HAnchor = HAnchor.ParentLeftRight; manualCommandTextEdit.VAnchor = VAnchor.ParentBottom; manualCommandTextEdit.ActualTextEditWidget.EnterPressed += new KeyEventHandler(manualCommandTextEdit_EnterPressed); manualCommandTextEdit.ActualTextEditWidget.KeyDown += new KeyEventHandler(manualCommandTextEdit_KeyDown); manualEntryLayout.AddChild(manualCommandTextEdit); } manualEntryTopToBottomLayout.AddChild(manualEntryLayout); Button clearConsoleButton = controlButtonFactory.Generate(LocalizedString.Get("Clear")); clearConsoleButton.Margin = new BorderDouble(0); clearConsoleButton.Click += (sender, e) => { PrinterOutputCache.Instance.Clear(); }; //Output Console text to screen Button exportConsoleTextButton = controlButtonFactory.Generate(LocalizedString.Get("Export...")); exportConsoleTextButton.Click += (sender, mouseEvent) => { UiThread.RunOnIdle(DoExportExportLog_Click); }; Button closeButton = controlButtonFactory.Generate(LocalizedString.Get("Close")); closeButton.Click += (sender, e) => { UiThread.RunOnIdle(CloseWindow); }; sendCommand = controlButtonFactory.Generate(LocalizedString.Get("Send")); sendCommand.Click += new EventHandler(sendManualCommandToPrinter_Click); FlowLayoutWidget bottomRowContainer = new FlowLayoutWidget(); bottomRowContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; bottomRowContainer.Margin = new BorderDouble(0, 3); bottomRowContainer.AddChild(sendCommand); bottomRowContainer.AddChild(clearConsoleButton); bottomRowContainer.AddChild(exportConsoleTextButton); bottomRowContainer.AddChild(new HorizontalSpacer()); if (showInWindow) { bottomRowContainer.AddChild(closeButton); } manualEntryTopToBottomLayout.AddChild(bottomRowContainer); manualEntryTopToBottomLayout.AnchorAll(); topLeftToRightLayout.AddChild(manualEntryTopToBottomLayout); } AddChild(topLeftToRightLayout); this.AnchorAll(); }
private void LoadContent() { this.Padding = new BorderDouble(3); this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; this.AnchorAll(); textImageButtonFactory.borderWidth = 0; editButtonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor; editButtonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor; editButtonFactory.disabledTextColor = ActiveTheme.Instance.TabLabelUnselected; editButtonFactory.disabledFillColor = new RGBA_Bytes(); editButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor; editButtonFactory.borderWidth = 0; editButtonFactory.Margin = new BorderDouble(10, 0); FlowLayoutWidget allControls = new FlowLayoutWidget(FlowDirection.TopToBottom); { enterEditModeButton = editButtonFactory.Generate("Edit".Localize(), centerText: true); enterEditModeButton.Click += enterEditModeButtonClick; leaveEditModeButton = editButtonFactory.Generate("Done".Localize(), centerText: true); leaveEditModeButton.Click += leaveEditModeButtonClick; // make sure the buttons are the same size even when localized if (leaveEditModeButton.Width < enterEditModeButton.Width) { editButtonFactory.FixedWidth = enterEditModeButton.Width; leaveEditModeButton = editButtonFactory.Generate("Done".Localize(), centerText: true); leaveEditModeButton.Click += leaveEditModeButtonClick; } else { editButtonFactory.FixedWidth = leaveEditModeButton.Width; enterEditModeButton = editButtonFactory.Generate("Edit".Localize(), centerText: true); enterEditModeButton.Click += enterEditModeButtonClick; } enterEditModeButton.Name = "Library Edit Button"; leaveEditModeButton.Visible = false; FlowLayoutWidget navigationPanel = new FlowLayoutWidget(); navigationPanel.HAnchor = HAnchor.ParentLeftRight; navigationPanel.Padding = new BorderDouble(0); navigationPanel.BackgroundColor = ActiveTheme.Instance.TransparentLightOverlay; navigationLabel = new TextWidget("My Library".Localize(), pointSize: 14); navigationLabel.VAnchor = Agg.UI.VAnchor.ParentCenter; navigationLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor; navigationPanel.AddChild(new GuiWidget(50, 0)); //Add this as temporary balance to edit buttons navigationPanel.AddChild(new HorizontalSpacer()); navigationPanel.AddChild(navigationLabel); navigationPanel.AddChild(new HorizontalSpacer()); buttonPanel = new FlowLayoutWidget(); buttonPanel.HAnchor = HAnchor.ParentLeftRight; buttonPanel.Padding = new BorderDouble(0, 3); buttonPanel.MinimumSize = new Vector2(0, 46); AddLibraryButtonElements(); //allControls.AddChild(navigationPanel); allControls.AddChild(CreateSearchPannel()); libraryDataView = new LibraryDataView(); breadCrumbWidget = new FolderBreadCrumbWidget(libraryDataView.SetCurrentLibraryProvider, libraryDataView.CurrentLibraryProvider); FlowLayoutWidget breadCrumbSpaceHolder = new FlowLayoutWidget() { HAnchor = HAnchor.ParentLeftRight, }; breadCrumbSpaceHolder.AddChild(breadCrumbWidget); libraryDataView.ChangedCurrentLibraryProvider += breadCrumbWidget.SetBreadCrumbs; libraryDataView.ChangedCurrentLibraryProvider += LibraryProviderChanged; breadCrumbAndActionBar = new FlowLayoutWidget() { HAnchor = HAnchor.ParentLeftRight, }; breadCrumbAndActionBar.AddChild(breadCrumbSpaceHolder); breadCrumbAndActionBar.AddChild(CreateActionsMenu()); allControls.AddChild(breadCrumbAndActionBar); allControls.AddChild(libraryDataView); allControls.AddChild(buttonPanel); } allControls.AnchorAll(); this.AddChild(allControls); }
public EditTemperaturePresetsWindow(string windowTitle, string temperatureSettings, EventHandler functionToCallOnSave) : base(360, 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 tempShortcutPresetLabel = LocalizedString.Get("Temperature Shortcut Presets"); string tempShortcutPresetLabelFull = string.Format("{0}:", tempShortcutPresetLabel); TextWidget elementHeader = new TextWidget(tempShortcutPresetLabelFull, 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 * GuiWidget.DeviceScale; 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 labelLabelContainer = new GuiWidget(); labelLabelContainer.Width = 66; labelLabelContainer.Height = 16; labelLabelContainer.Margin = new BorderDouble(3, 0); string labelLabelTxt = LocalizedString.Get("Label"); TextWidget labelLabel = new TextWidget(string.Format(labelLabelTxt), textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 10); labelLabel.HAnchor = HAnchor.ParentLeft; labelLabel.VAnchor = VAnchor.ParentCenter; labelLabelContainer.AddChild(labelLabel); GuiWidget tempLabelContainer = new GuiWidget(); tempLabelContainer.Width = 66; tempLabelContainer.Height = 16; tempLabelContainer.Margin = new BorderDouble(3, 0); TextWidget tempLabel = new TextWidget(string.Format("Temp (C)"), textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 10); tempLabel.HAnchor = HAnchor.ParentLeft; tempLabel.VAnchor = VAnchor.ParentCenter; tempLabelContainer.AddChild(tempLabel); leftRightLabels.AddChild(hLabelSpacer); leftRightLabels.AddChild(labelLabelContainer); leftRightLabels.AddChild(tempLabelContainer); presetsFormContainer.AddChild(leftRightLabels); // put in the temperature edit controls string[] settingsArray = temperatureSettings.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; string presetLabelTxt = LocalizedString.Get("Preset"); TextWidget label = new TextWidget(string.Format("{1} {0}", preset_count, presetLabelTxt), textColor: ActiveTheme.Instance.PrimaryTextColor); label.VAnchor = VAnchor.ParentCenter; leftRightEdit.AddChild(label); leftRightEdit.AddChild(new HorizontalSpacer()); MHTextEditWidget typeEdit = new MHTextEditWidget(settingsArray[i], pixelWidth: 60, tabIndex: tab_index++); typeEdit.Margin = new BorderDouble(3); leftRightEdit.AddChild(typeEdit); listWithValues.Add(typeEdit); double temperatureValue = 0; double.TryParse(settingsArray[i + 1], out temperatureValue); MHNumberEdit valueEdit = new MHNumberEdit(temperatureValue, 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; } { FlowLayoutWidget leftRightEdit = new FlowLayoutWidget(); leftRightEdit.Padding = new BorderDouble(3); leftRightEdit.HAnchor |= Agg.UI.HAnchor.ParentLeftRight; TextWidget maxWidgetLabel = new TextWidget(LocalizedString.Get("Max Temp"), textColor: ActiveTheme.Instance.PrimaryTextColor); maxWidgetLabel.VAnchor = VAnchor.ParentCenter; leftRightEdit.AddChild(maxWidgetLabel); leftRightEdit.AddChild(new HorizontalSpacer()); double maxTemperature = 0; double.TryParse(settingsArray[settingsArray.Count() - 1], out maxTemperature); MHNumberEdit valueEdit = new MHNumberEdit(maxTemperature, minValue: 0, pixelWidth: 60, tabIndex: tab_index); valueEdit.Margin = new BorderDouble(3); leftRightEdit.AddChild(valueEdit); listWithValues.Add(valueEdit); presetsFormContainer.AddChild(leftRightEdit); } textImageButtonFactory.FixedHeight = oldHeight; ShowAsSystemWindow(); MinimumSize = new Vector2(360, 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) => { CloseOnIdle(); }; 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 EditLevelingSettingsWindow() : base(400, 370) { Title = LocalizedString.Get("Leveling Settings".Localize()); 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("Sampled Positions".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); BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; double oldHeight = textImageButtonFactory.FixedHeight; textImageButtonFactory.FixedHeight = 30 * TextWidget.GlobalPointSizeScaleRatio; // put in the movement edit controls PrintLevelingData levelingData = PrintLevelingData.GetForPrinter(ActivePrinterProfile.Instance.ActivePrinter); if (EditSamplePositionList(levelingData)) { for (int i = 0; i < levelingData.SampledPositions.Count; i++) { positions.Add(levelingData.SampledPositions[i]); } } else { positions.Add(levelingData.SampledPosition0); positions.Add(levelingData.SampledPosition1); positions.Add(levelingData.SampledPosition2); } int tab_index = 0; for (int row = 0; row < positions.Count; row++) { FlowLayoutWidget leftRightEdit = new FlowLayoutWidget(); leftRightEdit.Padding = new BorderDouble(3); leftRightEdit.HAnchor |= Agg.UI.HAnchor.ParentLeftRight; TextWidget positionLabel; string whichPositionText = LocalizedString.Get("Position"); positionLabel = new TextWidget("{0} {1,-5}".FormatWith(whichPositionText, row + 1), textColor: ActiveTheme.Instance.PrimaryTextColor); positionLabel.VAnchor = VAnchor.ParentCenter; leftRightEdit.AddChild(positionLabel); for (int axis = 0; axis < 3; axis++) { GuiWidget hSpacer = new GuiWidget(); hSpacer.HAnchor = HAnchor.ParentLeftRight; leftRightEdit.AddChild(hSpacer); string axisName = "x"; if (axis == 1) axisName = "y"; else if (axis == 2) axisName = "z"; TextWidget typeEdit = new TextWidget(" {0}: ".FormatWith(axisName), textColor: ActiveTheme.Instance.PrimaryTextColor); typeEdit.VAnchor = VAnchor.ParentCenter; leftRightEdit.AddChild(typeEdit); int linkCompatibleRow = row; int linkCompatibleAxis = axis; double minValue = double.MinValue; if (axis == 2 && ActiveSliceSettings.Instance.GetActiveValue("z_can_be_negative") == "0") { minValue = 0; } MHNumberEdit valueEdit = new MHNumberEdit(positions[linkCompatibleRow][linkCompatibleAxis], allowNegatives: true, allowDecimals: true, minValue: minValue, pixelWidth: 60, tabIndex: tab_index++); valueEdit.ActuallNumberEdit.InternalTextEditWidget.EditComplete += (sender, e) => { Vector3 position = positions[linkCompatibleRow]; position[linkCompatibleAxis] = valueEdit.ActuallNumberEdit.Value; positions[linkCompatibleRow] = position; }; valueEdit.Margin = new BorderDouble(3); leftRightEdit.AddChild(valueEdit); } presetsFormContainer.AddChild(leftRightEdit); presetsFormContainer.AddChild(new CustomWidgets.HorizontalLine()); } textImageButtonFactory.FixedHeight = oldHeight; ShowAsSystemWindow(); MinimumSize = new Vector2(Width, Height); Button savePresetsButton = textImageButtonFactory.Generate("Save".Localize()); savePresetsButton.Click += new EventHandler(save_Click); Button cancelPresetsButton = textImageButtonFactory.Generate("Cancel".Localize()); cancelPresetsButton.Click += (sender, e) => { UiThread.RunOnIdle(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 PrintLibraryWidget() { SetDisplayAttributes(); textImageButtonFactory.normalTextColor = RGBA_Bytes.White; textImageButtonFactory.hoverTextColor = RGBA_Bytes.White; textImageButtonFactory.disabledTextColor = RGBA_Bytes.White; textImageButtonFactory.pressedTextColor = RGBA_Bytes.White; textImageButtonFactory.borderWidth = 0; searchButtonFactory.normalTextColor = ActiveTheme.Instance.PrimaryBackgroundColor; searchButtonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryBackgroundColor; searchButtonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryBackgroundColor; searchButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryBackgroundColor; searchButtonFactory.borderWidth = 0; FlowLayoutWidget allControls = new FlowLayoutWidget(FlowDirection.TopToBottom); { FlowLayoutWidget searchPanel = new FlowLayoutWidget(); searchPanel.BackgroundColor = new RGBA_Bytes(180, 180, 180); searchPanel.HAnchor = HAnchor.ParentLeftRight; searchPanel.Padding = new BorderDouble(3, 3); { searchInput = new MHTextEditWidget(); searchInput.Margin = new BorderDouble(6, 0); searchInput.HAnchor = HAnchor.ParentLeftRight; searchInput.VAnchor = VAnchor.ParentCenter; searchButton = searchButtonFactory.Generate(new LocalizedString("Search").Translated); searchButton.Margin = new BorderDouble(right:9); searchPanel.AddChild(searchInput); searchPanel.AddChild(searchButton); } FlowLayoutWidget buttonPanel = new FlowLayoutWidget(); buttonPanel.HAnchor = HAnchor.ParentLeftRight; buttonPanel.Padding = new BorderDouble(0, 3); { Button addToLibrary = textImageButtonFactory.Generate(new LocalizedString("Import").Translated, "icon_import_white_32x32.png"); buttonPanel.AddChild(addToLibrary); addToLibrary.Margin = new BorderDouble(0, 0, 3, 0); addToLibrary.Click += new ButtonBase.ButtonEventHandler(loadFile_Click); Button runCreator = textImageButtonFactory.Generate(new LocalizedString("Create").Translated, "icon_creator_white_32x32.png"); buttonPanel.AddChild(runCreator); runCreator.Margin = new BorderDouble(0, 0, 3, 0); runCreator.Click += (sender, e) => { OpenPluginChooserWindow(); }; addToQueueButton = textImageButtonFactory.Generate("Add to Queue"); addToQueueButton.Margin = new BorderDouble(3, 0); addToQueueButton.Click += new ButtonBase.ButtonEventHandler(addToQueueButton_Click); addToQueueButton.Visible = false; buttonPanel.AddChild(addToQueueButton); deleteFromLibraryButton = textImageButtonFactory.Generate("Remove"); deleteFromLibraryButton.Margin = new BorderDouble(3, 0); deleteFromLibraryButton.Click += new ButtonBase.ButtonEventHandler(deleteFromQueueButton_Click); deleteFromLibraryButton.Visible = false; buttonPanel.AddChild(deleteFromLibraryButton); GuiWidget spacer = new GuiWidget(); spacer.HAnchor = HAnchor.ParentLeftRight; buttonPanel.AddChild(spacer); } allControls.AddChild(searchPanel); allControls.AddChild(PrintLibraryListControl.Instance); allControls.AddChild(buttonPanel); } allControls.AnchorAll(); this.AddChild(allControls); AddHandlers(); }
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 View3DWidget(PrintItemWrapper printItemWrapper, Vector3 viewerVolume, Vector2 bedCenter, MeshViewerWidget.BedShape bedShape, WindowMode windowType, AutoRotate autoRotate, OpenMode openMode = OpenMode.Viewing) { this.openMode = openMode; this.windowType = windowType; allowAutoRotate = (autoRotate == AutoRotate.Enabled); autoRotating = allowAutoRotate; MeshGroupExtraData = new List<PlatingMeshGroupData>(); MeshGroupExtraData.Add(new PlatingMeshGroupData()); this.printItemWrapper = printItemWrapper; FlowLayoutWidget mainContainerTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); mainContainerTopToBottom.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth; mainContainerTopToBottom.VAnchor = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight; FlowLayoutWidget centerPartPreviewAndControls = new FlowLayoutWidget(FlowDirection.LeftToRight); centerPartPreviewAndControls.Name = "centerPartPreviewAndControls"; centerPartPreviewAndControls.AnchorAll(); GuiWidget viewArea = new GuiWidget(); viewArea.AnchorAll(); { meshViewerWidget = new MeshViewerWidget(viewerVolume, bedCenter, bedShape, "Press 'Add' to select an item.".Localize()); PutOemImageOnBed(); meshViewerWidget.AnchorAll(); } viewArea.AddChild(meshViewerWidget); centerPartPreviewAndControls.AddChild(viewArea); mainContainerTopToBottom.AddChild(centerPartPreviewAndControls); FlowLayoutWidget buttonBottomPanel = new FlowLayoutWidget(FlowDirection.LeftToRight); buttonBottomPanel.HAnchor = HAnchor.ParentLeftRight; buttonBottomPanel.Padding = new BorderDouble(3, 3); buttonBottomPanel.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; buttonRightPanel = CreateRightButtonPanel(viewerVolume.y); buttonRightPanel.Name = "buttonRightPanel"; buttonRightPanel.Visible = false; CreateOptionsContent(); // add in the plater tools { FlowLayoutWidget editToolBar = new FlowLayoutWidget(); string progressFindPartsLabel = "Entering Editor".Localize(); string progressFindPartsLabelFull = "{0}:".FormatWith(progressFindPartsLabel); processingProgressControl = new ProgressControl(progressFindPartsLabelFull, ActiveTheme.Instance.PrimaryTextColor, ActiveTheme.Instance.PrimaryAccentColor); processingProgressControl.VAnchor = Agg.UI.VAnchor.ParentCenter; editToolBar.AddChild(processingProgressControl); editToolBar.VAnchor |= Agg.UI.VAnchor.ParentCenter; processingProgressControl.Visible = false; // If the window is embeded (in the center pannel) and there is no item loaded then don't show the add button enterEditButtonsContainer = new FlowLayoutWidget(); { Button addButton = textImageButtonFactory.Generate("Insert".Localize(), "icon_insert_32x32.png"); addButton.ToolTipText = "Insert an .stl, .amf or .zip file".Localize(); addButton.Margin = new BorderDouble(right: 0); enterEditButtonsContainer.AddChild(addButton); addButton.Click += (sender, e) => { UiThread.RunOnIdle(() => { DoAddFileAfterCreatingEditData = true; EnterEditAndCreateSelectionData(); }); }; if (printItemWrapper != null && printItemWrapper.PrintItem.ReadOnly) { addButton.Enabled = false; } Button enterEdittingButton = textImageButtonFactory.Generate("Edit".Localize(), "icon_edit_32x32.png"); enterEdittingButton.Margin = new BorderDouble(right: 4); enterEdittingButton.Click += (sender, e) => { EnterEditAndCreateSelectionData(); }; if (printItemWrapper != null && printItemWrapper.PrintItem.ReadOnly) { enterEdittingButton.Enabled = false; } Button exportButton = textImageButtonFactory.Generate("Export...".Localize()); if (printItemWrapper != null && (printItemWrapper.PrintItem.Protected || printItemWrapper.PrintItem.ReadOnly)) { exportButton.Enabled = false; } exportButton.Margin = new BorderDouble(right: 10); exportButton.Click += (sender, e) => { UiThread.RunOnIdle(() => { OpenExportWindow(); }); }; enterEditButtonsContainer.AddChild(enterEdittingButton); enterEditButtonsContainer.AddChild(exportButton); } editToolBar.AddChild(enterEditButtonsContainer); doEdittingButtonsContainer = new FlowLayoutWidget(); doEdittingButtonsContainer.Visible = false; { Button addButton = textImageButtonFactory.Generate("Insert".Localize(), "icon_insert_32x32.png"); addButton.Margin = new BorderDouble(right: 10); doEdittingButtonsContainer.AddChild(addButton); addButton.Click += (sender, e) => { UiThread.RunOnIdle(() => { FileDialog.OpenFileDialog( new OpenFileDialogParams(ApplicationSettings.OpenDesignFileParams, multiSelect: true), (openParams) => { LoadAndAddPartsToPlate(openParams.FileNames); }); }); }; GuiWidget separator = new GuiWidget(1, 2); separator.BackgroundColor = ActiveTheme.Instance.PrimaryTextColor; separator.Margin = new BorderDouble(4, 2); separator.VAnchor = VAnchor.ParentBottomTop; doEdittingButtonsContainer.AddChild(separator); Button ungroupButton = textImageButtonFactory.Generate("Ungroup".Localize()); doEdittingButtonsContainer.AddChild(ungroupButton); ungroupButton.Click += (sender, e) => { UngroupSelectedMeshGroup(); }; Button groupButton = textImageButtonFactory.Generate("Group".Localize()); doEdittingButtonsContainer.AddChild(groupButton); groupButton.Click += (sender, e) => { GroupSelectedMeshs(); }; Button alignButton = textImageButtonFactory.Generate("Align".Localize()); doEdittingButtonsContainer.AddChild(alignButton); alignButton.Click += (sender, e) => { AlignToSelectedMeshGroup(); }; Button arrangeButton = textImageButtonFactory.Generate("Arrange".Localize()); doEdittingButtonsContainer.AddChild(arrangeButton); arrangeButton.Click += (sender, e) => { AutoArrangePartsInBackground(); }; GuiWidget separatorTwo = new GuiWidget(1, 2); separatorTwo.BackgroundColor = ActiveTheme.Instance.PrimaryTextColor; separatorTwo.Margin = new BorderDouble(4, 2); separatorTwo.VAnchor = VAnchor.ParentBottomTop; doEdittingButtonsContainer.AddChild(separatorTwo); Button copyButton = textImageButtonFactory.Generate("Copy".Localize()); doEdittingButtonsContainer.AddChild(copyButton); copyButton.Click += (sender, e) => { MakeCopyOfGroup(); }; Button deleteButton = textImageButtonFactory.Generate("Remove".Localize()); doEdittingButtonsContainer.AddChild(deleteButton); deleteButton.Click += (sender, e) => { DeleteSelectedMesh(); }; GuiWidget separatorThree = new GuiWidget(1, 2); separatorThree.BackgroundColor = ActiveTheme.Instance.PrimaryTextColor; separatorThree.Margin = new BorderDouble(4, 1); separatorThree.VAnchor = VAnchor.ParentBottomTop; doEdittingButtonsContainer.AddChild(separatorThree); Button leaveEditModeButton = textImageButtonFactory.Generate("Cancel".Localize(), centerText: true); leaveEditModeButton.Click += (sender, e) => { UiThread.RunOnIdle(() => { if (saveButtons.Visible) { StyledMessageBox.ShowMessageBox(ExitEditingAndSaveIfRequired, "Would you like to save your changes before exiting the editor?", "Save Changes", StyledMessageBox.MessageType.YES_NO); } else { if (partHasBeenEdited) { ExitEditingAndSaveIfRequired(false); } else { SwitchStateToNotEditing(); } } }); }; doEdittingButtonsContainer.AddChild(leaveEditModeButton); // put in the save button AddSaveAndSaveAs(doEdittingButtonsContainer); } KeyDown += (sender, e) => { KeyEventArgs keyEvent = e as KeyEventArgs; if (keyEvent != null && !keyEvent.Handled) { if (keyEvent.KeyCode == Keys.Delete || keyEvent.KeyCode == Keys.Back) { DeleteSelectedMesh(); } if (keyEvent.KeyCode == Keys.Escape) { if (meshSelectInfo.downOnPart) { meshSelectInfo.downOnPart = false; ScaleRotateTranslate translated = SelectedMeshGroupTransform; translated.translation = transformOnMouseDown; SelectedMeshGroupTransform = translated; Invalidate(); } } } }; editToolBar.AddChild(doEdittingButtonsContainer); buttonBottomPanel.AddChild(editToolBar); } GuiWidget buttonRightPanelHolder = new GuiWidget(HAnchor.FitToChildren, VAnchor.ParentBottomTop); buttonRightPanelHolder.Name = "buttonRightPanelHolder"; centerPartPreviewAndControls.AddChild(buttonRightPanelHolder); buttonRightPanelHolder.AddChild(buttonRightPanel); viewControls3D = new ViewControls3D(meshViewerWidget); buttonRightPanelDisabledCover = new Cover(HAnchor.ParentLeftRight, VAnchor.ParentBottomTop); buttonRightPanelDisabledCover.BackgroundColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryBackgroundColor, 150); buttonRightPanelHolder.AddChild(buttonRightPanelDisabledCover); viewControls3D.PartSelectVisible = false; LockEditControls(); GuiWidget leftRightSpacer = new GuiWidget(); leftRightSpacer.HAnchor = HAnchor.ParentLeftRight; buttonBottomPanel.AddChild(leftRightSpacer); if (windowType == WindowMode.StandAlone) { Button closeButton = textImageButtonFactory.Generate("Close".Localize()); buttonBottomPanel.AddChild(closeButton); closeButton.Click += (sender, e) => { CloseOnIdle(); }; } mainContainerTopToBottom.AddChild(buttonBottomPanel); this.AddChild(mainContainerTopToBottom); this.AnchorAll(); meshViewerWidget.TrackballTumbleWidget.TransformState = TrackBallController.MouseDownType.Rotation; AddChild(viewControls3D); AddHandlers(); UiThread.RunOnIdle(AutoSpin); if (printItemWrapper == null && windowType == WindowMode.Embeded) { enterEditButtonsContainer.Visible = false; } if (windowType == WindowMode.Embeded) { PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(SetEditControlsBasedOnPrinterState, ref unregisterEvents); if (windowType == WindowMode.Embeded) { // make sure we lock the controls if we are printing or paused switch (PrinterConnectionAndCommunication.Instance.CommunicationState) { case PrinterConnectionAndCommunication.CommunicationStates.Printing: case PrinterConnectionAndCommunication.CommunicationStates.Paused: LockEditControls(); break; } } } ActiveTheme.Instance.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents); upArrow = new UpArrow3D(this); heightDisplay = new HeightValueDisplay(this); heightDisplay.Visible = false; meshViewerWidget.interactionVolumes.Add(upArrow); // make sure the colors are set correctl ThemeChanged(this, null); saveButtons.VisibleChanged += (sender, e) => { partHasBeenEdited = true; }; }
private void CreateAndAddChildren() { TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory(); textImageButtonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor; CloseAllChildren(); gcodeViewWidget = null; gcodeProcessingStateInfoText = null; FlowLayoutWidget mainContainerTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); mainContainerTopToBottom.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth; mainContainerTopToBottom.VAnchor = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight; buttonBottomPanel = new FlowLayoutWidget(FlowDirection.LeftToRight); buttonBottomPanel.HAnchor = HAnchor.ParentLeftRight; buttonBottomPanel.Padding = new BorderDouble(3, 3); buttonBottomPanel.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; generateGCodeButton = textImageButtonFactory.Generate(LocalizedString.Get("Generate")); generateGCodeButton.Click += new EventHandler(generateButton_Click); buttonBottomPanel.AddChild(generateGCodeButton); layerSelectionButtonsPanel = new FlowLayoutWidget(FlowDirection.RightToLeft); layerSelectionButtonsPanel.HAnchor = HAnchor.ParentLeftRight; layerSelectionButtonsPanel.Padding = new BorderDouble(0); GuiWidget holdPanelOpen = new GuiWidget(1, generateGCodeButton.Height); layerSelectionButtonsPanel.AddChild(holdPanelOpen); if (windowMode == WindowMode.StandAlone) { Button closeButton = textImageButtonFactory.Generate(LocalizedString.Get("Close")); layerSelectionButtonsPanel.AddChild(closeButton); closeButton.Click += (sender, e) => { CloseOnIdle(); }; } FlowLayoutWidget centerPartPreviewAndControls = new FlowLayoutWidget(FlowDirection.LeftToRight); centerPartPreviewAndControls.AnchorAll(); gcodeDisplayWidget = new GuiWidget(HAnchor.ParentLeftRight, Agg.UI.VAnchor.ParentBottomTop); string firstProcessingMessage = "Press 'Add' to select an item.".Localize(); if (printItem != null) { firstProcessingMessage = "Loading G-Code...".Localize(); if (Path.GetExtension(printItem.FileLocation).ToUpper() == ".GCODE") { gcodeDisplayWidget.AddChild(CreateGCodeViewWidget(printItem.FileLocation)); } else { if (File.Exists(printItem.FileLocation)) { string gcodePathAndFileName = printItem.GetGCodePathAndFileName(); bool gcodeFileIsComplete = printItem.IsGCodeFileComplete(gcodePathAndFileName); if (printItem.SlicingHadError) { firstProcessingMessage = slicingErrorMessage; } else { firstProcessingMessage = pressGenerateMessage; } if (File.Exists(gcodePathAndFileName) && gcodeFileIsComplete) { gcodeDisplayWidget.AddChild(CreateGCodeViewWidget(gcodePathAndFileName)); } // we only hook these up to make sure we can regenerate the gcode when we want printItem.SlicingOutputMessage += sliceItem_SlicingOutputMessage; printItem.SlicingDone += sliceItem_Done; } else { firstProcessingMessage = string.Format("{0}\n'{1}'", fileNotFoundMessage, printItem.Name); } } } else { generateGCodeButton.Visible = false; } SetProcessingMessage(firstProcessingMessage); centerPartPreviewAndControls.AddChild(gcodeDisplayWidget); buttonRightPanel = CreateRightButtonPanel(); buttonRightPanel.Visible = false; centerPartPreviewAndControls.AddChild(buttonRightPanel); // add in a spacer layerSelectionButtonsPanel.AddChild(new GuiWidget(HAnchor.ParentLeftRight)); buttonBottomPanel.AddChild(layerSelectionButtonsPanel); mainContainerTopToBottom.AddChild(centerPartPreviewAndControls); mainContainerTopToBottom.AddChild(buttonBottomPanel); this.AddChild(mainContainerTopToBottom); meshViewerWidget = new MeshViewerWidget(viewerVolume, bedCenter, bedShape, "".Localize()); meshViewerWidget.AnchorAll(); meshViewerWidget.AllowBedRenderingWhenEmpty = true; gcodeDisplayWidget.AddChild(meshViewerWidget); meshViewerWidget.Visible = false; meshViewerWidget.TrackballTumbleWidget.DrawGlContent += new EventHandler(TrackballTumbleWidget_DrawGlContent); viewControls2D = new ViewControls2D(); AddChild(viewControls2D); viewControls2D.ResetView += (sender, e) => { SetDefaultView2D(); }; viewControls3D = new ViewControls3D(meshViewerWidget); viewControls3D.PartSelectVisible = false; AddChild(viewControls3D); viewControls3D.ResetView += (sender, e) => { SetDefaultView(); }; viewControls3D.ActiveButton = ViewControls3DButtons.Rotate; viewControls3D.Visible = false; viewControlsToggle = new ViewControlsToggle(); viewControlsToggle.HAnchor = Agg.UI.HAnchor.ParentRight; AddChild(viewControlsToggle); viewControlsToggle.Visible = false; //viewControls3D.translateButton.ClickButton(null); SetDefaultView(); viewControls2D.translateButton.Click += (sender, e) => { gcodeViewWidget.TransformState = ViewGcodeWidget.ETransformState.Move; }; viewControls2D.scaleButton.Click += (sender, e) => { gcodeViewWidget.TransformState = ViewGcodeWidget.ETransformState.Scale; }; AddHandlers(); }
private void DoLayout(string subjectText, string bodyText) { FlowLayoutWidget mainContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); mainContainer.AnchorAll(); GuiWidget labelContainer = new GuiWidget(); labelContainer.HAnchor = HAnchor.ParentLeftRight; labelContainer.Height = 30; TextWidget formLabel = new TextWidget(LocalizedString.Get("How can we help?"), pointSize: 16); formLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor; formLabel.VAnchor = VAnchor.ParentTop; formLabel.HAnchor = HAnchor.ParentLeft; formLabel.Margin = new BorderDouble(6, 3,6,6); labelContainer.AddChild(formLabel); mainContainer.AddChild(labelContainer); centerContainer = new GuiWidget(); centerContainer.AnchorAll(); centerContainer.Padding = new BorderDouble(3,0,3,3); messageContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); messageContainer.AnchorAll(); messageContainer.Visible = false; messageContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; messageContainer.Padding = new BorderDouble(10); submissionStatus = new TextWidget(LocalizedString.Get("Submitting your information..."), pointSize: 13); submissionStatus.AutoExpandBoundsToText = true; submissionStatus.Margin = new BorderDouble(0, 5); submissionStatus.TextColor = ActiveTheme.Instance.PrimaryTextColor; submissionStatus.HAnchor = HAnchor.ParentLeft; messageContainer.AddChild(submissionStatus); formContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); formContainer.AnchorAll(); formContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; formContainer.Padding = new BorderDouble(10); formContainer.AddChild(LabelGenerator(LocalizedString.Get("Question*"))); formContainer.AddChild(LabelGenerator(LocalizedString.Get("Briefly describe your question"), 9, 14)); questionInput = new MHTextEditWidget(subjectText); questionInput.HAnchor = HAnchor.ParentLeftRight; formContainer.AddChild(questionInput); questionErrorMessage = ErrorMessageGenerator(); formContainer.AddChild(questionErrorMessage); formContainer.AddChild(LabelGenerator(LocalizedString.Get("Details*"))); formContainer.AddChild(LabelGenerator(LocalizedString.Get("Fill in the details here"), 9, 14)); detailInput = new MHTextEditWidget(bodyText, pixelHeight: 120, multiLine: true); detailInput.HAnchor = HAnchor.ParentLeftRight; formContainer.AddChild(detailInput); detailErrorMessage = ErrorMessageGenerator(); formContainer.AddChild(detailErrorMessage); formContainer.AddChild(LabelGenerator(LocalizedString.Get("Your Email Address*"))); emailInput = new MHTextEditWidget(); emailInput.HAnchor = HAnchor.ParentLeftRight; formContainer.AddChild(emailInput); emailErrorMessage = ErrorMessageGenerator(); formContainer.AddChild(emailErrorMessage); formContainer.AddChild(LabelGenerator(LocalizedString.Get("Your Name*"))); nameInput = new MHTextEditWidget(); nameInput.HAnchor = HAnchor.ParentLeftRight; formContainer.AddChild(nameInput); nameErrorMessage = ErrorMessageGenerator(); formContainer.AddChild(nameErrorMessage); centerContainer.AddChild(formContainer); mainContainer.AddChild(centerContainer); FlowLayoutWidget buttonBottomPanel = GetButtonButtonPanel(); buttonBottomPanel.AddChild(submitButton); buttonBottomPanel.AddChild(cancelButton); buttonBottomPanel.AddChild(doneButton); mainContainer.AddChild(buttonBottomPanel); this.AddChild(mainContainer); }
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(); }
public ChooseConnectionWidget(ConnectionWindow windowController, SystemWindow container, bool editMode = false) : base(windowController, container) { { this.editMode = editMode; textImageButtonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.borderWidth = 0; editButtonFactory.normalTextColor = ActiveTheme.Instance.SecondaryAccentColor; editButtonFactory.hoverTextColor = RGBA_Bytes.White; editButtonFactory.disabledTextColor = ActiveTheme.Instance.SecondaryAccentColor; editButtonFactory.pressedTextColor = RGBA_Bytes.White; editButtonFactory.borderWidth = 0; editButtonFactory.FixedWidth = 60 * TextWidget.GlobalPointSizeScaleRatio; this.AnchorAll(); this.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; this.Padding = new BorderDouble(0); //To be re-enabled once native borders are turned off GuiWidget mainContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); mainContainer.AnchorAll(); mainContainer.Padding = new BorderDouble(3, 0, 3, 5); mainContainer.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; 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, 0); { string chooseThreeDPrinterConfigLabel = LocalizedString.Get("Choose a 3D Printer Configuration"); string chooseThreeDPrinterConfigFull = string.Format("{0}:", chooseThreeDPrinterConfigLabel); TextWidget elementHeader = new TextWidget(string.Format(chooseThreeDPrinterConfigFull), pointSize: 14); elementHeader.TextColor = this.defaultTextColor; elementHeader.HAnchor = HAnchor.ParentLeftRight; elementHeader.VAnchor = Agg.UI.VAnchor.ParentCenter; headerRow.AddChild(elementHeader); } FlowLayoutWidget editButtonRow = new FlowLayoutWidget(FlowDirection.LeftToRight); editButtonRow.BackgroundColor = ActiveTheme.Instance.TransparentDarkOverlay; editButtonRow.HAnchor = HAnchor.ParentLeftRight; editButtonRow.Margin = new BorderDouble(0, 3, 0, 0); editButtonRow.Padding = new BorderDouble(0, 3, 0, 0); Button enterLeaveEditModeButton; if (!this.editMode) { enterLeaveEditModeButton = editButtonFactory.Generate(LocalizedString.Get("Edit"), centerText: true); enterLeaveEditModeButton.Click += EditModeOnLink_Click; } else { enterLeaveEditModeButton = editButtonFactory.Generate(LocalizedString.Get("Done"), centerText: true); enterLeaveEditModeButton.Click += EditModeOffLink_Click; } editButtonRow.AddChild(enterLeaveEditModeButton); //To do - replace with scrollable widget FlowLayoutWidget printerListContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); //ListBox printerListContainer = new ListBox(); { printerListContainer.HAnchor = HAnchor.ParentLeftRight; printerListContainer.VAnchor = VAnchor.ParentBottomTop; printerListContainer.Padding = new BorderDouble(3); printerListContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; //Get a list of printer records and add them to radio button list foreach (Printer printer in GetAllPrinters()) { PrinterListItem printerListItem; if (this.editMode) { printerListItem = new PrinterListItemEdit(printer, this.windowController); } else { printerListItem = new PrinterListItemView(printer, this.windowController); } printerListContainer.AddChild(printerListItem); } } FlowLayoutWidget buttonContainer = new FlowLayoutWidget(FlowDirection.LeftToRight); buttonContainer.HAnchor = HAnchor.ParentLeft | HAnchor.ParentRight; buttonContainer.Margin = new BorderDouble(0, 3); { closeButton = textImageButtonFactory.Generate(LocalizedString.Get("Close")); Button addPrinterButton = textImageButtonFactory.Generate(LocalizedString.Get("Add"), "icon_circle_plus.png"); addPrinterButton.Click += new EventHandler(AddConnectionLink_Click); Button refreshListButton = textImageButtonFactory.Generate(LocalizedString.Get("Refresh")); refreshListButton.Click += new EventHandler(EditModeOffLink_Click); GuiWidget spacer = new GuiWidget(); spacer.HAnchor = HAnchor.ParentLeftRight; //Add buttons to ButtonContainer buttonContainer.AddChild(addPrinterButton); if (!this.editMode) { buttonContainer.AddChild(refreshListButton); } buttonContainer.AddChild(spacer); buttonContainer.AddChild(closeButton); } mainContainer.AddChild(headerRow); mainContainer.AddChild(editButtonRow); mainContainer.AddChild(printerListContainer); mainContainer.AddChild(buttonContainer); this.AddChild(mainContainer); BindCloseButtonClick(); } }
public ThemeSelectorWindow() :base(400, 200) { Title = LocalizedString.Get("Theme Selector").Localize(); FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); topToBottom.AnchorAll(); topToBottom.Padding = new BorderDouble(3, 0, 3, 5); //Create 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); //Create 'Theme Change' label and add it to Header string themeChangeHeader = LocalizedString.Get("Select Theme".Localize()); TextWidget elementHeader = new TextWidget(string.Format("{0}:", themeChangeHeader), pointSize: 14); elementHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor; elementHeader.HAnchor = HAnchor.ParentLeftRight; elementHeader.VAnchor = Agg.UI.VAnchor.ParentBottom; //Add label to header headerRow.AddChild(elementHeader); //Add Header topToBottom.AddChild(headerRow); //Theme Selector widget container and add themeselector FlowLayoutWidget themeChangeWidgetContainer = new FlowLayoutWidget(); themeChangeWidgetContainer.Padding = new BorderDouble(3); themeChangeWidgetContainer.HAnchor |= Agg.UI.HAnchor.ParentLeftRight; GuiWidget currentColorTheme = new GuiWidget(); currentColorTheme.HAnchor = HAnchor.ParentLeftRight; currentColorTheme.VAnchor = VAnchor.ParentBottomTop; currentColorTheme.BackgroundColor = ActiveTheme.Instance.PrimaryAccentColor; ThemeColorSelectorWidget themeSelector = new ThemeColorSelectorWidget(colorToChangeTo: currentColorTheme); themeSelector.Margin = new BorderDouble(right: 5); themeChangeWidgetContainer.AddChild(themeSelector); //Create CurrentColorTheme GUI Widgets GuiWidget currentColorThemeBorder = new GuiWidget(); currentColorThemeBorder.HAnchor = Agg.UI.HAnchor.ParentLeftRight; currentColorThemeBorder.VAnchor = VAnchor.ParentBottomTop; currentColorThemeBorder.Margin = new BorderDouble (top: 2, bottom: 2); currentColorThemeBorder.Padding = new BorderDouble(4); currentColorThemeBorder.BackgroundColor = RGBA_Bytes.White; FlowLayoutWidget presetsFormContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); { presetsFormContainer.HAnchor = HAnchor.ParentLeftRight; presetsFormContainer.VAnchor = VAnchor.ParentBottomTop; presetsFormContainer.Padding = new BorderDouble(3); presetsFormContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; } FlowLayoutWidget currentColorLabelContainer = new FlowLayoutWidget(FlowDirection.LeftToRight); currentColorLabelContainer.HAnchor = HAnchor.ParentLeftRight; currentColorLabelContainer.Margin = new BorderDouble(0, 3, 0, 0); currentColorLabelContainer.Padding = new BorderDouble(0, 3, 0, 3); string currentColorThemeLabelText = LocalizedString.Get("Currently Selected Theme".Localize()); TextWidget currentColorThemeHeader = new TextWidget(string.Format("{0}:", currentColorThemeLabelText), pointSize: 14); currentColorThemeHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor; currentColorThemeHeader.HAnchor = HAnchor.ParentLeftRight; currentColorThemeHeader.VAnchor = Agg.UI.VAnchor.ParentBottom; currentColorLabelContainer.AddChild(currentColorThemeHeader); // FlowLayoutWidget currentColorContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); currentColorContainer.HAnchor = HAnchor.ParentLeftRight; currentColorContainer.VAnchor = VAnchor.ParentBottomTop; currentColorContainer.Padding = new BorderDouble(3); currentColorContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; currentColorContainer.AddChild(currentColorThemeBorder); currentColorThemeBorder.AddChild(currentColorTheme); presetsFormContainer.AddChild(themeChangeWidgetContainer); topToBottom.AddChild(presetsFormContainer); topToBottom.AddChild(currentColorLabelContainer); topToBottom.AddChild(currentColorContainer); BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; FlowLayoutWidget buttonRow = new FlowLayoutWidget(); buttonRow.HAnchor = HAnchor.ParentLeftRight; buttonRow.Padding = new BorderDouble(0, 3); closeButton = textImageButtonFactory.Generate("Close"); closeButton.Click += (sender, e) => { UiThread.RunOnIdle((state) => { Close(); }); }; saveButton = textImageButtonFactory.Generate("Save"); saveButton.Click += (sender, e) => { UserSettings.Instance.set("ActiveThemeIndex",((GuiWidget)sender).Name); ActiveTheme.Instance.LoadThemeSettings(int.Parse(((GuiWidget)sender).Name));//GUIWIDGET }; buttonRow.AddChild(saveButton); buttonRow.AddChild(new HorizontalSpacer()); buttonRow.AddChild(closeButton); topToBottom.AddChild(buttonRow); AddChild(topToBottom); ShowAsSystemWindow(); }
public CreateFolderWindow(Action<CreateFolderReturnInfo> functionToCallToCreateNamedFolder) : base(480, 180) { Title = "MatterControl - Create Folder"; AlwaysOnTopOfMain = true; this.functionToCallToCreateNamedFolder = functionToCallToCreateNamedFolder; FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); topToBottom.AnchorAll(); topToBottom.Padding = new BorderDouble(3, 0, 3, 5); // 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 { string createFolderLabel = "Create New Folder:".Localize(); TextWidget elementHeader = new TextWidget(createFolderLabel, pointSize: 14); elementHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor; elementHeader.HAnchor = HAnchor.ParentLeftRight; elementHeader.VAnchor = Agg.UI.VAnchor.ParentBottom; headerRow.AddChild(elementHeader); topToBottom.AddChild(headerRow); this.AddChild(topToBottom); } //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; } string fileNameLabel = "Folder Name".Localize(); TextWidget textBoxHeader = new TextWidget(fileNameLabel, pointSize: 12); textBoxHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor; textBoxHeader.Margin = new BorderDouble(5); textBoxHeader.HAnchor = HAnchor.ParentLeft; //Adds text box and check box to the above container folderNameWidget = new MHTextEditWidget("", pixelWidth: 300, messageWhenEmptyAndNotSelected: "Enter a Folder Name Here".Localize()); folderNameWidget.Name = "Create Folder - Text Input"; folderNameWidget.HAnchor = HAnchor.ParentLeftRight; folderNameWidget.Margin = new BorderDouble(5); middleRowContainer.AddChild(textBoxHeader); middleRowContainer.AddChild(folderNameWidget); middleRowContainer.AddChild(new HorizontalSpacer()); topToBottom.AddChild(middleRowContainer); //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 createFolderButton = textImageButtonFactory.Generate("Create".Localize(), centerText: true); createFolderButton.Visible = true; createFolderButton.Cursor = Cursors.Hand; buttonRow.AddChild(createFolderButton); createFolderButton.Click += new EventHandler(createFolderButton_Click); folderNameWidget.ActualTextEditWidget.EnterPressed += new KeyEventHandler(ActualTextEditWidget_EnterPressed); //Adds Create and Close Button to button container buttonRow.AddChild(new HorizontalSpacer()); Button cancelButton = textImageButtonFactory.Generate("Cancel".Localize(), centerText: true); cancelButton.Visible = true; cancelButton.Cursor = Cursors.Hand; buttonRow.AddChild(cancelButton); cancelButton.Click += (sender, e) => { CloseOnIdle(); }; topToBottom.AddChild(buttonRow); ShowAsSystemWindow(); }