public PrinterConfigurationWidget() { SetDisplayAttributes(); HAnchor = Agg.UI.HAnchor.ParentLeftRight; VAnchor = Agg.UI.VAnchor.FitToChildren; FlowLayoutWidget mainLayoutContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); mainLayoutContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; mainLayoutContainer.VAnchor = Agg.UI.VAnchor.FitToChildren; mainLayoutContainer.Padding = new BorderDouble(top: 10); if (!ActiveSliceSettings.Instance.GetValue<bool>(SettingsKey.has_hardware_leveling)) { mainLayoutContainer.AddChild(new CalibrationSettingsWidget()); } mainLayoutContainer.AddChild(new HardwareSettingsWidget()); CloudSettingsWidget cloudGroupbox = new CloudSettingsWidget(); mainLayoutContainer.AddChild(cloudGroupbox); ApplicationSettingsWidget applicationGroupbox = new ApplicationSettingsWidget(); mainLayoutContainer.AddChild(applicationGroupbox); AddChild(mainLayoutContainer); AddHandlers(); //SetVisibleControls(); }
public FlowLayoutWidget createPrinterConnectionMessageContainer() { FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.TopToBottom); container.Margin = new BorderDouble(5); BorderDouble elementMargin = new BorderDouble(top: 5); TextWidget continueMessage = new TextWidget("Would you like to connect to this printer now?", 0, 0, 12); continueMessage.AutoExpandBoundsToText = true; continueMessage.TextColor = ActiveTheme.Instance.PrimaryTextColor; continueMessage.HAnchor = HAnchor.ParentLeftRight; continueMessage.Margin = elementMargin; TextWidget continueMessageTwo = new TextWidget("You can always configure this later.", 0, 0, 10); continueMessageTwo.AutoExpandBoundsToText = true; continueMessageTwo.TextColor = ActiveTheme.Instance.PrimaryTextColor; continueMessageTwo.HAnchor = HAnchor.ParentLeftRight; continueMessageTwo.Margin = elementMargin; printerErrorMessage = new TextWidget("", 0, 0, 10); printerErrorMessage.AutoExpandBoundsToText = true; printerErrorMessage.TextColor = RGBA_Bytes.Red; printerErrorMessage.HAnchor = HAnchor.ParentLeftRight; printerErrorMessage.Margin = elementMargin; container.AddChild(continueMessage); container.AddChild(continueMessageTwo); container.AddChild(printerErrorMessage); container.HAnchor = HAnchor.ParentLeftRight; return container; }
public PrinterConfigurationWidget() { SetDisplayAttributes(); HAnchor = Agg.UI.HAnchor.ParentLeftRight; VAnchor = Agg.UI.VAnchor.FitToChildren; FlowLayoutWidget mainLayoutContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); mainLayoutContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; mainLayoutContainer.VAnchor = Agg.UI.VAnchor.FitToChildren; mainLayoutContainer.Padding = new BorderDouble(top: 10); HardwareSettingsWidget hardwareGroupbox = new HardwareSettingsWidget(); mainLayoutContainer.AddChild(hardwareGroupbox); CloudSettingsWidget cloudGroupbox = new CloudSettingsWidget(); mainLayoutContainer.AddChild(cloudGroupbox); ApplicationSettingsWidget applicationGroupbox = new ApplicationSettingsWidget(); mainLayoutContainer.AddChild(applicationGroupbox); AddChild(mainLayoutContainer); AddHandlers(); //SetVisibleControls(); }
public CameraCalibrationWidget() { SuspendLayout(); FlowLayoutWidget TopToBottomLayout = new FlowLayoutWidget(FlowDirection.TopToBottom); { FlowLayoutWidget TopButtons = new FlowLayoutWidget(FlowDirection.LeftToRight); { connectButton = new Button("Connect"); connectButton.Click += new ButtonBase.ButtonEventHandler(ConnectButton_Click); TopButtons.AddChild(connectButton); } TopToBottomLayout.AddChild(TopButtons); xyJogControls = new XYJogControls(); TopToBottomLayout.AddChild(xyJogControls); disableMotors = new Button("Disable Motors"); disableMotors.Click += new ButtonBase.ButtonEventHandler(disableMotors_Click); TopToBottomLayout.AddChild(disableMotors); } AddChild(TopToBottomLayout); ResumeLayout(); }
protected override void AddChildElements() { AltGroupBox fanControlsGroupBox = new AltGroupBox(new TextWidget("Fan".Localize(), pointSize: 18, textColor: ActiveTheme.Instance.SecondaryAccentColor)); fanControlsGroupBox.Margin = new BorderDouble(0); fanControlsGroupBox.BorderColor = ActiveTheme.Instance.PrimaryTextColor; fanControlsGroupBox.HAnchor |= Agg.UI.HAnchor.ParentLeftRight; fanControlsGroupBox.VAnchor = Agg.UI.VAnchor.FitToChildren; this.HAnchor = Agg.UI.HAnchor.ParentLeftRight; this.AddChild(fanControlsGroupBox); FlowLayoutWidget leftToRight = new FlowLayoutWidget(); FlowLayoutWidget fanControlsLayout = new FlowLayoutWidget(FlowDirection.TopToBottom); fanControlsLayout.Padding = new BorderDouble(3, 5, 3, 0); { fanControlsLayout.AddChild(CreateFanControls()); } leftToRight.AddChild(fanControlsLayout); SetDisplayAttributes(); fanSpeedDisplay = new EditableNumberDisplay(textImageButtonFactory, "{0}%".FormatWith(PrinterConnectionAndCommunication.Instance.FanSpeed0To255.ToString()), "100%"); fanSpeedDisplay.EditComplete += (sender, e) => { PrinterConnectionAndCommunication.Instance.FanSpeed0To255 = (int)(fanSpeedDisplay.GetValue() * 255.5 / 100); }; leftToRight.AddChild(fanSpeedDisplay); fanControlsGroupBox.AddChild(leftToRight); }
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 ThemeColorSelectorWidget(GuiWidget colorToChangeTo) { this.Padding = new BorderDouble(2, 0); this.colorToChangeTo = colorToChangeTo; int themeCount = ActiveTheme.AvailableThemes.Count; var allThemes = ActiveTheme.AvailableThemes; int index = 0; for (int x = 0; x < themeCount / 2; x++) { var columnContainer = new FlowLayoutWidget(Agg.UI.FlowDirection.TopToBottom) { Width = containerHeight }; columnContainer.AddChild(CreateThemeButton(allThemes[index])); int secondRowIndex = index + themeCount / 2; columnContainer.AddChild(CreateThemeButton(allThemes[secondRowIndex])); this.AddChild(columnContainer); index++; } this.BackgroundColor = RGBA_Bytes.White; this.Width = containerHeight * (themeCount / 2); }
public RayTracerWindow(int width, int height) : base(width, height) { //CalculateIntersectCostsAndSaveToFile(); FlowLayoutWidget leftToRight = new FlowLayoutWidget(); leftToRight.HAnchor |= HAnchor.ParentLeftRight; leftToRight.VAnchor |= VAnchor.ParentBottomTop; previewWindowRayTrace = new RayTraceWidget(); AnchorAll(); previewWindowRayTrace.AnchorAll(); leftToRight.AddChild(previewWindowRayTrace); GuiWidget zBuffer = new GuiWidget(HAnchor.ParentLeftRight, VAnchor.ParentBottomTop); zBuffer.BackgroundColor = RGBA_Bytes.Blue; leftToRight.AddChild(zBuffer); AddChild(leftToRight); BackgroundColor = RGBA_Bytes.Black; ShowAsSystemWindow(); }
public RunningMacroPage(string message, bool showOkButton, bool showMaterialSelector, double expectedSeconds, double expectedTemperature) : base("Close", "Macro Feedback") { TextWidget syncingText = new TextWidget(message, textColor: ActiveTheme.Instance.PrimaryTextColor); contentRow.AddChild(syncingText); footerRow.AddChild(new HorizontalSpacer()); footerRow.AddChild(cancelButton); if (showMaterialSelector) { int extruderIndex = 0; contentRow.AddChild(new PresetSelectorWidget(string.Format($"{"Material".Localize()} {extruderIndex + 1}"), RGBA_Bytes.Orange, NamedSettingsLayers.Material, extruderIndex)); } var holder = new FlowLayoutWidget(); progressBar = new ProgressBar((int)(150 * GuiWidget.DeviceScale), (int)(15 * GuiWidget.DeviceScale)) { FillColor = ActiveTheme.Instance.PrimaryAccentColor, BorderColor = ActiveTheme.Instance.PrimaryTextColor, //HAnchor = HAnchor.ParentCenter, Margin = new BorderDouble(3, 0, 0, 10), }; progressBarText = new TextWidget("", pointSize: 10, textColor: ActiveTheme.Instance.PrimaryTextColor) { AutoExpandBoundsToText = true, Margin = new BorderDouble(5, 0, 0, 0), }; holder.AddChild(progressBar); holder.AddChild(progressBarText); contentRow.AddChild(holder); progressBar.Visible = false; if (expectedSeconds > 0) { timeToWaitMs = (long)(expectedSeconds * 1000); endTimeMs = UiThread.CurrentTimerMs + timeToWaitMs; UiThread.RunOnIdle(CountDownTime, 1); progressBar.Visible = true; } PrinterConnectionAndCommunication.Instance.WroteLine.RegisterEvent(LookForTempRequest, ref unregisterEvents); if (showOkButton) { Button okButton = textImageButtonFactory.Generate("Continue".Localize()); okButton.Margin = new BorderDouble(0, 0, 0, 25); okButton.HAnchor = HAnchor.ParentCenter; okButton.Click += (s, e) => { PrinterConnectionAndCommunication.Instance.MacroContinue(); UiThread.RunOnIdle(() => WizardWindow?.Close()); }; contentRow.AddChild(okButton); } }
public TextImageWidget(string label, RGBA_Bytes fillColor, RGBA_Bytes borderColor, RGBA_Bytes textColor, double borderWidth, BorderDouble margin, ImageBuffer image = null, double fontSize = 12, FlowDirection flowDirection = FlowDirection.LeftToRight, double height = 40, double width = 0, bool centerText = false, double imageSpacing = 0) : base() { this.image = image; this.fillColor = fillColor; this.borderColor = borderColor; this.borderWidth = borderWidth; this.Margin = new BorderDouble(0); this.Padding = new BorderDouble(0); TextWidget textWidget = new TextWidget(label, pointSize: fontSize); ImageWidget imageWidget; FlowLayoutWidget container = new FlowLayoutWidget(flowDirection); if (centerText) { // make sure the contents are centered GuiWidget leftSpace = new GuiWidget(0, 1); leftSpace.HAnchor = Agg.UI.HAnchor.ParentLeftRight; container.AddChild(leftSpace); } if (image != null && image.Width > 0) { imageWidget = new ImageWidget(image); imageWidget.VAnchor = VAnchor.ParentCenter; imageWidget.Margin = new BorderDouble(right: imageSpacing); container.AddChild(imageWidget); } if (label != "") { textWidget.VAnchor = VAnchor.ParentCenter; textWidget.TextColor = textColor; textWidget.Padding = new BorderDouble(3, 0); container.AddChild(textWidget); } if (centerText) { GuiWidget rightSpace = new GuiWidget(0, 1); rightSpace.HAnchor = Agg.UI.HAnchor.ParentLeftRight; container.AddChild(rightSpace); container.HAnchor = Agg.UI.HAnchor.ParentLeftRight | Agg.UI.HAnchor.FitToChildren; } container.VAnchor = Agg.UI.VAnchor.ParentCenter; container.MinimumSize = new Vector2(width, height); container.Margin = margin; this.AddChild(container); HAnchor = HAnchor.ParentLeftRight | HAnchor.FitToChildren; VAnchor = VAnchor.ParentCenter | Agg.UI.VAnchor.FitToChildren; }
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 MessageBox(String message, string windowTitle, MessageType messageType, double width, double height) : base(width, height) { BackgroundColor = new RGBA_Bytes(50, 50, 50, 240); FlowLayoutWidget topToBottomFlow = new FlowLayoutWidget(FlowDirection.TopToBottom); topToBottomFlow.HAnchor = Agg.UI.HAnchor.ParentCenter; topToBottomFlow.VAnchor = Agg.UI.VAnchor.ParentCenter; topToBottomFlow.AddChild(new TextWidget(message, textColor: RGBA_Bytes.White)); Title = windowTitle; // add a spacer topToBottomFlow.AddChild(new GuiWidget(10, 10)); switch (messageType) { case MessageType.YES_NO: { FlowLayoutWidget yesNoButtonsFlow = new FlowLayoutWidget(); Button yesButton = new Button("Yes"); yesButton.Click += new ButtonBase.ButtonEventHandler(okButton_Click); yesNoButtonsFlow.AddChild(yesButton); Button noButton = new Button("No"); noButton.Click += new ButtonBase.ButtonEventHandler(noButton_Click); yesNoButtonsFlow.AddChild(noButton); topToBottomFlow.AddChild(yesNoButtonsFlow); } break; case MessageType.OK: { Button okButton = new Button("Ok"); okButton.Click += new ButtonBase.ButtonEventHandler(okButton_Click); topToBottomFlow.AddChild(okButton); } break; default: throw new NotImplementedException(); } topToBottomFlow.SetBoundsToEncloseChildren(); AddChild(topToBottomFlow); IsModal = true; }
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 AboutWidget() { this.HAnchor = HAnchor.ParentLeftRight; this.VAnchor = VAnchor.ParentTop; this.Padding = new BorderDouble(5); this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; FlowLayoutWidget customInfoTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); customInfoTopToBottom.Name = "AboutPageCustomInfo"; customInfoTopToBottom.HAnchor = HAnchor.ParentLeftRight; customInfoTopToBottom.VAnchor = VAnchor.Max_FitToChildren_ParentHeight; customInfoTopToBottom.Padding = new BorderDouble(5, 10, 5, 0); if (ActiveTheme.Instance.IsTouchScreen) { customInfoTopToBottom.AddChild(new UpdateControlView()); } //AddMatterHackersInfo(customInfoTopToBottom); customInfoTopToBottom.AddChild(new GuiWidget(1, 10)); string aboutHtmlFile = Path.Combine("OEMSettings", "AboutPage.html"); string htmlContent = StaticData.Instance.ReadAllText(aboutHtmlFile); #if false // test { SystemWindow releaseNotes = new SystemWindow(640, 480); string releaseNotesFile = Path.Combine("OEMSettings", "ReleaseNotes.html"); string releaseNotesContent = StaticData.Instance.ReadAllText(releaseNotesFile); HtmlWidget content = new HtmlWidget(releaseNotesContent, RGBA_Bytes.Black); content.AddChild(new GuiWidget(HAnchor.AbsolutePosition, VAnchor.ParentBottomTop)); content.VAnchor |= VAnchor.ParentTop; content.BackgroundColor = RGBA_Bytes.White; releaseNotes.AddChild(content); releaseNotes.BackgroundColor = RGBA_Bytes.Cyan; UiThread.RunOnIdle((state) => { releaseNotes.ShowAsSystemWindow(); }, 1); } #endif HtmlWidget htmlWidget = new HtmlWidget(htmlContent, ActiveTheme.Instance.PrimaryTextColor); customInfoTopToBottom.AddChild(htmlWidget); this.AddChild(customInfoTopToBottom); }
protected override void AddChildElements() { AltGroupBox temperatureGroupBox = new AltGroupBox(new TextWidget("Temperature".Localize(), pointSize: 18, textColor: ActiveTheme.Instance.SecondaryAccentColor)); temperatureGroupBox.Margin = new BorderDouble(0); FlowLayoutWidget mainContainer = new FlowLayoutWidget(Agg.UI.FlowDirection.TopToBottom); mainContainer.HAnchor = HAnchor.ParentLeftRight; mainContainer.Margin = new BorderDouble(left: 0); temperatureGroupBox.AddChild(mainContainer); RGBA_Bytes separatorLineColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 100); int numberOfHeatedExtruders = 1; if (!ActiveSliceSettings.Instance.ExtrudersShareTemperature) { numberOfHeatedExtruders = ActiveSliceSettings.Instance.ExtruderCount; } if (numberOfHeatedExtruders > 1) { for (int i = 0; i < numberOfHeatedExtruders; i++) { DisableableWidget extruderTemperatureControlWidget = new DisableableWidget(); extruderTemperatureControlWidget.AddChild(new ExtruderTemperatureControlWidget(i)); mainContainer.AddChild(extruderTemperatureControlWidget); mainContainer.AddChild(new HorizontalLine(separatorLineColor)); ExtruderWidgetContainers.Add(extruderTemperatureControlWidget); } } else { DisableableWidget extruderTemperatureControlWidget = new DisableableWidget(); extruderTemperatureControlWidget.AddChild(new ExtruderTemperatureControlWidget()); mainContainer.AddChild(extruderTemperatureControlWidget); mainContainer.AddChild(new HorizontalLine(separatorLineColor)); ExtruderWidgetContainers.Add(extruderTemperatureControlWidget); } BedTemperatureControlWidget = new DisableableWidget(); BedTemperatureControlWidget.AddChild(new BedTemperatureControlWidget()); if (ActiveSliceSettings.Instance.HasHeatedBed()) { mainContainer.AddChild(BedTemperatureControlWidget); } this.AddChild(temperatureGroupBox); }
private void AddMinimumError() { GuiWidget thingToHide; { FlowLayoutWidget twoColumns = new FlowLayoutWidget(); twoColumns.Name = "twoColumns"; { FlowLayoutWidget leftColumn = new FlowLayoutWidget(FlowDirection.TopToBottom); leftColumn.Name = "leftColumn"; { FlowLayoutWidget topLeftStuff = new FlowLayoutWidget(FlowDirection.TopToBottom); topLeftStuff.Name = "topLeftStuff"; topLeftStuff.AddChild(new TextWidget("Top of Top Stuff")); thingToHide = new Button("thing to hide"); topLeftStuff.AddChild(thingToHide); topLeftStuff.AddChild(new TextWidget("Bottom of Top Stuff")); leftColumn.AddChild(topLeftStuff); //leftColumn.DebugShowBounds = true; } twoColumns.AddChild(leftColumn); } { FlowLayoutWidget rightColumn = new FlowLayoutWidget(FlowDirection.TopToBottom); rightColumn.Name = "rightColumn"; CheckBox hideCheckBox = new CheckBox("Hide Stuff"); rightColumn.AddChild(hideCheckBox); hideCheckBox.CheckedStateChanged += (sender, e) => { if (hideCheckBox.Checked) { thingToHide.Visible = false; } else { thingToHide.Visible = true; } }; twoColumns.AddChild(rightColumn); } this.AddChild(twoColumns); } }
public ManualPrinterControls() { SetDisplayAttributes(); FlowLayoutWidget controlsTopToBottomLayout = new FlowLayoutWidget(FlowDirection.TopToBottom); controlsTopToBottomLayout.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth; controlsTopToBottomLayout.VAnchor = Agg.UI.VAnchor.FitToChildren; controlsTopToBottomLayout.Name = "ManualPrinterControls.ControlsContainer"; controlsTopToBottomLayout.Margin = new BorderDouble(0); AddTemperatureControls(controlsTopToBottomLayout); AddMovementControls(controlsTopToBottomLayout); FlowLayoutWidget linearPanel = new FlowLayoutWidget(); linearPanel.HAnchor = Agg.UI.HAnchor.ParentLeftRight; controlsTopToBottomLayout.AddChild(linearPanel); AddFanControls(linearPanel); AddAtxPowerControls(linearPanel); AddMacroControls(controlsTopToBottomLayout); AddAdjustmentControls(controlsTopToBottomLayout); AddChild(controlsTopToBottomLayout); AddHandlers(); SetVisibleControls(); if (!pluginsQueuedToAdd) { UiThread.RunOnIdle(AddPlugins); pluginsQueuedToAdd = true; } }
internal OpenMenuContents(ObservableCollection<MenuItem> MenuItems, GuiWidget widgetRelativeTo, Vector2 openOffset, Direction direction, RGBA_Bytes backgroundColor, RGBA_Bytes borderColor, int borderWidth, double maxHeight, bool alignToRightEdge) { this.MenuItems = new List<MenuItem>(); this.MenuItems.AddRange(MenuItems); this.alignToRightEdge = alignToRightEdge; this.openOffset = openOffset; this.borderWidth = borderWidth; this.borderColor = borderColor; this.BackgroundColor = backgroundColor; this.direction = direction; this.widgetRelativeTo = widgetRelativeTo; scrollingWindow = new ScrollableWidget(true); { FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); foreach (MenuItem menu in MenuItems) { menu.ClearRemovedFlag(); topToBottom.AddChild(menu); menu.DoClickFunction = AllowClickingItems; } topToBottom.HAnchor = UI.HAnchor.ParentLeft | UI.HAnchor.FitToChildren; topToBottom.VAnchor = UI.VAnchor.ParentBottom; Width = topToBottom.Width; Height = topToBottom.Height; scrollingWindow.AddChild(topToBottom); } scrollingWindow.HAnchor = HAnchor.ParentLeftRight; scrollingWindow.VAnchor = VAnchor.ParentBottomTop; if (maxHeight > 0 && Height > maxHeight) { MakeMenuHaveScroll(maxHeight); } AddChild(scrollingWindow); LostFocus += new EventHandler(DropListItems_LostFocus); GuiWidget topParent = widgetRelativeTo.Parent; while (topParent.Parent != null) { // Regretably we don't know who it is that is the window that will actually think it is moving relative to its parent // but we need to know anytime our widgetRelativeTo has been moved by any change, so we hook them all. if (!widgetRefList.Contains(topParent)) { widgetRefList.Add(topParent); topParent.PositionChanged += new EventHandler(widgetRelativeTo_PositionChanged); topParent.BoundsChanged += new EventHandler(widgetRelativeTo_PositionChanged); } topParent = topParent.Parent; } topParent.AddChild(this); widgetRelativeTo_PositionChanged(widgetRelativeTo, null); widgetRelativeTo.Closed += widgetRelativeTo_Closed; }
GuiWidget CreateOptionsMenu() { ImageBuffer gearImage = new ImageBuffer(); string imagePathAndFile = Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "gear_icon.png"); ImageBMPIO.LoadImageData(imagePathAndFile, gearImage); FlowLayoutWidget leftToRight = new FlowLayoutWidget(); leftToRight.Margin = new BorderDouble(5, 0); string optionsString = new LocalizedString("Options").Translated; TextWidget optionsText = new TextWidget(optionsString, textColor: RGBA_Bytes.White); optionsText.VAnchor = Agg.UI.VAnchor.ParentCenter; optionsText.Margin = new BorderDouble(0, 0, 3, 0); leftToRight.AddChild(optionsText); GuiWidget gearWidget = new ImageWidget(gearImage); gearWidget.VAnchor = Agg.UI.VAnchor.ParentCenter; leftToRight.AddChild(gearWidget); leftToRight.HAnchor = HAnchor.FitToChildren; leftToRight.VAnchor = VAnchor.FitToChildren; Menu optionMenu = new Menu(leftToRight); optionMenu.OpenOffset = new Vector2(-2, -10); optionMenu.VAnchor = Agg.UI.VAnchor.ParentCenter; optionMenu.MenuItems.Add(new MenuItem(new ThemeColorSelectorWidget())); return optionMenu; }
public PowerControls() { AltGroupBox fanControlsGroupBox = new AltGroupBox(new TextWidget("ATX Power Control".Localize(), pointSize: 18, textColor: ActiveTheme.Instance.SecondaryAccentColor)); fanControlsGroupBox.Margin = new BorderDouble(0); fanControlsGroupBox.BorderColor = ActiveTheme.Instance.PrimaryTextColor; fanControlsGroupBox.HAnchor |= Agg.UI.HAnchor.ParentLeftRight; this.AddChild(fanControlsGroupBox); atxPowertoggleSwitch = ImageButtonFactory.CreateToggleSwitch(false); atxPowertoggleSwitch.Margin = new BorderDouble(6, 0, 6, 6); atxPowertoggleSwitch.CheckedStateChanged += (sender, e) => { PrinterConnectionAndCommunication.Instance.AtxPowerEnabled = atxPowertoggleSwitch.Checked; }; FlowLayoutWidget paddingContainer = new FlowLayoutWidget(); paddingContainer.Padding = new BorderDouble(3, 5, 3, 0); { paddingContainer.AddChild(atxPowertoggleSwitch); } fanControlsGroupBox.AddChild(paddingContainer); UpdateControlVisibility(null, null); PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(this.UpdateControlVisibility, ref unregisterEvents); PrinterConnectionAndCommunication.Instance.AtxPowerStateChanged.RegisterEvent(this.UpdatePowerSwitch, ref unregisterEvents); this.HAnchor = Agg.UI.HAnchor.ParentLeftRight; this.HAnchor = HAnchor.ParentLeftRight; this.VAnchor = VAnchor.ParentBottomTop; }
private void AddInfoRecursive(GuiWidget widgetToAddInfoAbout, FlowLayoutWidget layoutToAddInfoTo, int level = 0) { FlowLayoutWidget indented = new FlowLayoutWidget(); indented.AddChild(new LineWidget(15, 5)); FlowLayoutWidget widgetInfo = new FlowLayoutWidget(FlowDirection.TopToBottom); string info = widgetToAddInfoAbout.GetType().ToString(); if (widgetToAddInfoAbout.Name != null && widgetToAddInfoAbout.Name != "") { info += " " + widgetToAddInfoAbout.Name; } else if (widgetToAddInfoAbout.Text != null && widgetToAddInfoAbout.Text != "") { info += " " + widgetToAddInfoAbout.Text; } widgetInfo.AddChild(new TextWidget(info)); TextWidget sizeAndPositon = new TextWidget(string.Format(" Size {0}, Position {1}", widgetToAddInfoAbout.LocalBounds, widgetToAddInfoAbout.OriginRelativeParent), pointSize: 8, textColor: RGBA_Bytes.Red); sizeAndPositon.AutoExpandBoundsToText = true; widgetInfo.AddChild(sizeAndPositon); TextWidget boundsText = new TextWidget(string.Format(" Bounds {0}", widgetToAddInfoAbout.BoundsRelativeToParent), pointSize: 8, textColor: RGBA_Bytes.Red); boundsText.AutoExpandBoundsToText = true; widgetInfo.AddChild(boundsText); if (!widgetRefList.ContainsKey(widgetToAddInfoAbout)) { widgetRefList.Add(widgetToAddInfoAbout, new WidgetInList(sizeAndPositon, boundsText)); widgetToAddInfoAbout.PositionChanged += new EventHandler(updateWidgetInfo); widgetToAddInfoAbout.BoundsChanged += new EventHandler(updateWidgetInfo); } FlowLayoutWidget childrenWidgetInfo = new FlowLayoutWidget(FlowDirection.TopToBottom); indented.AddChild(childrenWidgetInfo); widgetInfo.AddChild(indented); foreach (GuiWidget child in widgetToAddInfoAbout.Children) { AddInfoRecursive(child, childrenWidgetInfo, level + 1); } layoutToAddInfoTo.AddChild(widgetInfo); }
private FlowLayoutWidget createPrinterBaudRateContainer() { FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.TopToBottom); container.Margin = new BorderDouble(0); container.VAnchor = VAnchor.ParentBottomTop; BorderDouble elementMargin = new BorderDouble(top: 3); string baudRateLabelText = LocalizedString.Get("Baud Rate"); string baudRateLabelTextFull = string.Format("{0}:", baudRateLabelText); TextWidget baudRateLabel = new TextWidget(baudRateLabelTextFull, 0, 0, 12); baudRateLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor; baudRateLabel.Margin = new BorderDouble(0, 0, 0, 10); baudRateLabel.HAnchor = HAnchor.ParentLeftRight; baudRateWidget = GetBaudRateWidget(); baudRateWidget.HAnchor = HAnchor.ParentLeftRight; FlowLayoutWidget baudRateMessageContainer = new FlowLayoutWidget(); baudRateMessageContainer.Margin = elementMargin; baudRateMessageContainer.HAnchor = HAnchor.ParentLeftRight; printerBaudRateError = new TextWidget(LocalizedString.Get("Select the baud rate."), 0, 0, 10); printerBaudRateError.TextColor = ActiveTheme.Instance.PrimaryTextColor; printerBaudRateError.AutoExpandBoundsToText = true; printerBaudRateHelpLink = linkButtonFactory.Generate(LocalizedString.Get("What's this?")); printerBaudRateHelpLink.Margin = new BorderDouble(left: 5); printerBaudRateHelpLink.VAnchor = VAnchor.ParentBottom; printerBaudRateHelpLink.Click += new EventHandler(printerBaudRateHelp_Click); printerBaudRateHelpMessage = new TextWidget(LocalizedString.Get("The term 'Baud Rate' roughly means the speed at which\ndata is transmitted. Baud rates may differ from printer to\nprinter. Refer to your printer manual for more info.\n\nTip: If you are uncertain - try 250000."), 0, 0, 10); printerBaudRateHelpMessage.TextColor = ActiveTheme.Instance.PrimaryTextColor; printerBaudRateHelpMessage.Margin = new BorderDouble(top: 10); printerBaudRateHelpMessage.Visible = false; baudRateMessageContainer.AddChild(printerBaudRateError); baudRateMessageContainer.AddChild(printerBaudRateHelpLink); container.AddChild(baudRateLabel); container.AddChild(baudRateWidget); container.AddChild(baudRateMessageContainer); container.AddChild(printerBaudRateHelpMessage); container.HAnchor = HAnchor.ParentLeftRight; return container; }
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 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(); }
private void AddNameSetting(string sliceSettingsKey, FlowLayoutWidget contentRow, ref int tabIndex) { GuiWidget control = SliceSettingsWidget.CreateSettingControl(sliceSettingsKey, ref tabIndex); if (control != null) { contentRow.AddChild(control); } }
public FlowLayoutWidget createPrinterConnectionMessageContainer() { FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.TopToBottom); container.VAnchor = VAnchor.ParentBottomTop; container.Margin = new BorderDouble(5); BorderDouble elementMargin = new BorderDouble(top: 5); TextWidget printerMessageOne = new TextWidget(new LocalizedString("MatterControl will now attempt to auto-detect printer.").Translated, 0, 0, 10); printerMessageOne.Margin = new BorderDouble(0, 10, 0,5); printerMessageOne.TextColor = RGBA_Bytes.White; printerMessageOne.HAnchor = HAnchor.ParentLeftRight; printerMessageOne.Margin = elementMargin; string printerMessageTwoTxt = new LocalizedString("Disconnect printer").Translated; string printerMessageTwoTxtEnd = new LocalizedString("if currently connected").Translated; string printerMessageTwoTxtFull = string.Format ("1.) {0} ({1}).", printerMessageTwoTxt, printerMessageTwoTxtEnd); TextWidget printerMessageTwo = new TextWidget(printerMessageTwoTxtFull, 0, 0, 12); printerMessageTwo.TextColor = RGBA_Bytes.White; printerMessageTwo.HAnchor = HAnchor.ParentLeftRight; printerMessageTwo.Margin = elementMargin; string printerMessageThreeTxt = new LocalizedString("Press").Translated; string printerMessageThreeTxtEnd = new LocalizedString ("Continue").Translated; string printerMessageThreeFull = string.Format ("2.) {0} '{1}'.", printerMessageThreeTxt, printerMessageThreeTxtEnd); TextWidget printerMessageThree = new TextWidget(printerMessageThreeFull, 0, 0, 12); printerMessageThree.TextColor = RGBA_Bytes.White; printerMessageThree.HAnchor = HAnchor.ParentLeftRight; printerMessageThree.Margin = elementMargin; GuiWidget vSpacer = new GuiWidget(); vSpacer.VAnchor = VAnchor.ParentBottomTop; Button manualLink = linkButtonFactory.Generate(new LocalizedString("Manual Configuration").Translated); manualLink.Margin = new BorderDouble(0, 5); manualLink.Click += new ButtonBase.ButtonEventHandler(ManualLink_Click); container.AddChild(printerMessageOne); container.AddChild(printerMessageTwo); container.AddChild(printerMessageThree); container.AddChild(vSpacer); container.AddChild(manualLink); container.HAnchor = HAnchor.ParentLeftRight; return container; }
public SetupWizardWifi() { contentRow.AddChild(new TextWidget("Wifi Setup".Localize() + ":", 0, 0, labelFontSize) { TextColor = ActiveTheme.Instance.PrimaryTextColor, Margin = new BorderDouble(bottom: 10) }); contentRow.AddChild(new TextWidget("Some features may require an internet connection.".Localize(), 0, 0, 12, textColor: ActiveTheme.Instance.PrimaryTextColor)); contentRow.AddChild(new TextWidget("Would you like to setup Wifi?".Localize(), 0, 0, 12, textColor: ActiveTheme.Instance.PrimaryTextColor)); var connectButtonContainer = new FlowLayoutWidget() { HAnchor = HAnchor.ParentLeftRight, Margin = new BorderDouble(0, 6) }; //Construct buttons Button skipButton = whiteImageButtonFactory.Generate("Skip".Localize(), centerText: true); skipButton.Click += (s, e) => this.WizardWindow.ChangeToSetupPrinterForm(); Button nextButton = textImageButtonFactory.Generate("Continue".Localize()); nextButton.Click += (s, e) => this.WizardWindow.ChangeToSetupPrinterForm(); nextButton.Visible = false; Button configureButton = whiteImageButtonFactory.Generate(LocalizedString.Get("Configure"), centerText: true); configureButton.Margin = new BorderDouble(0, 0, 10, 0); configureButton.Click += (s, e) => { nextButton.Visible = true; skipButton.Visible = false; configureButton.Visible = false; MatterControlApplication.Instance.ConfigureWifi(); }; connectButtonContainer.AddChild(configureButton); connectButtonContainer.AddChild(skipButton); connectButtonContainer.AddChild(new HorizontalSpacer()); contentRow.AddChild(connectButtonContainer); //Add buttons to buttonContainer footerRow.AddChild(nextButton); footerRow.AddChild(new HorizontalSpacer()); footerRow.AddChild(cancelButton); }
private SDCardManager() : base(400, 300) { BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; this.AnchorAll(); Title = "MatterControl - SD Card Manager"; this.ShowAsSystemWindow(); MinimumSize = new Vector2(Width, Height); FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); FlowLayoutWidget topButtons = new FlowLayoutWidget(); topButtons.AddChild(textImageButtonFactory.Generate("Upload")); topButtons.AddChild(textImageButtonFactory.Generate("Delete")); topButtons.AddChild(textImageButtonFactory.Generate("New Folder")); topButtons.AddChild(textImageButtonFactory.Generate("Print")); topButtons.AddChild(textImageButtonFactory.Generate("Stop")); topButtons.AddChild(textImageButtonFactory.Generate("Mount")); topButtons.AddChild(textImageButtonFactory.Generate("Unmount")); topToBottom.AddChild(topButtons); this.AddChild(topToBottom); }
protected void DoWrappingLayout() { if (doingLayout) { needAnotherLayout = true; return; } using (this.LayoutLock()) { doingLayout = true; // remove all the children we added foreach (var child in addedChildren) { if (child.Parent != null) { using (child.Parent.LayoutLock()) { child.Parent.RemoveChild(child); child.ClearRemovedFlag(); } } } // close all the row containers this.CloseChildren(); // add in new row container FlowLayoutWidget childContainerRow = new FlowLayoutWidget() { Margin = RowMargin, Padding = RowPadding, HAnchor = HAnchor.Stretch, }; base.AddChild(childContainerRow); var rowPaddingWidth = RowPadding.Width + RowMargin.Width + this.Margin.Width + this.Padding.Width; double runningSize = 0; MaxLineWidth = 0; foreach (var child in addedChildren) { var childWidth = child.Width + child.DeviceMarginAndBorder.Width; if (child.HAnchor == HAnchor.Stretch) { childWidth = child.MinimumSize.X + child.DeviceMarginAndBorder.Width; } if (runningSize + childWidth > this.Width - rowPaddingWidth || child is IHardBreak) { MaxLineWidth = Math.Max(MaxLineWidth, runningSize); runningSize = 0; var lastItemWasHorizontalSpacer = false; if (childContainerRow != null) { childContainerRow.PerformLayout(); if (childContainerRow.Children.LastOrDefault() is HorizontalSpacer) { lastItemWasHorizontalSpacer = true; } } childContainerRow = new FlowLayoutWidget() { Margin = RowMargin, Padding = RowPadding, HAnchor = HAnchor.Stretch, Border = RowBoarder, BorderColor = RowBoarderColor, }; if (lastItemWasHorizontalSpacer) { childContainerRow.AddChild(new HorizontalSpacer()); } base.AddChild(childContainerRow); } if (runningSize > 0 || !(child is ISkipIfFirst)) { // add the new child to the current row using (childContainerRow.LayoutLock()) { childContainerRow.AddChild(child); } runningSize += childWidth; MaxLineWidth = Math.Max(MaxLineWidth, runningSize); } } if (childContainerRow != null) { childContainerRow.PerformLayout(); } MakeProportionalIfRequired(); MakeCenterIfRequired(); doingLayout = false; } if (needAnotherLayout) { UiThread.RunOnIdle(DoWrappingLayout); needAnotherLayout = false; } // change the size to force a recursive layout event this.Height--; this.Height++; this.PerformLayout(); }
internal OpenMenuContents(ObservableCollection <MenuItem> MenuItems, GuiWidget widgetRelativeTo, Vector2 openOffset, Direction direction, RGBA_Bytes backgroundColor, RGBA_Bytes borderColor, int borderWidth, double maxHeight, bool alignToRightEdge) { this.MenuItems = new List <MenuItem>(); this.MenuItems.AddRange(MenuItems); this.alignToRightEdge = alignToRightEdge; this.openOffset = openOffset; this.borderWidth = borderWidth; this.borderColor = borderColor; this.BackgroundColor = backgroundColor; this.direction = direction; this.widgetRelativeTo = widgetRelativeTo; scrollingWindow = new ScrollableWidget(true); { FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); foreach (MenuItem menu in MenuItems) { menu.ClearRemovedFlag(); topToBottom.AddChild(menu); menu.DoClickFunction = AllowClickingItems; } topToBottom.HAnchor = UI.HAnchor.ParentLeft | UI.HAnchor.FitToChildren; topToBottom.VAnchor = UI.VAnchor.ParentBottom; Width = topToBottom.Width; Height = topToBottom.Height; scrollingWindow.AddChild(topToBottom); } scrollingWindow.HAnchor = HAnchor.ParentLeftRight; scrollingWindow.VAnchor = VAnchor.ParentBottomTop; if (maxHeight > 0 && Height > maxHeight) { MakeMenuHaveScroll(maxHeight); } AddChild(scrollingWindow); LostFocus += new EventHandler(DropListItems_LostFocus); GuiWidget topParent = widgetRelativeTo.Parent; while (topParent.Parent != null && topParent as SystemWindow == null) { // Regretably we don't know who it is that is the window that will actually think it is moving relative to its parent // but we need to know anytime our widgetRelativeTo has been moved by any change, so we hook them all. if (!widgetRefList.Contains(topParent)) { widgetRefList.Add(topParent); topParent.PositionChanged += new EventHandler(widgetRelativeTo_PositionChanged); topParent.BoundsChanged += new EventHandler(widgetRelativeTo_PositionChanged); } topParent = topParent.Parent; } topParent.AddChild(this); widgetRelativeTo_PositionChanged(widgetRelativeTo, null); widgetRelativeTo.Closed += widgetRelativeTo_Closed; }