public PrinterListItemEdit(Printer printerRecord, ConnectionWindow windowController) : base(printerRecord, windowController) { linkButtonFactory.fontSize = 10; linkButtonFactory.padding = 0; linkButtonFactory.margin = new BorderDouble(3, 0); this.printerRecord = printerRecord; this.Margin = new BorderDouble(1); this.BackgroundColor = this.defaultBackgroundColor; this.Padding = new BorderDouble(5); this.HAnchor = HAnchor.ParentLeftRight; printerName = new TextWidget(this.printerRecord.Name); printerName.TextColor = this.defaultTextColor; printerName.HAnchor = HAnchor.ParentLeftRight; editLink = linkButtonFactory.Generate(new LocalizedString("edit").Translated); editLink.VAnchor = VAnchor.ParentCenter; removeLink = linkButtonFactory.Generate(new LocalizedString("remove").Translated); removeLink.VAnchor = VAnchor.ParentCenter; this.AddChild(printerName); this.AddChild(editLink); this.AddChild(removeLink); BindHandlers(); }
private FlowLayoutWidget GetCloudSyncDashboardControls() { FlowLayoutWidget cloudSyncContainer = new FlowLayoutWidget(); cloudSyncContainer.HAnchor |= HAnchor.ParentLeftRight; cloudSyncContainer.VAnchor |= Agg.UI.VAnchor.ParentCenter; cloudSyncContainer.Margin = new BorderDouble(0, 0, 0, 0); cloudSyncContainer.Padding = new BorderDouble(0); Agg.Image.ImageBuffer cloudMonitorImage = StaticData.Instance.LoadIcon(Path.Combine("PrintStatusControls", "cloud-24x24.png")); if (!ActiveTheme.Instance.IsDarkTheme) { InvertLightness.DoInvertLightness(cloudMonitorImage); } ImageWidget cloudSyncIcon = new ImageWidget(cloudMonitorImage); cloudSyncIcon.Margin = new BorderDouble(right: 6, bottom: 6); TextWidget cloudSyncLabel = new TextWidget(LocalizedString.Get("Cloud Sync")); cloudSyncLabel.AutoExpandBoundsToText = true; cloudSyncLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor; cloudSyncLabel.VAnchor = VAnchor.ParentCenter; linkButtonFactory.fontSize = 10; Button cloudSyncGoLink = linkButtonFactory.Generate("GO TO DASHBOARD"); cloudSyncGoLink.ToolTipText = "Open cloud sync dashboard in web browser"; cloudSyncGoLink.Click += new EventHandler(cloudSyncGoButton_Click); cloudSyncContainer.AddChild(cloudSyncIcon); cloudSyncContainer.AddChild(cloudSyncLabel); cloudSyncContainer.AddChild(new HorizontalSpacer()); cloudSyncContainer.AddChild(cloudSyncGoLink); return(cloudSyncContainer); }
private FlowLayoutWidget GetSettingsRow(OrganizerSettingsData settingData, string sliceSettingValue = null) { FlowLayoutWidget container = new FlowLayoutWidget(); container.HAnchor = HAnchor.ParentLeftRight; double minSettingNameWidth = 400; if (ActiveSliceSettings.Instance.Contains(settingData.SlicerConfigName)) { int intEditWidth = 60; int doubleEditWidth = 60; int vectorXYEditWidth = 60; int multiLineEditHeight = 60; //Get the current value as a default value if (sliceSettingValue == null) { sliceSettingValue = ActiveSliceSettings.Instance.GetActiveValue(settingData.SlicerConfigName); } //Get the presentation name from the SettingNameLookup TextWidget settingName = new TextWidget(SettingNameLookup[settingData.SlicerConfigName], pointSize: 10); settingName.AutoExpandBoundsToText = false; settingName.EllipsisIfClipped = true; settingName.TextColor = ActiveTheme.Instance.PrimaryTextColor; settingName.VAnchor = Agg.UI.VAnchor.ParentCenter; settingName.MinimumSize = new Vector2(minSettingNameWidth, settingName.Height); settingName.Width = minSettingNameWidth; container.AddChild(settingName); switch (settingData.DataEditType) { case OrganizerSettingsData.DataEditTypes.INT: { int currentValue = 0; int.TryParse(sliceSettingValue, out currentValue); MHNumberEdit intEditWidget = new MHNumberEdit(currentValue, pixelWidth: intEditWidth, tabIndex: tabIndexForItem++); intEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((NumberEdit)sender).Value.ToString()); }; container.AddChild(intEditWidget); container.AddChild(getSettingInfoData(settingData)); } break; case OrganizerSettingsData.DataEditTypes.DOUBLE: { double currentValue = 0; double.TryParse(sliceSettingValue, out currentValue); MHNumberEdit doubleEditWidget = new MHNumberEdit(currentValue, allowNegatives: true, allowDecimals: true, pixelWidth: doubleEditWidth, tabIndex: tabIndexForItem++); doubleEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((NumberEdit)sender).Value.ToString()); }; container.AddChild(doubleEditWidget); container.AddChild(getSettingInfoData(settingData)); } break; case OrganizerSettingsData.DataEditTypes.POSITIVE_DOUBLE: { double currentValue = 0; double.TryParse(sliceSettingValue, out currentValue); MHNumberEdit doubleEditWidget = new MHNumberEdit(currentValue, allowDecimals: true, pixelWidth: doubleEditWidth, tabIndex: tabIndexForItem++); doubleEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((NumberEdit)sender).Value.ToString()); }; container.AddChild(doubleEditWidget); container.AddChild(getSettingInfoData(settingData)); } break; case OrganizerSettingsData.DataEditTypes.OFFSET: { double currentValue = 0; double.TryParse(sliceSettingValue, out currentValue); MHNumberEdit doubleEditWidget = new MHNumberEdit(currentValue, allowDecimals: true, allowNegatives: true, pixelWidth: doubleEditWidth, tabIndex: tabIndexForItem++); doubleEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((NumberEdit)sender).Value.ToString()); }; container.AddChild(doubleEditWidget); container.AddChild(getSettingInfoData(settingData)); } break; case OrganizerSettingsData.DataEditTypes.DOUBLE_OR_PERCENT: { MHTextEditWidget stringEdit = new MHTextEditWidget(sliceSettingValue, pixelWidth: 60, tabIndex: tabIndexForItem++); stringEdit.ActualTextEditWidget.EditComplete += (sender, e) => { TextEditWidget textEditWidget = (TextEditWidget)sender; string text = textEditWidget.Text; text = text.Trim(); bool isPercent = text.Contains("%"); if (isPercent) { text = text.Substring(0, text.IndexOf("%")); } double result; double.TryParse(text, out result); text = result.ToString(); if (isPercent) { text += "%"; } textEditWidget.Text = text; SaveSetting(settingData.SlicerConfigName, textEditWidget.Text); }; container.AddChild(stringEdit); container.AddChild(getSettingInfoData(settingData)); } break; case OrganizerSettingsData.DataEditTypes.CHECK_BOX: { CheckBox checkBoxWidget = new CheckBox(""); checkBoxWidget.VAnchor = Agg.UI.VAnchor.ParentBottom; checkBoxWidget.TextColor = ActiveTheme.Instance.PrimaryTextColor; checkBoxWidget.Checked = (sliceSettingValue == "1"); checkBoxWidget.CheckedStateChanged += (sender, e) => { if (((CheckBox)sender).Checked) { SaveSetting(settingData.SlicerConfigName, "1"); } else { SaveSetting(settingData.SlicerConfigName, "0"); } }; container.AddChild(checkBoxWidget); } break; case OrganizerSettingsData.DataEditTypes.STRING: { MHTextEditWidget stringEdit = new MHTextEditWidget(sliceSettingValue, pixelWidth: 120, tabIndex: tabIndexForItem++); stringEdit.ActualTextEditWidget.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((TextEditWidget)sender).Text); }; container.AddChild(stringEdit); } break; case OrganizerSettingsData.DataEditTypes.MULTI_LINE_TEXT: { string convertedNewLines = sliceSettingValue.Replace("\\n", "\n"); MHTextEditWidget stringEdit = new MHTextEditWidget(convertedNewLines, pointSize: 10, pixelWidth: 280, pixelHeight: multiLineEditHeight, multiLine: true, tabIndex: tabIndexForItem++); stringEdit.ActualTextEditWidget.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((TextEditWidget)sender).Text.Replace("\n", "\\n")); }; container.AddChild(stringEdit); } break; case OrganizerSettingsData.DataEditTypes.LIST: { StyledDropDownList selectableOptions = new StyledDropDownList("None", Direction.Down); selectableOptions.Margin = new BorderDouble(); string[] listItems = settingData.ExtraSettings.Split(','); foreach (string listItem in listItems) { MenuItem newItem = selectableOptions.AddItem(listItem); if (newItem.Text == sliceSettingValue) { selectableOptions.SelectedLabel = sliceSettingValue; } newItem.Selected += (sender, e) => { MenuItem menuItem = ((MenuItem)sender); SaveSetting(settingData.SlicerConfigName, menuItem.Text); }; } container.AddChild(selectableOptions); } break; case OrganizerSettingsData.DataEditTypes.VECTOR2: { string[] xyValueStrings = sliceSettingValue.Split(','); if (xyValueStrings.Length != 2) { xyValueStrings = new string[] { "0", "0" }; } double currentXValue = 0; double.TryParse(xyValueStrings[0], out currentXValue); MHNumberEdit xEditWidget = new MHNumberEdit(currentXValue, allowDecimals: true, pixelWidth: vectorXYEditWidth, tabIndex: tabIndexForItem++); double currentYValue = 0; double.TryParse(xyValueStrings[1], out currentYValue); MHNumberEdit yEditWidget = new MHNumberEdit(currentYValue, allowDecimals: true, pixelWidth: vectorXYEditWidth, tabIndex: tabIndexForItem++); { xEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, xEditWidget.ActuallNumberEdit.Value.ToString() + "," + yEditWidget.ActuallNumberEdit.Value.ToString()); }; container.AddChild(xEditWidget); TextWidget xText = new TextWidget("x"); xText.TextColor = ActiveTheme.Instance.PrimaryTextColor; xText.Margin = new BorderDouble(5, 0); container.AddChild(xText); } { yEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, xEditWidget.ActuallNumberEdit.Value.ToString() + "," + yEditWidget.ActuallNumberEdit.Value.ToString()); }; container.AddChild(yEditWidget); TextWidget yText = new TextWidget("y"); yText.TextColor = ActiveTheme.Instance.PrimaryTextColor; yText.Margin = new BorderDouble(5, 0); container.AddChild(yText); } } break; case OrganizerSettingsData.DataEditTypes.OFFSET2: { string[] xyValueStrings = sliceSettingValue.Split('x'); if (xyValueStrings.Length != 2) { xyValueStrings = new string[] { "0", "0" }; } double currentXValue = 0; double.TryParse(xyValueStrings[0], out currentXValue); MHNumberEdit xEditWidget = new MHNumberEdit(currentXValue, allowDecimals: true, allowNegatives: true, pixelWidth: vectorXYEditWidth, tabIndex: tabIndexForItem++); double currentYValue = 0; double.TryParse(xyValueStrings[1], out currentYValue); MHNumberEdit yEditWidget = new MHNumberEdit(currentYValue, allowDecimals: true, allowNegatives: true, pixelWidth: vectorXYEditWidth, tabIndex: tabIndexForItem++); { xEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, xEditWidget.ActuallNumberEdit.Value.ToString() + "x" + yEditWidget.ActuallNumberEdit.Value.ToString()); }; container.AddChild(xEditWidget); TextWidget xText = new TextWidget("x"); xText.TextColor = ActiveTheme.Instance.PrimaryTextColor; xText.Margin = new BorderDouble(5, 0); container.AddChild(xText); } { yEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, xEditWidget.ActuallNumberEdit.Value.ToString() + "x" + yEditWidget.ActuallNumberEdit.Value.ToString()); }; container.AddChild(yEditWidget); TextWidget yText = new TextWidget("y"); yText.TextColor = ActiveTheme.Instance.PrimaryTextColor; yText.Margin = new BorderDouble(5, 0); container.AddChild(yText); } } break; default: TextWidget missingSetting = new TextWidget(String.Format("Missing the setting for '{0}'.", settingData.DataEditType.ToString())); missingSetting.TextColor = ActiveTheme.Instance.PrimaryTextColor; missingSetting.BackgroundColor = RGBA_Bytes.Red; container.AddChild(missingSetting); break; } } else // the setting we think we are adding is not in the config.ini it may have been depricated { TextWidget settingName = new TextWidget(String.Format("Setting '{0}' not found in config.ini", settingData.SlicerConfigName)); settingName.TextColor = ActiveTheme.Instance.PrimaryTextColor; settingName.MinimumSize = new Vector2(minSettingNameWidth, settingName.MinimumSize.y); container.AddChild(settingName); container.BackgroundColor = RGBA_Bytes.Red; } container.AddChild(new HorizontalSpacer()); Button removeLink = linkButtonFactory.Generate("remove"); removeLink.Click += (sender, e) => { RemoveSetting(settingData.SlicerConfigName); }; removeLink.VAnchor = Agg.UI.VAnchor.ParentCenter; container.AddChild(removeLink); return(container); }
public PresetListItem(SlicePresetsWindow windowController, SliceSettingsCollection preset) { this.preset = preset; this.BackgroundColor = RGBA_Bytes.White; this.HAnchor = HAnchor.ParentLeftRight; this.Margin = new BorderDouble(6, 0, 6, 3); this.Padding = new BorderDouble(3); LinkButtonFactory linkButtonFactory = new LinkButtonFactory(); linkButtonFactory.fontSize = 10; int maxLabelWidth = 300; TextWidget materialLabel = new TextWidget(preset.Name, pointSize: 14); materialLabel.EllipsisIfClipped = true; materialLabel.VAnchor = Agg.UI.VAnchor.ParentCenter; materialLabel.MinimumSize = new Vector2(maxLabelWidth, materialLabel.Height); materialLabel.Width = maxLabelWidth; Button materialEditLink = linkButtonFactory.Generate("edit"); materialEditLink.VAnchor = Agg.UI.VAnchor.ParentCenter; materialEditLink.Click += (sender, e) => { UiThread.RunOnIdle(() => { windowController.ChangeToSlicePresetDetail(preset); }); }; Button materialRemoveLink = linkButtonFactory.Generate("remove"); materialRemoveLink.Margin = new BorderDouble(left: 4); materialRemoveLink.VAnchor = Agg.UI.VAnchor.ParentCenter; materialRemoveLink.Click += (sender, e) => { UiThread.RunOnIdle(() => { //Unwind this setting if it is currently active if (ActivePrinterProfile.Instance.ActivePrinter != null) { if (preset.Id == ActivePrinterProfile.Instance.ActiveQualitySettingsID) { ActivePrinterProfile.Instance.ActiveQualitySettingsID = 0; } string[] activeMaterialPresets = ActivePrinterProfile.Instance.ActivePrinter.MaterialCollectionIds.Split(','); for (int i = 0; i < activeMaterialPresets.Count(); i++) { int index = 0; Int32.TryParse(activeMaterialPresets[i], out index); if (preset.Id == index) { ActivePrinterProfile.Instance.SetMaterialSetting(i + 1, 0); } } } preset.Delete(); windowController.ChangeToSlicePresetList(); ActiveSliceSettings.Instance.LoadAllSettings(); ApplicationController.Instance.ReloadAdvancedControlsPanel(); }); }; this.AddChild(materialLabel); this.AddChild(new HorizontalSpacer()); this.AddChild(materialEditLink); this.AddChild(materialRemoveLink); this.Height = 35; }
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 { //No active COM ports } } else { this.ActivePrinter = activePrinter; string editHeaderTitleTxt = LocalizedString.Get("Edit"); 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 { //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("Printer 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; int portIndex = 0; foreach (string serialPort in FrostedSerialPort.GetPortNames()) { //Filter com port list based on usb type (applies to Mac mostly) bool looks_like_mac = serialPort.StartsWith("/dev/tty."); bool looks_like_pc = serialPort.StartsWith("COM"); if (looks_like_mac || looks_like_pc) { SerialPortIndexRadioButton comPortOption = createComPortOption(serialPort); comPortContainer.AddChild(comPortOption); portIndex++; } } //If there are no com ports in the filtered list assume we are missing something and show the unfiltered list if (portIndex == 0) { foreach (string serialPort in FrostedSerialPort.GetPortNames()) { SerialPortIndexRadioButton comPortOption = createComPortOption(serialPort); comPortContainer.AddChild(comPortOption); portIndex++; } } if (!printerComPortIsAvailable && this.ActivePrinter.ComPort != null) { SerialPortIndexRadioButton comPortOption = createComPortOption(this.ActivePrinter.ComPort); comPortOption.Enabled = false; comPortContainer.AddChild(comPortOption); portIndex++; } //If there are still no com ports show a message to that effect if (portIndex == 0) { TextWidget comPortOption = new TextWidget(LocalizedString.Get("No COM ports available")); comPortOption.Margin = new BorderDouble(3, 6, 5, 6); comPortOption.TextColor = this.subContainerTextColor; comPortContainer.AddChild(comPortOption); } #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); this.AddChild(mainContainer); BindSaveButtonHandlers(); BindBaudRateHandlers(); }
private FlowLayoutWidget CreateRightButtonPanel(double buildHeight) { FlowLayoutWidget buttonRightPanel = new FlowLayoutWidget(FlowDirection.TopToBottom); buttonRightPanel.Width = 200; { BorderDouble buttonMargin = new BorderDouble(top: 3); // put in the word editing menu { CheckBox expandWordOptions = expandMenuOptionFactory.GenerateCheckBoxButton("Word Edit".Localize(), "icon_arrow_right_no_border_32x32.png", "icon_arrow_down_no_border_32x32.png"); expandWordOptions.Margin = new BorderDouble(bottom: 2); buttonRightPanel.AddChild(expandWordOptions); FlowLayoutWidget wordOptionContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); wordOptionContainer.HAnchor = HAnchor.ParentLeftRight; wordOptionContainer.Visible = false; buttonRightPanel.AddChild(wordOptionContainer); sizeScrollBar = InsertUiForSlider(wordOptionContainer, "Size:".Localize(), .3, 2); { sizeScrollBar.ValueChanged += (sender, e) => { SetWordSize(MeshGroups, MeshGroupTransforms); //SetWordSpacing(MeshGroups, MeshGroupTransforms, MeshGroupExtraData); RebuildBase(); }; } heightScrollBar = InsertUiForSlider(wordOptionContainer, "Height:".Localize(), .05, 1); { heightScrollBar.ValueChanged += (sender, e) => { SetWordHeight(MeshGroups, MeshGroupTransforms); RebuildBase(); }; } // put in the user alpha checkbox { includeText = new CheckBox(new CheckBoxViewText("Include Text".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor)); includeText.ToolTipText = "Show normal text under the braille".Localize(); includeText.Checked = false; includeText.Margin = new BorderDouble(10, 5); includeText.HAnchor = HAnchor.ParentLeft; wordOptionContainer.AddChild(includeText); includeText.CheckedStateChanged += (sender, e) => { InsertTextNow(this.word); }; } // put in the user alpha checkbox { useGrade2 = new CheckBox(new CheckBoxViewText("Use Grade 2".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor)); useGrade2.ToolTipText = "Experimental support for Braille grade 2 (contractions)".Localize(); useGrade2.Checked = false; useGrade2.Margin = new BorderDouble(10, 5); useGrade2.HAnchor = HAnchor.ParentLeft; wordOptionContainer.AddChild(useGrade2); useGrade2.CheckedStateChanged += (sender, e) => { InsertTextNow(this.word); }; } // put in a link to the wikipedia article { LinkButtonFactory linkButtonFactory = new LinkButtonFactory(); linkButtonFactory.fontSize = 10; linkButtonFactory.textColor = ActiveTheme.Instance.PrimaryTextColor; Button moreAboutBrailleLink = linkButtonFactory.Generate("About Braille".Localize()); moreAboutBrailleLink.Margin = new BorderDouble(10, 5); moreAboutBrailleLink.HAnchor = HAnchor.ParentLeft; moreAboutBrailleLink.Click += (sender, e) => { UiThread.RunOnIdle(() => { MatterControlApplication.Instance.LaunchBrowser("https://en.wikipedia.org/wiki/Braille"); }); }; wordOptionContainer.AddChild(moreAboutBrailleLink); } expandWordOptions.CheckedStateChanged += (sender, e) => { wordOptionContainer.Visible = expandWordOptions.Checked; }; expandWordOptions.Checked = true; } GuiWidget verticalSpacer = new GuiWidget(); verticalSpacer.VAnchor = VAnchor.ParentBottomTop; buttonRightPanel.AddChild(verticalSpacer); saveButton = whiteButtonFactory.Generate("Save".Localize(), centerText: true); saveButton.Visible = false; saveButton.Cursor = Cursors.Hand; saveAndExitButton = whiteButtonFactory.Generate("Save & Exit".Localize(), centerText: true); saveAndExitButton.Visible = false; saveAndExitButton.Cursor = Cursors.Hand; //buttonRightPanel.AddChild(saveButton); buttonRightPanel.AddChild(saveAndExitButton); } buttonRightPanel.Padding = new BorderDouble(6, 6); buttonRightPanel.Margin = new BorderDouble(0, 1); buttonRightPanel.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; buttonRightPanel.VAnchor = VAnchor.ParentBottomTop; return(buttonRightPanel); }
private void CreateEditControls() { editControls = new FlowLayoutWidget(); editControls.Margin = new BorderDouble(right: 10); editControls.VAnchor = Agg.UI.VAnchor.FitToChildren | Agg.UI.VAnchor.ParentCenter; { FlowLayoutWidget layoutLeftToRight = new FlowLayoutWidget(); linkButtonFactory.margin = new BorderDouble(3); // view button { Button viewLink = linkButtonFactory.Generate(LocalizedString.Get("View")); viewLink.Click += (sender, e) => { string pathAndFile = PrintItemWrapper.FileLocation; if (File.Exists(pathAndFile)) { OpenViewWindow(); } else { ShowCantFindFileMessage(PrintItemWrapper); } }; layoutLeftToRight.AddChild(viewLink); } // copy button { Button copyLink = linkButtonFactory.Generate(LocalizedString.Get("Copy")); copyLink.Click += (sender, e) => { CreateCopyInQueue(); }; layoutLeftToRight.AddChild(copyLink); } // add to library button { if (this.PrintItemWrapper.PrintItem.PrintItemCollectionID == LibraryData.Instance.LibraryCollection.Id) { //rightColumnOptions.AddChild(new TextWidget("Libary Item")); } } // the export menu { Button exportLink = linkButtonFactory.Generate(LocalizedString.Get("Export")); exportLink.Click += (sender, e) => { OpenExportWindow(); }; layoutLeftToRight.AddChild(exportLink); } // spacer { layoutLeftToRight.AddChild(new GuiWidget(10, 10)); } // delete button { Button deleteLink = linkButtonFactory.Generate(LocalizedString.Get("Remove")); deleteLink.Click += (sender, e) => { DeletePartFromQueue(); }; layoutLeftToRight.AddChild(deleteLink); } // push off to the right the rest spacer { GuiWidget spaceFiller = new GuiWidget(10, 10); //layoutLeftToRight.AddChild(spaceFiller); } // up and down buttons { FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); // move up one button { Button moveUp = linkButtonFactory.Generate(" ^ "); moveUp.Click += (sender, e) => { int thisIndexInQueue = QueueData.Instance.GetIndex(PrintItemWrapper); QueueData.Instance.SwapItemsOnIdle(thisIndexInQueue, thisIndexInQueue - 1); }; topToBottom.AddChild(moveUp); } // move down one button { Button moveDown = linkButtonFactory.Generate(" v "); moveDown.Click += (sender, e) => { int thisIndexInQueue = QueueData.Instance.GetIndex(PrintItemWrapper); QueueData.Instance.SwapItemsOnIdle(thisIndexInQueue, thisIndexInQueue + 1); }; topToBottom.AddChild(moveDown); } // don't add this yet as we don't have icons for it and it should probably be drag and drop anyway //layoutLeftToRight.AddChild(topToBottom); } // now add the layout to the edit controls bar editControls.AddChild(layoutLeftToRight); } }
public CheckForUpdateWindow() : base(540, 350) { linkButtonFactory.fontSize = 10; linkButtonFactory.textColor = ActiveTheme.Instance.SecondaryAccentColor; FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); topToBottom.AnchorAll(); topToBottom.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; Padding = new BorderDouble(left: 5, right: 5); FlowLayoutWidget mainLabelContainer = new FlowLayoutWidget(FlowDirection.LeftToRight); mainLabelContainer.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; mainLabelContainer.VAnchor = VAnchor.FitToChildren; mainLabelContainer.HAnchor = HAnchor.ParentLeftRight; FlowLayoutWidget currentFeedAndDropDownContainer = new FlowLayoutWidget(FlowDirection.LeftToRight); currentFeedAndDropDownContainer.VAnchor = VAnchor.FitToChildren; currentFeedAndDropDownContainer.HAnchor = HAnchor.ParentLeftRight; currentFeedAndDropDownContainer.Margin = new BorderDouble(0, 5, 0, 0); currentFeedAndDropDownContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; TextWidget checkUpdateLabel = new TextWidget("Check for Update".Localize(), pointSize: 20); checkUpdateLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor; checkUpdateLabel.Margin = new BorderDouble(2, 10, 10, 5); UpdateControlView updateStatusWidget = new UpdateControlView(); String fullCurrentFeedLabel = "Update Channel".Localize(); TextWidget feedLabel = new TextWidget(fullCurrentFeedLabel, pointSize: 12); feedLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor; feedLabel.VAnchor = VAnchor.ParentCenter; feedLabel.Margin = new BorderDouble(left: 5); releaseOptionsDropList = new StyledDropDownList("Development", maxHeight: 200); releaseOptionsDropList.HAnchor = HAnchor.ParentLeftRight; MenuItem releaseOptionsDropDownItem = releaseOptionsDropList.AddItem("Stable".Localize(), "release"); releaseOptionsDropDownItem.Selected += new EventHandler(FixTabDot); MenuItem preReleaseDropDownItem = releaseOptionsDropList.AddItem("Beta".Localize(), "pre-release"); preReleaseDropDownItem.Selected += new EventHandler(FixTabDot); MenuItem developmentDropDownItem = releaseOptionsDropList.AddItem("Alpha".Localize(), "development"); developmentDropDownItem.Selected += new EventHandler(FixTabDot); List <string> acceptableUpdateFeedTypeValues = new List <string>() { "release", "pre-release", "development" }; string currentUpdateFeedType = UserSettings.Instance.get("UpdateFeedType"); if (acceptableUpdateFeedTypeValues.IndexOf(currentUpdateFeedType) == -1) { UserSettings.Instance.set("UpdateFeedType", "release"); } releaseOptionsDropList.SelectedValue = UserSettings.Instance.get("UpdateFeedType"); releaseOptionsDropList.SelectionChanged += new EventHandler(ReleaseOptionsDropList_SelectionChanged); string currentBuildNo = VersionInfo.Instance.BuildVersion; string currentBuildInfoLabel = String.Format("Current Build : {0}", currentBuildNo); currentBuildInfo = new TextWidget(currentBuildInfoLabel.Localize()); currentBuildInfo.HAnchor = HAnchor.ParentLeftRight; currentBuildInfo.Margin = new BorderDouble(left: 5, bottom: 15, top: 20); currentBuildInfo.TextColor = ActiveTheme.Instance.PrimaryTextColor; FlowLayoutWidget additionalInfoContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); additionalInfoContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; additionalInfoContainer.HAnchor = HAnchor.ParentLeftRight; additionalInfoContainer.Padding = new BorderDouble(left: 6, top: 6); string aboutUpdateChannel = "Changing your update channnel will change the version of MatterControl \nthat you recieve when updating:"; updateChannelLabel = new TextWidget(aboutUpdateChannel); updateChannelLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor; updateChannelLabel.HAnchor = HAnchor.ParentLeftRight; updateChannelLabel.Margin = new BorderDouble(bottom: 20); additionalInfoContainer.AddChild(updateChannelLabel); string stableFeedInfoText = "Stable: The current release version of MatterControl (recommended).".Localize(); stableInfoLabel = new TextWidget(stableFeedInfoText); stableInfoLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor; stableInfoLabel.HAnchor = HAnchor.ParentLeftRight; stableInfoLabel.Margin = new BorderDouble(bottom: 10); additionalInfoContainer.AddChild(stableInfoLabel); string betaFeedInfoText = "Beta: The release candidate version of MatterControl.".Localize(); betaInfoLabel = new TextWidget(betaFeedInfoText); betaInfoLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor; betaInfoLabel.HAnchor = HAnchor.ParentLeftRight; betaInfoLabel.Margin = new BorderDouble(bottom: 10); additionalInfoContainer.AddChild(betaInfoLabel); string alphaFeedInfoText = "Alpha: The in development version of MatterControl.".Localize(); alphaInfoLabel = new TextWidget(alphaFeedInfoText); alphaInfoLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor; alphaInfoLabel.HAnchor = HAnchor.ParentLeftRight; alphaInfoLabel.Margin = new BorderDouble(bottom: 10); additionalInfoContainer.AddChild(alphaInfoLabel); FlowLayoutWidget buttonContainer = new FlowLayoutWidget(FlowDirection.LeftToRight); buttonContainer.HAnchor = HAnchor.ParentLeftRight; buttonContainer.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; Button closeButton = textImageButtonFactory.Generate("Close".Localize(), centerText: true); closeButton.Click += (sender, e) => { CloseOnIdle(); }; Button whatsThisLink = linkButtonFactory.Generate("What's this?".Localize()); whatsThisLink.VAnchor = VAnchor.ParentCenter; whatsThisLink.Margin = new BorderDouble(left: 6); whatsThisLink.Click += (sender, e) => { UiThread.RunOnIdle(() => { if (!additionalInfoContainer.Visible) { additionalInfoContainer.Visible = true; } else { additionalInfoContainer.Visible = false; } }); }; mainLabelContainer.AddChild(checkUpdateLabel); topToBottom.AddChild(mainLabelContainer); topToBottom.AddChild(updateStatusWidget); topToBottom.AddChild(currentBuildInfo); currentFeedAndDropDownContainer.AddChild(feedLabel); currentFeedAndDropDownContainer.AddChild(whatsThisLink); currentFeedAndDropDownContainer.AddChild(new HorizontalSpacer()); currentFeedAndDropDownContainer.AddChild(releaseOptionsDropList); topToBottom.AddChild(currentFeedAndDropDownContainer); topToBottom.AddChild(additionalInfoContainer); buttonContainer.AddChild(new HorizontalSpacer()); buttonContainer.AddChild(closeButton); topToBottom.AddChild(new VerticalSpacer()); topToBottom.AddChild(buttonContainer); this.AddChild(topToBottom); additionalInfoContainer.Visible = false; this.Title = "Check for Update".Localize(); this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; this.ShowAsSystemWindow(); this.AlwaysOnTopOfMain = true; }
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"); 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("Printer 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, SoftKeyboardContentOffset.AndroidKeyboardOffset)); #else this.AddChild(mainContainer); #endif BindSaveButtonHandlers(); BindBaudRateHandlers(); }
public PrintLibraryListItem(PrintItemWrapper printItem) { this.printItem = printItem; linkButtonFactory.fontSize = 10; linkButtonFactory.textColor = RGBA_Bytes.White; WidgetTextColor = RGBA_Bytes.Black; WidgetBackgroundColor = RGBA_Bytes.White; TextInfo textInfo = new CultureInfo("en-US", false).TextInfo; SetDisplayAttributes(); FlowLayoutWidget mainContainer = new FlowLayoutWidget(FlowDirection.LeftToRight); mainContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; { GuiWidget selectionCheckBoxContainer = new GuiWidget(); selectionCheckBoxContainer.VAnchor = VAnchor.Max_FitToChildren_ParentHeight; selectionCheckBoxContainer.HAnchor = Agg.UI.HAnchor.FitToChildren; selectionCheckBoxContainer.Margin = new BorderDouble(left: 6); selectionCheckBox = new CheckBox(""); selectionCheckBox.VAnchor = VAnchor.ParentCenter; selectionCheckBox.HAnchor = HAnchor.ParentCenter; selectionCheckBoxContainer.AddChild(selectionCheckBox); FlowLayoutWidget leftColumn = new FlowLayoutWidget(FlowDirection.TopToBottom); leftColumn.VAnchor |= VAnchor.ParentTop; FlowLayoutWidget middleColumn = new FlowLayoutWidget(FlowDirection.TopToBottom); middleColumn.HAnchor = Agg.UI.HAnchor.ParentLeftRight; middleColumn.VAnchor = Agg.UI.VAnchor.ParentBottomTop; middleColumn.Padding = new BorderDouble(0, 6); middleColumn.Margin = new BorderDouble(10, 0); { string labelName = textInfo.ToTitleCase(printItem.Name); labelName = labelName.Replace('_', ' '); partLabel = new TextWidget(labelName, pointSize: 12); partLabel.TextColor = WidgetTextColor; partLabel.MinimumSize = new Vector2(1, 16); middleColumn.AddChild(partLabel); } FlowLayoutWidget rightColumn = new FlowLayoutWidget(FlowDirection.TopToBottom); rightColumn.VAnchor = Agg.UI.VAnchor.ParentBottomTop; buttonContainer = new FlowLayoutWidget(); buttonContainer.Margin = new BorderDouble(0, 6); buttonContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; { addToQueueLink = linkButtonFactory.Generate(new LocalizedString("Add to Queue").Translated); addToQueueLink.Margin = new BorderDouble(left: 0, right: 10); addToQueueLink.VAnchor = VAnchor.ParentCenter; addToQueueLink.Click += (sender, e) => { PrintQueueItem queueItem = new PrintQueueItem(this.printItem.Name, this.printItem.FileLocation); PrintQueueControl.Instance.AddChild(queueItem); }; viewLink = linkButtonFactory.Generate(new LocalizedString("View").Translated); viewLink.Margin = new BorderDouble(left: 0, right: 10); viewLink.VAnchor = VAnchor.ParentCenter; exportLink = linkButtonFactory.Generate(new LocalizedString("Export").Translated); exportLink.Margin = new BorderDouble(left: 0, right: 10); exportLink.VAnchor = VAnchor.ParentCenter; exportLink.Click += (sender, e) => { ExportLibraryItemWindow exportingWindow = new ExportLibraryItemWindow(this); exportingWindow.ShowAsSystemWindow(); }; removeLink = linkButtonFactory.Generate(new LocalizedString("Remove").Translated); removeLink.Margin = new BorderDouble(left: 10, right: 10); removeLink.VAnchor = VAnchor.ParentCenter; buttonContainer.AddChild(addToQueueLink); buttonContainer.AddChild(viewLink); buttonContainer.AddChild(exportLink); buttonContainer.AddChild(removeLink); } middleColumn.AddChild(buttonContainer); //rightColumn.AddChild(buttonContainer); mainContainer.AddChild(selectionCheckBoxContainer); { PartThumbnailWidget thumbnailWidget = new PartThumbnailWidget(printItem, "part_icon_transparent_40x40.png", "building_thumbnail_40x40.png", new Vector2(50, 50)); mainContainer.AddChild(thumbnailWidget); } mainContainer.AddChild(leftColumn); mainContainer.AddChild(middleColumn); mainContainer.AddChild(rightColumn); } this.AddChild(mainContainer); AddHandlers(); }
private FlowLayoutWidget CreateRightButtonPanel(double buildHeight) { FlowLayoutWidget buttonRightPanel = new FlowLayoutWidget(FlowDirection.TopToBottom); buttonRightPanel.Width = 200; { BorderDouble buttonMargin = new BorderDouble(top: 3); // put in the word editing menu { CheckBox expandWordOptions = ExpandMenuOptionFactory.GenerateCheckBoxButton("Word Edit".Localize(), View3DWidget.ArrowRight, View3DWidget.ArrowDown); expandWordOptions.Margin = new BorderDouble(bottom: 2); buttonRightPanel.AddChild(expandWordOptions); FlowLayoutWidget wordOptionContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); wordOptionContainer.HAnchor = HAnchor.ParentLeftRight; wordOptionContainer.Visible = false; buttonRightPanel.AddChild(wordOptionContainer); sizeScrollBar = InsertUiForSlider(wordOptionContainer, "Size:".Localize(), .3, 2); { sizeScrollBar.ValueChanged += (sender, e) => { SetWordSize(MeshGroups, MeshGroupTransforms); //SetWordSpacing(MeshGroups, MeshGroupTransforms, MeshGroupExtraData); RebuildBase(); }; } heightScrollBar = InsertUiForSlider(wordOptionContainer, "Height:".Localize(), .05, 1); { heightScrollBar.ValueChanged += (sender, e) => { SetWordHeight(MeshGroups, MeshGroupTransforms); RebuildBase(); }; } // put in the user alpha check box { includeText = new CheckBox(new CheckBoxViewText("Include Text".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor)); includeText.ToolTipText = "Show normal text above the braille".Localize(); includeText.Checked = false; includeText.Margin = new BorderDouble(10, 5); includeText.HAnchor = HAnchor.ParentLeft; wordOptionContainer.AddChild(includeText); includeText.CheckedStateChanged += (sender, e) => { InsertTextNow(this.word); }; } // put in the user alpha check box { useGrade2 = new CheckBox(new CheckBoxViewText("Use Grade 2".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor)); useGrade2.ToolTipText = "Experimental support for Braille grade 2 (contractions)".Localize(); useGrade2.Checked = false; useGrade2.Margin = new BorderDouble(10, 5); useGrade2.HAnchor = HAnchor.ParentLeft; wordOptionContainer.AddChild(useGrade2); useGrade2.CheckedStateChanged += (sender, e) => { InsertTextNow(this.word); }; } // put in a link to the wikipedia article { LinkButtonFactory linkButtonFactory = new LinkButtonFactory(); linkButtonFactory.fontSize = 10; linkButtonFactory.textColor = ActiveTheme.Instance.PrimaryTextColor; Button moreAboutBrailleLink = linkButtonFactory.Generate("About Braille".Localize()); moreAboutBrailleLink.Margin = new BorderDouble(10, 5); moreAboutBrailleLink.HAnchor = HAnchor.ParentLeft; moreAboutBrailleLink.Click += (sender, e) => { UiThread.RunOnIdle(() => { MatterControlApplication.Instance.LaunchBrowser("https://en.wikipedia.org/wiki/Braille"); }); }; wordOptionContainer.AddChild(moreAboutBrailleLink); } expandWordOptions.CheckedStateChanged += (sender, e) => { wordOptionContainer.Visible = expandWordOptions.Checked; }; expandWordOptions.Checked = true; } GuiWidget verticalSpacer = new GuiWidget(); verticalSpacer.VAnchor = VAnchor.ParentBottomTop; buttonRightPanel.AddChild(verticalSpacer); saveButton = WhiteButtonFactory.Generate("Save".Localize(), centerText: true); saveButton.Visible = false; saveButton.Cursor = Cursors.Hand; saveAndExitButton = WhiteButtonFactory.Generate("Save & Exit".Localize(), centerText: true); saveAndExitButton.Visible = false; saveAndExitButton.Cursor = Cursors.Hand; //buttonRightPanel.AddChild(saveButton); buttonRightPanel.AddChild(saveAndExitButton); } buttonRightPanel.Padding = new BorderDouble(6, 6); buttonRightPanel.Margin = new BorderDouble(0, 1); buttonRightPanel.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; buttonRightPanel.VAnchor = VAnchor.ParentBottomTop; return buttonRightPanel; }
public PresetListItem(SlicePresetsWindow windowController, SliceSettingsCollection preset) { this.preset = preset; this.BackgroundColor = RGBA_Bytes.White; this.HAnchor = HAnchor.ParentLeftRight; this.Margin = new BorderDouble(6, 0, 6, 3); this.Padding = new BorderDouble(3); LinkButtonFactory linkButtonFactory = new LinkButtonFactory(); linkButtonFactory.fontSize = 10; int maxLabelWidth = 300; TextWidget materialLabel = new TextWidget(preset.Name, pointSize: 14); materialLabel.EllipsisIfClipped = true; materialLabel.VAnchor = Agg.UI.VAnchor.ParentCenter; materialLabel.MinimumSize = new Vector2(maxLabelWidth, materialLabel.Height); materialLabel.Width = maxLabelWidth; Button materialEditLink = linkButtonFactory.Generate("edit"); materialEditLink.VAnchor = Agg.UI.VAnchor.ParentCenter; materialEditLink.Click += (sender, e) => { UiThread.RunOnIdle(() => { windowController.ChangeToSlicePresetDetail(preset); }); }; Button materialRemoveLink = linkButtonFactory.Generate("remove"); materialRemoveLink.Margin = new BorderDouble(left: 4); this.DebugShowBounds = true; materialRemoveLink.VAnchor = Agg.UI.VAnchor.ParentCenter; materialRemoveLink.Click += (sender, e) => { UiThread.RunOnIdle(() => { //Unwind this setting if it is currently active if (ActiveSliceSettings.Instance != null) { /* if (preset.Id == ActivePrinterProfile.Instance.ActiveQualitySettingsID) { ActivePrinterProfile.Instance.ActiveQualitySettingsID = 0; } string[] activeMaterialPresets = ActiveSliceSettings.Instance.MaterialCollectionIds.Split(','); for (int i = 0; i < activeMaterialPresets.Count(); i++) { int index = 0; Int32.TryParse(activeMaterialPresets[i], out index); if (preset.Id == index) { ActiveSliceSettings.Instance.SetMaterialPreset(i, ""); } } */ } preset.Delete(); windowController.ChangeToSlicePresetList(); ApplicationController.Instance.ReloadAdvancedControlsPanel(); }); }; this.AddChild(materialLabel); this.AddChild(new HorizontalSpacer()); this.AddChild(materialEditLink); this.AddChild(materialRemoveLink); this.Height = 35; }
public ToolsListItem(PrintItemWrapper printItem) { this.printItem = printItem; linkButtonFactory.fontSize = 10; linkButtonFactory.textColor = RGBA_Bytes.White; WidgetTextColor = RGBA_Bytes.Black; WidgetBackgroundColor = RGBA_Bytes.White; TextInfo textInfo = new CultureInfo("en-US", false).TextInfo; SetDisplayAttributes(); FlowLayoutWidget mainContainer = new FlowLayoutWidget(FlowDirection.LeftToRight); mainContainer.HAnchor |= Agg.UI.HAnchor.ParentLeftRight; { GuiWidget selectionCheckBoxContainer = new GuiWidget(); selectionCheckBoxContainer.VAnchor = VAnchor.Max_FitToChildren_ParentHeight; selectionCheckBoxContainer.HAnchor = Agg.UI.HAnchor.FitToChildren; selectionCheckBoxContainer.Margin = new BorderDouble(left: 6); selectionCheckBox = new CheckBox(""); selectionCheckBox.VAnchor = VAnchor.ParentCenter; selectionCheckBox.HAnchor = HAnchor.ParentCenter; selectionCheckBoxContainer.AddChild(selectionCheckBox); FlowLayoutWidget leftColumn = new FlowLayoutWidget(FlowDirection.TopToBottom); leftColumn.VAnchor |= VAnchor.ParentTop; FlowLayoutWidget middleColumn = new FlowLayoutWidget(FlowDirection.TopToBottom); middleColumn.VAnchor |= VAnchor.ParentTop; middleColumn.HAnchor |= HAnchor.ParentLeftRight; middleColumn.Padding = new BorderDouble(6); middleColumn.Margin = new BorderDouble(10, 0); { string labelName = textInfo.ToTitleCase(printItem.Name); labelName = labelName.Replace('_', ' '); partLabel = new TextWidget(labelName, pointSize: 12); partLabel.TextColor = WidgetTextColor; partLabel.MinimumSize = new Vector2(1, 16); middleColumn.AddChild(partLabel); } FlowLayoutWidget rightColumn = new FlowLayoutWidget(FlowDirection.TopToBottom); rightColumn.VAnchor |= VAnchor.ParentCenter; buttonContainer = new FlowLayoutWidget(); buttonContainer.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth; buttonContainer.VAnchor = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight; { viewLink = linkButtonFactory.Generate("View"); viewLink.Margin = new BorderDouble(left: 10, right: 10); viewLink.VAnchor = VAnchor.ParentCenter; removeLink = linkButtonFactory.Generate("Remove"); removeLink.Margin = new BorderDouble(right: 10); removeLink.VAnchor = VAnchor.ParentCenter; buttonContainer.AddChild(viewLink); buttonContainer.AddChild(removeLink); } rightColumn.AddChild(buttonContainer); mainContainer.AddChild(selectionCheckBoxContainer); mainContainer.AddChild(leftColumn); mainContainer.AddChild(middleColumn); mainContainer.AddChild(rightColumn); } this.AddChild(mainContainer); AddHandlers(); }
void AddChildElements() { TextInfo textInfo = new CultureInfo("en-US", false).TextInfo; { GuiWidget indicator = new GuiWidget(); indicator.VAnchor = Agg.UI.VAnchor.ParentBottomTop; indicator.Width = 15; if (printTask.PrintComplete) { indicator.BackgroundColor = new RGBA_Bytes(38, 147, 51, 180); } else { indicator.BackgroundColor = new RGBA_Bytes(252, 209, 22, 180); } FlowLayoutWidget middleColumn = new FlowLayoutWidget(FlowDirection.TopToBottom); middleColumn.HAnchor = Agg.UI.HAnchor.ParentLeftRight; middleColumn.Padding = new BorderDouble(6, 3); { FlowLayoutWidget labelContainer = new FlowLayoutWidget(); labelContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; string labelName = textInfo.ToTitleCase(printTask.PrintName); labelName = labelName.Replace('_', ' '); partLabel = new TextWidget(labelName, pointSize: 15); partLabel.TextColor = WidgetTextColor; labelContainer.AddChild(partLabel); middleColumn.AddChild(labelContainer); } RGBA_Bytes timeTextColor = RGBA_Bytes.Gray; buttonContainer = new FlowLayoutWidget(); buttonContainer.Margin = new BorderDouble(0); buttonContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; { TextWidget statusIndicator = new TextWidget("Status: Completed".Localize(), pointSize: 8); statusIndicator.Margin = new BorderDouble(right: 3); //buttonContainer.AddChild(statusIndicator); string printTimeLabel = "Time".Localize().ToUpper(); string printTimeLabelFull = string.Format("{0}: ", printTimeLabel); TextWidget timeLabel = new TextWidget(printTimeLabelFull, pointSize: 8); timeLabel.TextColor = timeTextColor; TextWidget timeIndicator; int minutes = printTask.PrintTimeMinutes; if (minutes < 0) { timeIndicator = new TextWidget("Unknown".Localize()); } else if (minutes > 60) { timeIndicator = new TextWidget("{0}hrs {1}min".FormatWith(printTask.PrintTimeMinutes / 60, printTask.PrintTimeMinutes % 60), pointSize: 12); } else { timeIndicator = new TextWidget(string.Format("{0}min", printTask.PrintTimeMinutes), pointSize: 12); } timeIndicator.Margin = new BorderDouble(right: 6); timeIndicator.TextColor = timeTextColor; buttonContainer.AddChild(timeLabel); buttonContainer.AddChild(timeIndicator); printAgainLink = linkButtonFactory.Generate("Reprint".Localize()); printAgainLink.Margin = new BorderDouble(left: 0, right: 0); printAgainLink.VAnchor = VAnchor.ParentCenter; printAgainLink.Click += (sender, e) => { QueueData.Instance.AddItem(new PrintItemWrapper(printTask.PrintItemId)); }; buttonContainer.AddChild(new HorizontalSpacer()); buttonContainer.AddChild(printAgainLink); middleColumn.AddChild(buttonContainer); } this.AddChild(indicator); this.AddChild(middleColumn); if (showTimestamp) { FlowLayoutWidget rightColumn = new FlowLayoutWidget(FlowDirection.TopToBottom); rightColumn.BackgroundColor = RGBA_Bytes.LightGray; rightColumn.Padding = new BorderDouble(6, 0); FlowLayoutWidget startTimeContainer = new FlowLayoutWidget(); startTimeContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; startTimeContainer.Padding = new BorderDouble(0, 3); string startLabelFull = "{0}:".FormatWith("Start".Localize().ToUpper()); TextWidget startLabel = new TextWidget(startLabelFull, pointSize: 8); startLabel.TextColor = timeTextColor; string startTimeString = printTask.PrintStart.ToString("MMM d yyyy h:mm ") + printTask.PrintStart.ToString("tt").ToLower(); TextWidget startDate = new TextWidget(startTimeString, pointSize: 12); startDate.TextColor = timeTextColor; startTimeContainer.AddChild(startLabel); startTimeContainer.AddChild(new HorizontalSpacer()); startTimeContainer.AddChild(startDate); FlowLayoutWidget endTimeContainer = new FlowLayoutWidget(); endTimeContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; endTimeContainer.Padding = new BorderDouble(0, 3); string endLabelFull = "{0}:".FormatWith("End".Localize().ToUpper()); TextWidget endLabel = new TextWidget(endLabelFull, pointSize: 8); endLabel.TextColor = timeTextColor; string endTimeString; if (printTask.PrintEnd != DateTime.MinValue) { endTimeString = printTask.PrintEnd.ToString("MMM d yyyy h:mm ") + printTask.PrintEnd.ToString("tt").ToLower(); } else { endTimeString = "Unknown".Localize(); } TextWidget endDate = new TextWidget(endTimeString, pointSize: 12); endDate.TextColor = timeTextColor; endTimeContainer.AddChild(endLabel); endTimeContainer.AddChild(new HorizontalSpacer()); endTimeContainer.AddChild(endDate); HorizontalLine horizontalLine = new HorizontalLine(); horizontalLine.BackgroundColor = RGBA_Bytes.Gray; rightColumn.AddChild(endTimeContainer); rightColumn.AddChild(horizontalLine); rightColumn.AddChild(startTimeContainer); rightColumn.Width = 220; this.AddChild(rightColumn); } } }