public void TextWidgetAutoSizeTest() { // resize works on text widgets { TextWidget textItem = new TextWidget("test Item", 10, 10); textItem.AutoExpandBoundsToText = true; double origWidth = textItem.Width; textItem.Text = "test Items"; double newlineWidth = textItem.Width; Assert.IsTrue(newlineWidth > origWidth); textItem.Text = "test Item"; double backToOrignWidth = textItem.Width; Assert.IsTrue(backToOrignWidth == origWidth); double origHeight = textItem.Height; textItem.Text = "test\nItem"; double newlineHeight = textItem.Height; textItem.Text = "test Item"; double backToOrignHeight = textItem.Height; Assert.IsTrue(backToOrignHeight == origHeight); } }
public void BottomAndTopTextControl(double controlPadding, double buttonMargin) { GuiWidget containerControl = new GuiWidget(200, 300); containerControl.DoubleBuffer = true; containerControl.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White); TextWidget controlButton1 = new TextWidget("text1"); controlButton1.Margin = new BorderDouble(buttonMargin); controlButton1.OriginRelativeParent = new VectorMath.Vector2(-controlButton1.LocalBounds.Left, -controlButton1.LocalBounds.Bottom + controlPadding + buttonMargin); controlButton1.LocalBounds = new RectangleDouble(controlButton1.LocalBounds.Left, controlButton1.LocalBounds.Bottom, controlButton1.LocalBounds.Right, controlButton1.LocalBounds.Bottom + containerControl.Height - (controlPadding + buttonMargin) * 2); containerControl.AddChild(controlButton1); containerControl.OnDraw(containerControl.NewGraphics2D()); GuiWidget containerTest = new GuiWidget(200, 200); containerTest.Padding = new BorderDouble(controlPadding); containerTest.DoubleBuffer = true; containerTest.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White); TextWidget testButton1 = new TextWidget("text1"); testButton1.Margin = new BorderDouble(buttonMargin); testButton1.VAnchor = VAnchor.ParentBottom | VAnchor.ParentTop; containerTest.AddChild(testButton1); containerTest.OnDraw(containerTest.NewGraphics2D()); OutputImages(containerControl, containerTest); // now change it's size containerTest.LocalBounds = containerControl.LocalBounds; containerTest.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White); containerTest.OnDraw(containerTest.NewGraphics2D()); OutputImages(containerControl, containerTest); Assert.IsTrue(containerControl.BackBuffer != null, "When we set a guiWidget to DoubleBuffer it needs to create one."); Assert.IsTrue(containerControl.BackBuffer == containerTest.BackBuffer, "The Anchored widget should be in the correct place."); }
static Control OrdinaryQuestionWidget(Racr.AstNode n) { Widget w; if (n.Type() == ValueTypes.Boolean) { w = new CheckWidget(n.GetLabel()); var cb = w.GetCheckBox(); cb.CheckedChanged += (object sender, EventArgs e) => { if (!cb.ContainsFocus) return; n.SetValue(cb.Checked); n.Root().Render(); }; } else { w = new TextWidget(n.GetLabel()); var tb = w.GetTextBox(); tb.TextChanged += (object sender, EventArgs e) => { if (!tb.ContainsFocus) return; if (n.Type() == ValueTypes.Number) { try { n.SetValue(Convert.ToDouble(tb.Text)); } catch { return; } } else n.SetValue(tb.Text); n.Root().Render(); }; } n.Parent().Widget().Controls.Add(w); return w; }
private GuiWidget createState(string word, double width, double height, ref RGBA_Bytes backgroundColor, ref RGBA_Bytes interiorColor, ref RGBA_Bytes thumbColor, ref RGBA_Bytes textColor) { TextWidget text = new TextWidget(word, pointSize: 10, textColor: textColor); text.VAnchor = VAnchor.ParentCenter; SwitchView switchGraphics = new SwitchView(width, height, word == onText, backgroundColor, interiorColor, thumbColor, textColor); switchGraphics.VAnchor = VAnchor.ParentCenter; switchGraphics.Margin = new BorderDouble(5, 0, 0, 0); GuiWidget switchNormalToPressed = new FlowLayoutWidget(FlowDirection.LeftToRight, text, switchGraphics); return switchNormalToPressed; }
public void TextWidgetVisibleTest() { { GuiWidget rectangleWidget = new GuiWidget(100, 50); TextWidget itemToAdd = new TextWidget("test Item", 10, 10); rectangleWidget.AddChild(itemToAdd); rectangleWidget.DoubleBuffer = true; rectangleWidget.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White); rectangleWidget.OnDraw(rectangleWidget.BackBuffer.NewGraphics2D()); ImageBuffer textOnly = new ImageBuffer(75, 20, 32, new BlenderBGRA()); textOnly.NewGraphics2D().Clear(RGBA_Bytes.White); textOnly.NewGraphics2D().DrawString("test Item", 1, 1); if (saveImagesForDebug) { ImageTgaIO.Save(rectangleWidget.BackBuffer, "-rectangleWidget.tga"); //ImageTgaIO.Save(itemToAdd.Children[0].BackBuffer, "-internalTextWidget.tga"); ImageTgaIO.Save(textOnly, "-textOnly.tga"); } Assert.IsTrue(rectangleWidget.BackBuffer.FindLeastSquaresMatch(textOnly, 1), "TextWidgets need to be drawing."); rectangleWidget.Close(); } { GuiWidget rectangleWidget = new GuiWidget(100, 50); TextEditWidget itemToAdd = new TextEditWidget("test Item", 10, 10); rectangleWidget.AddChild(itemToAdd); rectangleWidget.DoubleBuffer = true; rectangleWidget.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White); rectangleWidget.OnDraw(rectangleWidget.BackBuffer.NewGraphics2D()); ImageBuffer textOnly = new ImageBuffer(75, 20, 32, new BlenderBGRA()); textOnly.NewGraphics2D().Clear(RGBA_Bytes.White); TypeFacePrinter stringPrinter = new TypeFacePrinter("test Item", 12); IVertexSource offsetText = new VertexSourceApplyTransform(stringPrinter, Affine.NewTranslation(1, -stringPrinter.LocalBounds.Bottom)); textOnly.NewGraphics2D().Render(offsetText, RGBA_Bytes.Black); if (saveImagesForDebug) { ImageTgaIO.Save(rectangleWidget.BackBuffer, "-rectangleWidget.tga"); //ImageTgaIO.Save(itemToAdd.Children[0].BackBuffer, "-internalTextWidget.tga"); ImageTgaIO.Save(textOnly, "-textOnly.tga"); } Assert.IsTrue(rectangleWidget.BackBuffer.FindLeastSquaresMatch(textOnly, 1), "TextWidgets need to be drawing."); rectangleWidget.Close(); } }
public ToggleSwitchView(string onText, string offText, double width, double height, RGBA_Bytes backgroundColor, RGBA_Bytes interiorColor, RGBA_Bytes thumbColor, RGBA_Bytes textColor) { this.onText = onText; GuiWidget normal = createState(offText, width, height, ref backgroundColor, ref interiorColor, ref thumbColor, ref textColor); GuiWidget normalHover = createState(offText, width, height, ref backgroundColor, ref interiorColor, ref thumbColor, ref textColor); GuiWidget switchNormalToPressed = createState(onText, width, height, ref backgroundColor, ref interiorColor, ref thumbColor, ref textColor); GuiWidget pressed = createState(onText, width, height, ref backgroundColor, ref interiorColor, ref thumbColor, ref textColor); GuiWidget pressedHover = createState(onText, width, height, ref backgroundColor, ref interiorColor, ref thumbColor, ref textColor); GuiWidget switchPressedToNormal = createState(offText, width, height, ref backgroundColor, ref interiorColor, ref thumbColor, ref textColor); GuiWidget disabled = new TextWidget("disabled"); SetViewStates(normal, normalHover, switchNormalToPressed, pressed, pressedHover, switchPressedToNormal, disabled); this.VAnchor = VAnchor.FitToChildren; }
public RadioButton GenerateRadioButton(string label) { BorderDouble internalMargin = new BorderDouble(0); TextWidget nomalState = new TextWidget(label); TextWidget hoverState = new TextWidget(label); TextWidget checkingState = new TextWidget(label); TextWidget checkedState = new TextWidget(label); TextWidget disabledState = new TextWidget(label); RadioButtonViewStates checkBoxButtonViewWidget = new RadioButtonViewStates(nomalState, hoverState, checkingState, checkedState, disabledState); RadioButton radioButton = new RadioButton(checkBoxButtonViewWidget); radioButton.Margin = new BorderDouble(); return radioButton; }
public ApplicationSettingsPage() : base("Close".Localize()) { this.AlwaysOnTopOfMain = true; this.WindowTitle = this.HeaderText = "MatterControl " + "Settings".Localize(); this.WindowSize = new Vector2(700 * GuiWidget.DeviceScale, 600 * GuiWidget.DeviceScale); contentRow.Padding = theme.DefaultContainerPadding; contentRow.Padding = 0; contentRow.BackgroundColor = Color.Transparent; var generalPanel = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, }; var configureIcon = AggContext.StaticData.LoadIcon("fa-cog_16.png", 16, 16, theme.InvertIcons); var generalSection = new SectionWidget("General".Localize(), generalPanel, theme, expandingContent: false) { Name = "General Section", HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, }; contentRow.AddChild(generalSection); theme.ApplyBoxStyle(generalSection); #if __ANDROID__ // Camera Monitoring bool hasCamera = true || ApplicationSettings.Instance.get(ApplicationSettingsKey.HardwareHasCamera) == "true"; var previewButton = new IconButton(configureIcon, theme) { ToolTipText = "Preview".Localize() }; previewButton.Click += (s, e) => { AppContext.Platform.OpenCameraPreview(); }; var printer = ApplicationController.Instance.ActivePrinters.FirstOrDefault(); // TODO: Sort out how handle this better on Android and in a multi-printer setup if (printer != null) { this.AddSettingsRow( new SettingsItem( "Camera Monitoring".Localize(), theme, new SettingsItem.ToggleSwitchConfig() { Checked = printer.Settings.GetValue <bool>(SettingsKey.publish_bed_image), ToggleAction = (itemChecked) => { printer.Settings.SetValue(SettingsKey.publish_bed_image, itemChecked ? "1" : "0"); } }, previewButton, AggContext.StaticData.LoadIcon("camera-24x24.png", 24, 24)) { Enabled = printer.Settings.PrinterSelected }, generalPanel ); } #endif // Print Notifications var configureNotificationsButton = new IconButton(configureIcon, theme) { Name = "Configure Notification Settings Button", ToolTipText = "Configure Notifications".Localize(), Margin = new BorderDouble(left: 6), VAnchor = VAnchor.Center }; configureNotificationsButton.Click += (s, e) => { if (ApplicationController.ChangeToPrintNotification != null) { UiThread.RunOnIdle(() => { ApplicationController.ChangeToPrintNotification(this.DialogWindow); }); } }; this.AddSettingsRow( new SettingsItem( "Notifications".Localize(), theme, new SettingsItem.ToggleSwitchConfig() { Checked = UserSettings.Instance.get(UserSettingsKey.PrintNotificationsEnabled) == "true", ToggleAction = (itemChecked) => { UserSettings.Instance.set(UserSettingsKey.PrintNotificationsEnabled, itemChecked ? "true" : "false"); } }, configureNotificationsButton, AggContext.StaticData.LoadIcon("notify-24x24.png", 16, 16, theme.InvertIcons)), generalPanel); // LanguageControl var languageSelector = new LanguageSelector(theme); languageSelector.SelectionChanged += (s, e) => { UiThread.RunOnIdle(() => { string languageCode = languageSelector.SelectedValue; if (languageCode != UserSettings.Instance.get(UserSettingsKey.Language)) { UserSettings.Instance.set(UserSettingsKey.Language, languageCode); if (languageCode == "L10N") { #if DEBUG AppContext.Platform.GenerateLocalizationValidationFile(); #endif } ApplicationController.Instance.ResetTranslationMap(); ApplicationController.Instance.ReloadAll().ConfigureAwait(false); } }); }; this.AddSettingsRow(new SettingsItem("Language".Localize(), languageSelector, theme), generalPanel); #if !__ANDROID__ // ThumbnailRendering var thumbnailsModeDropList = new MHDropDownList("", theme, maxHeight: 200); thumbnailsModeDropList.AddItem("Flat".Localize(), "orthographic"); thumbnailsModeDropList.AddItem("3D".Localize(), "raytraced"); thumbnailsModeDropList.SelectedValue = UserSettings.Instance.ThumbnailRenderingMode; thumbnailsModeDropList.SelectionChanged += (s, e) => { string thumbnailRenderingMode = thumbnailsModeDropList.SelectedValue; if (thumbnailRenderingMode != UserSettings.Instance.ThumbnailRenderingMode) { UserSettings.Instance.ThumbnailRenderingMode = thumbnailRenderingMode; UiThread.RunOnIdle(() => { // Ask if the user they would like to rebuild their thumbnails StyledMessageBox.ShowMessageBox( (bool rebuildThumbnails) => { if (rebuildThumbnails) { string[] thumbnails = new string[] { ApplicationController.CacheablePath( Path.Combine("Thumbnails", "Content"), ""), ApplicationController.CacheablePath( Path.Combine("Thumbnails", "Library"), "") }; foreach (var directoryToRemove in thumbnails) { try { if (Directory.Exists(directoryToRemove)) { Directory.Delete(directoryToRemove, true); } } catch (Exception) { GuiWidget.BreakInDebugger(); } Directory.CreateDirectory(directoryToRemove); } ApplicationController.Instance.Library.NotifyContainerChanged(); } }, "You are switching to a different thumbnail rendering mode. If you want, your current thumbnails can be removed and recreated in the new style. You can switch back and forth at any time. There will be some processing overhead while the new thumbnails are created.\n\nDo you want to rebuild your existing thumbnails now?".Localize(), "Rebuild Thumbnails Now".Localize(), StyledMessageBox.MessageType.YES_NO, "Rebuild".Localize()); }); } }; this.AddSettingsRow( new SettingsItem( "Thumbnails".Localize(), thumbnailsModeDropList, theme), generalPanel); #endif // TextSize if (!double.TryParse(UserSettings.Instance.get(UserSettingsKey.ApplicationTextSize), out double currentTextSize)) { currentTextSize = 1.0; } double sliderThumbWidth = 10 * GuiWidget.DeviceScale; double sliderWidth = 100 * GuiWidget.DeviceScale; var textSizeSlider = new SolidSlider(new Vector2(), sliderThumbWidth, theme, .7, 1.4) { Name = "Text Size Slider", Margin = new BorderDouble(5, 0), Value = currentTextSize, HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Center, TotalWidthInPixels = sliderWidth, }; theme.ApplySliderStyle(textSizeSlider); var optionalContainer = new FlowLayoutWidget() { VAnchor = VAnchor.Center | VAnchor.Fit, HAnchor = HAnchor.Fit }; TextWidget sectionLabel = null; var textSizeApplyButton = new TextButton("Apply".Localize(), theme) { VAnchor = VAnchor.Center, BackgroundColor = theme.SlightShade, Visible = false, Margin = new BorderDouble(right: 6) }; textSizeApplyButton.Click += (s, e) => UiThread.RunOnIdle(() => { GuiWidget.DeviceScale = textSizeSlider.Value; ApplicationController.Instance.ReloadAll().ConfigureAwait(false); }); optionalContainer.AddChild(textSizeApplyButton); textSizeSlider.ValueChanged += (s, e) => { double textSizeNew = textSizeSlider.Value; UserSettings.Instance.set(UserSettingsKey.ApplicationTextSize, textSizeNew.ToString("0.0")); sectionLabel.Text = "Text Size".Localize() + $" : {textSizeNew:0.0}"; textSizeApplyButton.Visible = textSizeNew != currentTextSize; }; var textSizeRow = new SettingsItem( "Text Size".Localize() + $" : {currentTextSize:0.0}", textSizeSlider, theme, optionalContainer); sectionLabel = textSizeRow.Children <TextWidget>().FirstOrDefault(); this.AddSettingsRow(textSizeRow, generalPanel); var themeSection = CreateThemePanel(theme); contentRow.AddChild(themeSection); theme.ApplyBoxStyle(themeSection); var advancedPanel = new FlowLayoutWidget(FlowDirection.TopToBottom); var advancedSection = new SectionWidget("Advanced".Localize(), advancedPanel, theme, serializationKey: "ApplicationSettings-Advanced", expanded: false) { Name = "Advanced Section", HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, Margin = 0 }; contentRow.AddChild(advancedSection); theme.ApplyBoxStyle(advancedSection); // Touch Screen Mode this.AddSettingsRow( new SettingsItem( "Touch Screen Mode".Localize(), theme, new SettingsItem.ToggleSwitchConfig() { Checked = UserSettings.Instance.get(UserSettingsKey.ApplicationDisplayMode) == "touchscreen", ToggleAction = (itemChecked) => { string displayMode = itemChecked ? "touchscreen" : "responsive"; if (displayMode != UserSettings.Instance.get(UserSettingsKey.ApplicationDisplayMode)) { UserSettings.Instance.set(UserSettingsKey.ApplicationDisplayMode, displayMode); UiThread.RunOnIdle(() => ApplicationController.Instance.ReloadAll().ConfigureAwait(false)); } } }), advancedPanel); var openCacheButton = new IconButton(AggContext.StaticData.LoadIcon("fa-link_16.png", 16, 16, theme.InvertIcons), theme) { ToolTipText = "Open Folder".Localize(), }; openCacheButton.Click += (s, e) => UiThread.RunOnIdle(() => { Process.Start(ApplicationDataStorage.ApplicationUserDataPath); }); this.AddSettingsRow( new SettingsItem( "Application Storage".Localize(), openCacheButton, theme), advancedPanel); var clearCacheButton = new HoverIconButton(AggContext.StaticData.LoadIcon("remove.png", 16, 16, theme.InvertIcons), theme) { ToolTipText = "Clear Cache".Localize(), }; clearCacheButton.Click += (s, e) => UiThread.RunOnIdle(() => { CacheDirectory.DeleteCacheData(); }); this.AddSettingsRow( new SettingsItem( "Application Cache".Localize(), clearCacheButton, theme), advancedPanel); #if DEBUG var configurePluginsButton = new IconButton(configureIcon, theme) { ToolTipText = "Configure Plugins".Localize(), Margin = 0 }; configurePluginsButton.Click += (s, e) => { UiThread.RunOnIdle(() => { DialogWindow.Show <PluginsPage>(); }); }; this.AddSettingsRow( new SettingsItem( "Plugins".Localize(), configurePluginsButton, theme), advancedPanel); #endif advancedPanel.Children <SettingsItem>().First().Border = new BorderDouble(0, 1); // Enforce consistent SectionWidget spacing and last child borders foreach (var section in contentRow.Children <SectionWidget>()) { section.Margin = new BorderDouble(0, 10, 0, 0); if (section.ContentPanel.Children.LastOrDefault() is SettingsItem lastRow) { // If we're in a contentPanel that has SettingsItems... // Clear the last items bottom border lastRow.Border = lastRow.Border.Clone(bottom: 0); // Set a common margin on the parent container section.ContentPanel.Margin = new BorderDouble(2, 0); } } }
public MacroDetailPage(GCodeMacro gcodeMacro, PrinterSettings printerSettings) { // Form validation fields MHTextEditWidget macroNameInput; MHTextEditWidget macroCommandInput; TextWidget macroCommandError; TextWidget macroNameError; this.HeaderText = "Edit Macro".Localize(); this.printerSettings = printerSettings; var elementMargin = new BorderDouble(top: 3); contentRow.Padding += 3; contentRow.AddChild(new TextWidget("Macro Name".Localize() + ":", 0, 0, 12) { TextColor = theme.TextColor, HAnchor = HAnchor.Stretch, Margin = new BorderDouble(0, 0, 0, 1) }); contentRow.AddChild(macroNameInput = new MHTextEditWidget(GCodeMacro.FixMacroName(gcodeMacro.Name), theme) { HAnchor = HAnchor.Stretch }); contentRow.AddChild(macroNameError = new TextWidget("Give the macro a name".Localize() + ".", 0, 0, 10) { TextColor = theme.TextColor, HAnchor = HAnchor.Stretch, Margin = elementMargin }); contentRow.AddChild(new TextWidget("Macro Commands".Localize() + ":", 0, 0, 12) { TextColor = theme.TextColor, HAnchor = HAnchor.Stretch, Margin = new BorderDouble(0, 0, 0, 1) }); macroCommandInput = new MHTextEditWidget(gcodeMacro.GCode, theme, pixelHeight: 120, multiLine: true, typeFace: ApplicationController.GetTypeFace(NamedTypeFace.Liberation_Mono)) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch }; macroCommandInput.ActualTextEditWidget.VAnchor = VAnchor.Stretch; macroCommandInput.DrawFromHintedCache(); contentRow.AddChild(macroCommandInput); contentRow.AddChild(macroCommandError = new TextWidget("This should be in 'G-Code'".Localize() + ".", 0, 0, 10) { TextColor = theme.TextColor, HAnchor = HAnchor.Stretch, Margin = elementMargin }); var container = new FlowLayoutWidget { Margin = new BorderDouble(0, 5), HAnchor = HAnchor.Stretch }; contentRow.AddChild(container); var saveMacroButton = theme.CreateDialogButton("Save".Localize()); saveMacroButton.Click += (s, e) => { UiThread.RunOnIdle(() => { if (ValidateMacroForm()) { // SaveActiveMacro gcodeMacro.Name = macroNameInput.Text; gcodeMacro.GCode = macroCommandInput.Text; if (!printerSettings.Macros.Contains(gcodeMacro)) { printerSettings.Macros.Add(gcodeMacro); } printerSettings.NotifyMacrosChanged(); printerSettings.Save(); this.DialogWindow.ChangeToPage(new MacroListPage(printerSettings)); } }); }; this.AddPageAction(saveMacroButton); // Define field validation var validationMethods = new ValidationMethods(); var stringValidationHandlers = new FormField.ValidationHandler[] { validationMethods.StringIsNotEmpty }; formFields = new List <FormField> { new FormField(macroNameInput, macroNameError, stringValidationHandlers), new FormField(macroCommandInput, macroCommandError, stringValidationHandlers) }; }
public EditConnectionWidget(ConnectionWindow windowController, GuiWidget containerWindowToClose, Printer activePrinter = null, object state = null) : base(windowController, containerWindowToClose) { textImageButtonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.borderWidth = 0; linkButtonFactory.textColor = ActiveTheme.Instance.PrimaryTextColor; linkButtonFactory.fontSize = 8; this.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; this.AnchorAll(); 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, 3, 3, 5); mainContainer.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; string headerTitle; if (activePrinter == null) { headerTitle = string.Format("Add a Printer"); this.addNewPrinterFlag = true; this.ActivePrinter = new Printer(); this.ActivePrinter.Name = "Default Printer"; this.ActivePrinter.BaudRate = "250000"; try { this.ActivePrinter.ComPort = FrostedSerialPort.GetPortNames().FirstOrDefault(); } catch (Exception e) { Debug.Print(e.Message); GuiWidget.BreakInDebugger(); //No active COM ports } } else { this.ActivePrinter = activePrinter; string editHeaderTitleTxt = LocalizedString.Get("Edit Printer"); headerTitle = string.Format("{1} - {0}", this.ActivePrinter.Name, editHeaderTitleTxt); if (this.ActivePrinter.BaudRate == null) { this.ActivePrinter.BaudRate = "250000"; } if (this.ActivePrinter.ComPort == null) { try { this.ActivePrinter.ComPort = FrostedSerialPort.GetPortNames().FirstOrDefault(); } catch (Exception e) { Debug.Print(e.Message); GuiWidget.BreakInDebugger(); //No active COM ports } } } FlowLayoutWidget 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; { TextWidget headerLabel = new TextWidget(headerTitle, pointSize: 14); headerLabel.TextColor = this.defaultTextColor; headerRow.AddChild(headerLabel); } ConnectionControlContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); ConnectionControlContainer.Padding = new BorderDouble(5); ConnectionControlContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; ConnectionControlContainer.HAnchor = HAnchor.ParentLeftRight; { TextWidget printerNameLabel = new TextWidget(LocalizedString.Get("Name"), 0, 0, 10); printerNameLabel.TextColor = this.defaultTextColor; printerNameLabel.HAnchor = HAnchor.ParentLeftRight; printerNameLabel.Margin = new BorderDouble(0, 0, 0, 1); printerNameInput = new MHTextEditWidget(this.ActivePrinter.Name); printerNameInput.HAnchor |= HAnchor.ParentLeftRight; comPortLabelWidget = new FlowLayoutWidget(); Button refreshComPorts = linkButtonFactory.Generate(LocalizedString.Get("(refresh)")); refreshComPorts.Margin = new BorderDouble(left: 5); refreshComPorts.VAnchor = VAnchor.ParentBottom; refreshComPorts.Click += new EventHandler(RefreshComPorts); FlowLayoutWidget comPortContainer = null; #if !__ANDROID__ TextWidget comPortLabel = new TextWidget(LocalizedString.Get("Serial Port"), 0, 0, 10); comPortLabel.TextColor = this.defaultTextColor; comPortLabelWidget.AddChild(comPortLabel); comPortLabelWidget.AddChild(refreshComPorts); comPortLabelWidget.Margin = new BorderDouble(0, 0, 0, 10); comPortLabelWidget.HAnchor = HAnchor.ParentLeftRight; comPortContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); comPortContainer.Margin = new BorderDouble(0); comPortContainer.HAnchor = HAnchor.ParentLeftRight; CreateSerialPortControls(comPortContainer, this.ActivePrinter.ComPort); #endif TextWidget baudRateLabel = new TextWidget(LocalizedString.Get("Baud Rate"), 0, 0, 10); baudRateLabel.TextColor = this.defaultTextColor; baudRateLabel.Margin = new BorderDouble(0, 0, 0, 10); baudRateLabel.HAnchor = HAnchor.ParentLeftRight; baudRateWidget = GetBaudRateWidget(); baudRateWidget.HAnchor = HAnchor.ParentLeftRight; FlowLayoutWidget printerMakeContainer = createPrinterMakeContainer(); FlowLayoutWidget printerModelContainer = createPrinterModelContainer(); enableAutoconnect = new CheckBox(LocalizedString.Get("Auto Connect")); enableAutoconnect.TextColor = ActiveTheme.Instance.PrimaryTextColor; enableAutoconnect.Margin = new BorderDouble(top: 10); enableAutoconnect.HAnchor = HAnchor.ParentLeft; if (this.ActivePrinter.AutoConnectFlag) { enableAutoconnect.Checked = true; } if (state as StateBeforeRefresh != null) { enableAutoconnect.Checked = ((StateBeforeRefresh)state).autoConnect; } SerialPortControl serialPortScroll = new SerialPortControl(); if (comPortContainer != null) { serialPortScroll.AddChild(comPortContainer); } ConnectionControlContainer.VAnchor = VAnchor.ParentBottomTop; ConnectionControlContainer.AddChild(printerNameLabel); ConnectionControlContainer.AddChild(printerNameInput); ConnectionControlContainer.AddChild(printerMakeContainer); ConnectionControlContainer.AddChild(printerModelContainer); ConnectionControlContainer.AddChild(comPortLabelWidget); ConnectionControlContainer.AddChild(serialPortScroll); ConnectionControlContainer.AddChild(baudRateLabel); ConnectionControlContainer.AddChild(baudRateWidget); #if !__ANDROID__ ConnectionControlContainer.AddChild(enableAutoconnect); #endif } FlowLayoutWidget buttonContainer = new FlowLayoutWidget(FlowDirection.LeftToRight); buttonContainer.HAnchor = HAnchor.ParentLeft | HAnchor.ParentRight; //buttonContainer.VAnchor = VAnchor.BottomTop; buttonContainer.Margin = new BorderDouble(0, 5, 0, 3); { //Construct buttons saveButton = textImageButtonFactory.Generate(LocalizedString.Get("Save")); //saveButton.VAnchor = VAnchor.Bottom; cancelButton = textImageButtonFactory.Generate(LocalizedString.Get("Cancel")); //cancelButton.VAnchor = VAnchor.Bottom; cancelButton.Click += new EventHandler(CancelButton_Click); //Add buttons to buttonContainer buttonContainer.AddChild(saveButton); buttonContainer.AddChild(new HorizontalSpacer()); buttonContainer.AddChild(cancelButton); } //mainContainer.AddChild(new PrinterChooser()); mainContainer.AddChild(headerRow); mainContainer.AddChild(ConnectionControlContainer); mainContainer.AddChild(buttonContainer); #if __ANDROID__ this.AddChild(new SoftKeyboardContentOffset(mainContainer)); #else this.AddChild(mainContainer); #endif BindSaveButtonHandlers(); BindBaudRateHandlers(); }
public IconViewItem(ListViewItem item, int thumbWidth, int thumbHeight, ThemeConfig theme) : base(item, thumbWidth, thumbHeight, theme) { this.VAnchor = VAnchor.Fit; this.HAnchor = HAnchor.Fit; this.Padding = IconViewItem.ItemPadding; this.Margin = new BorderDouble(6, 0, 0, 6); this.Border = 1; int scaledWidth = (int)(thumbWidth * GuiWidget.DeviceScale); int scaledHeight = (int)(thumbHeight * GuiWidget.DeviceScale); int maxWidth = scaledWidth - 4; if (thumbWidth < 75) { imageWidget = new ImageWidget(scaledWidth, scaledHeight) { AutoResize = false, Name = "List Item Thumbnail", BackgroundColor = theme.ThumbnailBackground, Margin = 0, Selectable = false }; this.AddChild(imageWidget); } else { var container = new FlowLayoutWidget(FlowDirection.TopToBottom) { Selectable = false }; this.AddChild(container); imageWidget = new ImageWidget(scaledWidth, scaledHeight) { AutoResize = false, Name = "List Item Thumbnail", BackgroundColor = theme.ThumbnailBackground, Margin = 0, Selectable = false }; container.AddChild(imageWidget); text = new TextWidget(item.Model.Name, 0, 0, 9, textColor: theme.TextColor) { AutoExpandBoundsToText = false, EllipsisIfClipped = true, HAnchor = HAnchor.Center, Margin = new BorderDouble(0, 0, 0, 3), Selectable = false }; text.MaximumSize = new Vector2(maxWidth, 20); if (text.Printer.LocalBounds.Width > maxWidth) { text.Width = maxWidth; text.Text = item.Model.Name; } container.AddChild(text); } this.SetUnsizedThumbnail(loadingImage); }
private FlowLayoutWidget GetManualMoveBar() { FlowLayoutWidget manualMoveBar = new FlowLayoutWidget(); manualMoveBar.HAnchor = HAnchor.ParentLeftRight; manualMoveBar.Margin = new BorderDouble(3, 0, 3, 6); manualMoveBar.Padding = new BorderDouble(0); TextWidget xMoveLabel = new TextWidget("X:"); xMoveLabel.Margin = new BorderDouble(0, 0, 6, 0); xMoveLabel.VAnchor = VAnchor.ParentCenter; MHTextEditWidget xMoveEdit = new MHTextEditWidget("0"); xMoveEdit.Margin = new BorderDouble(0, 0, 6, 0); xMoveEdit.VAnchor = VAnchor.ParentCenter; TextWidget yMoveLabel = new TextWidget("Y:"); yMoveLabel.Margin = new BorderDouble(0, 0, 6, 0); yMoveLabel.VAnchor = VAnchor.ParentCenter; MHTextEditWidget yMoveEdit = new MHTextEditWidget("0"); yMoveEdit.Margin = new BorderDouble(0, 0, 6, 0); yMoveEdit.VAnchor = VAnchor.ParentCenter; TextWidget zMoveLabel = new TextWidget("Z:"); zMoveLabel.Margin = new BorderDouble(0, 0, 6, 0); zMoveLabel.VAnchor = VAnchor.ParentCenter; MHTextEditWidget zMoveEdit = new MHTextEditWidget("0"); zMoveEdit.Margin = new BorderDouble(0, 0, 6, 0); zMoveEdit.VAnchor = VAnchor.ParentCenter; manualMove = textImageButtonFactory.Generate("MOVE TO"); manualMove.Margin = new BorderDouble(0, 0, 6, 0); manualMove.Click += new ButtonBase.ButtonEventHandler(disableMotors_Click); GuiWidget spacer = new GuiWidget(); spacer.HAnchor = HAnchor.ParentLeftRight; manualMoveBar.AddChild(xMoveLabel); manualMoveBar.AddChild(xMoveEdit); manualMoveBar.AddChild(yMoveLabel); manualMoveBar.AddChild(yMoveEdit); manualMoveBar.AddChild(zMoveLabel); manualMoveBar.AddChild(zMoveEdit); manualMoveBar.AddChild(manualMove); manualMoveBar.AddChild(spacer); return(manualMoveBar); }
public override void Init() { RelativeX = 0.0f; RelativeY = 0.0f; RelativeWidth = 1f; RelativeHeight = 1f; var textWidget1 = new TextWidget(1) { Color = new Color4(0.35f, 0.35f, 0.35f, 1f), Text = "Re-insert Print Bed", RelativeWidth = 1f, Size = FontSize.Medium, Alignment = QFontAlignment.Centre }; textWidget1.SetPosition(0, 25); AddChildElement(textWidget1); var frame = new Frame(2); frame.SetPosition(0, 50); frame.RelativeWidth = 1f; frame.RelativeHeight = 0.75f; frame.BGColor = new Color4(246, 246, 246, byte.MaxValue); frame.BorderColor = new Color4(220, 220, 220, byte.MaxValue); AddChildElement(frame); Sprite.pixel_perfect = true; var imageWidget1 = new ImageWidget(0); imageWidget1.Init(Host, "extendedcontrols", 240f, 512f, 359f, 612f, 0.0f, 512f, 119f, 612f, 0.0f, 512f, 119f, 612f); imageWidget1.SetSize(120, 102); imageWidget1.SetPosition(10, 5); frame.AddChildElement(imageWidget1); var textWidget2 = new TextWidget(1) { Color = new Color4(0.35f, 0.35f, 0.35f, 1f), Text = "1. Wrap extra filament back on the spool and place the filament spool into the compartment. Make sure the label filament can unravel counter-clockwise." }; textWidget2.SetSize(380, 100); textWidget2.Size = FontSize.Medium; textWidget2.Alignment = QFontAlignment.Left; textWidget2.VAlignment = TextVerticalAlignment.Top; textWidget2.SetPosition(140, 5); frame.AddChildElement(textWidget2); var imageWidget2 = new ImageWidget(0); imageWidget2.Init(Host, "extendedcontrols", 120f, 613f, 239f, 713f, 0.0f, 512f, 119f, 612f, 0.0f, 512f, 119f, 612f); imageWidget2.SetSize(120, 102); imageWidget2.SetPosition(10, 110); frame.AddChildElement(imageWidget2); var textWidget3 = new TextWidget(1) { Color = new Color4(0.35f, 0.35f, 0.35f, 1f), Text = "2. Re-insert the print bed" }; textWidget3.SetSize(380, 100); textWidget3.Size = FontSize.Medium; textWidget3.Alignment = QFontAlignment.Left; textWidget3.VAlignment = TextVerticalAlignment.Top; textWidget3.SetPosition(140, 110); frame.AddChildElement(textWidget3); var imageWidget3 = new ImageWidget(0); imageWidget3.Init(Host, "extendedcontrols", 120f, 512f, 239f, 612f, 0.0f, 512f, 119f, 612f, 0.0f, 512f, 119f, 612f); imageWidget3.SetSize(120, 102); imageWidget3.SetPosition(10, 215); frame.AddChildElement(imageWidget3); var textWidget4 = new TextWidget(1) { Color = new Color4(0.35f, 0.35f, 0.35f, 1f), Text = "3. Make sure the print bed is secure and pull it forward to lock it." }; textWidget4.SetSize(380, 100); textWidget4.Size = FontSize.Medium; textWidget4.Alignment = QFontAlignment.Left; textWidget4.VAlignment = TextVerticalAlignment.Top; textWidget4.SetPosition(140, 215); frame.AddChildElement(textWidget4); Sprite.pixel_perfect = false; var buttonWidget = new ButtonWidget(8); buttonWidget.Init(Host, "guicontrols", 896f, 192f, 959f, byte.MaxValue, 896f, 256f, 959f, 319f, 896f, 320f, 959f, 383f, 960f, 128f, 1023f, 191f); buttonWidget.Size = FontSize.Medium; buttonWidget.Text = "Next"; buttonWidget.SetGrowableWidth(4, 4, 32); buttonWidget.SetGrowableHeight(4, 4, 32); buttonWidget.SetSize(100, 32); buttonWidget.SetPosition(400, -50); buttonWidget.RelativeX = 0.8f; buttonWidget.RelativeY = -1000f; buttonWidget.SetCallback(new ButtonCallback(((Manage3DInkChildWindow)this).MyButtonCallback)); AddChildElement(buttonWidget); }
public JogControls(XYZColors colors) { moveButtonFactory.normalTextColor = RGBA_Bytes.Black; double distanceBetweenControls = 12; double buttonSeparationDistance = 10; FlowLayoutWidget allControlsTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); allControlsTopToBottom.HAnchor |= Agg.UI.HAnchor.ParentLeftRight; { FlowLayoutWidget allControlsLeftToRight = new FlowLayoutWidget(); FlowLayoutWidget xYZWithDistance = new FlowLayoutWidget(FlowDirection.TopToBottom); { FlowLayoutWidget xYZControls = new FlowLayoutWidget(); { GuiWidget xyGrid = CreateXYGridControl(colors, distanceBetweenControls, buttonSeparationDistance); xYZControls.AddChild(xyGrid); FlowLayoutWidget zButtons = CreateZButtons(XYZColors.zColor, buttonSeparationDistance, out zPlusControl, out zMinusControl); zButtons.VAnchor = Agg.UI.VAnchor.ParentBottom; xYZControls.AddChild(zButtons); xYZWithDistance.AddChild(xYZControls); } this.KeyDown += (sender, e) => { double moveAmountPositive = AxisMoveAmount; double moveAmountNegative = -AxisMoveAmount; int eMoveAmountPositive = EAxisMoveAmount; int eMoveAmountNegative = -EAxisMoveAmount; if (OsInformation.OperatingSystem == OSType.Windows) { if (e.KeyCode == Keys.Home && hotKeysEnabled) { PrinterConnectionAndCommunication.Instance.HomeAxis(PrinterConnectionAndCommunication.Axis.XYZ); } else if (e.KeyCode == Keys.Z && hotKeysEnabled) { PrinterConnectionAndCommunication.Instance.HomeAxis(PrinterConnectionAndCommunication.Axis.Z); } else if (e.KeyCode == Keys.Y && hotKeysEnabled) { PrinterConnectionAndCommunication.Instance.HomeAxis(PrinterConnectionAndCommunication.Axis.Y); } else if (e.KeyCode == Keys.X && hotKeysEnabled) { PrinterConnectionAndCommunication.Instance.HomeAxis(PrinterConnectionAndCommunication.Axis.X); } else if (e.KeyCode == Keys.Left && hotKeysEnabled) { PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.X, moveAmountNegative, MovementControls.XSpeed); } else if (e.KeyCode == Keys.Right && hotKeysEnabled) { PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.X, moveAmountPositive, MovementControls.XSpeed); } else if (e.KeyCode == Keys.Up && hotKeysEnabled) { PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.Y, moveAmountPositive, MovementControls.YSpeed); } else if (e.KeyCode == Keys.Down && hotKeysEnabled) { PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.Y, moveAmountNegative, MovementControls.YSpeed); } else if (e.KeyCode == Keys.PageUp && hotKeysEnabled) { PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.Z, moveAmountPositive, MovementControls.ZSpeed); } else if (e.KeyCode == Keys.PageDown && hotKeysEnabled) { PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.Z, moveAmountNegative, MovementControls.ZSpeed); } else if (e.KeyCode == Keys.E && hotKeysEnabled) { PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.E, eMoveAmountPositive, MovementControls.EFeedRate(0)); } else if (e.KeyCode == Keys.R && hotKeysEnabled) { PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.E, eMoveAmountNegative, MovementControls.EFeedRate(0)); } } else if (OsInformation.OperatingSystem == OSType.Mac) { if (e.KeyCode == Keys.LButton && hotKeysEnabled) { PrinterConnectionAndCommunication.Instance.HomeAxis(PrinterConnectionAndCommunication.Axis.XYZ); } else if (e.KeyCode == Keys.Z && hotKeysEnabled) { PrinterConnectionAndCommunication.Instance.HomeAxis(PrinterConnectionAndCommunication.Axis.Z); } else if (e.KeyCode == Keys.Y && hotKeysEnabled) { PrinterConnectionAndCommunication.Instance.HomeAxis(PrinterConnectionAndCommunication.Axis.Y); } else if (e.KeyCode == Keys.X && hotKeysEnabled) { PrinterConnectionAndCommunication.Instance.HomeAxis(PrinterConnectionAndCommunication.Axis.X); } else if (e.KeyCode == Keys.Left && hotKeysEnabled) { PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.X, moveAmountNegative, MovementControls.XSpeed); } else if (e.KeyCode == Keys.Right && hotKeysEnabled) { PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.X, moveAmountPositive, MovementControls.XSpeed); } else if (e.KeyCode == Keys.Up && hotKeysEnabled) { PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.Y, moveAmountPositive, MovementControls.YSpeed); } else if (e.KeyCode == Keys.Down && hotKeysEnabled) { PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.Y, moveAmountNegative, MovementControls.YSpeed); } else if (e.KeyCode == (Keys.Back | Keys.Cancel) && hotKeysEnabled) { PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.Z, moveAmountPositive, MovementControls.ZSpeed); } else if (e.KeyCode == Keys.Clear && hotKeysEnabled) { PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.Z, moveAmountNegative, MovementControls.ZSpeed); } else if (e.KeyCode == Keys.E && hotKeysEnabled) { PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.E, eMoveAmountPositive, MovementControls.EFeedRate(0)); } else if (e.KeyCode == Keys.R && hotKeysEnabled) { PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.E, eMoveAmountNegative, MovementControls.EFeedRate(0)); } } }; // add in some movement radio buttons FlowLayoutWidget setMoveDistanceControl = new FlowLayoutWidget(); TextWidget buttonsLabel = new TextWidget("Distance:", textColor: RGBA_Bytes.White); buttonsLabel.VAnchor = Agg.UI.VAnchor.ParentCenter; //setMoveDistanceControl.AddChild(buttonsLabel); { TextImageButtonFactory buttonFactory = new TextImageButtonFactory(); buttonFactory.FixedHeight = 20 * TextWidget.GlobalPointSizeScaleRatio; buttonFactory.FixedWidth = 30 * TextWidget.GlobalPointSizeScaleRatio; buttonFactory.fontSize = 8; buttonFactory.Margin = new BorderDouble(0); buttonFactory.checkedBorderColor = ActiveTheme.Instance.PrimaryTextColor; FlowLayoutWidget moveRadioButtons = new FlowLayoutWidget(); var radioList = new ObservableCollection <GuiWidget>(); pointZeroOneButton = buttonFactory.GenerateRadioButton("0.02"); pointZeroOneButton.VAnchor = Agg.UI.VAnchor.ParentCenter; pointZeroOneButton.CheckedStateChanged += (sender, e) => { if (((RadioButton)sender).Checked) { SetXYZMoveAmount(.02); } }; pointZeroOneButton.SiblingRadioButtonList = radioList; moveRadioButtons.AddChild(pointZeroOneButton); RadioButton pointOneButton = buttonFactory.GenerateRadioButton("0.1"); pointOneButton.VAnchor = Agg.UI.VAnchor.ParentCenter; pointOneButton.CheckedStateChanged += (sender, e) => { if (((RadioButton)sender).Checked) { SetXYZMoveAmount(.1); } }; pointOneButton.SiblingRadioButtonList = radioList; moveRadioButtons.AddChild(pointOneButton); RadioButton oneButton = buttonFactory.GenerateRadioButton("1"); oneButton.VAnchor = Agg.UI.VAnchor.ParentCenter; oneButton.CheckedStateChanged += (sender, e) => { if (((RadioButton)sender).Checked) { SetXYZMoveAmount(1); } }; oneButton.SiblingRadioButtonList = radioList; moveRadioButtons.AddChild(oneButton); tooBigForBabyStepping = new DisableableWidget() { VAnchor = VAnchor.FitToChildren, HAnchor = HAnchor.FitToChildren }; var tooBigFlowLayout = new FlowLayoutWidget(); tooBigForBabyStepping.AddChild(tooBigFlowLayout); tenButton = buttonFactory.GenerateRadioButton("10"); tenButton.VAnchor = Agg.UI.VAnchor.ParentCenter; tenButton.CheckedStateChanged += (sender, e) => { if (((RadioButton)sender).Checked) { SetXYZMoveAmount(10); } }; tenButton.SiblingRadioButtonList = radioList; tooBigFlowLayout.AddChild(tenButton); oneHundredButton = buttonFactory.GenerateRadioButton("100"); oneHundredButton.VAnchor = Agg.UI.VAnchor.ParentCenter; oneHundredButton.CheckedStateChanged += (sender, e) => { if (((RadioButton)sender).Checked) { SetXYZMoveAmount(100); } }; oneHundredButton.SiblingRadioButtonList = radioList; tooBigFlowLayout.AddChild(oneHundredButton); moveRadioButtons.AddChild(tooBigForBabyStepping); tenButton.Checked = true; moveRadioButtons.Margin = new BorderDouble(0, 3); setMoveDistanceControl.AddChild(moveRadioButtons); TextWidget mmLabel = new TextWidget("mm", textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 8); mmLabel.VAnchor = Agg.UI.VAnchor.ParentCenter; tooBigFlowLayout.AddChild(mmLabel); } setMoveDistanceControl.HAnchor = Agg.UI.HAnchor.ParentLeft; xYZWithDistance.AddChild(setMoveDistanceControl); } allControlsLeftToRight.AddChild(xYZWithDistance); #if !__ANDROID__ allControlsLeftToRight.AddChild(GetHotkeyControlContainer()); #endif GuiWidget barBetweenZAndE = new GuiWidget(2, 2); barBetweenZAndE.VAnchor = Agg.UI.VAnchor.ParentBottomTop; barBetweenZAndE.BackgroundColor = RGBA_Bytes.White; barBetweenZAndE.Margin = new BorderDouble(distanceBetweenControls, 5); allControlsLeftToRight.AddChild(barBetweenZAndE); FlowLayoutWidget eButtons = CreateEButtons(buttonSeparationDistance); disableableEButtons = new DisableableWidget() { HAnchor = HAnchor.FitToChildren, VAnchor = VAnchor.FitToChildren | VAnchor.ParentTop, }; disableableEButtons.AddChild(eButtons); allControlsLeftToRight.AddChild(disableableEButtons); allControlsTopToBottom.AddChild(allControlsLeftToRight); } this.AddChild(allControlsTopToBottom); this.HAnchor = HAnchor.FitToChildren; this.VAnchor = VAnchor.FitToChildren; Margin = new BorderDouble(3); // this.HAnchor |= HAnchor.ParentLeftRight; }
public ContactFormPage() { this.WindowTitle = "MatterControl : " + "Submit Feedback".Localize(); this.HeaderText = "How can we improve?".Localize(); contentRow.Padding = theme.DefaultContainerPadding; submitButton = theme.CreateDialogButton("Submit".Localize()); submitButton.Click += (sender, eventArgs) => { if (ValidateContactForm()) { ContactFormRequest postRequest = new ContactFormRequest(questionInput.Text, detailInput.Text, emailInput.Text, nameInput.Text, ""); contentRow.RemoveAllChildren(); contentRow.AddChild(messageContainer); submitButton.Visible = false; postRequest.RequestSucceeded += (s, e) => { submissionStatus.Text = "Thank you! Your information has been submitted.".Localize(); this.SetCancelButtonText("Done".Localize()); }; postRequest.RequestFailed += (s, e) => { submissionStatus.Text = "Sorry! We weren't able to submit your request.".Localize(); }; postRequest.Request(); } }; this.AddPageAction(submitButton); messageContainer = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch }; submissionStatus = new TextWidget("Submitting your information...".Localize(), pointSize: 13) { AutoExpandBoundsToText = true, Margin = new BorderDouble(0, 5), TextColor = theme.Colors.PrimaryTextColor, HAnchor = HAnchor.Left }; messageContainer.AddChild(submissionStatus); // Default sizing results in too much top whitespace, revise Subject row to only be as big as content var subjectRow = CreateLabelRow("Subject".Localize()); subjectRow.VAnchor = VAnchor.Fit; contentRow.AddChild(subjectRow); contentRow.AddChild(questionInput = new MHTextEditWidget("") { HAnchor = HAnchor.Stretch }); contentRow.AddChild(questionErrorMessage = CreateErrorRow()); contentRow.AddChild(CreateLabelRow("Message".Localize())); contentRow.AddChild(detailInput = new MHTextEditWidget("", pixelHeight: 120, multiLine: true) { HAnchor = HAnchor.Stretch }); contentRow.AddChild(detailErrorMessage = CreateErrorRow()); contentRow.AddChild(CreateLabelRow("Email Address".Localize())); contentRow.AddChild(emailInput = new MHTextEditWidget { HAnchor = HAnchor.Stretch }); contentRow.AddChild(emailErrorMessage = CreateErrorRow()); contentRow.AddChild(CreateLabelRow("Name".Localize())); contentRow.AddChild(nameInput = new MHTextEditWidget { HAnchor = HAnchor.Stretch }); contentRow.AddChild(nameErrorMessage = CreateErrorRow()); }
public void SetContainer(ILibraryContainer currentContainer) { var linkButtonFactory = ApplicationController.Instance.Theme.LinkButtonFactory; var theme = ApplicationController.Instance.Theme; this.CloseAllChildren(); var upbutton = new IconButton(AggContext.StaticData.LoadIcon(Path.Combine("FileDialog", "up_folder_20.png"), theme.InvertIcons), theme) { VAnchor = VAnchor.Fit | VAnchor.Center, Enabled = currentContainer.Parent != null, Name = "Library Up Button", Margin = theme.ButtonSpacing, MinimumSize = new Vector2(theme.ButtonHeight, theme.ButtonHeight) }; upbutton.Click += (s, e) => { if (listView.ActiveContainer.Parent != null) { UiThread.RunOnIdle(() => listView.SetActiveContainer(listView.ActiveContainer.Parent)); } }; this.AddChild(upbutton); bool firstItem = true; if (this.Width < 250) { Button containerButton = linkButtonFactory.Generate(listView.ActiveContainer.Name == null ? "?" : listView.ActiveContainer.Name); containerButton.Name = "Bread Crumb Button " + listView.ActiveContainer.Name; containerButton.VAnchor = VAnchor.Center; containerButton.Margin = theme.ButtonSpacing; this.AddChild(containerButton); } else { var extraSpacing = (theme.ButtonSpacing).Clone(left: theme.ButtonSpacing.Right * .4); foreach (var container in currentContainer.AncestorsAndSelf().Reverse()) { if (!firstItem) { // Add path separator var textContainer = new GuiWidget() // HACK: Workaround for VAlign.Center failure in this specific case. Remove wrapper(with padding) once fixed and directly add TextWidget child { HAnchor = HAnchor.Fit, VAnchor = VAnchor.Fit | VAnchor.Center, Padding = new BorderDouble(top: 4), Margin = extraSpacing, }; textContainer.AddChild(new TextWidget("/", pointSize: theme.DefaultFontSize + 2, textColor: ActiveTheme.Instance.PrimaryTextColor)); this.AddChild(textContainer); } // Create a button for each container Button containerButton = linkButtonFactory.Generate(container.Name); containerButton.Name = "Bread Crumb Button " + container.Name; containerButton.VAnchor = VAnchor.Center; containerButton.Margin = theme.ButtonSpacing; containerButton.Click += (s, e) => { UiThread.RunOnIdle(() => listView.SetActiveContainer(container)); }; this.AddChild(containerButton); firstItem = false; } // while all the buttons don't fit in the control if (this.Parent != null && this.Width > 0 && this.Children.Count > 4 && this.GetChildrenBoundsIncludingMargins().Width > (this.Width - 20)) { // lets take out the > and put in a ... this.RemoveChild(1); var separator = new TextWidget("...", textColor: ActiveTheme.Instance.PrimaryTextColor) { VAnchor = VAnchor.Center, Margin = new BorderDouble(right: 5) }; this.AddChild(separator, 1); while (this.GetChildrenBoundsIncludingMargins().Width > this.Width - 20 && this.Children.Count > 4) { this.RemoveChild(3); this.RemoveChild(2); } } } }
public EePromRepetierWidget() : base(540, 480) { BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; currentEePromSettings = new EePromRepetierStorage(); FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); topToBottom.VAnchor = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight; topToBottom.HAnchor = Agg.UI.HAnchor.ParentLeftRight; topToBottom.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; topToBottom.Padding = new BorderDouble(3, 0); FlowLayoutWidget row = new FlowLayoutWidget(); row.HAnchor = Agg.UI.HAnchor.ParentLeftRight; row.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; GuiWidget descriptionWidget = AddDescription(LocalizedString.Get("Description")); descriptionWidget.Margin = new BorderDouble(left: 3); row.AddChild(descriptionWidget); CreateSpacer(row); GuiWidget valueText = new TextWidget(LocalizedString.Get("Value"), textColor: ActiveTheme.Instance.PrimaryTextColor); valueText.VAnchor = Agg.UI.VAnchor.ParentCenter; valueText.Margin = new BorderDouble(left: 5, right: 60); row.AddChild(valueText); topToBottom.AddChild(row); { ScrollableWidget settingsAreaScrollBox = new ScrollableWidget(true); settingsAreaScrollBox.ScrollArea.HAnchor |= Agg.UI.HAnchor.ParentLeftRight; settingsAreaScrollBox.AnchorAll(); settingsAreaScrollBox.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; topToBottom.AddChild(settingsAreaScrollBox); settingsColmun = new FlowLayoutWidget(FlowDirection.TopToBottom); settingsColmun.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth; settingsAreaScrollBox.AddChild(settingsColmun); } FlowLayoutWidget buttonBar = new FlowLayoutWidget(); buttonBar.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth; buttonBar.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; buttonSave = textImageButtonFactory.Generate(LocalizedString.Get("Save To EEPROM")); buttonSave.Margin = new BorderDouble(0, 3); buttonBar.AddChild(buttonSave); CreateSpacer(buttonBar); buttonCancel = textImageButtonFactory.Generate(LocalizedString.Get("Cancel")); buttonCancel.Margin = new BorderDouble(3); buttonBar.AddChild(buttonCancel); topToBottom.AddChild(buttonBar); this.AddChild(topToBottom); translate(); //MatterControlApplication.Instance.LanguageChanged += translate; ShowAsSystemWindow(); currentEePromSettings.Clear(); PrinterConnectionAndCommunication.Instance.CommunicationUnconditionalFromPrinter.RegisterEvent(currentEePromSettings.Add, ref unregisterEvents); currentEePromSettings.eventAdded += NewSettingReadFromPrinter; currentEePromSettings.AskPrinterForSettings(); #if SIMULATE_CONNECTION UiThread.RunOnIdle(AddSimulatedItems); #endif }
private FlowLayoutWidget GetAutoLevelControl() { FlowLayoutWidget buttonRow = new FlowLayoutWidget(); buttonRow.HAnchor = HAnchor.ParentLeftRight; buttonRow.Margin = new BorderDouble(0, 4); configureAutoLevelButton = textImageButtonFactory.Generate("Configure".Localize().ToUpper()); configureAutoLevelButton.Margin = new BorderDouble(left: 6); configureAutoLevelButton.VAnchor = VAnchor.ParentCenter; TextWidget notificationSettingsLabel = new TextWidget("Automatic Print Leveling"); notificationSettingsLabel.AutoExpandBoundsToText = true; notificationSettingsLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor; notificationSettingsLabel.VAnchor = VAnchor.ParentCenter; Button editButton = textImageButtonFactory.GenerateEditButton(); editButton.VAnchor = Agg.UI.VAnchor.ParentCenter; editButton.Click += (sender, e) => { UiThread.RunOnIdle((state) => { if (editLevelingSettingsWindow == null) { editLevelingSettingsWindow = new EditLevelingSettingsWindow(); editLevelingSettingsWindow.Closed += (sender2, e2) => { editLevelingSettingsWindow = null; }; } else { editLevelingSettingsWindow.BringToFront(); } }); }; Button runPrintLevelingButton = textImageButtonFactory.Generate("Configure".Localize().ToUpper()); runPrintLevelingButton.Margin = new BorderDouble(left: 6); runPrintLevelingButton.VAnchor = VAnchor.ParentCenter; runPrintLevelingButton.Click += (sender, e) => { UiThread.RunOnIdle((state) => { LevelWizardBase.ShowPrintLevelWizard(LevelWizardBase.RuningState.UserRequestedCalibration); }); }; Agg.Image.ImageBuffer levelingImage = new Agg.Image.ImageBuffer(); ImageIO.LoadImageData(Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "Icons", "PrintStatusControls", "leveling-24x24.png"), levelingImage); if (!ActiveTheme.Instance.IsDarkTheme) { InvertLightness.DoInvertLightness(levelingImage); } ImageWidget levelingIcon = new ImageWidget(levelingImage); levelingIcon.Margin = new BorderDouble(right: 6); enablePrintLevelingButton = textImageButtonFactory.Generate("Enable".Localize().ToUpper()); enablePrintLevelingButton.Margin = new BorderDouble(left: 6); enablePrintLevelingButton.VAnchor = VAnchor.ParentCenter; enablePrintLevelingButton.Click += new EventHandler(enablePrintLeveling_Click); disablePrintLevelingButton = textImageButtonFactory.Generate("Disable".Localize().ToUpper()); disablePrintLevelingButton.Margin = new BorderDouble(left: 6); disablePrintLevelingButton.VAnchor = VAnchor.ParentCenter; disablePrintLevelingButton.Click += new EventHandler(disablePrintLeveling_Click); printLevelingStatusLabel = new TextWidget(""); printLevelingStatusLabel.AutoExpandBoundsToText = true; printLevelingStatusLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor; printLevelingStatusLabel.VAnchor = VAnchor.ParentCenter; GuiWidget hSpacer = new GuiWidget(); hSpacer.HAnchor = HAnchor.ParentLeftRight; ActivePrinterProfile.Instance.DoPrintLevelingChanged.RegisterEvent((sender, e) => { SetPrintLevelButtonVisiblity(); }, ref unregisterEvents); buttonRow.AddChild(levelingIcon); buttonRow.AddChild(printLevelingStatusLabel); buttonRow.AddChild(editButton); buttonRow.AddChild(new HorizontalSpacer()); buttonRow.AddChild(enablePrintLevelingButton); buttonRow.AddChild(disablePrintLevelingButton); buttonRow.AddChild(runPrintLevelingButton); SetPrintLevelButtonVisiblity(); return(buttonRow); }
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; 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, 3); { 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.ParentBottom; ActionLink editModeLink; if (!this.editMode) { editModeLink = actionLinkFactory.Generate(LocalizedString.Get("Edit"), 12, EditModeOnLink_Click); } else { editModeLink = actionLinkFactory.Generate(LocalizedString.Get("Done"), 12, EditModeOffLink_Click); } //editModeLink.TextColor = new RGBA_Bytes(250, 250, 250); editModeLink.TextColor = ActiveTheme.Instance.PrimaryTextColor; editModeLink.VAnchor = Agg.UI.VAnchor.ParentBottom; headerRow.AddChild(elementHeader); headerRow.AddChild(editModeLink); } //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 ButtonBase.ButtonEventHandler(AddConnectionLink_Click); Button refreshListButton = textImageButtonFactory.Generate(LocalizedString.Get("Refresh")); refreshListButton.Click += new ButtonBase.ButtonEventHandler(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(printerListContainer); mainContainer.AddChild(buttonContainer); this.AddChild(mainContainer); BindCloseButtonClick(); } }
private void AddModelInfo(FlowLayoutWidget buttonPanel) { textImageButtonFactory.FixedWidth = 44; FlowLayoutWidget modelInfoContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); modelInfoContainer.HAnchor = HAnchor.ParentLeftRight; modelInfoContainer.Padding = new BorderDouble(5); string printTimeLbl = new LocalizedString("Print Time").Translated; string printTimeLblFull = string.Format("{0}:", printTimeLbl); // put in the print time modelInfoContainer.AddChild(new TextWidget(printTimeLblFull, textColor: RGBA_Bytes.White)); { string timeRemainingText = "---"; if (gcodeViewWidget != null && gcodeViewWidget.LoadedGCode != null) { int secondsRemaining = (int)gcodeViewWidget.LoadedGCode.GCodeCommandQueue[0].secondsToEndFromHere; int hoursRemaining = (int)(secondsRemaining / (60 * 60)); int minutesRemaining = (int)((secondsRemaining + 30) / 60 - hoursRemaining * 60); // +30 for rounding secondsRemaining = secondsRemaining % 60; if (hoursRemaining > 0) { timeRemainingText = string.Format("{0} h, {1} min", hoursRemaining, minutesRemaining); } else { timeRemainingText = string.Format("{0} min", minutesRemaining); } } GuiWidget estimatedPrintTime = new TextWidget(string.Format("{0}", timeRemainingText), textColor: RGBA_Bytes.White, pointSize: 10); estimatedPrintTime.HAnchor = Agg.UI.HAnchor.ParentLeft; estimatedPrintTime.Margin = new BorderDouble(3, 0, 0, 3); modelInfoContainer.AddChild(estimatedPrintTime); } //modelInfoContainer.AddChild(new TextWidget("Size:", textColor: RGBA_Bytes.White)); string filamentLengthLbl = new LocalizedString("Filament Length").Translated; string filamentLengthLblFull = string.Format("{0}:", filamentLengthLbl); // show the filament used modelInfoContainer.AddChild(new TextWidget(filamentLengthLblFull, textColor: RGBA_Bytes.White)); { double filamentUsed = gcodeViewWidget.LoadedGCode.GetFilamentUsedMm(ActiveSliceSettings.Instance.NozzleDiameter); GuiWidget estimatedPrintTime = new TextWidget(string.Format("{0:0.0} mm", filamentUsed), textColor: RGBA_Bytes.White, pointSize: 10); estimatedPrintTime.HAnchor = Agg.UI.HAnchor.ParentLeft; estimatedPrintTime.Margin = new BorderDouble(3, 0, 0, 3); modelInfoContainer.AddChild(estimatedPrintTime); } string filamentVolumeLbl = new LocalizedString("Filament Volume").Translated; string filamentVolumeLblFull = string.Format("{0}:", filamentVolumeLbl); modelInfoContainer.AddChild(new TextWidget(filamentVolumeLblFull, textColor: RGBA_Bytes.White)); { var density = 1.0; string filamentType = "PLA"; if (filamentType == "ABS") { density = 1.04; } else if (filamentType == "PLA") { density = 1.24; } double filamentMm3 = gcodeViewWidget.LoadedGCode.GetFilamentCubicMm(ActiveSliceSettings.Instance.FillamentDiameter); GuiWidget estimatedPrintTime = new TextWidget(string.Format("{0:0.00} cm3", filamentMm3 / 1000), textColor: RGBA_Bytes.White, pointSize: 10); estimatedPrintTime.HAnchor = Agg.UI.HAnchor.ParentLeft; estimatedPrintTime.Margin = new BorderDouble(3, 0, 0, 3); modelInfoContainer.AddChild(estimatedPrintTime); } string weightLbl = new LocalizedString("Weight").Translated; string weightLblFull = string.Format("{0}:", weightLbl); modelInfoContainer.AddChild(new TextWidget(weightLblFull, textColor: RGBA_Bytes.White)); { var density = 1.0; string filamentType = "PLA"; if (filamentType == "ABS") { density = 1.04; } else if (filamentType == "PLA") { density = 1.24; } double filamentWeightGrams = gcodeViewWidget.LoadedGCode.GetFilamentWeightGrams(ActiveSliceSettings.Instance.FillamentDiameter, density); GuiWidget estimatedPrintTime = new TextWidget(string.Format("{0:0.00} g", filamentWeightGrams), textColor: RGBA_Bytes.White, pointSize: 10); estimatedPrintTime.HAnchor = Agg.UI.HAnchor.ParentLeft; estimatedPrintTime.Margin = new BorderDouble(3, 0, 0, 3); modelInfoContainer.AddChild(estimatedPrintTime); } //modelInfoContainer.AddChild(new TextWidget("Layer Count:", textColor: RGBA_Bytes.White)); buttonPanel.AddChild(modelInfoContainer); textImageButtonFactory.FixedWidth = 0; }
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(LocalizedString.Get("MatterControl will now attempt to auto-detect printer."), 0, 0, 10); printerMessageOne.Margin = new BorderDouble(0, 10, 0, 5); printerMessageOne.TextColor = ActiveTheme.Instance.PrimaryTextColor; printerMessageOne.HAnchor = HAnchor.ParentLeftRight; printerMessageOne.Margin = elementMargin; string printerMessageTwoTxt = LocalizedString.Get("Disconnect printer"); string printerMessageTwoTxtEnd = LocalizedString.Get("if currently connected"); string printerMessageTwoTxtFull = string.Format("1.) {0} ({1}).", printerMessageTwoTxt, printerMessageTwoTxtEnd); TextWidget printerMessageTwo = new TextWidget(printerMessageTwoTxtFull, 0, 0, 12); printerMessageTwo.TextColor = ActiveTheme.Instance.PrimaryTextColor; printerMessageTwo.HAnchor = HAnchor.ParentLeftRight; printerMessageTwo.Margin = elementMargin; string printerMessageThreeTxt = LocalizedString.Get("Press"); string printerMessageThreeTxtEnd = LocalizedString.Get("Continue"); string printerMessageThreeFull = string.Format("2.) {0} '{1}'.", printerMessageThreeTxt, printerMessageThreeTxtEnd); TextWidget printerMessageThree = new TextWidget(printerMessageThreeFull, 0, 0, 12); printerMessageThree.TextColor = ActiveTheme.Instance.PrimaryTextColor; printerMessageThree.HAnchor = HAnchor.ParentLeftRight; printerMessageThree.Margin = elementMargin; GuiWidget vSpacer = new GuiWidget(); vSpacer.VAnchor = VAnchor.ParentBottomTop; string setupManualConfigurationOrSkipConnectionText = LocalizedString.Get(("You can also")); string setupManualConfigurationOrSkipConnectionTextFull = String.Format("{0}:", setupManualConfigurationOrSkipConnectionText); TextWidget setupManualConfigurationOrSkipConnectionWidget = new TextWidget(setupManualConfigurationOrSkipConnectionTextFull, 0, 0, 10); setupManualConfigurationOrSkipConnectionWidget.TextColor = ActiveTheme.Instance.PrimaryTextColor; setupManualConfigurationOrSkipConnectionWidget.HAnchor = HAnchor.ParentLeftRight; setupManualConfigurationOrSkipConnectionWidget.Margin = elementMargin; Button manualLink = linkButtonFactory.Generate(LocalizedString.Get("Manually Configure Connection")); manualLink.Margin = new BorderDouble(0, 5); manualLink.Click += new EventHandler(ManualLink_Click); string printerMessageFourText = LocalizedString.Get("or"); TextWidget printerMessageFour = new TextWidget(printerMessageFourText, 0, 0, 10); printerMessageFour.TextColor = ActiveTheme.Instance.PrimaryTextColor; printerMessageFour.HAnchor = HAnchor.ParentLeftRight; printerMessageFour.Margin = elementMargin; Button skipConnectionLink = linkButtonFactory.Generate(LocalizedString.Get("Skip Connection Setup")); skipConnectionLink.Margin = new BorderDouble(0, 8); skipConnectionLink.Click += new EventHandler(SkipConnectionLink_Click); container.AddChild(printerMessageOne); container.AddChild(printerMessageTwo); container.AddChild(printerMessageThree); container.AddChild(vSpacer); container.AddChild(setupManualConfigurationOrSkipConnectionWidget); container.AddChild(manualLink); container.AddChild(printerMessageFour); container.AddChild(skipConnectionLink); container.HAnchor = HAnchor.ParentLeftRight; return(container); }
public void ListMenuTests() { string menuSelected = ""; GuiWidget container = new GuiWidget(400, 400); TextWidget menueView = new TextWidget("Edit"); Menu listMenu = new Menu(menueView); listMenu.OriginRelativeParent = new Vector2(10, 300); MenuItem cutMenuItem = new MenuItem(new TextWidget("Cut")); cutMenuItem.Selected += (sender, e) => { menuSelected = "Cut"; }; listMenu.MenuItems.Add(cutMenuItem); MenuItem copyMenuItem = new MenuItem(new TextWidget("Copy")); copyMenuItem.Selected += (sender, e) => { menuSelected = "Copy"; }; listMenu.MenuItems.Add(copyMenuItem); MenuItem pastMenuItem = new MenuItem(new TextWidget("Paste")); pastMenuItem.Selected += (sender, e) => { menuSelected = "Paste"; }; listMenu.MenuItems.Add(pastMenuItem); container.AddChild(listMenu); Assert.IsTrue(!listMenu.IsOpen); // open the menu container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 11, 300, 0)); Assert.IsTrue(!listMenu.IsOpen); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 11, 300, 0)); UiThread.DoRunAllPending(); Assert.IsTrue(listMenu.IsOpen); // all the menu itmes should be added to the open menu Assert.IsTrue(cutMenuItem.Parent != null); Assert.IsTrue(copyMenuItem.Parent != null); Assert.IsTrue(pastMenuItem.Parent != null); // click on menu again to close container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 11, 300, 0)); UiThread.DoRunAllPending(); Assert.IsTrue(!listMenu.IsOpen); // all the mune itmes should be removed from the closed menu Assert.IsTrue(cutMenuItem.Parent == null); Assert.IsTrue(copyMenuItem.Parent == null); Assert.IsTrue(pastMenuItem.Parent == null); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 11, 300, 0)); UiThread.DoRunAllPending(); Assert.IsTrue(!listMenu.IsOpen); // all the menu itmes should be removed from the closed menu Assert.IsTrue(cutMenuItem.Parent == null); Assert.IsTrue(copyMenuItem.Parent == null); Assert.IsTrue(pastMenuItem.Parent == null); // open the menu container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 11, 300, 0)); UiThread.DoRunAllPending(); Assert.IsTrue(!listMenu.IsOpen); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 11, 300, 0)); UiThread.DoRunAllPending(); Assert.IsTrue(listMenu.IsOpen); // all the menu itmes should be added to the open menu Assert.IsTrue(cutMenuItem.Parent != null); Assert.IsTrue(copyMenuItem.Parent != null); Assert.IsTrue(pastMenuItem.Parent != null); // click off menu to close container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 5, 299, 0)); UiThread.DoRunAllPending(); Assert.IsTrue(!listMenu.IsOpen); // all the mune itmes should be removed from the closed menu Assert.IsTrue(cutMenuItem.Parent == null); Assert.IsTrue(copyMenuItem.Parent == null); Assert.IsTrue(pastMenuItem.Parent == null); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 5, 299, 0)); UiThread.DoRunAllPending(); Assert.IsTrue(!listMenu.IsOpen); // open the menu again container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 11, 300, 0)); UiThread.DoRunAllPending(); Assert.IsTrue(!listMenu.IsOpen); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 11, 300, 0)); UiThread.DoRunAllPending(); Assert.IsTrue(listMenu.IsOpen); // select the first item container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 11, 290, 0)); UiThread.DoRunAllPending(); Assert.IsTrue(listMenu.IsOpen); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 11, 290, 0)); UiThread.DoRunAllPending(); Assert.IsTrue(!listMenu.IsOpen); Assert.IsTrue(menuSelected == "Cut"); // open the menu container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 11, 300, 0)); UiThread.DoRunAllPending(); Assert.IsTrue(!listMenu.IsOpen); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 11, 300, 0)); UiThread.DoRunAllPending(); Assert.IsTrue(listMenu.IsOpen); // select the second item menuSelected = ""; container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 11, 275, 0)); UiThread.DoRunAllPending(); Assert.IsTrue(listMenu.IsOpen); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 11, 275, 0)); UiThread.DoRunAllPending(); Assert.IsTrue(!listMenu.IsOpen); Assert.IsTrue(menuSelected == "Copy"); // make sure click down then move off item does not select it. menuSelected = ""; // open the menu container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 11, 300, 0)); UiThread.DoRunAllPending(); Assert.IsTrue(!listMenu.IsOpen); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 11, 300, 0)); UiThread.DoRunAllPending(); Assert.IsTrue(listMenu.IsOpen); // click down on the first item container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 11, 290, 0)); UiThread.DoRunAllPending(); Assert.IsTrue(listMenu.IsOpen); // move off of it container.OnMouseMove(new MouseEventArgs(MouseButtons.None, 1, 5, 290, 0)); UiThread.DoRunAllPending(); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 5, 290, 0)); UiThread.DoRunAllPending(); Assert.IsTrue(!listMenu.IsOpen); Assert.IsTrue(menuSelected == ""); // make sure click down and then move to new items selects the new item. // click and draw down to item should work as well }
public EditLevelingSettingsWindow() : base(400, 370) { AlwaysOnTopOfMain = true; 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 * GuiWidget.DeviceScale; // put in the movement edit controls PrintLevelingData levelingData = ActiveSliceSettings.Instance.Helpers.GetPrintLevelingData(); for (int i = 0; i < levelingData.SampledPositions.Count; i++) { positions.Add(levelingData.SampledPositions[i]); } 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++) { leftRightEdit.AddChild(new HorizontalSpacer()); 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; MHNumberEdit valueEdit = new MHNumberEdit(positions[linkCompatibleRow][linkCompatibleAxis], allowNegatives: true, allowDecimals: true, 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 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.FitToChildren; 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.Name = "Add new printer button"; addPrinterButton.ToolTipText = "Add a new Printer Profile".Localize(); 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); } ScrollableWidget printerListScrollArea = new ScrollableWidget(true); printerListScrollArea.ScrollArea.HAnchor |= Agg.UI.HAnchor.ParentLeftRight; printerListScrollArea.AnchorAll(); printerListScrollArea.AddChild(printerListContainer); FlowLayoutWidget printerListScrollContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); printerListScrollContainer.HAnchor = HAnchor.ParentLeftRight; printerListScrollContainer.VAnchor = VAnchor.ParentBottomTop; printerListScrollContainer.Padding = new BorderDouble(3); printerListScrollContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; mainContainer.AddChild(headerRow); mainContainer.AddChild(editButtonRow); mainContainer.AddChild(printerListScrollContainer); printerListScrollContainer.AddChild(printerListScrollArea); mainContainer.AddChild(buttonContainer); this.AddChild(mainContainer); BindCloseButtonClick(); } }
public TemperatureWidgetBase(PrinterConfig printer, string textValue, ThemeConfig theme) { this.printer = printer; this.AlignToRightEdge = true; this.DrawArrow = true; this.HAnchor = HAnchor.Fit; this.VAnchor = VAnchor.Fit | VAnchor.Center; this.Cursor = Cursors.Hand; this.MakeScrollable = false; this.AlignToRightEdge = true; ImageWidget = new ImageWidget(AggContext.StaticData.LoadIcon("hotend.png", theme.InvertIcons)) { VAnchor = VAnchor.Center, Margin = new BorderDouble(right: 5) }; alwaysEnabled = new List <GuiWidget>(); var container = new FlowLayoutWidget() { HAnchor = HAnchor.Fit, VAnchor = VAnchor.Fit, Padding = new BorderDouble(10, 5, 0, 5) }; this.AddChild(container); container.AddChild(this.ImageWidget); CurrentTempIndicator = new TextWidget(textValue, pointSize: 11) { TextColor = theme.Colors.PrimaryTextColor, VAnchor = VAnchor.Center, AutoExpandBoundsToText = true }; container.AddChild(CurrentTempIndicator); container.AddChild(new TextWidget("/") { TextColor = theme.Colors.PrimaryTextColor }); goalTempIndicator = new TextWidget(textValue, pointSize: 11) { TextColor = theme.Colors.PrimaryTextColor, VAnchor = VAnchor.Center, AutoExpandBoundsToText = true }; container.AddChild(goalTempIndicator); DirectionIndicator = new TextWidget(textValue, pointSize: 11) { TextColor = theme.Colors.PrimaryTextColor, VAnchor = VAnchor.Center, AutoExpandBoundsToText = true, Margin = new BorderDouble(left: 5) }; container.AddChild(DirectionIndicator); bool isEnabled = printer.Connection.IsConnected; printer.Connection.CommunicationStateChanged.RegisterEvent((s, e) => { if (isEnabled != printer.Connection.IsConnected) { isEnabled = printer.Connection.IsConnected; var flowLayout = this.PopupContent.Children.OfType <FlowLayoutWidget>().FirstOrDefault(); if (flowLayout != null) { foreach (var child in flowLayout.Children.Except(alwaysEnabled)) { child.Enabled = isEnabled; } } } }, ref unregisterEvents); }
private void AddAdjustmentControls(FlowLayoutWidget controlsTopToBottomLayout) { GroupBox adjustmentControlsGroupBox = new GroupBox(LocalizedString.Get("Tuning Adjustment (while printing)")); adjustmentControlsGroupBox.Margin = new BorderDouble(0); adjustmentControlsGroupBox.TextColor = ActiveTheme.Instance.PrimaryTextColor; adjustmentControlsGroupBox.BorderColor = ActiveTheme.Instance.PrimaryTextColor; adjustmentControlsGroupBox.HAnchor = Agg.UI.HAnchor.ParentLeftRight; adjustmentControlsGroupBox.Height = 90; { FlowLayoutWidget tuningRatiosLayout = new FlowLayoutWidget(FlowDirection.TopToBottom); tuningRatiosLayout.Margin = new BorderDouble(0, 0, 0, 6); tuningRatiosLayout.AnchorAll(); tuningRatiosLayout.Padding = new BorderDouble(3, 0, 3, 0); TextWidget feedRateDescription; { FlowLayoutWidget feedRateLeftToRight; { feedRateValue = new NumberEdit(1, allowDecimals: true, minValue: minFeedRateRatio, maxValue: maxFeedRateRatio, pixelWidth: 40); feedRateLeftToRight = new FlowLayoutWidget(); feedRateDescription = new TextWidget(LocalizedString.Get("Speed Multiplier")); feedRateDescription.TextColor = ActiveTheme.Instance.PrimaryTextColor; feedRateDescription.VAnchor = VAnchor.ParentCenter; feedRateLeftToRight.AddChild(feedRateDescription); feedRateRatioSlider = new Slider(new Vector2(), 300, minFeedRateRatio, maxFeedRateRatio); feedRateRatioSlider.Margin = new BorderDouble(5, 0); feedRateRatioSlider.Value = PrinterCommunication.Instance.FeedRateRatio; feedRateRatioSlider.View.BackgroundColor = new RGBA_Bytes(); feedRateRatioSlider.ValueChanged += (sender, e) => { PrinterCommunication.Instance.FeedRateRatio = feedRateRatioSlider.Value; }; PrinterCommunication.Instance.FeedRateRatioChanged.RegisterEvent(FeedRateRatioChanged_Event, ref unregisterEvents); feedRateValue.EditComplete += (sender, e) => { feedRateRatioSlider.Value = feedRateValue.Value; }; feedRateLeftToRight.AddChild(feedRateRatioSlider); tuningRatiosLayout.AddChild(feedRateLeftToRight); feedRateLeftToRight.AddChild(feedRateValue); feedRateValue.Margin = new BorderDouble(0, 0, 5, 0); feedRateValue.VAnchor = VAnchor.ParentCenter; textImageButtonFactory.FixedHeight = (int)feedRateValue.Height + 1; Button setFeedRateButton = textImageButtonFactory.Generate(LocalizedString.Get("Set")); setFeedRateButton.VAnchor = VAnchor.ParentCenter; feedRateLeftToRight.AddChild(setFeedRateButton); } TextWidget extrusionDescription; { extrusionValue = new NumberEdit(1, allowDecimals: true, minValue: minExtrutionRatio, maxValue: maxExtrusionRatio, pixelWidth: 40); FlowLayoutWidget leftToRight = new FlowLayoutWidget(); leftToRight.Margin = new BorderDouble(top: 10); extrusionDescription = new TextWidget(LocalizedString.Get("Extrusion Multiplier")); extrusionDescription.TextColor = ActiveTheme.Instance.PrimaryTextColor; extrusionDescription.VAnchor = VAnchor.ParentCenter; leftToRight.AddChild(extrusionDescription); extrusionRatioSlider = new Slider(new Vector2(), 300, minExtrutionRatio, maxExtrusionRatio); extrusionRatioSlider.Margin = new BorderDouble(5, 0); extrusionRatioSlider.Value = PrinterCommunication.Instance.ExtrusionRatio; extrusionRatioSlider.View.BackgroundColor = new RGBA_Bytes(); extrusionRatioSlider.ValueChanged += (sender, e) => { PrinterCommunication.Instance.ExtrusionRatio = extrusionRatioSlider.Value; }; PrinterCommunication.Instance.ExtrusionRatioChanged.RegisterEvent(ExtrusionRatioChanged_Event, ref unregisterEvents); extrusionValue.EditComplete += (sender, e) => { extrusionRatioSlider.Value = extrusionValue.Value; }; leftToRight.AddChild(extrusionRatioSlider); tuningRatiosLayout.AddChild(leftToRight); leftToRight.AddChild(extrusionValue); extrusionValue.Margin = new BorderDouble(0, 0, 5, 0); extrusionValue.VAnchor = VAnchor.ParentCenter; textImageButtonFactory.FixedHeight = (int)extrusionValue.Height + 1; Button setExtrusionButton = textImageButtonFactory.Generate(LocalizedString.Get("Set")); setExtrusionButton.VAnchor = VAnchor.ParentCenter; leftToRight.AddChild(setExtrusionButton); } feedRateDescription.Width = extrusionDescription.Width; feedRateDescription.MinimumSize = new Vector2(extrusionDescription.Width, feedRateDescription.MinimumSize.y); feedRateLeftToRight.HAnchor = HAnchor.FitToChildren; feedRateLeftToRight.VAnchor = VAnchor.FitToChildren; } adjustmentControlsGroupBox.AddChild(tuningRatiosLayout); } tuningAdjustmentControlsContainer = new DisableableWidget(); tuningAdjustmentControlsContainer.AddChild(adjustmentControlsGroupBox); controlsTopToBottomLayout.AddChild(tuningAdjustmentControlsContainer); }
static Control ComputedQuestionWidget(Racr.AstNode n) { Widget w; if (n.Type() == ValueTypes.Boolean) w = new CheckWidget(n.GetLabel(), false); else w = new TextWidget(n.GetLabel(), false); n.Parent().Widget().Controls.Add(w); return w; }
public static GuiWidget PrintProgressWidget(PrinterConfig printer, ThemeConfig theme) { var bodyRow = new GuiWidget() { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Top | VAnchor.Fit, // BackgroundColor = new Color(theme.Colors.PrimaryBackgroundColor, 128), MinimumSize = new Vector2(275, 140), }; // Progress section var expandingContainer = new HorizontalSpacer() { VAnchor = VAnchor.Fit | VAnchor.Center }; bodyRow.AddChild(expandingContainer); var progressContainer = new FlowLayoutWidget(FlowDirection.TopToBottom) { VAnchor = VAnchor.Center | VAnchor.Fit, HAnchor = HAnchor.Stretch, }; expandingContainer.AddChild(progressContainer); var progressDial = new ProgressDial(theme) { HAnchor = HAnchor.Center, Height = 200 * DeviceScale, Width = 200 * DeviceScale }; progressContainer.AddChild(progressDial); var bottomRow = new GuiWidget() { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit }; progressContainer.AddChild(bottomRow); var resliceMessageRow = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, Visible = false }; progressContainer.AddChild(resliceMessageRow); var timeContainer = new FlowLayoutWidget() { HAnchor = HAnchor.Center | HAnchor.Fit, Margin = 3 }; bottomRow.AddChild(timeContainer); // we can only reslice on 64 bit, because in 64 bit we always have the gcode loaded if (IntPtr.Size == 8) { var resliceButton = new TextButton("Re-Slice", theme) { HAnchor = HAnchor.Right, VAnchor = VAnchor.Center, Margin = new BorderDouble(0, 0, 7, 0), Name = "Re-Slice Button" }; bool activelySlicing = false; resliceButton.Click += (s, e) => { resliceButton.Enabled = false; UiThread.RunOnIdle(async() => { bool doSlicing = !activelySlicing && printer.Bed.EditContext.SourceItem != null; if (doSlicing) { var errors = printer.ValidateSettings(); if (errors.Any(err => err.ErrorLevel == ValidationErrorLevel.Error)) { doSlicing = false; ApplicationController.Instance.ShowValidationErrors("Slicing Error".Localize(), errors); } } if (doSlicing) { activelySlicing = true; if (bottomRow.Name == null) { bottomRow.Name = printer.Bed.EditContext.GCodeFilePath(printer); } await ApplicationController.Instance.Tasks.Execute("Saving".Localize(), printer, printer.Bed.SaveChanges); // start up a new slice on a background thread await ApplicationController.Instance.SliceItemLoadOutput( printer, printer.Bed.Scene, printer.Bed.EditContext.GCodeFilePath(printer)); // Switch to the 3D layer view if on Model view if (printer.ViewState.ViewMode == PartViewMode.Model) { printer.ViewState.ViewMode = PartViewMode.Layers3D; } resliceMessageRow.Visible = true; resliceMessageRow.VAnchor = VAnchor.Absolute; resliceMessageRow.VAnchor = VAnchor.Fit; } else { resliceButton.Enabled = true; } }); }; bottomRow.AddChild(resliceButton); // setup the message row { // when it is done queue it to the change to gcode stream var switchMessage = "Switch to new G-Code?\n\nBefore you switch, check that your are seeing the changes you expect.".Localize(); resliceMessageRow.AddChild(new WrappedTextWidget(switchMessage, theme.DefaultFontSize, textColor: theme.TextColor) { Margin = new BorderDouble(7, 3) }); var switchButtonRow = new FlowLayoutWidget(FlowDirection.RightToLeft) { HAnchor = HAnchor.Stretch }; resliceMessageRow.AddChild(switchButtonRow); var switchButton = new TextButton("Switch", theme) { VAnchor = VAnchor.Center, Margin = new BorderDouble(5), Name = "Switch Button" }; switchButtonRow.AddChild(switchButton); switchButton.Click += (s, e) => { if (printer.Connection != null && (printer.Connection.Printing || printer.Connection.Paused)) { printer.Connection.SwitchToGCode(printer.Bed.EditContext.GCodeFilePath(printer)); bottomRow.Name = printer.Bed.EditContext.GCodeFilePath(printer); } activelySlicing = false; resliceButton.Enabled = true; resliceMessageRow.Visible = false; }; var cancelButton = new TextButton("Cancel", theme) { VAnchor = VAnchor.Center, Margin = new BorderDouble(5), Name = "Cancel Re-Slice Button" }; switchButtonRow.AddChild(cancelButton); cancelButton.Click += async(s, e) => { await ApplicationController.Instance.SliceItemLoadOutput( printer, printer.Bed.Scene, bottomRow.Name); activelySlicing = false; resliceButton.Enabled = true; resliceMessageRow.Visible = false; }; } } timeContainer.AddChild(new ImageWidget(AggContext.StaticData.LoadIcon("fa-clock_24.png", theme.InvertIcons)) { VAnchor = VAnchor.Center }); var timeStack = new FlowLayoutWidget(FlowDirection.TopToBottom) { Margin = new BorderDouble(10, 0, 0, 0), Padding = new BorderDouble(5, 0, 0, 0), VAnchor = VAnchor.Center | VAnchor.Fit }; timeContainer.AddChild(timeStack); var timePrinted = new TextWidget("", pointSize: 16, textColor: theme.TextColor) { AutoExpandBoundsToText = true, HAnchor = HAnchor.Center, }; timeStack.AddChild(timePrinted); var timeToEnd = new TextWidget("", pointSize: 9, textColor: theme.TextColor) { AutoExpandBoundsToText = true, HAnchor = HAnchor.Center, }; timeStack.AddChild(timeToEnd); var runningInterval = UiThread.SetInterval(() => { int totalSecondsPrinted = printer.Connection.SecondsPrinted; int hoursPrinted = totalSecondsPrinted / (60 * 60); int minutesPrinted = totalSecondsPrinted / 60 - hoursPrinted * 60; var secondsPrinted = totalSecondsPrinted % 60; // TODO: Consider if the consistency of a common time format would look and feel better than changing formats based on elapsed duration timePrinted.Text = GetFormatedTime(hoursPrinted, minutesPrinted, secondsPrinted); int totalSecondsToEnd = printer.Connection.SecondsToEnd; int hoursToEnd = totalSecondsToEnd / (60 * 60); int minutesToEnd = totalSecondsToEnd / 60 - hoursToEnd * 60; var secondsToEnd = totalSecondsToEnd % 60; timeToEnd.Text = GetFormatedTime(hoursToEnd, minutesToEnd, secondsToEnd); progressDial.LayerIndex = printer.Connection.CurrentlyPrintingLayer; progressDial.LayerCompletedRatio = printer.Connection.RatioIntoCurrentLayerSeconds; progressDial.CompletedRatio = printer.Connection.PercentComplete / 100; switch (printer.Connection.CommunicationState) { case CommunicationStates.PreparingToPrint: case CommunicationStates.Printing: case CommunicationStates.Paused: bodyRow.Visible = true; break; default: bodyRow.Visible = false; break; } }, 1); bodyRow.Closed += (s, e) => UiThread.ClearInterval(runningInterval); bodyRow.Visible = false; return(bodyRow); }
private void CreateAboutMenuContent(Element menu) { TextWidget text = new TextWidget(); text.Font = Fonts.Instance.TanksAltFont; text.Location = new Vector(BattleGame.ResolutionX / 2, 350); text.Size = new Vector(600, 280); { var gameInfo = "Simple Tanks game (based on Vortex2D.NET).\n"; var courseInfo = "Course - The Perspective Software\n"; var lecturerInfo = "Lecturer - Druzhinin U.V.\n"; var studentsInfo = "Students - Zhdanov A.V., Shaihutdinov R.G.\n"; text.Text = gameInfo + courseInfo + lecturerInfo + studentsInfo; text.Enabled = false; } menu.AddChild(text); }
public void ConstructPrintQueueItem() { linkButtonFactory.fontSize = 10; linkButtonFactory.textColor = RGBA_Bytes.Black; WidgetTextColor = RGBA_Bytes.Black; WidgetBackgroundColor = RGBA_Bytes.White; TextInfo textInfo = new CultureInfo("en-US", false).TextInfo; SetDisplayAttributes(); FlowLayoutWidget topToBottomLayout = new FlowLayoutWidget(FlowDirection.TopToBottom); topToBottomLayout.HAnchor |= Agg.UI.HAnchor.ParentLeftRight; FlowLayoutWidget topContentsFlowLayout = new FlowLayoutWidget(FlowDirection.LeftToRight); topContentsFlowLayout.HAnchor |= Agg.UI.HAnchor.ParentLeftRight; { FlowLayoutWidget leftColumn = new FlowLayoutWidget(FlowDirection.TopToBottom); leftColumn.VAnchor = VAnchor.ParentTop | Agg.UI.VAnchor.FitToChildren; { PartThumbnailWidget thumbnailWidget = new PartThumbnailWidget(PrintItemWrapper, "part_icon_transparent_40x40.png", "building_thumbnail_40x40.png", new Vector2(50, 50)); leftColumn.AddChild(thumbnailWidget); } FlowLayoutWidget middleColumn = new FlowLayoutWidget(FlowDirection.TopToBottom); middleColumn.VAnchor = VAnchor.ParentTop | Agg.UI.VAnchor.FitToChildren; middleColumn.HAnchor = HAnchor.ParentLeftRight;// | Agg.UI.HAnchor.FitToChildren; middleColumn.Padding = new BorderDouble(8); middleColumn.Margin = new BorderDouble(10, 0); { string labelName = textInfo.ToTitleCase(PrintItemWrapper.Name); labelName = labelName.Replace('_', ' '); partLabel = new TextWidget(labelName, pointSize: 14); partLabel.TextColor = WidgetTextColor; partLabel.MinimumSize = new Vector2(1, 16); string partStatusLblTxt = new LocalizedString("Status").Translated; string partStatusLblTxtTest = new LocalizedString("Queued to Print").Translated; string partStatusLblTxtFull = string.Format("{0}: {1}", partStatusLblTxt, partStatusLblTxtTest); partStatus = new TextWidget(partStatusLblTxtFull, pointSize: 10); partStatus.AutoExpandBoundsToText = true; partStatus.TextColor = WidgetTextColor; partStatus.MinimumSize = new Vector2(50, 12); middleColumn.AddChild(partLabel); middleColumn.AddChild(partStatus); } CreateEditControls(); topContentsFlowLayout.AddChild(leftColumn); topContentsFlowLayout.AddChild(middleColumn); topContentsFlowLayout.AddChild(editControls); editControls.Visible = false; } topToBottomLayout.AddChild(topContentsFlowLayout); this.AddChild(topToBottomLayout); AddHandlers(); }
private void SetupMenuItem(TextWidget tw) { tw.Font = Fonts.Instance.TankBigFont; tw.TextPallete = MenuTextPallete; tw.Size = MenuItemSize; tw.CursorType = Vortex.Input.CursorType.Pointer; }
public void BackBuffersAreScreenAligned() { // make sure draw string and a text widget produce the same result when drawn to the same spot { ImageBuffer drawStringImage = new ImageBuffer(100, 20, 24, new BlenderBGR()); { Graphics2D drawStringGraphics = drawStringImage.NewGraphics2D(); drawStringGraphics.Clear(RGBA_Bytes.White); drawStringGraphics.DrawString("test", 0, 0); SaveImage(drawStringImage, "z draw string.tga"); } ImageBuffer textWidgetImage = new ImageBuffer(100, 20, 24, new BlenderBGR()); { TextWidget textWidget = new TextWidget("test"); Graphics2D textWidgetGraphics = textWidgetImage.NewGraphics2D(); textWidgetGraphics.Clear(RGBA_Bytes.White); textWidget.OnDraw(textWidgetGraphics); } Assert.IsTrue(drawStringImage == textWidgetImage); } // make sure that a back buffer is always trying to draw 1:1 pixels to the buffer above { ImageBuffer drawStringOffsetImage = new ImageBuffer(100, 20, 32, new BlenderBGRA()); { Graphics2D drawStringGraphics = drawStringOffsetImage.NewGraphics2D(); drawStringGraphics.Clear(RGBA_Bytes.White); drawStringGraphics.DrawString("test", 23.3, 0); SaveImage(drawStringOffsetImage, "z draw offset string.tga"); } GuiWidget container = new GuiWidget(100, 20); container.DoubleBuffer = true; { TextWidget textWidget = new TextWidget("test", 23.3); container.AddChild(textWidget); container.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White); container.OnDraw(container.BackBuffer.NewGraphics2D()); SaveImage(container.BackBuffer, "z offset text widget.tga"); } Vector2 bestPosition; double bestLeastSquares; double maxError = 10; container.BackBuffer.FindLeastSquaresMatch(drawStringOffsetImage, out bestPosition, out bestLeastSquares, maxError); Assert.IsTrue(bestLeastSquares < maxError); } { ImageBuffer drawStringOffsetImage = new ImageBuffer(100, 20, 32, new BlenderBGRA()); { Graphics2D drawStringGraphics = drawStringOffsetImage.NewGraphics2D(); drawStringGraphics.Clear(RGBA_Bytes.White); drawStringGraphics.DrawString("test", 23.8, 0); SaveImage(drawStringOffsetImage, "z draw offset string.tga"); } GuiWidget container1 = new GuiWidget(100, 20); container1.DoubleBuffer = true; GuiWidget container2 = new GuiWidget(90, 20); container2.OriginRelativeParent = new Vector2(.5, 0); container1.AddChild(container2); { TextWidget textWidget = new TextWidget("test", 23.3); container2.AddChild(textWidget); container1.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White); container1.OnDraw(container1.BackBuffer.NewGraphics2D()); SaveImage(container1.BackBuffer, "z offset text widget.tga"); } Assert.IsTrue(container1.BackBuffer.FindLeastSquaresMatch(drawStringOffsetImage, 5)); } }
private FlowLayoutWidget GetAutoLevelControl() { FlowLayoutWidget buttonRow = new FlowLayoutWidget(); buttonRow.Name = "AutoLevelRowItem"; buttonRow.HAnchor = HAnchor.ParentLeftRight; buttonRow.Margin = new BorderDouble(0, 4); ImageBuffer levelingImage = StaticData.Instance.LoadIcon("leveling_32x32.png", 24, 24).InvertLightness(); if (!ActiveTheme.Instance.IsDarkTheme) { levelingImage.InvertLightness(); } ImageWidget levelingIcon = new ImageWidget(levelingImage); levelingIcon.Margin = new BorderDouble(right: 6); buttonRow.AddChild(levelingIcon); // label printLevelingStatusLabel = new TextWidget("") { AutoExpandBoundsToText = true, TextColor = ActiveTheme.Instance.PrimaryTextColor, VAnchor = VAnchor.ParentCenter, Text = "Software Print Leveling".Localize() }; buttonRow.AddChild(printLevelingStatusLabel); // edit button Button editButton = TextImageButtonFactory.GetThemedEditButton(); editButton.Margin = new BorderDouble(2, 2, 2, 0); editButton.VAnchor = Agg.UI.VAnchor.ParentTop; editButton.VAnchor = VAnchor.ParentCenter; editButton.Click += (sender, e) => { UiThread.RunOnIdle(() => { if (editLevelingSettingsWindow == null) { editLevelingSettingsWindow = new EditLevelingSettingsWindow(); editLevelingSettingsWindow.Closed += (sender2, e2) => { editLevelingSettingsWindow = null; }; } else { editLevelingSettingsWindow.BringToFront(); } }); }; buttonRow.AddChild(editButton); buttonRow.AddChild(new HorizontalSpacer()); // configure button runPrintLevelingButton = textImageButtonFactory.Generate("Configure".Localize().ToUpper()); runPrintLevelingButton.Margin = new BorderDouble(left: 6); runPrintLevelingButton.VAnchor = VAnchor.ParentCenter; runPrintLevelingButton.Click += (sender, e) => { UiThread.RunOnIdle(() => LevelWizardBase.ShowPrintLevelWizard(LevelWizardBase.RuningState.UserRequestedCalibration)); }; buttonRow.AddChild(runPrintLevelingButton); // put in the switch CheckBox printLevelingSwitch = ImageButtonFactory.CreateToggleSwitch(ActiveSliceSettings.Instance.GetValue <bool>(SettingsKey.print_leveling_enabled)); printLevelingSwitch.VAnchor = VAnchor.ParentCenter; printLevelingSwitch.Margin = new BorderDouble(left: 16); printLevelingSwitch.CheckedStateChanged += (sender, e) => { ActiveSliceSettings.Instance.Helpers.DoPrintLeveling(printLevelingSwitch.Checked); }; PrinterSettings.PrintLevelingEnabledChanged.RegisterEvent((sender, e) => { printLevelingSwitch.Checked = ActiveSliceSettings.Instance.GetValue <bool>(SettingsKey.print_leveling_enabled); }, ref unregisterEvents); // only show the switch if leveling can be turned off (it can't if it is required). if (!ActiveSliceSettings.Instance.GetValue <bool>(SettingsKey.print_leveling_required_to_print)) { buttonRow.AddChild(printLevelingSwitch); } return(buttonRow); }
public InlineEditControl(string defaultSizeString = "-0000.00") { theme = AppContext.Theme; base.Visible = false; double pointSize = 10; this.Padding = new BorderDouble(3); numberDisplay = new TextWidget(defaultSizeString, 0, 0, pointSize, justification: Agg.Font.Justification.Center, textColor: theme.TextColor) { Visible = false, VAnchor = VAnchor.Bottom, HAnchor = HAnchor.Left, Text = "0", AutoExpandBoundsToText = true, }; this.BeforeDraw += (s, e) => { if (s is GuiWidget widget) { var test = true; if (test) { // return; } var bounds = widget.LocalBounds; e.Graphics2D.Render(new RoundedRect(bounds, 3 * GuiWidget.DeviceScale), theme.BackgroundColor.WithAlpha(200)); } }; AddChild(numberDisplay); numberEdit = new MHNumberEdit(0, theme, pixelWidth: numberDisplay.Width, allowNegatives: true, allowDecimals: true) { Visible = false, VAnchor = VAnchor.Bottom, HAnchor = HAnchor.Left, SelectAllOnFocus = true, }; numberEdit.ActuallNumberEdit.InternalNumberEdit.TextChanged += (s, e) => { numberDisplay.Text = GetDisplayString == null ? "None" : GetDisplayString.Invoke(Value); this.OnTextChanged(e); }; numberEdit.ActuallNumberEdit.InternalNumberEdit.MaxDecimalsPlaces = 2; numberEdit.ActuallNumberEdit.EditComplete += (s, e) => { EditComplete?.Invoke(this, e); timeSinceMouseUp.Restart(); numberEdit.Visible = false; numberDisplay.Visible = true; }; AddChild(numberEdit); VAnchor = VAnchor.Fit; HAnchor = HAnchor.Fit; runningInterval = UiThread.SetInterval(HideIfApplicable, .1); }
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("How can we improve?".Localize(), 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("Submitting your information...".Localize(), 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("Subject*".Localize())); questionInput = new MHTextEditWidget(subjectText); questionInput.HAnchor = HAnchor.ParentLeftRight; formContainer.AddChild(questionInput); questionErrorMessage = ErrorMessageGenerator(); formContainer.AddChild(questionErrorMessage); formContainer.AddChild(LabelGenerator("Message*".Localize())); detailInput = new MHTextEditWidget(bodyText, pixelHeight: 120, multiLine: true); detailInput.HAnchor = HAnchor.ParentLeftRight; formContainer.AddChild(detailInput); detailErrorMessage = ErrorMessageGenerator(); formContainer.AddChild(detailErrorMessage); formContainer.AddChild(LabelGenerator("Email Address*".Localize())); emailInput = new MHTextEditWidget(); emailInput.HAnchor = HAnchor.ParentLeftRight; formContainer.AddChild(emailInput); emailErrorMessage = ErrorMessageGenerator(); formContainer.AddChild(emailErrorMessage); formContainer.AddChild(LabelGenerator("Name*".Localize())); 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 void ScrollingToEndShowsEnd() { GuiWidget container = new GuiWidget(); container.DoubleBuffer = true; container.LocalBounds = new RectangleDouble(0, 0, 110, 30); TextEditWidget editField1 = new TextEditWidget("This is a nice long text string", 0, 0, pixelWidth: 100); container.AddChild(editField1); TextWidget firstWordText = new TextWidget("This"); RectangleDouble bounds = firstWordText.LocalBounds; bounds.Offset(bounds.Left, bounds.Bottom); firstWordText.LocalBounds = bounds; firstWordText.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White); firstWordText.OnDraw(firstWordText.BackBuffer.NewGraphics2D()); TextWidget lastWordText = new TextWidget("string"); bounds = lastWordText.LocalBounds; bounds.Offset(bounds.Left, bounds.Bottom); lastWordText.LocalBounds = bounds; lastWordText.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White); lastWordText.OnDraw(lastWordText.BackBuffer.NewGraphics2D()); container.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White); container.BackgroundColor = RGBA_Bytes.White; container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 1, 1, 0)); container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, 1, 1, 0)); Assert.IsTrue(editField1.ContainsFocus == true); container.OnDraw(container.BackBuffer.NewGraphics2D()); OutputImage(firstWordText.BackBuffer, "Control - Left.tga"); OutputImage(lastWordText.BackBuffer, "Control - Right.tga"); OutputImage(container.BackBuffer, "Test - Start.tga"); Vector2 bestPosition; double bestLeastSquares; container.BackBuffer.FindLeastSquaresMatch(firstWordText.BackBuffer, out bestPosition, out bestLeastSquares); Assert.IsTrue(bestLeastSquares < 2000000); container.BackBuffer.FindLeastSquaresMatch(lastWordText.BackBuffer, out bestPosition, out bestLeastSquares); Assert.IsTrue(bestLeastSquares > 2000000); SendKeyDown(Keys.End, container); container.OnDraw(container.BackBuffer.NewGraphics2D()); OutputImage(container.BackBuffer, "Test - Scrolled.tga"); container.BackBuffer.FindLeastSquaresMatch(firstWordText.BackBuffer, out bestPosition, out bestLeastSquares); Assert.IsTrue(bestLeastSquares > 2000000); container.BackBuffer.FindLeastSquaresMatch(lastWordText.BackBuffer, out bestPosition, out bestLeastSquares); Assert.IsTrue(bestLeastSquares < 2000000); container.Close(); }
public void AddElements() { Title = LocalizedString.Get("Design Add-ons"); 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 elementHeaderLabelBeg = LocalizedString.Get("Select a Design Tool"); string elementHeaderLabelFull = string.Format("{0}:", elementHeaderLabelBeg); string elementHeaderLabel = elementHeaderLabelFull; TextWidget elementHeader = new TextWidget(string.Format(elementHeaderLabel), pointSize: 14); elementHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor; elementHeader.HAnchor = HAnchor.ParentLeftRight; elementHeader.VAnchor = Agg.UI.VAnchor.ParentBottom; headerRow.AddChild(elementHeader); } topToBottom.AddChild(headerRow); GuiWidget presetsFormContainer = new GuiWidget(); { presetsFormContainer.HAnchor = HAnchor.ParentLeftRight; presetsFormContainer.VAnchor = VAnchor.ParentBottomTop; presetsFormContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; } FlowLayoutWidget pluginRowContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); pluginRowContainer.AnchorAll(); presetsFormContainer.AddChild(pluginRowContainer); unlockButtonFactory.Margin = new BorderDouble(10, 0); if (ActiveTheme.Instance.IsDarkTheme) { unlockButtonFactory.normalFillColor = new RGBA_Bytes(0, 0, 0, 100); unlockButtonFactory.normalBorderColor = new RGBA_Bytes(0, 0, 0, 100); unlockButtonFactory.hoverFillColor = new RGBA_Bytes(0, 0, 0, 50); unlockButtonFactory.hoverBorderColor = new RGBA_Bytes(0, 0, 0, 50); } else { unlockButtonFactory.normalFillColor = new RGBA_Bytes(0, 0, 0, 50); unlockButtonFactory.normalBorderColor = new RGBA_Bytes(0, 0, 0, 50); unlockButtonFactory.hoverFillColor = new RGBA_Bytes(0, 0, 0, 100); unlockButtonFactory.hoverBorderColor = new RGBA_Bytes(0, 0, 0, 100); } foreach (CreatorInformation creatorInfo in RegisteredCreators.Instance.Creators) { FlowLayoutWidget pluginListingContainer = new FlowLayoutWidget(); pluginListingContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; pluginListingContainer.BackgroundColor = RGBA_Bytes.White; pluginListingContainer.Padding = new BorderDouble(0); pluginListingContainer.Margin = new BorderDouble(6, 0, 6, 6); ClickWidget pluginRow = new ClickWidget(); pluginRow.Margin = new BorderDouble(6, 0, 6, 0); pluginRow.Height = 38; pluginRow.HAnchor = Agg.UI.HAnchor.ParentLeftRight; FlowLayoutWidget macroRow = new FlowLayoutWidget(); macroRow.AnchorAll(); macroRow.BackgroundColor = RGBA_Bytes.White; if (creatorInfo.iconPath != "") { ImageBuffer imageBuffer = LoadImage(creatorInfo.iconPath); ImageWidget imageWidget = new ImageWidget(imageBuffer); imageWidget.VAnchor = Agg.UI.VAnchor.ParentCenter; macroRow.AddChild(imageWidget); } bool userHasPermission; if (!creatorInfo.paidAddOnFlag) { userHasPermission = true; } else { userHasPermission = creatorInfo.permissionFunction(); } string addOnDescription; addOnDescription = creatorInfo.description; TextWidget buttonLabel = new TextWidget(addOnDescription, pointSize: 14); buttonLabel.Margin = new BorderDouble(left: 10); buttonLabel.VAnchor = Agg.UI.VAnchor.ParentCenter; macroRow.AddChild(buttonLabel); if (!userHasPermission) { TextWidget demoLabel = new TextWidget("(demo)", pointSize: 10); demoLabel.Margin = new BorderDouble(left: 4); demoLabel.VAnchor = Agg.UI.VAnchor.ParentCenter; macroRow.AddChild(demoLabel); } FlowLayoutWidget hSpacer = new FlowLayoutWidget(); hSpacer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; macroRow.AddChild(hSpacer); CreatorInformation callCorrectFunctionHold = creatorInfo; pluginRow.Click += (sender, e) => { if (RegisteredCreators.Instance.Creators.Count > 0) { UiThread.RunOnIdle(CloseOnIdle, callCorrectFunctionHold); } else { UiThread.RunOnIdle(CloseOnIdle); } }; pluginRow.Cursor = Cursors.Hand; macroRow.Selectable = false; pluginRow.AddChild(macroRow); pluginListingContainer.AddChild(pluginRow); if (!userHasPermission) { Button unlockButton = unlockButtonFactory.Generate("Unlock"); unlockButton.Margin = new BorderDouble(0); unlockButton.Cursor = Cursors.Hand; unlockButton.Click += (sender, e) => { callCorrectFunctionHold.unlockFunction(); }; pluginListingContainer.AddChild(unlockButton); } pluginRowContainer.AddChild(pluginListingContainer); if (callCorrectFunctionHold.unlockRegisterFunction != null) { callCorrectFunctionHold.unlockRegisterFunction(TriggerReload, ref unregisterEvents); } } topToBottom.AddChild(presetsFormContainer); BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; Button cancelPresetsButton = textImageButtonFactory.Generate(LocalizedString.Get("Cancel")); cancelPresetsButton.Click += (sender, e) => { UiThread.RunOnIdle(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(hButtonSpacer); buttonRow.AddChild(cancelPresetsButton); topToBottom.AddChild(buttonRow); AddChild(topToBottom); }
private void CreateInstructionsMenu(Element menu) { TextWidget text = new TextWidget(); text.Font = Fonts.Instance.TanksAltFont; text.Location = new Vector(BattleGame.ResolutionX / 2, 350); text.Size = new Vector(300, 280); text.Text = "Arrow keys - movement,\nSpace - fire,\nP - pause,\nEscape - main menu"; text.Enabled = false; menu.AddChild(text); }
public void doLayout() { this.RemoveAllChildren(); TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory(); FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); topToBottom.Padding = new BorderDouble(10); topToBottom.AnchorAll(); string fileExportLabelTxt = new LocalizedString("File export options").Translated; TextWidget exportLabel = new TextWidget(string.Format("{0}:", fileExportLabelTxt)); exportLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor; topToBottom.AddChild(exportLabel); GuiWidget dividerLine = new GuiWidget(); dividerLine.HAnchor = Agg.UI.HAnchor.ParentLeftRight; dividerLine.Height = 1; dividerLine.Margin = new BorderDouble(0, 3); dividerLine.BackgroundColor = RGBA_Bytes.White; topToBottom.AddChild(dividerLine); if (!partIsGCode) { string exportSTLTxt = new LocalizedString("Export as").Translated; string exportSTLTxtFull = string.Format("{0} STL", exportSTLTxt); Button exportAsSTLButton = textImageButtonFactory.Generate(exportSTLTxtFull); exportAsSTLButton.Click += new ButtonBase.ButtonEventHandler(exportSTL_Click); //exportSTL.HAnchor = Agg.UI.HAnchor.ParentCenter; topToBottom.AddChild(exportAsSTLButton); } bool showExportGCodeButton = ActivePrinterProfile.Instance.ActivePrinter != null || partIsGCode; if (showExportGCodeButton) { string exportGCodeText = new LocalizedString("Export as").Translated; string exportGCodeTextFull = string.Format("{0} GCode", exportGCodeText); Button exportGCode = textImageButtonFactory.Generate(exportGCodeTextFull); //exportGCode.HAnchor = Agg.UI.HAnchor.ParentCenter; exportGCode.Click += new ButtonBase.ButtonEventHandler(exportGCode_Click); topToBottom.AddChild(exportGCode); } GuiWidget vSpacer = new GuiWidget(); vSpacer.VAnchor = Agg.UI.VAnchor.ParentBottomTop; topToBottom.AddChild(vSpacer); if (!showExportGCodeButton) { string noGCodeMessageText = new LocalizedString("Note").Translated; string noGCodeMessageTextFull = new LocalizedString("To enable GCode export, select a printer profile").Translated; TextWidget noGCodeMessage = new TextWidget(string.Format("{0}: {1}.", noGCodeMessageText, noGCodeMessageTextFull), textColor: RGBA_Bytes.White, pointSize: 10); topToBottom.AddChild(noGCodeMessage); } // TODO: make this work on the mac and then delete this if if (MatterHackers.Agg.UI.WindowsFormsAbstract.GetOSType() == WindowsFormsAbstract.OSType.Windows) { showInFolderAfterSave = new CheckBox(new LocalizedString("Show file in folder after save").Translated, RGBA_Bytes.White, 10); showInFolderAfterSave.Margin = new BorderDouble(top: 10); topToBottom.AddChild(showInFolderAfterSave); } this.AddChild(topToBottom); }
public MainMenuScene() { Vector menuStartAt = new Vector(BattleGame.ResolutionX / 2, BattleGame.ResolutionY / 2 + 20); TextWidget menuItem = new TextWidget(); SetupMenuItem(menuItem); menuItem.Text = "Start Game"; menuItem.Location = menuStartAt; menuItem.OnClick += delegate(Element sender, MouseEventArgs args) { StartGame(); }; m_menu.AddChild(menuItem); menuStartAt.Y += MenuItemSize.Y; menuItem = new TextWidget(); SetupMenuItem(menuItem); menuItem.Text = "Instructions"; menuItem.Location = menuStartAt; menuItem.OnClick += delegate(Element sender, MouseEventArgs args) { GoToSubmenu(m_instructionsMenu); }; m_menu.AddChild(menuItem); menuStartAt.Y += MenuItemSize.Y; menuItem = new TextWidget(); SetupMenuItem(menuItem); menuItem.Text = "About"; menuItem.Location = menuStartAt; menuItem.OnClick += delegate(Element sender, MouseEventArgs args) { GoToSubmenu(m_aboutMenu); }; m_menu.AddChild(menuItem); menuStartAt.Y += MenuItemSize.Y; menuItem = new TextWidget(); SetupMenuItem(menuItem); menuItem.Text = "Exit"; menuItem.Location = menuStartAt; menuItem.OnClick += delegate(Element sender, MouseEventArgs args) { BattleGame.Terminate(); }; m_menu.AddChild(menuItem); menuItem = new TextWidget(); SetupMenuItem(menuItem); menuItem.Text = "Back To Menu"; menuItem.Location = new Vector(menuStartAt.X, 500); menuItem.OnClick += delegate(Element sender, MouseEventArgs args) { BackToMenu(m_instructionsMenu); }; m_instructionsMenu.AddChild(menuItem); menuItem = new TextWidget(); SetupMenuItem(menuItem); menuItem.Text = "Back To Menu"; menuItem.Location = new Vector(menuStartAt.X, 500); menuItem.OnClick += delegate(Element sender, MouseEventArgs args) { BackToMenu(m_aboutMenu); }; m_aboutMenu.AddChild(menuItem); m_aboutMenu.Location = new Vector(BattleGame.ResolutionX, 0); m_instructionsMenu.Location = new Vector(BattleGame.ResolutionX, 0); CreateAboutMenuContent(m_aboutMenu); CreateInstructionsMenu(m_instructionsMenu); AddChild(m_menu); AddChild(m_aboutMenu); AddChild(m_instructionsMenu); }
public override void OnEntry(GameTime gameTime) { SpriteFont f = game.Content.Load <SpriteFont>(uic.Font); wr = new WidgetRenderer(G, f); using (var s = File.OpenRead(uic.SoundHover)) { seHover = SoundEffect.FromStream(s); } // List Of Possible Button Actions Action <RectButton, Vector2>[] fBPs = { OnBPPlay, OnBPOptions, OnBPArmyPainter, OnBPLevelEditor, OnBPExit }; buttons = new RectButton[uic.Buttons.Length]; buttonsText = new TextWidget[buttons.Length]; tPanels = new Texture2D[buttons.Length + 2]; int bw = G.Viewport.Width; bw -= 5 * uic.ButtonSpacing.X; bw /= 4; int bh = G.Viewport.Height - uic.ButtonSpacing.Y * 3 - uic.TitlePanelTextSize; for (int i = 0; i < buttons.Length; i++) { var uicButton = uic.Buttons[i]; using (var s = File.OpenRead(uicButton.ImageFile)) { tPanels[i] = Texture2D.FromStream(G, s); } buttons[i] = new RectButton(wr, bw, bh, uicButton.ColorInactive, uicButton.ColorActive, tPanels[i]); buttons[i].Hook(); buttons[i].OnButtonPress += MenuScreen_OnButtonPress; buttons[i].OnButtonPress += fBPs[uicButton.ActionIndex]; buttons[i].OnMouseEntry += MenuScreen_OnMouseEntry; buttons[i].LayerDepth = 1f; buttons[i].OffsetAlignX = Alignment.RIGHT; buttons[i].Offset = new Point(uic.ButtonSpacing.X, 0); if (i % 3 != 0) { buttons[i].Parent = buttons[i - 1]; } buttonsText[i] = new TextWidget(wr); buttonsText[i].Font = f; buttonsText[i].OffsetAlignX = Alignment.MID; buttonsText[i].OffsetAlignY = Alignment.TOP; buttonsText[i].Offset = new Point(0, 30); buttonsText[i].AlignX = Alignment.MID; buttonsText[i].AlignY = Alignment.MID; buttonsText[i].Parent = buttons[i]; buttonsText[i].LayerDepth = 0.9f; buttonsText[i].Color = uicButton.ColorText; buttonsText[i].Height = uic.ButtonTextSize; buttonsText[i].Text = uicButton.Text; } using (var s = File.OpenRead(uic.ButtonImageUp)) { tPanels[buttons.Length] = Texture2D.FromStream(G, s); } btnUp = new RectButton(wr, bw, bh / 2, uic.ButtonUDInactiveColor, uic.ButtonUDActiveColor, tPanels[buttons.Length]); btnUp.Offset = new Point((bw + uic.ButtonSpacing.X) * 3, 0); btnUp.OnButtonPress += MenuScreen_OnButtonPress; btnUp.OnMouseEntry += MenuScreen_OnMouseEntry; btnUp.OnButtonPress += OnBPUp; btnUp.Hook(); using (var s = File.OpenRead(uic.ButtonImageDown)) { tPanels[buttons.Length + 1] = Texture2D.FromStream(G, s); } btnDown = new RectButton(wr, bw, bh / 2, uic.ButtonUDInactiveColor, uic.ButtonUDActiveColor, tPanels[buttons.Length + 1]); btnDown.OffsetAlignY = Alignment.BOTTOM; btnDown.Parent = btnUp; btnDown.OnButtonPress += MenuScreen_OnButtonPress; btnDown.OnMouseEntry += MenuScreen_OnMouseEntry; btnDown.OnButtonPress += OnBPDown; btnDown.Hook(); row = 0; ViewRow(row); txtMainMenu = new TextWidget(wr); txtMainMenu.Anchor = new Point(G.Viewport.Width / 2, uic.ButtonSpacing.Y); txtMainMenu.Height = uic.TitlePanelTextSize; txtMainMenu.AlignX = Alignment.MID; txtMainMenu.Color = uic.ColorTitleText; txtMainMenu.Text = uic.TitlePanelText; KeyboardEventDispatcher.OnKeyPressed += OnKeyPressed; }
public TemperatureWidgetBase(PrinterConfig printer, string textValue, ThemeConfig theme) : base(theme) { this.printer = printer; this.AlignToRightEdge = true; this.DrawArrow = true; this.HAnchor = HAnchor.Fit; this.VAnchor = VAnchor.Fit | VAnchor.Center; this.Cursor = Cursors.Hand; this.MakeScrollable = false; this.AlignToRightEdge = true; ImageWidget = new ImageWidget(StaticData.Instance.LoadIcon("hotend.png", 14, 14, theme.InvertIcons)) { VAnchor = VAnchor.Center, Margin = new BorderDouble(right: 5) }; alwaysEnabled = new List <GuiWidget>(); var container = new FlowLayoutWidget() { HAnchor = HAnchor.Fit, VAnchor = VAnchor.Fit, Padding = new BorderDouble(10, 5, 0, 5) }; this.AddChild(container); container.AddChild(this.ImageWidget); CurrentTempIndicator = new TextWidget(textValue, pointSize: 11) { TextColor = theme.TextColor, VAnchor = VAnchor.Center, AutoExpandBoundsToText = true }; container.AddChild(CurrentTempIndicator); container.AddChild(new TextWidget("/") { TextColor = theme.TextColor }); goalTempIndicator = new TextWidget(textValue, pointSize: 11) { TextColor = theme.TextColor, VAnchor = VAnchor.Center, AutoExpandBoundsToText = true }; container.AddChild(goalTempIndicator); DirectionIndicator = new TextWidget(textValue, pointSize: 11) { TextColor = theme.TextColor, VAnchor = VAnchor.Center, AutoExpandBoundsToText = true, Margin = new BorderDouble(left: 5) }; container.AddChild(DirectionIndicator); // Register listeners printer.Connection.CommunicationStateChanged += Connection_CommunicationStateChanged; foreach (var child in this.Children) { child.Selectable = false; } }
public void SetUpdateNotification(object sender, EventArgs widgetEvent) { switch (UpdateControlData.Instance.UpdateStatus) { case UpdateControlData.UpdateStatusStates.MayBeAvailable: { popUpAboutPage.RemoveAllChildren(); Button updateStatusMessage = linkButtonFactory.Generate("Check For Update".Localize()); updateStatusMessage.Click += (sender2, e) => { UiThread.RunOnIdle(CheckForUpdateWindow.Show); }; popUpAboutPage.AddChild(updateStatusMessage); popUpAboutPage.Visible = true; } break; case UpdateControlData.UpdateStatusStates.ReadyToInstall: case UpdateControlData.UpdateStatusStates.UpdateAvailable: case UpdateControlData.UpdateStatusStates.UpdateDownloading: { popUpAboutPage.RemoveAllChildren(); Button updateStatusMessage = linkButtonFactory.Generate("Update Available".Localize()); updateStatusMessage.Click += (sender2, e) => { UiThread.RunOnIdle(CheckForUpdateWindow.Show); }; var updateMark = new UpdateNotificationMark(); updateMark.Margin = new BorderDouble(0, 0, 3, 2); updateMark.VAnchor = VAnchor.ParentTop; popUpAboutPage.AddChild(updateMark); popUpAboutPage.AddChild(updateStatusMessage); popUpAboutPage.Visible = true; } break; case UpdateControlData.UpdateStatusStates.UpToDate: if (AlwaysShowUpdateStatus) { popUpAboutPage.RemoveAllChildren(); TextWidget updateStatusMessage = new TextWidget("Up to Date".Localize(), textColor: linkButtonFactory.textColor, pointSize: linkButtonFactory.fontSize); updateStatusMessage.VAnchor = VAnchor.ParentCenter; popUpAboutPage.AddChild(updateStatusMessage); popUpAboutPage.Visible = true; UiThread.RunOnIdle((state) => popUpAboutPage.Visible = false, 3); AlwaysShowUpdateStatus = false; } else { popUpAboutPage.Visible = false; } break; case UpdateControlData.UpdateStatusStates.CheckingForUpdate: if (AlwaysShowUpdateStatus) { popUpAboutPage.RemoveAllChildren(); TextWidget updateStatusMessage = new TextWidget("Checking For Update...".Localize(), textColor: linkButtonFactory.textColor, pointSize: linkButtonFactory.fontSize); updateStatusMessage.VAnchor = VAnchor.ParentCenter; popUpAboutPage.AddChild(updateStatusMessage); popUpAboutPage.Visible = true; } else { popUpAboutPage.Visible = false; } break; default: throw new NotImplementedException(); } }
private static void AddContents(GuiWidget widgetToAddItemsTo) { string[] listItems = new string[] { "Item1", "Item2", "Item3", "Item4" }; widgetToAddItemsTo.Padding = new BorderDouble(5); widgetToAddItemsTo.BackgroundColor = new RGBA_Bytes(68, 68, 68); //Get a list of printer records and add them to radio button list foreach (string listItem in listItems) { TextWidget textItem = new TextWidget(listItem); textItem.BackgroundColor = RGBA_Bytes.Blue; textItem.Margin = new BorderDouble(2); widgetToAddItemsTo.AddChild(textItem); } }
public PrintDialogFrame(int ID, GUIHost host, PrinterView printerview, SpoolerConnection spooler_connection, PopupMessageBox message_box, ModelLoadingManager modelloadingmanager, SettingsManager settings, PrintDialogMainWindow printDialogWindow) : base(ID, printDialogWindow) { this.modelloadingmanager = modelloadingmanager; this.message_box = message_box; this.spooler_connection = spooler_connection; this.printerview = printerview; settingsManager = settings; this.host = host; CenterHorizontallyInParent = true; CenterVerticallyInParent = true; SetSize(750, 550); var printdialog = Resources.printdialog; var xmlFrame = new XMLFrame(ID) { RelativeWidth = 1f, RelativeHeight = 1f }; AddChildElement(xmlFrame); xmlFrame.Init(host, printdialog, new ButtonCallback(MyButtonCallback)); mPrintQualityButtons = new Dictionary <PrintQuality, ButtonWidget> { { PrintQuality.Expert, (ButtonWidget)FindChildElement(111) }, { PrintQuality.VeryHighQuality, (ButtonWidget)FindChildElement(116) }, { PrintQuality.HighQuality, (ButtonWidget)FindChildElement(112) }, { PrintQuality.MediumQuality, (ButtonWidget)FindChildElement(113) }, { PrintQuality.FastPrint, (ButtonWidget)FindChildElement(114) }, { PrintQuality.VeryFastPrint, (ButtonWidget)FindChildElement(115) }, { PrintQuality.Custom, (ButtonWidget)FindChildElement(118) } }; mFillDensityButtons = new Dictionary <FillQuality, ButtonWidget> { { FillQuality.ExtraHigh, (ButtonWidget)FindChildElement(220) }, { FillQuality.High, (ButtonWidget)FindChildElement(221) }, { FillQuality.Medium, (ButtonWidget)FindChildElement(222) }, { FillQuality.Low, (ButtonWidget)FindChildElement(223) }, { FillQuality.HollowThickWalls, (ButtonWidget)FindChildElement(224) }, { FillQuality.HollowThinWalls, (ButtonWidget)FindChildElement(225) }, { FillQuality.Solid, (ButtonWidget)FindChildElement(227) }, { FillQuality.Custom, (ButtonWidget)FindChildElement(228) } }; print_button = (ButtonWidget)FindChildElement(401); quality_scroll_list = (HorizontalLayoutScrollList)FindChildElement(110); density_scroll_list = (HorizontalLayoutScrollList)FindChildElement(219); printQualityPrev_button = (ButtonWidget)FindChildElement(109); printQualityPrev_button.SetCallback(new ButtonCallback(MyButtonCallback)); printQualityNext_button = (ButtonWidget)FindChildElement(117); printQualityNext_button.SetCallback(new ButtonCallback(MyButtonCallback)); fillDensityPrev_button = (ButtonWidget)FindChildElement(218); fillDensityPrev_button.SetCallback(new ButtonCallback(MyButtonCallback)); fillDensityNext_button = (ButtonWidget)FindChildElement(226); fillDensityNext_button.SetCallback(new ButtonCallback(MyButtonCallback)); support_checkbutton = (ButtonWidget)FindChildElement(301); support_everywhere = (ButtonWidget)FindChildElement(303); support_printbedonly = (ButtonWidget)FindChildElement(313); UseWaveBonding = (ButtonWidget)FindChildElement(305); raft_checkbutton = (ButtonWidget)FindChildElement(307); verifybed_checkbutton = (ButtonWidget)FindChildElement(309); verifybed_text = (TextWidget)FindChildElement(310); printQuality_editbox = (EditBoxWidget)FindChildElement(108); fillDensity_editbox = (EditBoxWidget)FindChildElement(217); enableskirt_checkbutton = (ButtonWidget)FindChildElement(311); heatedBedButton_checkbox = (ButtonWidget)FindChildElement(315); heatedBedButton_text = (TextWidget)FindChildElement(316); untetheredButton_checkbox = (ButtonWidget)FindChildElement(317); sdOnlyButton_checkbox = (ButtonWidget)FindChildElement(319); sdOnlyButton_text = (TextWidget)FindChildElement(320); sdCheckboxesFrame = (XMLFrame)FindChildElement(321); mPrintQualityButtons[PrintQuality.Custom].Visible = false; mFillDensityButtons[FillQuality.Custom].Visible = false; LoadSettings(); }
public void EnsureCorrectSizeOnChildrenVisibleChange() { // just one column changes correctly { FlowLayoutWidget testColumn = new FlowLayoutWidget(FlowDirection.TopToBottom); testColumn.Name = "testColumn"; GuiWidget item1 = new GuiWidget(10, 10); item1.Name = "item1"; testColumn.AddChild(item1); Assert.IsTrue(testColumn.Height == 10); GuiWidget item2 = new GuiWidget(11, 11); item2.Name = "item2"; testColumn.AddChild(item2); Assert.IsTrue(testColumn.Height == 21); GuiWidget item3 = new GuiWidget(12, 12); item3.Name = "item3"; testColumn.AddChild(item3); Assert.IsTrue(testColumn.Height == 33); item2.Visible = false; Assert.IsTrue(testColumn.Height == 22); item2.Visible = true; Assert.IsTrue(testColumn.Height == 33); } // nested columns change correctly { GuiWidget.DefaultEnforceIntegerBounds = true; CheckBox hideCheckBox; FlowLayoutWidget leftColumn; FlowLayoutWidget topLeftStuff; GuiWidget everything = new GuiWidget(500, 500); GuiWidget firstItem; GuiWidget thingToHide; { FlowLayoutWidget twoColumns = new FlowLayoutWidget(); twoColumns.Name = "twoColumns"; twoColumns.VAnchor = UI.VAnchor.ParentTop; { leftColumn = new FlowLayoutWidget(FlowDirection.TopToBottom); leftColumn.Name = "leftColumn"; { topLeftStuff = new FlowLayoutWidget(FlowDirection.TopToBottom); topLeftStuff.Name = "topLeftStuff"; firstItem = new TextWidget("Top of Top Stuff"); topLeftStuff.AddChild(firstItem); 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"; 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); } everything.AddChild(twoColumns); Assert.IsTrue(firstItem.OriginRelativeParent.y == 54); //Assert.IsTrue(firstItem.OriginRelativeParent.y - topLeftStuff.LocalBounds.Bottom == 54); Assert.IsTrue(twoColumns.BoundsRelativeToParent.Top == 500); Assert.IsTrue(leftColumn.BoundsRelativeToParent.Top == 67); Assert.IsTrue(leftColumn.BoundsRelativeToParent.Bottom == 0); Assert.IsTrue(leftColumn.OriginRelativeParent.y == 0); Assert.IsTrue(topLeftStuff.BoundsRelativeToParent.Top == 67); Assert.IsTrue(topLeftStuff.Height == 67); Assert.IsTrue(leftColumn.Height == 67); hideCheckBox.Checked = true; Assert.IsTrue(firstItem.OriginRelativeParent.y == 21); Assert.IsTrue(leftColumn.OriginRelativeParent.y == 0); Assert.IsTrue(leftColumn.BoundsRelativeToParent.Bottom == 0); Assert.IsTrue(topLeftStuff.Height == 34); Assert.IsTrue(leftColumn.Height == 34); } GuiWidget.DefaultEnforceIntegerBounds = false; } }
private FlowLayoutWidget CreateEButtons(double buttonSeparationDistance) { int extruderCount = ActiveSliceSettings.Instance.ExtruderCount; FlowLayoutWidget eButtons = new FlowLayoutWidget(FlowDirection.TopToBottom); { FlowLayoutWidget eMinusButtonAndText = new FlowLayoutWidget(); BorderDouble extrusionMargin = new BorderDouble(4, 0, 4, 0); if (extruderCount == 1) { ExtrudeButton eMinusControl = moveButtonFactory.Generate("E-", MovementControls.EFeedRate(0), 0); eMinusControl.Margin = extrusionMargin; eMinusControl.ToolTipText = "Retract filament"; eMinusButtonAndText.AddChild(eMinusControl); eMinusButtons.Add(eMinusControl); } else { for (int i = 0; i < extruderCount; i++) { ExtrudeButton eMinusControl = moveButtonFactory.Generate(string.Format("E{0}-", i + 1), MovementControls.EFeedRate(0), i); eMinusControl.ToolTipText = "Retract filament"; eMinusControl.Margin = extrusionMargin; eMinusButtonAndText.AddChild(eMinusControl); eMinusButtons.Add(eMinusControl); } } TextWidget eMinusControlLabel = new TextWidget(LocalizedString.Get("Retract"), pointSize: 11); eMinusControlLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor; eMinusControlLabel.VAnchor = Agg.UI.VAnchor.ParentCenter; eMinusButtonAndText.AddChild(eMinusControlLabel); eButtons.AddChild(eMinusButtonAndText); eMinusButtonAndText.HAnchor = HAnchor.FitToChildren; eMinusButtonAndText.VAnchor = VAnchor.FitToChildren; FlowLayoutWidget buttonSpacerContainer = new FlowLayoutWidget(); for (int i = 0; i < extruderCount; i++) { GuiWidget eSpacer = new GuiWidget(2, buttonSeparationDistance); double buttonWidth = eMinusButtons[i].Width + 6; eSpacer.Margin = new BorderDouble((buttonWidth / 2), 0, ((buttonWidth) / 2), 0); eSpacer.BackgroundColor = XYZColors.eColor; buttonSpacerContainer.AddChild(eSpacer); } eButtons.AddChild(buttonSpacerContainer); buttonSpacerContainer.HAnchor = HAnchor.FitToChildren; buttonSpacerContainer.VAnchor = VAnchor.FitToChildren; FlowLayoutWidget ePlusButtonAndText = new FlowLayoutWidget(); if (extruderCount == 1) { ExtrudeButton ePlusControl = moveButtonFactory.Generate("E+", MovementControls.EFeedRate(0), 0); ePlusControl.Margin = extrusionMargin; ePlusControl.ToolTipText = "Extrude filament"; ePlusButtonAndText.AddChild(ePlusControl); ePlusButtons.Add(ePlusControl); } else { for (int i = 0; i < extruderCount; i++) { ExtrudeButton ePlusControl = moveButtonFactory.Generate(string.Format("E{0}+", i + 1), MovementControls.EFeedRate(0), i); ePlusControl.Margin = extrusionMargin; ePlusControl.ToolTipText = "Extrude filament"; ePlusButtonAndText.AddChild(ePlusControl); ePlusButtons.Add(ePlusControl); } } TextWidget ePlusControlLabel = new TextWidget(LocalizedString.Get("Extrude"), pointSize: 11); ePlusControlLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor; ePlusControlLabel.VAnchor = Agg.UI.VAnchor.ParentCenter; ePlusButtonAndText.AddChild(ePlusControlLabel); eButtons.AddChild(ePlusButtonAndText); ePlusButtonAndText.HAnchor = HAnchor.FitToChildren; ePlusButtonAndText.VAnchor = VAnchor.FitToChildren; } eButtons.AddChild(new GuiWidget(10, 6)); // add in some movement radio buttons FlowLayoutWidget setMoveDistanceControl = new FlowLayoutWidget(); TextWidget buttonsLabel = new TextWidget("Distance:", textColor: RGBA_Bytes.White); buttonsLabel.VAnchor = Agg.UI.VAnchor.ParentCenter; //setMoveDistanceControl.AddChild(buttonsLabel); { TextImageButtonFactory buttonFactory = new TextImageButtonFactory(); buttonFactory.FixedHeight = 20 * TextWidget.GlobalPointSizeScaleRatio; buttonFactory.FixedWidth = 30 * TextWidget.GlobalPointSizeScaleRatio; buttonFactory.fontSize = 8; buttonFactory.Margin = new BorderDouble(0); buttonFactory.checkedBorderColor = ActiveTheme.Instance.PrimaryTextColor; FlowLayoutWidget moveRadioButtons = new FlowLayoutWidget(); RadioButton oneButton = buttonFactory.GenerateRadioButton("1"); oneButton.VAnchor = Agg.UI.VAnchor.ParentCenter; oneButton.CheckedStateChanged += (sender, e) => { if (((RadioButton)sender).Checked) { SetEMoveAmount(1); } }; moveRadioButtons.AddChild(oneButton); RadioButton tenButton = buttonFactory.GenerateRadioButton("10"); tenButton.VAnchor = Agg.UI.VAnchor.ParentCenter; tenButton.CheckedStateChanged += (sender, e) => { if (((RadioButton)sender).Checked) { SetEMoveAmount(10); } }; moveRadioButtons.AddChild(tenButton); RadioButton oneHundredButton = buttonFactory.GenerateRadioButton("100"); oneHundredButton.VAnchor = Agg.UI.VAnchor.ParentCenter; oneHundredButton.CheckedStateChanged += (sender, e) => { if (((RadioButton)sender).Checked) { SetEMoveAmount(100); } }; moveRadioButtons.AddChild(oneHundredButton); tenButton.Checked = true; moveRadioButtons.Margin = new BorderDouble(0, 3); setMoveDistanceControl.AddChild(moveRadioButtons); } TextWidget mmLabel = new TextWidget("mm", textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 8); mmLabel.VAnchor = Agg.UI.VAnchor.ParentCenter; setMoveDistanceControl.AddChild(mmLabel); setMoveDistanceControl.HAnchor = Agg.UI.HAnchor.ParentLeft; eButtons.AddChild(setMoveDistanceControl); eButtons.HAnchor = HAnchor.FitToChildren; eButtons.VAnchor = VAnchor.FitToChildren | VAnchor.ParentBottom; return(eButtons); }