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; }
protected void Add2DViewControls() { TextImageButtonFactory iconTextImageButtonFactory = new TextImageButtonFactory(); iconTextImageButtonFactory.AllowThemeToAdjustImage = false; FlowLayoutWidget transformTypeSelector = new FlowLayoutWidget(); transformTypeSelector.BackgroundColor = new RGBA_Bytes(0, 0, 0, 120); iconTextImageButtonFactory.FixedHeight = 20; iconTextImageButtonFactory.FixedWidth = 20; string translateIconPath = Path.Combine("Icons", "ViewTransformControls", "translate.png"); translateButton = iconTextImageButtonFactory.GenerateRadioButton("", translateIconPath); translateButton.Margin = new BorderDouble(3); transformTypeSelector.AddChild(translateButton); string scaleIconPath = Path.Combine("Icons", "ViewTransformControls", "scale.png"); scaleButton = iconTextImageButtonFactory.GenerateRadioButton("", scaleIconPath); scaleButton.Margin = new BorderDouble(3); transformTypeSelector.AddChild(scaleButton); transformTypeSelector.Margin = new BorderDouble(5); transformTypeSelector.HAnchor |= Agg.UI.HAnchor.ParentLeft; transformTypeSelector.VAnchor = Agg.UI.VAnchor.ParentTop; AddChild(transformTypeSelector); translateButton.Checked = true; }
public PrintActionRow(QueueDataView queueDataView) { this.HAnchor = HAnchor.ParentLeftRight; textImageButtonFactory = new TextImageButtonFactory() { normalTextColor = RGBA_Bytes.White, disabledTextColor = RGBA_Bytes.LightGray, hoverTextColor = RGBA_Bytes.White, pressedTextColor = RGBA_Bytes.White, AllowThemeToAdjustImage = false, borderWidth = 1, FixedHeight = 52 * GuiWidget.DeviceScale, fontSize = 14, normalBorderColor = new RGBA_Bytes(255, 255, 255, 100), hoverBorderColor = new RGBA_Bytes(255, 255, 255, 100) }; this.queueDataView = queueDataView; AddChildElements(); // Add Handlers PrinterConnectionAndCommunication.Instance.ActivePrintItemChanged.RegisterEvent(onStateChanged, ref unregisterEvents); PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(onStateChanged, ref unregisterEvents); ProfileManager.ProfilesListChanged.RegisterEvent(onStateChanged, ref unregisterEvents); }
private FlowLayoutWidget GetBottomRow(TextImageButtonFactory buttonFactory) { var container = new FlowLayoutWidget() { HAnchor = HAnchor.ParentLeftRight, Margin = new BorderDouble(top: 3) }; Button duplicateButton = buttonFactory.Generate("Duplicate".Localize()); duplicateButton.Click += (s, e) => { UiThread.RunOnIdle(() => { string sanitizedName = numberMatch.Replace(presetNameInput.Text, "").Trim(); string newProfileName = GetNonCollidingName(sanitizedName, presetsContext.PresetLayers.Select(preset => preset.ValueOrDefault(SettingsKey.layer_name))); var clonedLayer = presetsContext.PersistenceLayer.Clone(); clonedLayer.Name = newProfileName; presetsContext.PresetLayers.Add(clonedLayer); presetsContext.SetAsActive(clonedLayer.LayerID); presetsContext.PersistenceLayer = clonedLayer; middleRow.CloseAllChildren(); middleRow.AddChild(CreateSliceSettingsWidget(clonedLayer)); presetNameInput.Text = newProfileName; }); }; Button deleteButton = buttonFactory.Generate("Delete".Localize()); deleteButton.Click += (s, e) => { UiThread.RunOnIdle(() => { presetsContext.DeleteLayer(); this.Close(); }); }; Button closeButton = buttonFactory.Generate("Close".Localize()); closeButton.Click += (sender, e) => { this.CloseOnIdle(); }; container.AddChild(duplicateButton); container.AddChild(deleteButton); container.AddChild(new HorizontalSpacer()); container.AddChild(closeButton); return(container); }
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 ViewControls2D() { if (UserSettings.Instance.IsTouchScreen) { 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 * GuiWidget.DeviceScale; iconTextImageButtonFactory.FixedWidth = buttonHeight * GuiWidget.DeviceScale; 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 ViewControls2D() { if (ActiveTheme.Instance.DisplayMode == ActiveTheme.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("", resetViewIconPath); 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("", translateIconPath); translateButton.ToolTipText = "Move".Localize(); translateButton.Margin = new BorderDouble(3); AddChild(translateButton); string scaleIconPath = Path.Combine("ViewTransformControls", "scale.png"); scaleButton = iconTextImageButtonFactory.GenerateRadioButton("", scaleIconPath); 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 SlicePresetListWidget(SlicePresetsWindow windowController) { this.windowController = windowController; this.AnchorAll(); linkButtonFactory = new LinkButtonFactory(); buttonFactory = new TextImageButtonFactory(); buttonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor; buttonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor; buttonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryTextColor; buttonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor; buttonFactory.borderWidth = 0; AddElements(); }
public SlicePresetListWidget(SlicePresetsWindow windowController) { this.windowController = windowController; this.AnchorAll(); linkButtonFactory = new LinkButtonFactory(); buttonFactory = new TextImageButtonFactory(); buttonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor; buttonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor; buttonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryTextColor; buttonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor; buttonFactory.borderWidth = 0; AddElements(); AddHandlers(); }
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 SlicePresetsWindow(PresetsContext presetsContext) : base(641, 481) { this.presetsContext = presetsContext; this.AlwaysOnTopOfMain = true; this.Title = LocalizedString.Get("Slice Presets Editor"); this.MinimumSize = new Vector2(640, 480); this.AnchorAll(); var linkButtonFactory = new LinkButtonFactory() { fontSize = 8, textColor = ActiveTheme.Instance.SecondaryAccentColor }; var buttonFactory = new TextImageButtonFactory() { normalTextColor = ActiveTheme.Instance.PrimaryTextColor, hoverTextColor = ActiveTheme.Instance.PrimaryTextColor, disabledTextColor = ActiveTheme.Instance.PrimaryTextColor, pressedTextColor = ActiveTheme.Instance.PrimaryTextColor, borderWidth = 0 }; FlowLayoutWidget mainContainer = new FlowLayoutWidget(FlowDirection.TopToBottom) { Padding = new BorderDouble(3) }; mainContainer.AnchorAll(); middleRow = new GuiWidget(); middleRow.AnchorAll(); middleRow.AddChild(CreateSliceSettingsWidget(presetsContext.PersistenceLayer)); mainContainer.AddChild(GetTopRow()); mainContainer.AddChild(middleRow); mainContainer.AddChild(GetBottomRow(buttonFactory)); this.AddChild(mainContainer); BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; }
public SlicePresetDetailWidget(SlicePresetsWindow windowController) { this.windowController = windowController; this.AnchorAll(); if (this.windowController.ActivePresetLayer == null) { initSlicePreset(); } linkButtonFactory.fontSize = 10; linkButtonFactory.textColor = ActiveTheme.Instance.SecondaryAccentColor; buttonFactory = new TextImageButtonFactory(); buttonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor; buttonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor; buttonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryTextColor; buttonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor; buttonFactory.borderWidth = 0; AddElements(); AddHandlers(); }
public SlicePresetDetailWidget(SlicePresetsWindow windowController) { this.windowController = windowController; this.AnchorAll(); if (this.windowController.ActivePresetLayer == null) { initSlicePreset(); } linkButtonFactory.fontSize = 8; linkButtonFactory.textColor = ActiveTheme.Instance.SecondaryAccentColor; buttonFactory = new TextImageButtonFactory(); buttonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor; buttonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor; buttonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryTextColor; buttonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor; buttonFactory.borderWidth = 0; AddElements(); AddHandlers(); }
void AddViewControls() { TextImageButtonFactory iconTextImageButtonFactory = new TextImageButtonFactory(); FlowLayoutWidget transformTypeSelector = new FlowLayoutWidget(); transformTypeSelector.BackgroundColor = new RGBA_Bytes(0, 0, 0, 120); iconTextImageButtonFactory.FixedHeight = 20; iconTextImageButtonFactory.FixedWidth = 20; string translateIconPath = Path.Combine("Icons", "ViewTransformControls", "translate.png"); RadioButton translateButton = iconTextImageButtonFactory.GenerateRadioButton("", translateIconPath); translateButton.Margin = new BorderDouble(3); transformTypeSelector.AddChild(translateButton); translateButton.Click += (sender, e) => { gcodeViewWidget.TransformState = GCodeViewWidget.ETransformState.Move; }; string scaleIconPath = Path.Combine("Icons", "ViewTransformControls", "scale.png"); RadioButton scaleButton = iconTextImageButtonFactory.GenerateRadioButton("", scaleIconPath); scaleButton.Margin = new BorderDouble(3); transformTypeSelector.AddChild(scaleButton); scaleButton.Click += (sender, e) => { gcodeViewWidget.TransformState = GCodeViewWidget.ETransformState.Scale; }; transformTypeSelector.Margin = new BorderDouble(5); transformTypeSelector.HAnchor |= Agg.UI.HAnchor.ParentLeft; transformTypeSelector.VAnchor = Agg.UI.VAnchor.ParentTop; AddChild(transformTypeSelector); translateButton.Checked = true; }
protected void AddChildElements() { actionBarButtonFactory.invertImageLocation = false; actionBarButtonFactory.borderWidth = 1; if (ActiveTheme.Instance.IsDarkTheme) { actionBarButtonFactory.normalBorderColor = new RGBA_Bytes(77, 77, 77); } else { actionBarButtonFactory.normalBorderColor = new RGBA_Bytes(190, 190, 190); } actionBarButtonFactory.hoverBorderColor = new RGBA_Bytes(128, 128, 128); // connect and disconnect buttons { connectPrinterButton = actionBarButtonFactory.Generate("Connect".Localize().ToUpper(), "icon_power_32x32.png"); connectPrinterButton.Name = "Connect to printer button"; connectPrinterButton.ToolTipText = "Connect to the currently selected printer".Localize(); connectPrinterButton.Margin = new BorderDouble(6, 0, 3, 3); connectPrinterButton.VAnchor = VAnchor.ParentTop; connectPrinterButton.Cursor = Cursors.Hand; connectPrinterButton.Click += (s, e) => { Button buttonClicked = ((Button)s); if (buttonClicked.Enabled) { if (ActiveSliceSettings.Instance.PrinterSelected) { UserRequestedConnectToActivePrinter(); } } }; disconnectPrinterButton = actionBarButtonFactory.Generate("Disconnect".Localize().ToUpper(), "icon_power_32x32.png"); disconnectPrinterButton.ToolTipText = "Disconnect from current printer".Localize(); disconnectPrinterButton.Margin = new BorderDouble(6, 0, 3, 3); disconnectPrinterButton.VAnchor = VAnchor.ParentTop; disconnectPrinterButton.Cursor = Cursors.Hand; disconnectPrinterButton.Click += (s, e) => UiThread.RunOnIdle(OnIdleDisconnect); actionBarButtonFactory.invertImageLocation = true; this.AddChild(connectPrinterButton); this.AddChild(disconnectPrinterButton); } // printer selector and edit button { GuiWidget container = new GuiWidget() { HAnchor = HAnchor.ParentLeftRight, VAnchor = VAnchor.FitToChildren, }; FlowLayoutWidget printerSelectorAndEditButton = new FlowLayoutWidget() { HAnchor = HAnchor.ParentLeftRight, }; printerSelector = new PrinterSelector() { HAnchor = HAnchor.ParentLeftRight, Cursor = Cursors.Hand, Margin = new BorderDouble(0, 6, 0, 3) }; printerSelector.AddPrinter += (s, e) => WizardWindow.ShowPrinterSetup(true); // make sure the control can get smaller but maintains its height printerSelector.MinimumSize = new Vector2(0, connectPrinterButton.MinimumSize.y); printerSelectorAndEditButton.AddChild(printerSelector); editPrinterButton = TextImageButtonFactory.GetThemedEditButton(); editPrinterButton.Name = "Edit Printer Button"; editPrinterButton.VAnchor = VAnchor.ParentCenter; editPrinterButton.Click += UiNavigation.OpenEditPrinterWizard_Click; printerSelectorAndEditButton.AddChild(editPrinterButton); container.AddChild(printerSelectorAndEditButton); printerSelectorAndEditOverlay = new GuiWidget() { HAnchor = HAnchor.ParentLeftRight, VAnchor = VAnchor.ParentBottomTop, Selectable = false, }; container.AddChild(printerSelectorAndEditOverlay); this.AddChild(container); } // reset connection button { string resetConnectionText = "Reset\nConnection".Localize().ToUpper(); Button resetConnectionButton = actionBarButtonFactory.Generate(resetConnectionText, "e_stop4.png"); resetConnectionButton.Margin = new BorderDouble(6, 0, 3, 3); this.AddChild(resetConnectionButton); resetConnectionButton.Click += new EventHandler((s, e) => PrinterConnectionAndCommunication.Instance.RebootBoard()); resetConnectionButton.Visible = ActiveSliceSettings.Instance.GetValue <bool>(SettingsKey.show_reset_connection); SliceSettingsWidget.SettingChanged.RegisterEvent((sender, e) => { StringEventArgs stringEvent = e as StringEventArgs; if (stringEvent != null) { if (stringEvent.Data == SettingsKey.show_reset_connection) { resetConnectionButton.Visible = ActiveSliceSettings.Instance.GetValue <bool>(SettingsKey.show_reset_connection); } } }, ref unregisterEvents); } // Bind connect button states to active printer state this.SetConnectionButtonVisibleState(); ActiveSliceSettings.ActivePrinterChanged.RegisterEvent(onActivePrinterChanged, ref unregisterEvents); PrinterConnectionAndCommunication.Instance.EnableChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents); PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents); }
public void doLayout() { this.RemoveAllChildren(); TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory(); FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); topToBottom.Padding = new BorderDouble(10); topToBottom.AnchorAll(); TextWidget exportLabel = new TextWidget("File export options:"); exportLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor; topToBottom.AddChild(exportLabel); GuiWidget dividerLine = new GuiWidget(); dividerLine.HAnchor = Agg.UI.HAnchor.ParentLeftRight; dividerLine.Height = 1; dividerLine.Margin = new BorderDouble(0, 3); dividerLine.BackgroundColor = RGBA_Bytes.White; topToBottom.AddChild(dividerLine); if (!partIsGCode) { Button exportSTL = textImageButtonFactory.Generate("Export as STL"); exportSTL.Click += new ButtonBase.ButtonEventHandler(exportSTL_Click); //exportSTL.HAnchor = Agg.UI.HAnchor.ParentCenter; topToBottom.AddChild(exportSTL); } bool showExportGCodeButton = PrinterCommunication.Instance.ActivePrinter != null || partIsGCode; if (showExportGCodeButton) { Button exportGCode = textImageButtonFactory.Generate("Export as GCode"); //exportGCode.HAnchor = Agg.UI.HAnchor.ParentCenter; exportGCode.Click += new ButtonBase.ButtonEventHandler(exportGCode_Click); topToBottom.AddChild(exportGCode); } GuiWidget vSpacer = new GuiWidget(); vSpacer.VAnchor = Agg.UI.VAnchor.ParentBottomTop; topToBottom.AddChild(vSpacer); if (!showExportGCodeButton) { TextWidget noGCodeMessage = new TextWidget("Note: To enable GCode export, select a printer profile.", textColor: RGBA_Bytes.White, pointSize: 10); topToBottom.AddChild(noGCodeMessage); } // TODO: make this work on the mac and then delete this if if (MatterHackers.Agg.UI.WindowsFormsAbstract.GetOSType() == WindowsFormsAbstract.OSType.Windows) { showInFolderAfterSave = new CheckBox("Show file in folder after save", RGBA_Bytes.White, 10); showInFolderAfterSave.Margin = new BorderDouble(top: 10); topToBottom.AddChild(showInFolderAfterSave); } this.AddChild(topToBottom); }
public void doLayout() { this.RemoveAllChildren(); TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory(); FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); topToBottom.Padding = new BorderDouble(10); topToBottom.AnchorAll(); string fileExportLabelTxt = new LocalizedString("File export options").Translated; TextWidget exportLabel = new TextWidget(string.Format("{0}:", fileExportLabelTxt)); exportLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor; topToBottom.AddChild(exportLabel); GuiWidget dividerLine = new GuiWidget(); dividerLine.HAnchor = Agg.UI.HAnchor.ParentLeftRight; dividerLine.Height = 1; dividerLine.Margin = new BorderDouble(0, 3); dividerLine.BackgroundColor = RGBA_Bytes.White; topToBottom.AddChild(dividerLine); if (!partIsGCode) { string exportSTLTxt = new LocalizedString ("Export as").Translated; string exportSTLTxtFull = string.Format ("{0} STL", exportSTLTxt); Button exportAsSTLButton = textImageButtonFactory.Generate(exportSTLTxtFull); exportAsSTLButton.Click += new ButtonBase.ButtonEventHandler(exportSTL_Click); //exportSTL.HAnchor = Agg.UI.HAnchor.ParentCenter; topToBottom.AddChild(exportAsSTLButton); } bool showExportGCodeButton = ActivePrinterProfile.Instance.ActivePrinter != null || partIsGCode; if (showExportGCodeButton) { string exportGCodeText = new LocalizedString("Export as").Translated; string exportGCodeTextFull = string.Format ("{0} GCode", exportGCodeText); Button exportGCode = textImageButtonFactory.Generate(exportGCodeTextFull); //exportGCode.HAnchor = Agg.UI.HAnchor.ParentCenter; exportGCode.Click += new ButtonBase.ButtonEventHandler(exportGCode_Click); topToBottom.AddChild(exportGCode); } GuiWidget vSpacer = new GuiWidget(); vSpacer.VAnchor = Agg.UI.VAnchor.ParentBottomTop; topToBottom.AddChild(vSpacer); if (!showExportGCodeButton) { string noGCodeMessageText = new LocalizedString("Note").Translated; string noGCodeMessageTextFull = new LocalizedString("To enable GCode export, select a printer profile").Translated; TextWidget noGCodeMessage = new TextWidget(string.Format("{0}: {1}.", noGCodeMessageText, noGCodeMessageTextFull), textColor: RGBA_Bytes.White, pointSize: 10); topToBottom.AddChild(noGCodeMessage); } // TODO: make this work on the mac and then delete this if if (MatterHackers.Agg.UI.WindowsFormsAbstract.GetOSType() == WindowsFormsAbstract.OSType.Windows) { showInFolderAfterSave = new CheckBox(new LocalizedString("Show file in folder after save").Translated, RGBA_Bytes.White, 10); showInFolderAfterSave.Margin = new BorderDouble(top: 10); topToBottom.AddChild(showInFolderAfterSave); } this.AddChild(topToBottom); }
public SliceSettingsWidget(List<PrinterSettingsLayer> layerCascade = null, NamedSettingsLayers viewFilter = NamedSettingsLayers.All) { this.layerCascade = layerCascade; this.viewFilter = viewFilter; // The last layer of the layerFilters is the target persistence layer persistenceLayer = layerCascade?.First() ?? ActiveSliceSettings.Instance.UserLayer; textImageButtonFactory = new TextImageButtonFactory(); textImageButtonFactory.normalFillColor = RGBA_Bytes.Transparent; textImageButtonFactory.FixedHeight = 15 * GuiWidget.DeviceScale; textImageButtonFactory.fontSize = 8; textImageButtonFactory.borderWidth = 1; textImageButtonFactory.normalBorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200); textImageButtonFactory.hoverBorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200); this.textImageButtonFactory.disabledTextColor = RGBA_Bytes.Gray; this.textImageButtonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor; this.textImageButtonFactory.normalTextColor = ActiveTheme.Instance.SecondaryTextColor; this.textImageButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor; buttonFactory.FixedHeight = 20 * GuiWidget.DeviceScale; buttonFactory.fontSize = 10; buttonFactory.normalFillColor = RGBA_Bytes.White; buttonFactory.normalTextColor = RGBA_Bytes.DarkGray; FlowLayoutWidget pageTopToBottomLayout = new FlowLayoutWidget(FlowDirection.TopToBottom, vAnchor: Agg.UI.VAnchor.ParentTop); pageTopToBottomLayout.AnchorAll(); pageTopToBottomLayout.Padding = new BorderDouble(3, 0); this.AddChild(pageTopToBottomLayout); settingsControlBar = new SettingsControlBar() { HAnchor = HAnchor.ParentLeftRight, BackgroundColor = ActiveTheme.Instance.TransparentDarkOverlay, Padding = new BorderDouble(8, 12, 8, 8) }; pageTopToBottomLayout.AddChild(settingsControlBar); noConnectionMessageContainer = new AltGroupBox(new TextWidget("No Printer Selected".Localize(), pointSize: 18, textColor: ActiveTheme.Instance.SecondaryAccentColor)); noConnectionMessageContainer.Margin = new BorderDouble(top: 10); noConnectionMessageContainer.BorderColor = ActiveTheme.Instance.PrimaryTextColor; noConnectionMessageContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight; noConnectionMessageContainer.Height = 90; string noConnectionString = "No printer is currently selected. Please select a printer to edit slice settings.".Localize(); noConnectionString += "\n\n" + "NOTE: You need to select a printer, but do not need to connect to it.".Localize(); TextWidget noConnectionMessage = new TextWidget(noConnectionString, pointSize: 10); noConnectionMessage.Margin = new BorderDouble(5); noConnectionMessage.TextColor = ActiveTheme.Instance.PrimaryTextColor; noConnectionMessage.VAnchor = VAnchor.ParentCenter; noConnectionMessageContainer.AddChild(noConnectionMessage); pageTopToBottomLayout.AddChild(noConnectionMessageContainer); topCategoryTabs = new TabControl(); topCategoryTabs.TabBar.BorderColor = ActiveTheme.Instance.PrimaryTextColor; topCategoryTabs.Margin = new BorderDouble(top: 8); topCategoryTabs.AnchorAll(); sliceSettingsDetailControl = new SliceSettingsDetailControl(layerCascade); List<TabBar> sideTabBarsListForLayout = new List<TabBar>(); for (int topCategoryIndex = 0; topCategoryIndex < SliceSettingsOrganizer.Instance.UserLevels[UserLevel].CategoriesList.Count; topCategoryIndex++) { OrganizerCategory category = SliceSettingsOrganizer.Instance.UserLevels[UserLevel].CategoriesList[topCategoryIndex]; string categoryPageLabel = category.Name.Localize(); TabPage categoryPage = new TabPage(categoryPageLabel); SimpleTextTabWidget textTabWidget = new SimpleTextTabWidget(categoryPage, category.Name + " Tab", 16, ActiveTheme.Instance.TabLabelSelected, new RGBA_Bytes(), ActiveTheme.Instance.TabLabelUnselected, new RGBA_Bytes()); categoryPage.AnchorAll(); topCategoryTabs.AddTab(textTabWidget); TabControl sideTabs = CreateSideTabsAndPages(category); sideTabBarsListForLayout.Add(sideTabs.TabBar); categoryPage.AddChild(sideTabs); } topCategoryTabs.TabBar.AddChild(new HorizontalSpacer()); topCategoryTabs.TabBar.AddChild(sliceSettingsDetailControl); if (sliceSettingsDetailControl.SelectedValue == "Advanced" && ActiveSliceSettings.Instance.Helpers.ActiveSliceEngineType() == SlicingEngineTypes.Slic3r) { TabPage extraSettingsPage = new TabPage("Other"); SimpleTextTabWidget extraSettingsTextTabWidget = new SimpleTextTabWidget(extraSettingsPage, "Other Tab", 16, ActiveTheme.Instance.TabLabelSelected, new RGBA_Bytes(), ActiveTheme.Instance.TabLabelUnselected, new RGBA_Bytes()); extraSettingsPage.AnchorAll(); int count; TabControl extraSettingsSideTabs = CreateExtraSettingsSideTabsAndPages(topCategoryTabs, out count); if (count > 0) { topCategoryTabs.AddTab(extraSettingsTextTabWidget); sideTabBarsListForLayout.Add(extraSettingsSideTabs.TabBar); extraSettingsPage.AddChild(extraSettingsSideTabs); } } double sideTabBarsMinimumWidth = 0; foreach (TabBar tabBar in sideTabBarsListForLayout) { sideTabBarsMinimumWidth = Math.Max(sideTabBarsMinimumWidth, tabBar.Width); } foreach (TabBar tabBar in sideTabBarsListForLayout) { tabBar.MinimumSize = new Vector2(sideTabBarsMinimumWidth, tabBar.MinimumSize.y); } // check if there is only one left side tab. If so hide the left tabs and expand the content. foreach(var tabList in sideTabBarsListForLayout) { if(tabList.CountVisibleChildren() == 1) { tabList.MinimumSize = new Vector2(0, 0); tabList.Width = 0; } } pageTopToBottomLayout.AddChild(topCategoryTabs); AddHandlers(); SetVisibleControls(); // Make sure we are on the right tab when we create this view { string settingsName = "SliceSettingsWidget_CurrentTab"; string selectedTab = UserSettings.Instance.get(settingsName); topCategoryTabs.SelectTab(selectedTab); topCategoryTabs.TabBar.TabIndexChanged += (object sender, EventArgs e) => { string selectedTabName = topCategoryTabs.TabBar.SelectedTabName; if (!string.IsNullOrEmpty(selectedTabName)) { if (layerCascade == null) { UserSettings.Instance.set(settingsName, selectedTabName); } } }; } this.AnchorAll(); }
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); }
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); }
private FlowLayoutWidget CreateSaveButtons() { TextImageButtonFactory saveButtonFactory = new TextImageButtonFactory(); saveButtonFactory.FixedWidth = 56; saveButtonFactory.FixedHeight = 40; saveButtonFactory.normalFillColor = RGBA_Bytes.White; saveButtonFactory.normalTextColor = RGBA_Bytes.Black; saveButtonFactory.hoverTextColor = RGBA_Bytes.Black; saveButtonFactory.hoverFillColor = new RGBA_Bytes(255, 255, 255, 200); FlowLayoutWidget saveButtons = new FlowLayoutWidget(); //Create Save Button Button saveButton = saveButtonFactory.Generate(LocalizedString.Get("Save"), centerText: true); saveButton.Cursor = Cursors.Hand; saveButtons.AddChild(saveButton); saveButton.Click += (sender, e) => { MergeAndSavePartsToStl(); }; //Create Save As Button saveButtonFactory.FixedWidth = SideBarButtonWidth - saveButtonFactory.FixedWidth - 2; Button saveAsButton = saveButtonFactory.Generate("Save As".Localize(), centerText: true); saveAsButton.Cursor = Cursors.Hand; saveButtons.AddChild(saveAsButton); saveAsButton.Click += (sender, e) => { if(saveAsWindowIsOpen == false) { saveAsWindow = new SaveAsWindow(MergeAndSavePartsToStl); this.saveAsWindowIsOpen = true; saveAsWindow.Closed += new EventHandler(SaveAsWindow_Closed); } else { if(saveAsWindowIsOpen != null) { saveAsWindow.BringToFront(); } } }; saveButtons.Visible = false; return saveButtons; }
private void CreateAndAddChildren() { TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory(); textImageButtonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor; CloseAllChildren(); gcodeViewWidget = null; gcodeProcessingStateInfoText = null; FlowLayoutWidget mainContainerTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); mainContainerTopToBottom.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth; mainContainerTopToBottom.VAnchor = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight; buttonBottomPanel = new FlowLayoutWidget(FlowDirection.LeftToRight); buttonBottomPanel.HAnchor = HAnchor.ParentLeftRight; buttonBottomPanel.Padding = new BorderDouble(3, 3); buttonBottomPanel.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; generateGCodeButton = textImageButtonFactory.Generate(LocalizedString.Get("Generate")); generateGCodeButton.Click += new EventHandler(generateButton_Click); buttonBottomPanel.AddChild(generateGCodeButton); layerSelectionButtonsPanel = new FlowLayoutWidget(FlowDirection.RightToLeft); layerSelectionButtonsPanel.HAnchor = HAnchor.ParentLeftRight; layerSelectionButtonsPanel.Padding = new BorderDouble(0); GuiWidget holdPanelOpen = new GuiWidget(1, generateGCodeButton.Height); layerSelectionButtonsPanel.AddChild(holdPanelOpen); if (windowMode == WindowMode.StandAlone) { Button closeButton = textImageButtonFactory.Generate(LocalizedString.Get("Close")); layerSelectionButtonsPanel.AddChild(closeButton); closeButton.Click += (sender, e) => { CloseOnIdle(); }; } FlowLayoutWidget centerPartPreviewAndControls = new FlowLayoutWidget(FlowDirection.LeftToRight); centerPartPreviewAndControls.AnchorAll(); gcodeDisplayWidget = new GuiWidget(HAnchor.ParentLeftRight, Agg.UI.VAnchor.ParentBottomTop); string firstProcessingMessage = "Press 'Add' to select an item.".Localize(); if (printItem != null) { firstProcessingMessage = "Loading G-Code...".Localize(); if (Path.GetExtension(printItem.FileLocation).ToUpper() == ".GCODE") { gcodeDisplayWidget.AddChild(CreateGCodeViewWidget(printItem.FileLocation)); } else { if (File.Exists(printItem.FileLocation)) { string gcodePathAndFileName = printItem.GetGCodePathAndFileName(); bool gcodeFileIsComplete = printItem.IsGCodeFileComplete(gcodePathAndFileName); if (printItem.SlicingHadError) { firstProcessingMessage = slicingErrorMessage; } else { firstProcessingMessage = pressGenerateMessage; } if (File.Exists(gcodePathAndFileName) && gcodeFileIsComplete) { gcodeDisplayWidget.AddChild(CreateGCodeViewWidget(gcodePathAndFileName)); } // we only hook these up to make sure we can regenerate the gcode when we want printItem.SlicingOutputMessage += sliceItem_SlicingOutputMessage; printItem.SlicingDone += sliceItem_Done; } else { firstProcessingMessage = string.Format("{0}\n'{1}'", fileNotFoundMessage, printItem.Name); } } } else { generateGCodeButton.Visible = false; } SetProcessingMessage(firstProcessingMessage); centerPartPreviewAndControls.AddChild(gcodeDisplayWidget); buttonRightPanel = CreateRightButtonPanel(); buttonRightPanel.Visible = false; centerPartPreviewAndControls.AddChild(buttonRightPanel); // add in a spacer layerSelectionButtonsPanel.AddChild(new GuiWidget(HAnchor.ParentLeftRight)); buttonBottomPanel.AddChild(layerSelectionButtonsPanel); mainContainerTopToBottom.AddChild(centerPartPreviewAndControls); mainContainerTopToBottom.AddChild(buttonBottomPanel); this.AddChild(mainContainerTopToBottom); meshViewerWidget = new MeshViewerWidget(viewerVolume, bedCenter, bedShape, "".Localize()); meshViewerWidget.AnchorAll(); meshViewerWidget.AllowBedRenderingWhenEmpty = true; gcodeDisplayWidget.AddChild(meshViewerWidget); meshViewerWidget.Visible = false; meshViewerWidget.TrackballTumbleWidget.DrawGlContent += new EventHandler(TrackballTumbleWidget_DrawGlContent); viewControls2D = new ViewControls2D(); AddChild(viewControls2D); viewControls2D.ResetView += (sender, e) => { SetDefaultView2D(); }; viewControls3D = new ViewControls3D(meshViewerWidget); viewControls3D.PartSelectVisible = false; AddChild(viewControls3D); viewControls3D.ResetView += (sender, e) => { SetDefaultView(); }; viewControls3D.ActiveButton = ViewControls3DButtons.Rotate; viewControls3D.Visible = false; viewControlsToggle = new ViewControlsToggle(); viewControlsToggle.HAnchor = Agg.UI.HAnchor.ParentRight; AddChild(viewControlsToggle); viewControlsToggle.Visible = false; //viewControls3D.translateButton.ClickButton(null); SetDefaultView(); viewControls2D.translateButton.Click += (sender, e) => { gcodeViewWidget.TransformState = ViewGcodeWidget.ETransformState.Move; }; viewControls2D.scaleButton.Click += (sender, e) => { gcodeViewWidget.TransformState = ViewGcodeWidget.ETransformState.Scale; }; AddHandlers(); }
public FlowLayoutWidget GetPulldownContainer() { var dropDownList = CreateDropdown(); FlowLayoutWidget container = new FlowLayoutWidget(); container.HAnchor = HAnchor.ParentLeftRight; container.Padding = new BorderDouble(6, 0); editButton = TextImageButtonFactory.GetThemedEditButton(); editButton.ToolTipText = "Edit Selected Setting".Localize(); editButton.Enabled = dropDownList.SelectedIndex != -1; editButton.VAnchor = VAnchor.ParentCenter; editButton.Margin = new BorderDouble(left: 6); editButton.Click += (sender, e) => { if (layerType == NamedSettingsLayers.Material) { if (ApplicationController.Instance.EditMaterialPresetsWindow == null) { string presetsID = ActiveSliceSettings.Instance.GetMaterialPresetKey(extruderIndex); if (string.IsNullOrEmpty(presetsID)) { return; } var layerToEdit = ActiveSliceSettings.Instance.MaterialLayers.Where(layer => layer.LayerID == presetsID).FirstOrDefault(); var presetsContext = new PresetsContext(ActiveSliceSettings.Instance.MaterialLayers, layerToEdit) { LayerType = NamedSettingsLayers.Material, SetAsActive = (materialKey) => { ActiveSliceSettings.Instance.SetMaterialPreset(this.extruderIndex, materialKey); }, DeleteLayer = () => { var materialKeys = ActiveSliceSettings.Instance.MaterialSettingsKeys; for (var i = 0; i < materialKeys.Count; i++) { if (materialKeys[i] == presetsID) { materialKeys[i] = ""; } } ActiveSliceSettings.Instance.SetMaterialPreset(extruderIndex, ""); ActiveSliceSettings.Instance.MaterialLayers.Remove(layerToEdit); ActiveSliceSettings.Instance.Save(); UiThread.RunOnIdle(() => ApplicationController.Instance.ReloadAdvancedControlsPanel()); } }; ApplicationController.Instance.EditMaterialPresetsWindow = new SlicePresetsWindow(presetsContext); ApplicationController.Instance.EditMaterialPresetsWindow.Closed += (s, e2) => { ApplicationController.Instance.EditMaterialPresetsWindow = null; ApplicationController.Instance.ReloadAdvancedControlsPanel(); }; ApplicationController.Instance.EditMaterialPresetsWindow.ShowAsSystemWindow(); } else { ApplicationController.Instance.EditMaterialPresetsWindow.BringToFront(); } } if (layerType == NamedSettingsLayers.Quality) { if (ApplicationController.Instance.EditQualityPresetsWindow == null) { string presetsID = ActiveSliceSettings.Instance.ActiveQualityKey; if (string.IsNullOrEmpty(presetsID)) { return; } var layerToEdit = ActiveSliceSettings.Instance.QualityLayers.Where(layer => layer.LayerID == presetsID).FirstOrDefault(); var presetsContext = new PresetsContext(ActiveSliceSettings.Instance.QualityLayers, layerToEdit) { LayerType = NamedSettingsLayers.Quality, SetAsActive = (qualityKey) => ActiveSliceSettings.Instance.ActiveQualityKey = qualityKey, DeleteLayer = () => { ActiveSliceSettings.Instance.ActiveQualityKey = ""; ActiveSliceSettings.Instance.QualityLayers.Remove(layerToEdit); ActiveSliceSettings.Instance.Save(); UiThread.RunOnIdle(() => ApplicationController.Instance.ReloadAdvancedControlsPanel()); } }; ApplicationController.Instance.EditQualityPresetsWindow = new SlicePresetsWindow(presetsContext); ApplicationController.Instance.EditQualityPresetsWindow.Closed += (s, e2) => { ApplicationController.Instance.EditQualityPresetsWindow = null; ApplicationController.Instance.ReloadAdvancedControlsPanel(); }; ApplicationController.Instance.EditQualityPresetsWindow.ShowAsSystemWindow(); } else { ApplicationController.Instance.EditQualityPresetsWindow.BringToFront(); } } }; container.AddChild(dropDownList); container.AddChild(editButton); return(container); }
private FlowLayoutWidget GetAutoLevelControl() { FlowLayoutWidget buttonRow = new FlowLayoutWidget(); buttonRow.Name = "AutoLevelRowItem"; buttonRow.HAnchor = HAnchor.ParentLeftRight; buttonRow.Margin = new BorderDouble(0, 4); ImageBuffer levelingImage = StaticData.Instance.LoadIcon("leveling_32x32.png", 24, 24).InvertLightness(); if (!ActiveTheme.Instance.IsDarkTheme) { levelingImage.InvertLightness(); } ImageWidget levelingIcon = new ImageWidget(levelingImage); levelingIcon.Margin = new BorderDouble(right: 6); buttonRow.AddChild(levelingIcon); // label printLevelingStatusLabel = new TextWidget("") { AutoExpandBoundsToText = true, TextColor = ActiveTheme.Instance.PrimaryTextColor, VAnchor = VAnchor.ParentCenter, Text = "Software Print Leveling".Localize() }; buttonRow.AddChild(printLevelingStatusLabel); // edit button Button editButton = TextImageButtonFactory.GetThemedEditButton(); editButton.Margin = new BorderDouble(2, 2, 2, 0); editButton.VAnchor = Agg.UI.VAnchor.ParentTop; editButton.VAnchor = VAnchor.ParentCenter; editButton.Click += (sender, e) => { UiThread.RunOnIdle(() => { if (editLevelingSettingsWindow == null) { editLevelingSettingsWindow = new EditLevelingSettingsWindow(); editLevelingSettingsWindow.Closed += (sender2, e2) => { editLevelingSettingsWindow = null; }; } else { editLevelingSettingsWindow.BringToFront(); } }); }; buttonRow.AddChild(editButton); buttonRow.AddChild(new HorizontalSpacer()); // configure button runPrintLevelingButton = textImageButtonFactory.Generate("Configure".Localize().ToUpper()); runPrintLevelingButton.Margin = new BorderDouble(left: 6); runPrintLevelingButton.VAnchor = VAnchor.ParentCenter; runPrintLevelingButton.Click += (sender, e) => { UiThread.RunOnIdle(() => LevelWizardBase.ShowPrintLevelWizard(LevelWizardBase.RuningState.UserRequestedCalibration)); }; buttonRow.AddChild(runPrintLevelingButton); // put in the switch CheckBox printLevelingSwitch = ImageButtonFactory.CreateToggleSwitch(ActiveSliceSettings.Instance.GetValue <bool>(SettingsKey.print_leveling_enabled)); printLevelingSwitch.VAnchor = VAnchor.ParentCenter; printLevelingSwitch.Margin = new BorderDouble(left: 16); printLevelingSwitch.CheckedStateChanged += (sender, e) => { ActiveSliceSettings.Instance.Helpers.DoPrintLeveling(printLevelingSwitch.Checked); }; PrinterSettings.PrintLevelingEnabledChanged.RegisterEvent((sender, e) => { printLevelingSwitch.Checked = ActiveSliceSettings.Instance.GetValue <bool>(SettingsKey.print_leveling_enabled); }, ref unregisterEvents); // only show the switch if leveling can be turned off (it can't if it is required). if (!ActiveSliceSettings.Instance.GetValue <bool>(SettingsKey.print_leveling_required_to_print)) { buttonRow.AddChild(printLevelingSwitch); } return(buttonRow); }
protected override void AddChildElements() { actionBarButtonFactory.invertImageLocation = false; actionBarButtonFactory.borderWidth = 1; if (ActiveTheme.Instance.IsDarkTheme) { actionBarButtonFactory.normalBorderColor = new RGBA_Bytes(77, 77, 77); } else { actionBarButtonFactory.normalBorderColor = new RGBA_Bytes(190, 190, 190); } actionBarButtonFactory.hoverBorderColor = new RGBA_Bytes(128, 128, 128); string connectString = "Connect".Localize().ToUpper(); connectPrinterButton = actionBarButtonFactory.Generate(connectString, "icon_power_32x32.png"); connectPrinterButton.ToolTipText = "Connect to the currently selected printer".Localize(); if (ApplicationController.Instance.WidescreenMode) { connectPrinterButton.Margin = new BorderDouble(0, 0, 3, 3); } else { connectPrinterButton.Margin = new BorderDouble(6, 0, 3, 3); } connectPrinterButton.VAnchor = VAnchor.ParentTop; connectPrinterButton.Cursor = Cursors.Hand; string disconnectString = "Disconnect".Localize().ToUpper(); disconnectPrinterButton = actionBarButtonFactory.Generate(disconnectString, "icon_power_32x32.png"); disconnectPrinterButton.ToolTipText = "Disconnect from current printer".Localize(); if (ApplicationController.Instance.WidescreenMode) { disconnectPrinterButton.Margin = new BorderDouble(0, 0, 3, 3); } else { disconnectPrinterButton.Margin = new BorderDouble(6, 0, 3, 3); } disconnectPrinterButton.VAnchor = VAnchor.ParentTop; disconnectPrinterButton.Cursor = Cursors.Hand; string resetConnectionText = "Reset\nConnection".Localize().ToUpper(); resetConnectionButton = actionBarButtonFactory.Generate(resetConnectionText, "e_stop4.png"); if (ApplicationController.Instance.WidescreenMode) { resetConnectionButton.Margin = new BorderDouble(0, 0, 3, 3); } else { resetConnectionButton.Margin = new BorderDouble(6, 0, 3, 3); } // Bind connect button states to active printer state this.SetConnectionButtonVisibleState(); actionBarButtonFactory.invertImageLocation = true; this.AddChild(connectPrinterButton); this.AddChild(disconnectPrinterButton); FlowLayoutWidget printerSelectorAndEditButton = new FlowLayoutWidget() { HAnchor = HAnchor.ParentLeftRight, }; int rightMarginForWideScreenMode = ApplicationController.Instance.WidescreenMode ? 6 : 0; printerSelector = new PrinterSelector() { HAnchor = HAnchor.ParentLeftRight, Cursor = Cursors.Hand, Margin = new BorderDouble(0, 6, rightMarginForWideScreenMode, 3) }; printerSelector.AddPrinter += (s, e) => WizardWindow.Show(); printerSelector.MinimumSize = new Vector2(printerSelector.MinimumSize.x, connectPrinterButton.MinimumSize.y); printerSelectorAndEditButton.AddChild(printerSelector); Button editButton = TextImageButtonFactory.GetThemedEditButton(); editButton.VAnchor = VAnchor.ParentCenter; editButton.Click += UiNavigation.GoToEditPrinter_Click; printerSelectorAndEditButton.AddChild(editButton); this.AddChild(printerSelectorAndEditButton); this.AddChild(resetConnectionButton); }
private FlowLayoutWidget GetBottomRow(TextImageButtonFactory buttonFactory) { var container = new FlowLayoutWidget() { HAnchor = HAnchor.ParentLeftRight, Margin = new BorderDouble(top: 3) }; Button duplicateButton = buttonFactory.Generate("Duplicate".Localize()); duplicateButton.Click += (s, e) => { UiThread.RunOnIdle(() => { string sanitizedName = numberMatch.Replace(presetNameInput.Text, "").Trim(); string newProfileName = GetNonCollidingName(sanitizedName, presetsContext.PresetLayers.Select(preset => preset.ValueOrDefault(SettingsKey.layer_name))); var clonedLayer = presetsContext.PersistenceLayer.Clone(); clonedLayer.Name = newProfileName; presetsContext.PresetLayers.Add(clonedLayer); presetsContext.SetAsActive(clonedLayer.LayerID); presetsContext.PersistenceLayer = clonedLayer; middleRow.CloseAllChildren(); middleRow.AddChild(CreateSliceSettingsWidget(clonedLayer)); presetNameInput.Text = newProfileName; }); }; Button deleteButton = buttonFactory.Generate("Delete".Localize()); deleteButton.Click += (s, e) => { UiThread.RunOnIdle(() => { presetsContext.DeleteLayer(); this.Close(); }); }; Button closeButton = buttonFactory.Generate("Close".Localize()); closeButton.Click += (sender, e) => { this.CloseOnIdle(); }; container.AddChild(duplicateButton); container.AddChild(deleteButton); container.AddChild(new HorizontalSpacer()); container.AddChild(closeButton); return container; }
public virtual FlowLayoutWidget GetPulldownContainer() { dropDownList = CreateDropdown(); FlowLayoutWidget container = new FlowLayoutWidget(); container.HAnchor = HAnchor.ParentLeftRight; container.Padding = new BorderDouble(6, 0); editButton = TextImageButtonFactory.GetThemedEditButton(); editButton.ToolTipText = "Edit Selected Setting".Localize(); editButton.VAnchor = VAnchor.ParentCenter; editButton.Margin = new BorderDouble(left: 6); editButton.Click += (sender, e) => { if (layerType == NamedSettingsLayers.Material) { if (ApplicationController.Instance.EditMaterialPresetsWindow == null) { string presetsKey = ActiveSliceSettings.Instance.MaterialPresetKey(extruderIndex); if (string.IsNullOrEmpty(presetsKey)) { return; } var presetsContext = new PresetsContext(ActiveSliceSettings.Instance.MaterialLayers, presetsKey) { LayerType = NamedSettingsLayers.Material, SetAsActive = (materialKey) => { ActiveSliceSettings.Instance.ActiveMaterialKey = materialKey; ActiveSliceSettings.Instance.SetMaterialPreset(this.extruderIndex, materialKey); } }; ApplicationController.Instance.EditMaterialPresetsWindow = new SlicePresetsWindow(presetsContext); ApplicationController.Instance.EditMaterialPresetsWindow.Closed += (s, e2) => { ApplicationController.Instance.EditMaterialPresetsWindow = null; ApplicationController.Instance.ReloadAdvancedControlsPanel(); }; ApplicationController.Instance.EditMaterialPresetsWindow.ShowAsSystemWindow(); } else { ApplicationController.Instance.EditMaterialPresetsWindow.BringToFront(); } } if (layerType == NamedSettingsLayers.Quality) { if (ApplicationController.Instance.EditQualityPresetsWindow == null) { string presetsKey = ActiveSliceSettings.Instance.ActiveQualityKey; if (string.IsNullOrEmpty(presetsKey)) { return; } var presetsContext = new PresetsContext(ActiveSliceSettings.Instance.QualityLayers, presetsKey) { LayerType = NamedSettingsLayers.Quality, SetAsActive = (qualityKey) => ActiveSliceSettings.Instance.ActiveQualityKey = qualityKey }; ApplicationController.Instance.EditQualityPresetsWindow = new SlicePresetsWindow(presetsContext); ApplicationController.Instance.EditQualityPresetsWindow.Closed += (s, e2) => { ApplicationController.Instance.EditQualityPresetsWindow = null; ApplicationController.Instance.ReloadAdvancedControlsPanel(); }; ApplicationController.Instance.EditQualityPresetsWindow.ShowAsSystemWindow(); } else { ApplicationController.Instance.EditQualityPresetsWindow.BringToFront(); } } }; container.AddChild(dropDownList); container.AddChild(editButton); return(container); }
private AnchoredDropDownList CreateDropdown() { AnchoredDropDownList dropDownList = new AnchoredDropDownList("- default -", maxHeight: 300); dropDownList.Margin = new BorderDouble(0, 3); dropDownList.MinimumSize = new Vector2(dropDownList.LocalBounds.Width, dropDownList.LocalBounds.Height); MenuItem defaultMenuItem = dropDownList.AddItem("- default -", "0"); defaultMenuItem.Selected += new EventHandler(onItemSelect); var listSource = (filterTag == "material") ? ActiveSliceSettings.Instance.AllMaterialKeys() : ActiveSliceSettings.Instance.AllQualityKeys(); foreach (var presetName in listSource) { MenuItem menuItem = dropDownList.AddItem(presetName, presetName); menuItem.Selected += onItemSelect; } // put in a small bottom region { FlowLayoutWidget container = new FlowLayoutWidget(); container.HAnchor = HAnchor.ParentLeftRight; TextImageButtonFactory buttonFactory = new TextImageButtonFactory(); buttonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor; buttonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor; buttonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryTextColor; buttonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor; buttonFactory.borderWidth = 0; Button addPresetButton = buttonFactory.Generate(LocalizedString.Get("Add"), "icon_circle_plus.png"); addPresetButton.ToolTipText = "Add a new Settings Preset".Localize(); addPresetButton.Click += (sender, e) => { onNewItemSelect(sender, e); }; container.AddChild(addPresetButton); Button importPresetButton = buttonFactory.Generate(LocalizedString.Get("Import")); importPresetButton.ToolTipText = "Import an existing Settings Preset".Localize(); importPresetButton.Click += (sender, e) => { }; container.AddChild(importPresetButton); dropDownList.MenuItems.Add(new MenuItem(container)); } try { string settingsKey; if (filterTag == "material") { settingsKey = ActiveSliceSettings.Instance.GetMaterialPresetKey(extruderIndex); } else { settingsKey = ActiveSliceSettings.Instance.ActiveQualityKey; } if (!string.IsNullOrEmpty(settingsKey)) { dropDownList.SelectedValue = settingsKey; } } catch (Exception ex) { GuiWidget.BreakInDebugger(ex.Message); } return dropDownList; }
private FlowLayoutWidget GetBottomRow(TextImageButtonFactory buttonFactory) { var container = new FlowLayoutWidget() { HAnchor = HAnchor.ParentLeftRight, Margin = new BorderDouble(top: 3) }; Button duplicateButton = buttonFactory.Generate("Duplicate".Localize()); duplicateButton.Click += (s, e) => { UiThread.RunOnIdle(() => { string sanitizedName = numberMatch.Replace(presetNameInput.Text, "").Trim(); string newProfileName = GetNonCollidingName(sanitizedName, presetsContext.PresetsDictionary.Values.Select(preset => preset.Name)); var clonedLayer = presetsContext.PersistenceLayer.Clone(); clonedLayer.Name = newProfileName; presetsContext.PresetsDictionary[clonedLayer.ID] = clonedLayer; presetsContext.SetAsActive(clonedLayer.ID); presetsContext.PersistenceLayer = clonedLayer; middleRow.CloseAllChildren(); middleRow.AddChild(CreateSliceSettingsWidget(clonedLayer)); presetNameInput.Text = newProfileName; }); }; Button importButton = buttonFactory.Generate("Import".Localize()); importButton.Click += (s, e) => { throw new NotImplementedException(); }; Button exportButton = buttonFactory.Generate("Export".Localize()); exportButton.Click += (s, e) => UiThread.RunOnIdle(SaveAs); Button closeButton = buttonFactory.Generate("Close".Localize()); closeButton.Click += (sender, e) => { UiThread.RunOnIdle(() => { if (initialPresetName != presetsContext.PersistenceLayer.Name) { // TODO: If we get to the point where we refresh rather than reload, we need // to rebuild the target droplist to display the new name ApplicationController.Instance.ReloadAdvancedControlsPanel(); } this.Close(); }); }; container.AddChild(duplicateButton); //Only show duplicate/import/export buttons if setting has been saved. if (false) { container.AddChild(importButton); container.AddChild(exportButton); } container.AddChild(new HorizontalSpacer()); container.AddChild(closeButton); return(container); }
void CreateAndAddChildren(object state) { TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory(); textImageButtonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor; CloseAndRemoveAllChildren(); gcodeViewWidget = null; gcodeProcessingStateInfoText = null; FlowLayoutWidget mainContainerTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); mainContainerTopToBottom.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth; mainContainerTopToBottom.VAnchor = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight; buttonBottomPanel = new FlowLayoutWidget(FlowDirection.LeftToRight); buttonBottomPanel.HAnchor = HAnchor.ParentLeftRight; buttonBottomPanel.Padding = new BorderDouble(3, 3); buttonBottomPanel.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; generateGCodeButton = textImageButtonFactory.Generate(LocalizedString.Get("Generate")); generateGCodeButton.Click += new EventHandler(generateButton_Click); buttonBottomPanel.AddChild(generateGCodeButton); layerSelectionButtonsPanel = new FlowLayoutWidget(FlowDirection.RightToLeft); layerSelectionButtonsPanel.HAnchor = HAnchor.ParentLeftRight; layerSelectionButtonsPanel.Padding = new BorderDouble(0); GuiWidget holdPanelOpen = new GuiWidget(1, generateGCodeButton.Height); layerSelectionButtonsPanel.AddChild(holdPanelOpen); if (widgetHasCloseButton) { Button closeButton = textImageButtonFactory.Generate(LocalizedString.Get("Close")); layerSelectionButtonsPanel.AddChild(closeButton); closeButton.Click += (sender, e) => { CloseOnIdle(); }; } FlowLayoutWidget centerPartPreviewAndControls = new FlowLayoutWidget(FlowDirection.LeftToRight); centerPartPreviewAndControls.AnchorAll(); gcodeDisplayWidget = new GuiWidget(HAnchor.ParentLeftRight, Agg.UI.VAnchor.ParentBottomTop); SetProcessingMessage("Press 'Add' to select an item.".Localize()); if (printItem != null) { SetProcessingMessage(LocalizedString.Get("Loading GCode...")); if (Path.GetExtension(printItem.FileLocation).ToUpper() == ".GCODE") { gcodeDisplayWidget.AddChild(CreateGCodeViewWidget(printItem.FileLocation)); } else { if (File.Exists(printItem.FileLocation)) { string gcodePathAndFileName = printItem.GetGCodePathAndFileName(); bool gcodeFileIsComplete = printItem.IsGCodeFileComplete(gcodePathAndFileName); if (printItem.SlicingHadError) { SetProcessingMessage(slicingErrorMessage); } else { SetProcessingMessage(pressGenerateMessage); } if (File.Exists(gcodePathAndFileName) && gcodeFileIsComplete) { gcodeDisplayWidget.AddChild(CreateGCodeViewWidget(gcodePathAndFileName)); } // we only hook these up to make sure we can regenerate the gcode when we want printItem.SlicingOutputMessage.RegisterEvent(sliceItem_SlicingOutputMessage, ref unregisterEvents); printItem.SlicingDone.RegisterEvent(sliceItem_Done, ref unregisterEvents); } else { SetProcessingMessage(string.Format("{0}\n'{1}'", fileNotFoundMessage, printItem.Name)); } } } else { generateGCodeButton.Visible = false; } centerPartPreviewAndControls.AddChild(gcodeDisplayWidget); buttonRightPanel = CreateRightButtonPanel(); buttonRightPanel.Visible = false; centerPartPreviewAndControls.AddChild(buttonRightPanel); // add in a spacer layerSelectionButtonsPanel.AddChild(new GuiWidget(HAnchor.ParentLeftRight)); buttonBottomPanel.AddChild(layerSelectionButtonsPanel); mainContainerTopToBottom.AddChild(centerPartPreviewAndControls); mainContainerTopToBottom.AddChild(buttonBottomPanel); this.AddChild(mainContainerTopToBottom); meshViewerWidget = new MeshViewerWidget(viewerVolume, bedCenter, bedShape, "".Localize()); meshViewerWidget.AnchorAll(); meshViewerWidget.AllowBedRenderingWhenEmpty = true; gcodeDisplayWidget.AddChild(meshViewerWidget); meshViewerWidget.Visible = false; meshViewerWidget.TrackballTumbleWidget.DrawGlContent += new EventHandler(TrackballTumbleWidget_DrawGlContent); viewControls2D = new ViewControls2D(); AddChild(viewControls2D); viewControls3D = new ViewControls3D(meshViewerWidget); viewControls3D.PartSelectVisible = false; AddChild(viewControls3D); viewControls3D.rotateButton.ClickButton(null); viewControls3D.Visible = false; viewControlsToggle = new ViewControlsToggle(); viewControlsToggle.HAnchor = Agg.UI.HAnchor.ParentRight; AddChild(viewControlsToggle); viewControlsToggle.Visible = false; //viewControls3D.translateButton.ClickButton(null); // move things into the right place and scale { Vector3 bedCenter3D = new Vector3(bedCenter, 0); meshViewerWidget.PrinterBed.Translate(bedCenter3D); meshViewerWidget.TrackballTumbleWidget.TrackBallController.Scale = .05; meshViewerWidget.TrackballTumbleWidget.TrackBallController.Translate(-bedCenter3D); } viewControls2D.translateButton.Click += (sender, e) => { gcodeViewWidget.TransformState = ViewGcodeWidget.ETransformState.Move; }; viewControls2D.scaleButton.Click += (sender, e) => { gcodeViewWidget.TransformState = ViewGcodeWidget.ETransformState.Scale; }; AddHandlers(); }
public static GuiWidget CreatePrinterExtraControls() { var dataArea = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.ParentLeftRight, }; // OEM_LAYER_DATE: string lastUpdateTime = "March 1, 2016"; if (ActiveSliceSettings.Instance?.OemLayer != null) { string fromCreatedDate = ActiveSliceSettings.Instance.OemLayer.ValueOrDefault(SettingsKey.created_date); try { if (!string.IsNullOrEmpty(fromCreatedDate)) { DateTime time = Convert.ToDateTime(fromCreatedDate).ToLocalTime(); lastUpdateTime = time.ToString("MMMM d, yyyy ") + time.ToString("h:mm tt"); } } catch { } } lastUpdateTime = "Default settings updated: {0} ".Localize().FormatWith(lastUpdateTime); dataArea.AddChild(new TextWidget(lastUpdateTime, textColor: ActiveTheme.Instance.SecondaryTextColor) { HAnchor= HAnchor.ParentCenter, Margin = new BorderDouble(0, 15), }); // DELETE_PRINTER: { // This is a place holder type to allow us to put in the control that will allow the deletion of a printer profile TextImageButtonFactory buttonFactory = new TextImageButtonFactory(); buttonFactory.borderWidth = 1; if (ActiveTheme.Instance.IsDarkTheme) { buttonFactory.normalBorderColor = new RGBA_Bytes(99, 99, 99); } else { buttonFactory.normalBorderColor = new RGBA_Bytes(140, 140, 140); } buttonFactory.normalTextColor = RGBA_Bytes.Red; var button = buttonFactory.Generate("Delete Printer".Localize()); button.Name = "Delete Printer Button"; button.HAnchor = HAnchor.ParentCenter; button.Click += (s, e) => { StyledMessageBox.ShowMessageBox((doDelete) => { if (doDelete) { ActiveSliceSettings.Instance.Helpers.SetMarkedForDelete(true); } }, "Are you sure you want to delete your currently selected printer?".Localize(), "Delete Printer?".Localize(), StyledMessageBox.MessageType.YES_NO, "Delete Printer".Localize()); }; dataArea.AddChild(button); } return dataArea; }
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); }
private FlowLayoutWidget GetBottomRow(TextImageButtonFactory buttonFactory) { var container = new FlowLayoutWidget() { HAnchor = HAnchor.ParentLeftRight, Margin = new BorderDouble(top: 3) }; Button duplicateButton = buttonFactory.Generate("Duplicate".Localize()); duplicateButton.Click += (s, e) => { UiThread.RunOnIdle(() => { string sanitizedName = numberMatch.Replace(presetNameInput.Text, "").Trim(); string newProfileName = GetNonCollidingName(sanitizedName, presetsContext.PresetLayers.Select(preset => preset.ValueOrDefault("layer_name"))); var clonedLayer = presetsContext.PersistenceLayer.Clone(); clonedLayer.Name = newProfileName; presetsContext.PresetLayers.Add(clonedLayer); presetsContext.SetAsActive(clonedLayer.LayerID); presetsContext.PersistenceLayer = clonedLayer; middleRow.CloseAllChildren(); middleRow.AddChild(CreateSliceSettingsWidget(clonedLayer)); presetNameInput.Text = newProfileName; }); }; Button deleteButton = buttonFactory.Generate("Delete".Localize()); deleteButton.Click += (s, e) => { UiThread.RunOnIdle(() => { presetsContext.DeleteLayer(); this.Close(); }); }; Button closeButton = buttonFactory.Generate("Close".Localize()); closeButton.Click += (sender, e) => { UiThread.RunOnIdle(() => { if (initialPresetName != presetsContext.PersistenceLayer.Name) { // TODO: If we get to the point where we refresh rather than reload, we need // to rebuild the target droplist to display the new name ApplicationController.Instance.ReloadAdvancedControlsPanel(); } this.Close(); }); }; container.AddChild(duplicateButton); container.AddChild(deleteButton); container.AddChild(new HorizontalSpacer()); container.AddChild(closeButton); return(container); }