public SaveAsPage(Action <string, ILibraryContainer> itemSaver) : base(itemSaver, "Save".Localize()) { this.WindowTitle = "MatterControl - " + "Save As".Localize(); this.Name = "Save As Window"; this.WindowSize = new Vector2(480 * GuiWidget.DeviceScale, 500 * GuiWidget.DeviceScale); this.HeaderText = "Save New Design".Localize() + ":"; // put in the area to type in the new name var fileNameHeader = new TextWidget("Design Name".Localize(), pointSize: 12) { TextColor = theme.TextColor, Margin = new BorderDouble(5), HAnchor = HAnchor.Left }; contentRow.AddChild(fileNameHeader); // Adds text box and check box to the above container itemNameWidget = new MHTextEditWidget("", theme, pixelWidth: 300, messageWhenEmptyAndNotSelected: "Enter a Design Name Here".Localize()) { HAnchor = HAnchor.Stretch, Margin = new BorderDouble(5) }; itemNameWidget.ActualTextEditWidget.EnterPressed += (s, e) => { acceptButton.InvokeClick(); }; contentRow.AddChild(itemNameWidget); var icon = AggContext.StaticData.LoadIcon("fa-folder-new_16.png", 16, 16, ApplicationController.Instance.MenuTheme.InvertIcons); var isEnabled = false; if (librarySelectorWidget.ActiveContainer is ILibraryWritableContainer writableContainer) { isEnabled = writableContainer?.AllowAction(ContainerActions.AddContainers) == true; } var createFolderButton = new TextIconButton("Create Folder".Localize(), icon, theme) { Enabled = isEnabled, HAnchor = HAnchor.Left, VAnchor = VAnchor.Absolute, DrawIconOverlayOnDisabled = true }; libraryNavContext.ContainerChanged += (s, e) => { createFolderButton.Enabled = libraryNavContext.ActiveContainer is ILibraryWritableContainer; }; createFolderButton.Name = "Create Folder In Button"; contentRow.AddChild(createFolderButton); createFolderButton.Click += CreateFolder_Click; }
public static GuiWidget GetUnlockRow(ThemeConfig theme, string url) { var detailsLink = new TextIconButton("Unlock".Localize(), StaticData.Instance.LoadIcon("locked.png", 16, 16, theme.InvertIcons), theme) { Margin = 5, ToolTipText = "Visit MatterHackers.com to Purchase".Localize() }; detailsLink.Click += (s, e) => { ApplicationController.LaunchBrowser(url); }; theme.ApplyPrimaryActionStyle(detailsLink); return(new SettingsRow("Demo Mode".Localize(), null, detailsLink, theme)); }
public static FlowLayoutWidget GetUnlockRow(ThemeConfig theme, string unlockLinkUrl) { var row = CreateSettingsRow("Demo Mode".Localize()); var detailsLink = new TextIconButton("Unlock".Localize(), AggContext.StaticData.LoadIcon("locked.png", 16, 16, theme.InvertIcons), theme) { Margin = 5 }; detailsLink.Click += (s, e) => { ApplicationController.Instance.LaunchBrowser(UnlockLinkAttribute.UnlockPageBaseUrl + unlockLinkUrl); }; row.AddChild(detailsLink); theme.ApplyPrimaryActionStyle(detailsLink); return(row); }
private void AddWebPageLinkIfRequired(PPEContext context, FlowLayoutWidget editControlsContainer, ThemeConfig theme) { if (context.item.GetType().GetCustomAttributes(typeof(WebPageLinkAttribute), true).FirstOrDefault() is WebPageLinkAttribute unlockLink) { var detailsLink = new TextIconButton(unlockLink.Name.Localize(), StaticData.Instance.LoadIcon("internet.png", 16, 16, theme.InvertIcons), theme) { BackgroundColor = theme.MinimalShade, ToolTipText = unlockLink.Url, }; detailsLink.Click += (s, e) => { ApplicationController.LaunchBrowser(unlockLink.Url); }; // website row editControlsContainer.AddChild(new SettingsRow("Website".Localize(), null, detailsLink, theme)); } }
private static GuiWidget CreateIconOrTextButton(string iconFilename, string buttonText, Object clickAction, string toolTip, string name, ThemeConfig theme, double marginX) { if (string.IsNullOrEmpty(buttonText)) { return(new IconButton(StaticData.Instance.LoadIcon(iconFilename, 12, 12, theme.InvertIcons), theme) { Margin = theme.ButtonSpacing, Enabled = clickAction != null, ToolTipText = toolTip, Name = name, }); } else { var oldSize = theme.DefaultFontSize; theme.DefaultFontSize = 8; var pauseButton = new TextIconButton(buttonText, StaticData.Instance.LoadIcon(iconFilename, 12, 12, theme.InvertIcons), theme) { Margin = new BorderDouble(marginX, 0), Padding = new BorderDouble(7, 3), VAnchor = VAnchor.Fit | VAnchor.Center, HAnchor = HAnchor.Fit, // BackgroundColor = new Color(theme.AccentMimimalOverlay, 50), HoverColor = theme.AccentMimimalOverlay, BorderColor = theme.TextColor, BackgroundOutlineWidth = 1, // Margin = theme.ButtonSpacing, Enabled = clickAction != null, ToolTipText = toolTip, Name = name, }; ((TextIconButton)pauseButton).BackgroundRadius = pauseButton.Height / 2; theme.DefaultFontSize = oldSize; return(pauseButton); } }
private void AddUnlockLinkIfRequired(PPEContext context, FlowLayoutWidget editControlsContainer, ThemeConfig theme) { var unlockLink = context.item.GetType().GetCustomAttributes(typeof(UnlockLinkAttribute), true).FirstOrDefault() as UnlockLinkAttribute; if (unlockLink != null && !string.IsNullOrEmpty(unlockLink.UnlockPageLink) && !context.item.Persistable) { var row = CreateSettingsRow(context.item.Persistable ? "Registered".Localize() : "Demo Mode".Localize()); var detailsLink = new TextIconButton("Unlock".Localize(), AggContext.StaticData.LoadIcon("locked.png", 16, 16, theme.InvertIcons), theme) { Margin = 5 }; detailsLink.Click += (s, e) => { ApplicationController.Instance.LaunchBrowser(UnlockLinkAttribute.UnlockPageBaseUrl + unlockLink.UnlockPageLink); }; row.AddChild(detailsLink); theme.ApplyPrimaryActionStyle(detailsLink); editControlsContainer.AddChild(row); } }
public PrinterActionsBar(PrinterConfig printer, PrinterTabPage printerTabPage, ThemeConfig theme) : base(theme) { this.printer = printer; this.printerTabPage = printerTabPage; this.HAnchor = HAnchor.Stretch; this.VAnchor = VAnchor.Fit; var defaultMargin = theme.ButtonSpacing; // add the reset button first (if there is one) if (printer.Settings.GetValue <bool>(SettingsKey.show_reset_connection)) { var resetConnectionButton = new TextIconButton( "Reset".Localize(), AggContext.StaticData.LoadIcon("e_stop.png", 14, 14, theme.InvertIcons), theme) { ToolTipText = "Reboots the firmware on the controller".Localize(), Margin = defaultMargin }; resetConnectionButton.Click += (s, e) => { UiThread.RunOnIdle(printer.Connection.RebootBoard); }; this.AddChild(resetConnectionButton); } this.AddChild(new PrinterConnectButton(printer, theme)); // add the start print button GuiWidget startPrintButton; this.AddChild(startPrintButton = new PrintPopupMenu(printer, theme) { Margin = theme.ButtonSpacing }); void SetPrintButtonStyle(object s, EventArgs e) { switch (printer.Connection.CommunicationState) { case CommunicationStates.FinishedPrint: case CommunicationStates.Connected: theme.ApplyPrimaryActionStyle(startPrintButton); break; default: theme.RemovePrimaryActionStyle(startPrintButton); break; } } // make sure the buttons state is set correctly printer.Connection.CommunicationStateChanged += SetPrintButtonStyle; startPrintButton.Closed += (s, e) => printer.Connection.CommunicationStateChanged -= SetPrintButtonStyle; // and set the style right now SetPrintButtonStyle(this, null); this.AddChild(new SliceButton(printer, printerTabPage, theme) { Name = "Generate Gcode Button", Margin = theme.ButtonSpacing, }); // Add vertical separator this.AddChild(new ToolbarSeparator(theme) { VAnchor = VAnchor.Absolute, Height = theme.ButtonHeight, }); var buttonGroupB = new ObservableCollection <GuiWidget>(); var iconPath = Path.Combine("ViewTransformControls", "model.png"); modelViewButton = new RadioIconButton(AggContext.StaticData.LoadIcon(iconPath, 16, 16, theme.InvertIcons), theme) { SiblingRadioButtonList = buttonGroupB, Name = "Model View Button", Checked = printer?.ViewState.ViewMode == PartViewMode.Model || printer == null, ToolTipText = "Model View".Localize(), Margin = theme.ButtonSpacing }; modelViewButton.Click += SwitchModes_Click; buttonGroupB.Add(modelViewButton); AddChild(modelViewButton); viewModes.Add(PartViewMode.Model, modelViewButton); iconPath = Path.Combine("ViewTransformControls", "gcode_3d.png"); layers3DButton = new RadioIconButton(AggContext.StaticData.LoadIcon(iconPath, 16, 16, theme.InvertIcons), theme) { SiblingRadioButtonList = buttonGroupB, Name = "Layers3D Button", Checked = printer?.ViewState.ViewMode == PartViewMode.Layers3D, ToolTipText = "3D Layer View".Localize(), Margin = theme.ButtonSpacing }; layers3DButton.Click += SwitchModes_Click; buttonGroupB.Add(layers3DButton); viewModes.Add(PartViewMode.Layers3D, layers3DButton); if (!UserSettings.Instance.IsTouchScreen) { this.AddChild(layers3DButton); } iconPath = Path.Combine("ViewTransformControls", "gcode_2d.png"); layers2DButton = new RadioIconButton(AggContext.StaticData.LoadIcon(iconPath, 16, 16, theme.InvertIcons), theme) { SiblingRadioButtonList = buttonGroupB, Name = "Layers2D Button", Checked = printer?.ViewState.ViewMode == PartViewMode.Layers2D, ToolTipText = "2D Layer View".Localize(), Margin = theme.ButtonSpacing, }; layers2DButton.Click += SwitchModes_Click; buttonGroupB.Add(layers2DButton); this.AddChild(layers2DButton); viewModes.Add(PartViewMode.Layers2D, layers2DButton); this.AddChild(new HorizontalSpacer()); int hotendCount = printer.Settings.Helpers.HotendCount(); if (!printer.Settings.GetValue <bool>(SettingsKey.sla_printer)) { for (int extruderIndex = 0; extruderIndex < hotendCount; extruderIndex++) { this.AddChild(new TemperatureWidgetHotend(printer, extruderIndex, theme, hotendCount) { Margin = new BorderDouble(right: 10) }); } } if (printer.Settings.GetValue <bool>(SettingsKey.has_heated_bed)) { this.AddChild(new TemperatureWidgetBed(printer, theme)); } this.OverflowButton.Name = "Printer Overflow Menu"; this.ExtendOverflowMenu = (popupMenu) => { this.GeneratePrinterOverflowMenu(popupMenu, ApplicationController.Instance.MenuTheme); }; printer.ViewState.ViewModeChanged += (s, e) => { if (viewModes[e.ViewMode] is RadioIconButton activeButton && viewModes[e.PreviousMode] is RadioIconButton previousButton && !buttonIsBeingClicked) { // Show slide to animation from previous to current, on completion update view to current by setting active.Checked previousButton.SlideToNewState( activeButton, this, () => { activeButton.Checked = true; }, theme); } }; // Register listeners printer.Connection.ConnectionSucceeded += CheckForPrintRecovery; // if we are already connected than check if there is a print recovery right now if (printer.Connection.CommunicationState == CommunicationStates.Connected) { CheckForPrintRecovery(null, null); } }
public SaveAsPage(Action <string, ILibraryContainer> itemSaver) : base(itemSaver, "Save".Localize()) { this.WindowTitle = "MatterControl - " + "Save As".Localize(); this.Name = "Save As Window"; this.WindowSize = new Vector2(480 * GuiWidget.DeviceScale, 500 * GuiWidget.DeviceScale); this.HeaderText = "Save New Design".Localize() + ":"; // put in the area to type in the new name var fileNameHeader = new TextWidget("Design Name".Localize(), pointSize: 12) { TextColor = theme.TextColor, Margin = new BorderDouble(5), HAnchor = HAnchor.Left }; contentRow.AddChild(fileNameHeader); // Adds text box and check box to the above container itemNameWidget = new MHTextEditWidget("", theme, pixelWidth: 300, messageWhenEmptyAndNotSelected: "Enter a Design Name Here".Localize()) { HAnchor = HAnchor.Stretch, Margin = new BorderDouble(5), Name = "Design Name Edit Field" }; itemNameWidget.ActualTextEditWidget.EnterPressed += (s, e) => { if (librarySelectorWidget.ActiveContainer is ILibraryWritableContainer) { acceptButton.InvokeClick(); } }; contentRow.AddChild(itemNameWidget); var icon = StaticData.Instance.LoadIcon("fa-folder-new_16.png", 16, 16).SetToColor(ApplicationController.Instance.MenuTheme.TextColor); var isEnabled = false; if (librarySelectorWidget.ActiveContainer is ILibraryWritableContainer writableContainer) { isEnabled = writableContainer?.AllowAction(ContainerActions.AddContainers) == true; } var folderButtonRow = new FlowLayoutWidget() { HAnchor = HAnchor.Left | HAnchor.Fit, }; contentRow.AddChild(folderButtonRow); // add a create folder button var createFolderButton = new TextIconButton("Create Folder".Localize(), icon, theme) { Enabled = isEnabled, VAnchor = VAnchor.Absolute, DrawIconOverlayOnDisabled = true }; createFolderButton.Name = "Create Folder In Button"; folderButtonRow.AddChild(createFolderButton); var refreshButton = new IconButton(StaticData.Instance.LoadIcon("fa-refresh_14.png", 16, 16).SetToColor(theme.TextColor), theme) { ToolTipText = "Refresh Folder".Localize(), Enabled = isEnabled, }; refreshButton.Click += (s, e) => { librarySelectorWidget.ActiveContainer.Load(); }; // folderButtonRow.AddChild(refreshButton); createFolderButton.Click += CreateFolder_Click; // add a message to navigate to a writable folder var writableMessage = new TextWidget("Please select a writable folder".Localize(), pointSize: theme.DefaultFontSize) { TextColor = theme.TextColor, Margin = new BorderDouble(5, 0), VAnchor = VAnchor.Center }; footerRow.AddChild(writableMessage, 0); footerRow.AddChild(new HorizontalSpacer(), 1); // change footer in this context footerRow.HAnchor = HAnchor.Stretch; footerRow.Margin = 0; libraryNavContext.ContainerChanged += (s, e) => { var writable = libraryNavContext.ActiveContainer is ILibraryWritableContainer; createFolderButton.Enabled = writable; refreshButton.Enabled = writable; writableMessage.Visible = !writable; }; }
public PrinterActionsBar(PrinterConfig printer, PrinterTabPage printerTabPage, ThemeConfig theme) : base(theme) { this.printer = printer; this.printerTabPage = printerTabPage; this.HAnchor = HAnchor.Stretch; this.VAnchor = VAnchor.Fit; var defaultMargin = theme.ButtonSpacing; // add the reset button first (if there is one) if (printer.Settings.GetValue <bool>(SettingsKey.show_reset_connection)) { var resetConnectionButton = new TextIconButton( "Reset".Localize(), AggContext.StaticData.LoadIcon("e_stop.png", 14, 14, theme.InvertIcons), theme) { ToolTipText = "Reboots the firmware on the controller".Localize(), Margin = defaultMargin }; resetConnectionButton.Click += (s, e) => { UiThread.RunOnIdle(printer.Connection.RebootBoard); }; this.AddChild(resetConnectionButton); } this.AddChild(new PrinterConnectButton(printer, theme)); this.AddChild(new PrintButton(printer, theme)); this.AddChild(new SliceButton(printer, printerTabPage, theme) { Name = "Generate Gcode Button", Margin = theme.ButtonSpacing, }); // Add vertical separator this.AddChild(new ToolbarSeparator(theme) { VAnchor = VAnchor.Absolute, Height = theme.ButtonHeight, }); var buttonGroupB = new ObservableCollection <GuiWidget>(); var iconPath = Path.Combine("ViewTransformControls", "model.png"); modelViewButton = new RadioIconButton(AggContext.StaticData.LoadIcon(iconPath, 16, 16, theme.InvertIcons), theme) { SiblingRadioButtonList = buttonGroupB, Name = "Model View Button", Checked = printer?.ViewState.ViewMode == PartViewMode.Model || printer == null, ToolTipText = "Model View".Localize(), Margin = theme.ButtonSpacing }; modelViewButton.Click += SwitchModes_Click; buttonGroupB.Add(modelViewButton); AddChild(modelViewButton); iconPath = Path.Combine("ViewTransformControls", "gcode_3d.png"); layers3DButton = new RadioIconButton(AggContext.StaticData.LoadIcon(iconPath, 16, 16, theme.InvertIcons), theme) { SiblingRadioButtonList = buttonGroupB, Name = "Layers3D Button", Checked = printer?.ViewState.ViewMode == PartViewMode.Layers3D, ToolTipText = "3D Layer View".Localize(), Margin = theme.ButtonSpacing }; layers3DButton.Click += SwitchModes_Click; buttonGroupB.Add(layers3DButton); if (!UserSettings.Instance.IsTouchScreen) { this.AddChild(layers3DButton); } iconPath = Path.Combine("ViewTransformControls", "gcode_2d.png"); layers2DButton = new RadioIconButton(AggContext.StaticData.LoadIcon(iconPath, 16, 16, theme.InvertIcons), theme) { SiblingRadioButtonList = buttonGroupB, Name = "Layers2D Button", Checked = printer?.ViewState.ViewMode == PartViewMode.Layers2D, ToolTipText = "2D Layer View".Localize(), Margin = theme.ButtonSpacing, }; layers2DButton.Click += SwitchModes_Click; buttonGroupB.Add(layers2DButton); this.AddChild(layers2DButton); this.AddChild(new HorizontalSpacer()); bool shareTemp = printer.Settings.GetValue <bool>(SettingsKey.extruders_share_temperature); int extruderCount = shareTemp ? 1 : printer.Settings.GetValue <int>(SettingsKey.extruder_count); if (!printer.Settings.GetValue <bool>(SettingsKey.sla_printer)) { for (int extruderIndex = 0; extruderIndex < extruderCount; extruderIndex++) { this.AddChild(new TemperatureWidgetHotend(printer, extruderIndex, theme) { Margin = new BorderDouble(right: 10) }); } } if (printer.Settings.GetValue <bool>(SettingsKey.has_heated_bed)) { this.AddChild(new TemperatureWidgetBed(printer, theme)); } this.OverflowButton.Name = "Printer Overflow Menu"; this.ExtendOverflowMenu = (popupMenu) => { this.GeneratePrinterOverflowMenu(popupMenu, ApplicationController.Instance.MenuTheme); }; printer.ViewState.ViewModeChanged += (s, e) => { RadioIconButton activeButton = null; if (e.ViewMode == PartViewMode.Layers2D) { activeButton = layers2DButton; } else if (e.ViewMode == PartViewMode.Layers3D) { activeButton = layers3DButton; } else { activeButton = modelViewButton; } if (activeButton != null) { activeButton.Checked = true; if (!buttonIsBeingClicked) { activeButton.FlashBackground(theme.Colors.PrimaryAccentColor.WithContrast(theme.Colors.PrimaryTextColor, 6).ToColor()); } } }; printer.Connection.ConnectionSucceeded.RegisterEvent((s, e) => { UiThread.RunOnIdle(() => { PrintRecovery.CheckIfNeedToRecoverPrint(printer); }); }, ref unregisterEvents); }
public PopupMenuButton CreateSplitButton(SplitButtonParams buttonParams, OperationGroup operationGroup = null) { PopupMenuButton menuButton = null; GuiWidget innerButton; if (buttonParams.ButtonText == null) { innerButton = new IconButton(buttonParams.Icon, this) { Name = buttonParams.ButtonName + " Inner SplitButton", Enabled = buttonParams.ButtonEnabled, ToolTipText = buttonParams.ButtonTooltip, }; // Remove right Padding for drop style innerButton.Padding = innerButton.Padding.Clone(right: 0); } else { if (buttonParams.Icon == null) { innerButton = new TextButton(buttonParams.ButtonText, this) { Name = buttonParams.ButtonName, Enabled = buttonParams.ButtonEnabled, ToolTipText = buttonParams.ButtonTooltip, }; } else { innerButton = new TextIconButton(buttonParams.ButtonText, buttonParams.Icon, this) { Name = buttonParams.ButtonName, Enabled = buttonParams.ButtonEnabled, ToolTipText = buttonParams.ButtonTooltip, }; } } innerButton.Click += (s, e) => { buttonParams.ButtonAction.Invoke(menuButton); }; if (operationGroup == null) { menuButton = new PopupMenuButton(innerButton, this); } else { menuButton = new OperationGroupButton(operationGroup, innerButton, this); } var theme = ApplicationController.Instance.MenuTheme; menuButton.DynamicPopupContent = () => { var popupMenu = new PopupMenu(theme); buttonParams.ExtendPopupMenu?.Invoke(popupMenu); return(popupMenu); }; menuButton.Name = buttonParams.ButtonName + " Menu SplitButton"; if (buttonParams.ButtonText == null) { menuButton.BackgroundColor = this.ToolbarButtonBackground; } else { menuButton.BackgroundColor = this.MinimalShade; } menuButton.HoverColor = this.ToolbarButtonHover; menuButton.MouseDownColor = this.ToolbarButtonDown; menuButton.DrawArrow = true; menuButton.Margin = this.ButtonSpacing; menuButton.DistinctPopupButton = true; menuButton.BackgroundRadius = new RadiusCorners(theme.ButtonRadius, theme.ButtonRadius, 0, 0); innerButton.Selectable = true; return(menuButton); }