public ViewControls2D() { if (ActiveTheme.Instance.DisplayMode == ActiveTheme.ApplicationDisplayType.Touchscreen) { buttonHeight = 40; } else { buttonHeight = 20; } TextImageButtonFactory iconTextImageButtonFactory = new TextImageButtonFactory(); iconTextImageButtonFactory.AllowThemeToAdjustImage = false; iconTextImageButtonFactory.checkedBorderColor = RGBA_Bytes.White; BackgroundColor = new RGBA_Bytes(0, 0, 0, 120); iconTextImageButtonFactory.FixedHeight = buttonHeight; iconTextImageButtonFactory.FixedWidth = buttonHeight; string translateIconPath = Path.Combine("ViewTransformControls", "translate.png"); translateButton = iconTextImageButtonFactory.GenerateRadioButton("", translateIconPath); translateButton.Margin = new BorderDouble(3); AddChild(translateButton); string scaleIconPath = Path.Combine("ViewTransformControls", "scale.png"); scaleButton = iconTextImageButtonFactory.GenerateRadioButton("", scaleIconPath); scaleButton.Margin = new BorderDouble(3); AddChild(scaleButton); Margin = new BorderDouble(5); HAnchor |= Agg.UI.HAnchor.ParentLeft; VAnchor = Agg.UI.VAnchor.ParentTop; translateButton.Checked = true; }
public ViewControlsToggle() { TextImageButtonFactory iconTextImageButtonFactory = new TextImageButtonFactory(); iconTextImageButtonFactory.AllowThemeToAdjustImage = false; iconTextImageButtonFactory.checkedBorderColor = RGBA_Bytes.White; BackgroundColor = new RGBA_Bytes(0, 0, 0, 120); iconTextImageButtonFactory.FixedHeight = buttonHeight; iconTextImageButtonFactory.FixedWidth = buttonHeight; string select2dIconPath = Path.Combine("ViewTransformControls", "2d.png"); twoDimensionButton = iconTextImageButtonFactory.GenerateRadioButton("", select2dIconPath); twoDimensionButton.Margin = new BorderDouble(3); AddChild(twoDimensionButton); string select3dIconPath = Path.Combine("ViewTransformControls", "3d.png"); threeDimensionButton = iconTextImageButtonFactory.GenerateRadioButton("", select3dIconPath); threeDimensionButton.Margin = new BorderDouble(3); if (ActiveTheme.Instance.DisplayMode != ActiveTheme.ApplicationDisplayType.Touchscreen) { AddChild(threeDimensionButton); if (UserSettings.Instance.get("LayerViewDefault") == "3D Layer" && (UserSettings.Instance.Fields.StartCountDurringExit == UserSettings.Instance.Fields.StartCount - 1 || userChangedTo3DThisRun) ) { threeDimensionButton.Checked = true; } else { twoDimensionButton.Checked = true; } } else { twoDimensionButton.Checked = true; } threeDimensionButton.Click += (sender, e) => { userChangedTo3DThisRun = true; }; Margin = new BorderDouble(5, 5, 200, 5); HAnchor |= Agg.UI.HAnchor.ParentRight; VAnchor = Agg.UI.VAnchor.ParentTop; }
public ViewControlsToggle() { TextImageButtonFactory iconTextImageButtonFactory = new TextImageButtonFactory(); iconTextImageButtonFactory.AllowThemeToAdjustImage = false; BackgroundColor = new RGBA_Bytes(0, 0, 0, 120); iconTextImageButtonFactory.FixedHeight = 20; iconTextImageButtonFactory.FixedWidth = 20; string translateIconPath = Path.Combine("ViewTransformControls", "2d.png"); twoDimensionButton = iconTextImageButtonFactory.GenerateRadioButton("", translateIconPath); twoDimensionButton.Margin = new BorderDouble(3); AddChild(twoDimensionButton); string scaleIconPath = Path.Combine("ViewTransformControls", "3d.png"); threeDimensionButton = iconTextImageButtonFactory.GenerateRadioButton("", scaleIconPath); threeDimensionButton.Margin = new BorderDouble(3); AddChild(threeDimensionButton); Margin = new BorderDouble(5,5,195,5); HAnchor |= Agg.UI.HAnchor.ParentRight; VAnchor = Agg.UI.VAnchor.ParentTop; string defaultView = UserSettings.Instance.get ("LayerViewDefault"); if (defaultView == null) { UserSettings.Instance.set ("LayerViewDefault", "2D Layer"); } if (defaultView == "2D Layer") { twoDimensionButton.Checked = true; } else if (defaultView == "3D Layer") { threeDimensionButton.Checked = true; } else { twoDimensionButton.Checked = true; } }
public ViewControls2D() { TextImageButtonFactory iconTextImageButtonFactory = new TextImageButtonFactory(); iconTextImageButtonFactory.AllowThemeToAdjustImage = false; BackgroundColor = new RGBA_Bytes(0, 0, 0, 120); iconTextImageButtonFactory.FixedHeight = 20; iconTextImageButtonFactory.FixedWidth = 20; string translateIconPath = Path.Combine("ViewTransformControls", "translate.png"); translateButton = iconTextImageButtonFactory.GenerateRadioButton("", translateIconPath); translateButton.Margin = new BorderDouble(3); AddChild(translateButton); string scaleIconPath = Path.Combine("ViewTransformControls", "scale.png"); scaleButton = iconTextImageButtonFactory.GenerateRadioButton("", scaleIconPath); scaleButton.Margin = new BorderDouble(3); AddChild(scaleButton); Margin = new BorderDouble(5); HAnchor |= Agg.UI.HAnchor.ParentLeft; VAnchor = Agg.UI.VAnchor.ParentTop; translateButton.Checked = true; }
public ExportSettingsPage() : base("Cancel", "Export As") { var container = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.ParentLeftRight, }; contentRow.AddChild(container); if (true) { // export as matter control matterControlButton = new RadioButton("MatterControl".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor); matterControlButton.Checked = true; container.AddChild(matterControlButton); // export as slic3r slic3rButton = new RadioButton("Slic3r".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor); container.AddChild(slic3rButton); // export as cura #if DEBUG curaButton = new RadioButton("Cura".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor); container.AddChild(curaButton); #endif } else { // export as matter control matterControlButton = new RadioButton("Export MatterControl settings (*.printer)".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor); matterControlButton.Checked = true; container.AddChild(matterControlButton); // export as slic3r slic3rButton = new RadioButton("Export Slic3r settings (*.ini)".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor); container.AddChild(slic3rButton); container.AddChild( CreateDetailInfo("Export as a config.ini file that can be read by older versions of Matter Control and Slic3r.") ); // export as cura #if DEBUG curaButton = new RadioButton("Export Cura settings (*.ini)".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor); container.AddChild(curaButton); container.AddChild( CreateDetailInfo("Export as a file that can be read by Cura.\nNote: Not all settings are exportable in this format.") ); #endif } var exportButton = textImageButtonFactory.Generate("Export Settings".Localize()); exportButton.Click += (s, e) => UiThread.RunOnIdle(exportButton_Click); exportButton.Visible = true; cancelButton.Visible = true; //Add buttons to buttonContainer footerRow.AddChild(exportButton); footerRow.AddChild(new HorizontalSpacer()); footerRow.AddChild(cancelButton); }
public RadioButton GenerateRadioButton(string label, string iconImageName = null) { ImageBuffer iconImage = null; if (iconImageName != null) { iconImage = new ImageBuffer(); ImageBMPIO.LoadImageData(this.GetImageLocation(iconImageName), iconImage); } BorderDouble internalMargin = new BorderDouble(0); TextImageWidget nomalState = new TextImageWidget(label, normalFillColor, normalBorderColor, normalTextColor, borderWidth, internalMargin, iconImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, width: this.FixedWidth, centerText: true); TextImageWidget hoverState = new TextImageWidget(label, hoverFillColor, hoverBorderColor, hoverTextColor, borderWidth, internalMargin, iconImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, width: this.FixedWidth, centerText: true); TextImageWidget checkingState = new TextImageWidget(label, hoverFillColor, RGBA_Bytes.White, hoverTextColor, borderWidth, internalMargin, iconImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, width: this.FixedWidth, centerText: true); TextImageWidget checkedState = new TextImageWidget(label, pressedFillColor, RGBA_Bytes.White, pressedTextColor, borderWidth, internalMargin, iconImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, width: this.FixedWidth, centerText: true); TextImageWidget disabledState = new TextImageWidget(label, disabledFillColor, disabledBorderColor, disabledTextColor, borderWidth, internalMargin, iconImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, width: this.FixedWidth, centerText: true); RadioButtonViewStates checkBoxButtonViewWidget = new RadioButtonViewStates(nomalState, hoverState, checkingState, checkedState, disabledState); RadioButton radioButton = new RadioButton(checkBoxButtonViewWidget); radioButton.Margin = Margin; return radioButton; }
public ViewControls3D(MeshViewerWidget meshViewerWidget) { if (UserSettings.Instance.DisplayMode == ApplicationDisplayType.Touchscreen) { buttonHeight = 40; } else { buttonHeight = 0; } this.meshViewerWidget = meshViewerWidget; TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory(); textImageButtonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor; BackgroundColor = new RGBA_Bytes(0, 0, 0, 120); textImageButtonFactory.FixedHeight = buttonHeight; textImageButtonFactory.FixedWidth = buttonHeight; textImageButtonFactory.AllowThemeToAdjustImage = false; textImageButtonFactory.checkedBorderColor = RGBA_Bytes.White; string resetViewIconPath = Path.Combine("ViewTransformControls", "reset.png"); resetViewButton = textImageButtonFactory.Generate("", StaticData.Instance.LoadIcon(resetViewIconPath, 32,32).InvertLightness()); resetViewButton.ToolTipText = "Reset View".Localize(); AddChild(resetViewButton); resetViewButton.Click += (sender, e) => { ResetView?.Invoke(this, null); }; string rotateIconPath = Path.Combine("ViewTransformControls", "rotate.png"); rotateButton = textImageButtonFactory.GenerateRadioButton("", StaticData.Instance.LoadIcon(rotateIconPath,32,32)); rotateButton.ToolTipText = "Rotate (Alt + Left Mouse)".Localize(); rotateButton.Margin = new BorderDouble(3); AddChild(rotateButton); rotateButton.Click += (sender, e) => { this.ActiveButton = ViewControls3DButtons.Rotate; }; string translateIconPath = Path.Combine("ViewTransformControls", "translate.png"); translateButton = textImageButtonFactory.GenerateRadioButton("", StaticData.Instance.LoadIcon(translateIconPath,32,32)); translateButton.ToolTipText = "Move (Shift + Left Mouse)".Localize(); translateButton.Margin = new BorderDouble(3); AddChild(translateButton); translateButton.Click += (sender, e) => { this.ActiveButton = ViewControls3DButtons.Translate; }; string scaleIconPath = Path.Combine("ViewTransformControls", "scale.png"); scaleButton = textImageButtonFactory.GenerateRadioButton("", StaticData.Instance.LoadIcon(scaleIconPath,32,32)); scaleButton.ToolTipText = "Zoom (Ctrl + Left Mouse)".Localize(); scaleButton.Margin = new BorderDouble(3); AddChild(scaleButton); scaleButton.Click += (sender, e) => { this.ActiveButton = ViewControls3DButtons.Scale; }; partSelectSeparator = new GuiWidget(2, 32); partSelectSeparator.BackgroundColor = RGBA_Bytes.White; partSelectSeparator.Margin = new BorderDouble(3); AddChild(partSelectSeparator); string partSelectIconPath = Path.Combine("ViewTransformControls", "partSelect.png"); partSelectButton = textImageButtonFactory.GenerateRadioButton("", StaticData.Instance.LoadIcon(partSelectIconPath,32,32)); partSelectButton.ToolTipText = "Select Part".Localize(); partSelectButton.Margin = new BorderDouble(3); AddChild(partSelectButton); partSelectButton.Click += (sender, e) => { this.ActiveButton = ViewControls3DButtons.PartSelect; }; Margin = new BorderDouble(5); HAnchor |= Agg.UI.HAnchor.ParentLeft; VAnchor = Agg.UI.VAnchor.ParentTop; rotateButton.Checked = true; SetMeshViewerDisplayTheme(); partSelectButton.CheckedStateChanged += SetMeshViewerDisplayTheme; ActiveTheme.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents); }
public SelectPartsOfPrinterToImport(string settingsFilePath, PrinterSettingsLayer destinationLayer, string sectionName = null) : base(unlocalizedTextForTitle: "Import Wizard") { this.isMergeIntoUserLayer = destinationLayer == ActiveSliceSettings.Instance.UserLayer; this.destinationLayer = destinationLayer; this.sectionName = sectionName; // TODO: Need to handle load failures for import attempts settingsToImport = PrinterSettings.LoadFile(settingsFilePath); this.headerLabel.Text = "Select What to Import".Localize(); this.settingsFilePath = settingsFilePath; var scrollWindow = new ScrollableWidget() { AutoScroll = true, HAnchor = HAnchor.ParentLeftRight, VAnchor = VAnchor.ParentBottomTop, }; scrollWindow.ScrollArea.HAnchor = HAnchor.ParentLeftRight; contentRow.AddChild(scrollWindow); var container = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.ParentLeftRight, }; scrollWindow.AddChild(container); if (isMergeIntoUserLayer) { container.AddChild(new WrappedTextWidget(importMessage, textColor: ActiveTheme.Instance.PrimaryTextColor)); } // add in the check boxes to select what to import container.AddChild(new TextWidget("Main Settings:") { TextColor = ActiveTheme.Instance.PrimaryTextColor, Margin = new BorderDouble(0, 3, 0, isMergeIntoUserLayer ? 10 : 0), }); var mainProfileRadioButton = new RadioButton("Printer Profile") { TextColor = ActiveTheme.Instance.PrimaryTextColor, Margin = new BorderDouble(5, 0), HAnchor = HAnchor.ParentLeft, Checked = true, }; container.AddChild(mainProfileRadioButton); if (settingsToImport.QualityLayers.Count > 0) { container.AddChild(new TextWidget("Quality Presets:") { TextColor = ActiveTheme.Instance.PrimaryTextColor, Margin = new BorderDouble(0, 3, 0, 15), }); int buttonIndex = 0; foreach (var qualitySetting in settingsToImport.QualityLayers) { RadioButton qualityButton = new RadioButton(qualitySetting.Name) { TextColor = ActiveTheme.Instance.PrimaryTextColor, Margin = new BorderDouble(5, 0, 0, 0), HAnchor = HAnchor.ParentLeft, }; container.AddChild(qualityButton); int localButtonIndex = buttonIndex; qualityButton.CheckedStateChanged += (s, e) => { if (qualityButton.Checked) { selectedQuality = localButtonIndex; } else { selectedQuality = -1; } }; buttonIndex++; } } if (settingsToImport.MaterialLayers.Count > 0) { container.AddChild(new TextWidget("Material Presets:") { TextColor = ActiveTheme.Instance.PrimaryTextColor, Margin = new BorderDouble(0, 3, 0, 15), }); int buttonIndex = 0; foreach (var materialSetting in settingsToImport.MaterialLayers) { RadioButton materialButton = new RadioButton(materialSetting.Name) { TextColor = ActiveTheme.Instance.PrimaryTextColor, Margin = new BorderDouble(5, 0), HAnchor = HAnchor.ParentLeft, }; container.AddChild(materialButton); int localButtonIndex = buttonIndex; materialButton.CheckedStateChanged += (s, e) => { if (materialButton.Checked) { selectedMaterial = localButtonIndex; } else { selectedMaterial = -1; } }; buttonIndex++; } } var mergeButtonTitle = this.isMergeIntoUserLayer ? "Merge".Localize() : "Import".Localize(); var mergeButton = textImageButtonFactory.Generate(mergeButtonTitle); mergeButton.Name = "Merge Profile"; mergeButton.Click += (s, e) => UiThread.RunOnIdle(() => { bool copyName = false; PrinterSettingsLayer sourceLayer = null; if (selectedMaterial > -1) { sourceLayer = settingsToImport.MaterialLayers[selectedMaterial]; copyName = true; } else if (selectedQuality > -1) { sourceLayer = settingsToImport.QualityLayers[selectedQuality]; copyName = true; } List<PrinterSettingsLayer> sourceFilter; if (selectedQuality == -1 && selectedMaterial == -1) { sourceFilter = new List<PrinterSettingsLayer>() { settingsToImport.OemLayer, settingsToImport.UserLayer }; } else { sourceFilter = new List<PrinterSettingsLayer>() { sourceLayer }; } ActiveSliceSettings.Instance.Merge(destinationLayer, settingsToImport, sourceFilter, copyName); this.Parents<SystemWindow>().FirstOrDefault()?.CloseOnIdle(); }); footerRow.AddChild(mergeButton); footerRow.AddChild(new HorizontalSpacer()); footerRow.AddChild(cancelButton); if (settingsToImport.QualityLayers.Count == 0 && settingsToImport.MaterialLayers.Count == 0) { // Only main setting so don't ask what to merge just do it. UiThread.RunOnIdle(() => { var sourceFilter = new List<PrinterSettingsLayer>() { settingsToImport.OemLayer ?? new PrinterSettingsLayer(), settingsToImport.UserLayer ?? new PrinterSettingsLayer() }; ActiveSliceSettings.Instance.Merge(destinationLayer, settingsToImport, sourceFilter, false); UiThread.RunOnIdle(ApplicationController.Instance.ReloadAdvancedControlsPanel); string successMessage = importPrinterSuccessMessage.FormatWith(Path.GetFileNameWithoutExtension(settingsFilePath)); if (!isMergeIntoUserLayer) { string sourceName = isMergeIntoUserLayer ? Path.GetFileNameWithoutExtension(settingsFilePath) : destinationLayer[SettingsKey.layer_name]; successMessage = ImportSettingsPage.importSettingSuccessMessage.FormatWith(sourceName, sectionName); } WizardWindow.ChangeToPage(new ImportSucceeded(successMessage) { WizardWindow = this.WizardWindow, }); }); } }
public ImportSettingsPage() : base("Cancel", "Import Wizard") { var container = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.ParentLeftRight, }; contentRow.AddChild(container); if (true) { container.AddChild(new TextWidget("Merge Into:") { TextColor = ActiveTheme.Instance.PrimaryTextColor, Margin = new BorderDouble(0, 0, 0, 5), }); // merge into current settings mergeButton = new RadioButton("Current".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor); mergeButton.Checked = true; container.AddChild(mergeButton); container.AddChild(new TextWidget("Create New:") { TextColor = ActiveTheme.Instance.PrimaryTextColor, Margin = new BorderDouble(0, 0, 0, 15), }); // add new profile newPrinterButton = new RadioButton("Printer".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor); container.AddChild(newPrinterButton); // add as quality preset newQualityPresetButton = new RadioButton("Quality preset".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor); container.AddChild(newQualityPresetButton); // add as material preset newMaterialPresetButton = new RadioButton("Material preset".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor); container.AddChild(newMaterialPresetButton); } else { // add new profile newPrinterButton = new RadioButton("Import as new printer profile".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor); newPrinterButton.Checked = true; container.AddChild(newPrinterButton); container.AddChild( CreateDetailInfo("Add a new printer profile to your list of available printers.\nThis will not change your current settings.") ); // merge into current settings mergeButton = new RadioButton("Merge into current printer profile".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor); container.AddChild(mergeButton); container.AddChild( CreateDetailInfo("Merge settings and presets (if any) into your current profile. \nYou will still be able to revert to the factory settings at any time.") ); // add as quality preset newQualityPresetButton = new RadioButton("Import settings as new QUALITY preset".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor); container.AddChild(newQualityPresetButton); container.AddChild( CreateDetailInfo("Add new quality preset with the settings from this import.") ); // add as material preset newMaterialPresetButton = new RadioButton("Import settings as new MATERIAL preset".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor); container.AddChild(newMaterialPresetButton); container.AddChild( CreateDetailInfo("Add new material preset with the settings from this import.") ); } var importButton = textImageButtonFactory.Generate("Choose File".Localize()); importButton.Click += (s, e) => UiThread.RunOnIdle(() => { FileDialog.OpenFileDialog( new OpenFileDialogParams("settings files|*.ini;*.printer;*.slice"), (dialogParams) => { if (!string.IsNullOrEmpty(dialogParams.FileName)) { ImportSettingsFile(dialogParams.FileName); } }); }); importButton.Visible = true; cancelButton.Visible = true; //Add buttons to buttonContainer footerRow.AddChild(importButton); footerRow.AddChild(new HorizontalSpacer()); footerRow.AddChild(cancelButton); }
public GuiWidget GetBaudRateWidget() { FlowLayoutWidget baudRateContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); baudRateContainer.Margin = new BorderDouble(0); List<string> baudRates = new List<string> { "115200", "250000" }; BorderDouble baudRateMargin = new BorderDouble(3, 3, 5, 0); foreach (string baudRate in baudRates) { BaudRateRadioButton baudOption = new BaudRateRadioButton(baudRate); BaudRateButtonsList.Add(baudOption); baudOption.Margin = baudRateMargin; baudOption.TextColor = ActiveTheme.Instance.PrimaryTextColor; if (this.ActivePrinter.BaudRate == baudRate) { baudOption.Checked = true; } baudRateContainer.AddChild(baudOption); } otherBaudRateRadioButton = new RadioButton(LocalizedString.Get("Other")); otherBaudRateRadioButton.Margin = baudRateMargin; otherBaudRateRadioButton.TextColor = ActiveTheme.Instance.PrimaryTextColor; baudRateContainer.AddChild(otherBaudRateRadioButton); //See if the baud rate of the current print is in the list of displayed rates, //flag the 'other' option if it is not and prefill the rate. otherBaudRateInput = new MHTextEditWidget(""); otherBaudRateInput.Visible = false; otherBaudRateInput.HAnchor = HAnchor.ParentLeftRight; if (this.ActivePrinter.BaudRate != null) { if (!baudRates.Contains(this.ActivePrinter.BaudRate.ToString())) { otherBaudRateRadioButton.Checked = true; otherBaudRateInput.Text = this.ActivePrinter.BaudRate.ToString(); otherBaudRateInput.Visible = true; } } baudRateContainer.AddChild(otherBaudRateInput); return baudRateContainer; }
public RadioButton AddRadioButton(string text) { RadioButton newRadioButton = new RadioButton(text); newRadioButton.Margin = new BorderDouble(5, 0); newRadioButton.HAnchor = UI.HAnchor.ParentLeft; radioButtons.Add(newRadioButton); AddChild(newRadioButton); return newRadioButton; }
private void AddMaterialControls(FlowLayoutWidget buttonPanel) { extruderButtons.Clear(); for (int extruderIndex = 0; extruderIndex < ActiveSliceSettings.Instance.ExtruderCount; extruderIndex++) { FlowLayoutWidget colorSelectionContainer = new FlowLayoutWidget(FlowDirection.LeftToRight); colorSelectionContainer.HAnchor = HAnchor.ParentLeftRight; colorSelectionContainer.Padding = new BorderDouble(5); string colorLabelText = "Extruder {0}".Localize().FormatWith(extruderIndex + 1); RadioButton extruderSelection = new RadioButton(colorLabelText, textColor: ActiveTheme.Instance.PrimaryTextColor); extruderButtons.Add(extruderSelection); extruderSelection.SiblingRadioButtonList = extruderButtons; colorSelectionContainer.AddChild(extruderSelection); colorSelectionContainer.AddChild(new HorizontalSpacer()); int extruderIndexLocal = extruderIndex; extruderSelection.Click += (sender, e) => { if (SelectedMeshGroupIndex != -1) { foreach (Mesh mesh in SelectedMeshGroup.Meshes) { MeshMaterialData material = MeshMaterialData.Get(mesh); if (material.MaterialIndex != extruderIndexLocal + 1) { material.MaterialIndex = extruderIndexLocal + 1; PartHasBeenChanged(); } } } }; this.SelectionChanged += (sender, e) => { if (SelectedMeshGroup != null) { Mesh mesh = SelectedMeshGroup.Meshes[0]; MeshMaterialData material = MeshMaterialData.Get(mesh); for (int i = 0; i < extruderButtons.Count; i++) { if (material.MaterialIndex - 1 == i) { ((RadioButton)extruderButtons[i]).Checked = true; } } } }; #if false // no color swatch for this build GuiWidget colorSwatch = new GuiWidget(15,15); colorSwatch.Draw += (sender, e) => { DrawEventArgs drawEvent = e as DrawEventArgs; GuiWidget widget = sender as GuiWidget; if(widget != null && drawEvent != null && drawEvent.graphics2D != null) { drawEvent.graphics2D.Rectangle(widget.LocalBounds, RGBA_Bytes.Black); } }; colorSwatch.BackgroundColor = MeshViewerWidget.GetMaterialColor(extruderIndexLocal+1); Button swatchButton = new Button(0, 0, colorSwatch); swatchButton.Click += (sender, e) => { nextColor++; RGBA_Bytes color = SelectionColors[nextColor % SelectionColors.Length]; MeshViewerWidget.SetMaterialColor(extruderIndexLocal+1, color); colorSwatch.BackgroundColor = color; }; colorSelectionContainer.AddChild(swatchButton); #endif buttonPanel.AddChild(colorSelectionContainer); } }
public ViewControls2D() { if (UserSettings.Instance.DisplayMode == ApplicationDisplayType.Touchscreen) { buttonHeight = 40; } else { buttonHeight = 0; } TextImageButtonFactory iconTextImageButtonFactory = new TextImageButtonFactory(); iconTextImageButtonFactory.AllowThemeToAdjustImage = false; iconTextImageButtonFactory.checkedBorderColor = RGBA_Bytes.White; BackgroundColor = new RGBA_Bytes(0, 0, 0, 120); iconTextImageButtonFactory.FixedHeight = buttonHeight; iconTextImageButtonFactory.FixedWidth = buttonHeight; string resetViewIconPath = Path.Combine("ViewTransformControls", "reset.png"); resetViewButton = iconTextImageButtonFactory.Generate("", StaticData.Instance.LoadIcon(resetViewIconPath,32,32).InvertLightness()); resetViewButton.ToolTipText = "Reset View".Localize(); AddChild(resetViewButton); resetViewButton.Click += (sender, e) => { ResetView?.Invoke(this, null); }; string translateIconPath = Path.Combine("ViewTransformControls", "translate.png"); translateButton = iconTextImageButtonFactory.GenerateRadioButton("", StaticData.Instance.LoadIcon(translateIconPath,32,32)); translateButton.ToolTipText = "Move".Localize(); translateButton.Margin = new BorderDouble(3); AddChild(translateButton); string scaleIconPath = Path.Combine("ViewTransformControls", "scale.png"); scaleButton = iconTextImageButtonFactory.GenerateRadioButton("", StaticData.Instance.LoadIcon(scaleIconPath,32,32)); scaleButton.ToolTipText = "Zoom".Localize(); scaleButton.Margin = new BorderDouble(3); AddChild(scaleButton); Margin = new BorderDouble(5); HAnchor |= Agg.UI.HAnchor.ParentLeft; VAnchor = Agg.UI.VAnchor.ParentTop; translateButton.Checked = true; }
public MatterCadWidget() { SuspendLayout(); verticleSpliter = new Splitter(); { // pannel 1 stuff textSide = new FlowLayoutWidget(FlowDirection.TopToBottom); { matterScriptEditor = new TextEditWidget("", pixelWidth: 300, pixelHeight: 500, multiLine: true); matterScriptEditor.ShowBounds = true; //matterScriptEditor.LocalBounds = new rect_d(0, 0, 200, 300); textSide.AddChild(matterScriptEditor); textSide.Resize += new ResizeEventHandler(textSide_Resize); FlowLayoutWidget buttonBar = new FlowLayoutWidget(); { Button loadFile = new Button("Load Matter Script"); loadFile.Click += new ButtonBase.ButtonEventHandler(loadFile_Click); buttonBar.AddChild(loadFile); runMatterScript = new Button("Run Matter Script"); runMatterScript.Click += new ButtonBase.ButtonEventHandler(runMatterScript_Click); buttonBar.AddChild(runMatterScript); outputScad = new Button("Output SCAD"); outputScad.Click += new ButtonBase.ButtonEventHandler(outputScad_Click); buttonBar.AddChild(outputScad); } textSide.AddChild(buttonBar); } // pannel 2 stuff FlowLayoutWidget rightStuff = new FlowLayoutWidget(FlowDirection.TopToBottom); { previewWindowRayTrace = new PreviewWindowRayTrace(); rightStuff.AddChild(previewWindowRayTrace); previewWindowGL = new PreviewWindowGL(); previewWindowGL.DrawGlContent += new PreviewWindowGL.DrawGlContentEventHandler(glLightedView_DrawGlContent); rightStuff.AddChild(previewWindowGL); FlowLayoutWidget radioButtons = new FlowLayoutWidget(); { RadioButton rayTrace = new RadioButton("Ray Trace"); radioButtons.AddChild(rayTrace); RadioButton openGL = new RadioButton("OpenGL"); radioButtons.AddChild(openGL); rayTrace.CheckedStateChanged += new RadioButton.CheckedStateChangedEventHandler(rayTrace_CheckedStateChanged); openGL.CheckedStateChanged += new RadioButton.CheckedStateChangedEventHandler(openGL_CheckedStateChanged); //rayTrace.Checked = true; openGL.Checked = true; } rightStuff.AddChild(radioButtons); } verticleSpliter.Panel2.AddChild(rightStuff); verticleSpliter.Panel1.AddChild(textSide); } ResumeLayout(); AddChild(verticleSpliter); }
public ViewControls3D(MeshViewerWidget meshViewerWidget) { if (ActiveTheme.Instance.DisplayMode == ActiveTheme.ApplicationDisplayType.Touchscreen) { buttonHeight = 40; } else { buttonHeight = 20; } this.meshViewerWidget = meshViewerWidget; TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory(); textImageButtonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor; BackgroundColor = new RGBA_Bytes(0, 0, 0, 120); textImageButtonFactory.FixedHeight = buttonHeight; textImageButtonFactory.FixedWidth = buttonHeight; textImageButtonFactory.AllowThemeToAdjustImage = false; textImageButtonFactory.checkedBorderColor = RGBA_Bytes.White; string rotateIconPath = Path.Combine("ViewTransformControls", "rotate.png"); rotateButton = textImageButtonFactory.GenerateRadioButton("", rotateIconPath); rotateButton.Margin = new BorderDouble(3); AddChild(rotateButton); rotateButton.Click += (sender, e) => { meshViewerWidget.TrackballTumbleWidget.TransformState = TrackBallController.MouseDownType.Rotation; }; string translateIconPath = Path.Combine("ViewTransformControls", "translate.png"); translateButton = textImageButtonFactory.GenerateRadioButton("", translateIconPath); translateButton.Margin = new BorderDouble(3); AddChild(translateButton); translateButton.Click += (sender, e) => { meshViewerWidget.TrackballTumbleWidget.TransformState = TrackBallController.MouseDownType.Translation; }; string scaleIconPath = Path.Combine("ViewTransformControls", "scale.png"); scaleButton = textImageButtonFactory.GenerateRadioButton("", scaleIconPath); scaleButton.Margin = new BorderDouble(3); AddChild(scaleButton); scaleButton.Click += (sender, e) => { meshViewerWidget.TrackballTumbleWidget.TransformState = TrackBallController.MouseDownType.Scale; }; partSelectSeparator = new GuiWidget(2, 32); partSelectSeparator.BackgroundColor = RGBA_Bytes.White; partSelectSeparator.Margin = new BorderDouble(3); AddChild(partSelectSeparator); string partSelectIconPath = Path.Combine("ViewTransformControls", "partSelect.png"); partSelectButton = textImageButtonFactory.GenerateRadioButton("", partSelectIconPath); partSelectButton.Margin = new BorderDouble(3); AddChild(partSelectButton); partSelectButton.Click += (sender, e) => { meshViewerWidget.TrackballTumbleWidget.TransformState = TrackBallController.MouseDownType.None; }; Margin = new BorderDouble(5); HAnchor |= Agg.UI.HAnchor.ParentLeft; VAnchor = Agg.UI.VAnchor.ParentTop; rotateButton.Checked = true; SetMeshViewerDisplayTheme(); partSelectButton.CheckedStateChanged += SetMeshViewerDisplayTheme; ActiveTheme.Instance.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents); }
private void CreateRenderTypeRadioButtons(FlowLayoutWidget viewOptionContainer) { string renderTypeString = UserSettings.Instance.get("defaultRenderSetting"); if (renderTypeString == null) { if (ActiveTheme.Instance.DisplayMode == ActiveTheme.ApplicationDisplayType.Touchscreen) { renderTypeString = "Shaded"; } else { renderTypeString = "Outlines"; } UserSettings.Instance.set("defaultRenderSetting", renderTypeString); } RenderOpenGl.RenderTypes renderType; bool canParse = Enum.TryParse<RenderOpenGl.RenderTypes>(renderTypeString, out renderType); if (canParse) { meshViewerWidget.RenderType = renderType; } { RadioButton renderTypeShaded = new RadioButton("Shaded".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor); renderTypeShaded.Checked = (meshViewerWidget.RenderType == RenderTypes.Shaded); renderTypeShaded.CheckedStateChanged += (sender, e) => { meshViewerWidget.RenderType = RenderTypes.Shaded; UserSettings.Instance.set("defaultRenderSetting", meshViewerWidget.RenderType.ToString()); }; viewOptionContainer.AddChild(renderTypeShaded); } { RadioButton renderTypeOutlines = new RadioButton("Outlines".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor); renderTypeOutlines.Checked = (meshViewerWidget.RenderType == RenderTypes.Outlines); renderTypeOutlines.CheckedStateChanged += (sender, e) => { meshViewerWidget.RenderType = RenderTypes.Outlines; UserSettings.Instance.set("defaultRenderSetting", meshViewerWidget.RenderType.ToString()); }; viewOptionContainer.AddChild(renderTypeOutlines); } { RadioButton renderTypePolygons = new RadioButton("Polygons".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor); renderTypePolygons.Checked = (meshViewerWidget.RenderType == RenderTypes.Polygons); renderTypePolygons.CheckedStateChanged += (sender, e) => { meshViewerWidget.RenderType = RenderTypes.Polygons; UserSettings.Instance.set("defaultRenderSetting", meshViewerWidget.RenderType.ToString()); }; viewOptionContainer.AddChild(renderTypePolygons); } }
private void AddMaterialControls(FlowLayoutWidget buttonPanel) { extruderButtons.Clear(); for (int extruderIndex = 0; extruderIndex < ActiveSliceSettings.Instance.ExtruderCount; extruderIndex++) { FlowLayoutWidget colorSelectionContainer = new FlowLayoutWidget(FlowDirection.LeftToRight); colorSelectionContainer.HAnchor = HAnchor.ParentLeftRight; colorSelectionContainer.Padding = new BorderDouble(5); string colorLabelText = "Extruder {0}".Localize().FormatWith(extruderIndex + 1); RadioButton extruderSelection = new RadioButton(colorLabelText, textColor: ActiveTheme.Instance.PrimaryTextColor); extruderButtons.Add(extruderSelection); extruderSelection.SiblingRadioButtonList = extruderButtons; colorSelectionContainer.AddChild(extruderSelection); colorSelectionContainer.AddChild(new HorizontalSpacer()); int extruderIndexLocal = extruderIndex; extruderSelection.Click += (sender, e) => { if (SelectedMeshGroupIndex != -1) { foreach (Mesh mesh in SelectedMeshGroup.Meshes) { MeshMaterialData material = MeshMaterialData.Get(mesh); if (material.MaterialIndex != extruderIndexLocal + 1) { material.MaterialIndex = extruderIndexLocal + 1; PartHasBeenChanged(); } } } }; this.SelectionChanged += (sender, e) => { if (SelectedMeshGroup != null) { Mesh mesh = SelectedMeshGroup.Meshes[0]; MeshMaterialData material = MeshMaterialData.Get(mesh); for (int i = 0; i < extruderButtons.Count; i++) { if (material.MaterialIndex - 1 == i) { ((RadioButton)extruderButtons[i]).Checked = true; } } } }; buttonPanel.AddChild(colorSelectionContainer); } }
private async void LoadHistoryItems() { TextWidget loadingText = new TextWidget("Retrieving History from Web..."); loadingText.TextColor = ActiveTheme.Instance.PrimaryTextColor; scrollWindow.AddChild(loadingText); var results = await ApplicationController.GetProfileHistory(ProfileManager.Instance.ActiveProfile.DeviceToken); printerProfileData = results; if(printerProfileData != null) { loadingText.Visible= false; List<DateTime> sourceTimes = new List<DateTime>(); foreach (var printerProfile in results.OrderByDescending(d => d.Key)) { // AppEngine results are current in the form of: "2016-07-21 00:43:30.965830" sourceTimes.Add(Convert.ToDateTime(printerProfile.Key).ToLocalTime()); } var groupedTimes = RelativeTime.GroupTimes(DateTime.Now, sourceTimes); FlowLayoutWidget topToBottomStuff = new FlowLayoutWidget(FlowDirection.TopToBottom); scrollWindow.AddChild(topToBottomStuff); foreach (var group in groupedTimes) { // add in the group header topToBottomStuff.AddChild(new TextWidget(RelativeTime.BlockDescriptions[group.Key], textColor: ActiveTheme.Instance.PrimaryTextColor) { Margin = new BorderDouble(0, 0, 0, 5), }); foreach (var time in group.Value) { // add in the radio buttons var profileVersionButton = new RadioButton(time.Value, textColor: ActiveTheme.Instance.PrimaryTextColor) { Margin = new BorderDouble(5, 0), }; profileVersionButton.Checked = false; radioButtonList.Add(profileVersionButton); topToBottomStuff.AddChild(profileVersionButton); } } foreach(var printerProfile in results) { orderedProfiles.Add(printerProfile.Key.ToString()); } } else { loadingText.Text = "Failed To Download History!"; loadingText.TextColor = RGBA_Bytes.Red; } //remove loading profile text/icon }
public RadioButton GenerateRadioButton(string label, string iconImageName = null) { ImageBuffer iconImage = null; if (iconImageName != null) { iconImage = StaticData.Instance.LoadIcon(iconImageName); if (!ActiveTheme.Instance.IsDarkTheme && AllowThemeToAdjustImage) { InvertLightness.DoInvertLightness(iconImage); } } BorderDouble internalMargin = new BorderDouble(0); TextImageWidget nomalState = new TextImageWidget(label, normalFillColor, normalBorderColor, normalTextColor, borderWidth, internalMargin, iconImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, width: this.FixedWidth, centerText: true); TextImageWidget hoverState = new TextImageWidget(label, hoverFillColor, hoverBorderColor, hoverTextColor, borderWidth, internalMargin, iconImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, width: this.FixedWidth, centerText: true); TextImageWidget checkingState = new TextImageWidget(label, hoverFillColor, checkedBorderColor, hoverTextColor, borderWidth, internalMargin, iconImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, width: this.FixedWidth, centerText: true); TextImageWidget checkedState = new TextImageWidget(label, pressedFillColor, checkedBorderColor, pressedTextColor, borderWidth, internalMargin, iconImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, width: this.FixedWidth, centerText: true); TextImageWidget disabledState = new TextImageWidget(label, disabledFillColor, disabledBorderColor, disabledTextColor, borderWidth, internalMargin, iconImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, width: this.FixedWidth, centerText: true); RadioButtonViewStates checkBoxButtonViewWidget = new RadioButtonViewStates(nomalState, hoverState, checkingState, checkedState, disabledState); RadioButton radioButton = new RadioButton(checkBoxButtonViewWidget); radioButton.Margin = Margin; return radioButton; }
void AddViewControls() { FlowLayoutWidget transformTypeSelector = new FlowLayoutWidget(); transformTypeSelector.BackgroundColor = new RGBA_Bytes(0, 0, 0, 120); textImageButtonFactory.FixedHeight = 20; textImageButtonFactory.FixedWidth = 20; string rotateIconPath = Path.Combine("Icons", "ViewTransformControls", "rotate.png"); rotateViewButton = textImageButtonFactory.GenerateRadioButton("", rotateIconPath); rotateViewButton.Margin = new BorderDouble(3); transformTypeSelector.AddChild(rotateViewButton); rotateViewButton.Click += (sender, e) => { meshViewerWidget.TrackballTumbleWidget.TransformState = TrackBallController.MouseDownType.Rotation; }; string translateIconPath = Path.Combine("Icons", "ViewTransformControls", "translate.png"); RadioButton translateButton = textImageButtonFactory.GenerateRadioButton("", translateIconPath); translateButton.Margin = new BorderDouble(3); transformTypeSelector.AddChild(translateButton); translateButton.Click += (sender, e) => { meshViewerWidget.TrackballTumbleWidget.TransformState = TrackBallController.MouseDownType.Translation; }; string scaleIconPath = Path.Combine("Icons", "ViewTransformControls", "scale.png"); RadioButton scaleButton = textImageButtonFactory.GenerateRadioButton("", scaleIconPath); scaleButton.Margin = new BorderDouble(3); transformTypeSelector.AddChild(scaleButton); scaleButton.Click += (sender, e) => { meshViewerWidget.TrackballTumbleWidget.TransformState = TrackBallController.MouseDownType.Scale; }; viewControlsSeparator = new GuiWidget(2, 32); viewControlsSeparator.Visible = false; viewControlsSeparator.BackgroundColor = RGBA_Bytes.White; viewControlsSeparator.Margin = new BorderDouble(3); transformTypeSelector.AddChild(viewControlsSeparator); string partSelectIconPath = Path.Combine("Icons", "ViewTransformControls", "partSelect.png"); partSelectButton = textImageButtonFactory.GenerateRadioButton("", partSelectIconPath); partSelectButton.Visible = false; partSelectButton.Margin = new BorderDouble(3); transformTypeSelector.AddChild(partSelectButton); partSelectButton.Click += (sender, e) => { meshViewerWidget.TrackballTumbleWidget.TransformState = TrackBallController.MouseDownType.None; }; transformTypeSelector.Margin = new BorderDouble(5); transformTypeSelector.HAnchor |= Agg.UI.HAnchor.ParentLeft; transformTypeSelector.VAnchor = Agg.UI.VAnchor.ParentTop; AddChild(transformTypeSelector); rotateViewButton.Checked = true; }