protected override void OnClick(MouseEventArgs mouseEvent) { if (mouseEvent.Button == MouseButtons.Right) { var theme = ApplicationController.Instance.MenuTheme; // show a right click menu ('Set as Default' & 'Help') var popupMenu = new PopupMenu(theme); var historyItems = PrintHistoryData.Instance.GetHistoryItems(1).Select(f => new PrintHistoryItem(f)).ToList <ILibraryItem>(); var exportPrintHistory = popupMenu.CreateMenuItem("Export History".Localize() + "..."); exportPrintHistory.Enabled = historyItems.Count > 0; exportPrintHistory.Click += (s, e) => { }; bool showFilter = false; if (showFilter) { popupMenu.CreateSubMenu("Filter".Localize(), theme, (subMenu) => { // foreach (var printer in AllPrinters) // { // var menuItem = subMenu.CreateMenuItem(nodeOperation.Title, nodeOperation.IconCollector?.Invoke(menuTheme.InvertIcons)); // menuItem.Click += (s, e) => // { // nodeOperation.Operation(selectedItem, scene).ConfigureAwait(false); // }; // } }); } popupMenu.CreateSeparator(); var clearPrintHistory = popupMenu.CreateMenuItem("Clear History".Localize()); clearPrintHistory.Enabled = historyItems.Count > 0; clearPrintHistory.Click += (s, e) => { // clear history StyledMessageBox.ShowMessageBox( (clearHistory) => { if (clearHistory) { PrintHistoryData.Instance.ClearHistory(); } }, "Are you sure you want to clear your print history?".Localize(), "Clear History?".Localize(), StyledMessageBox.MessageType.YES_NO, "Clear History".Localize()); }; ShowMenu(mouseEvent, popupMenu); } base.OnClick(mouseEvent); }
public static void AddTextWidgetRightClickMenu() { InternalTextEditWidget.DefaultRightClick += (s, e) => { var textEditWidget = s as InternalTextEditWidget; var theme = ApplicationController.Instance.MenuTheme; var popupMenu = new PopupMenu(theme); var cut = popupMenu.CreateMenuItem("Cut".Localize()); cut.Enabled = !string.IsNullOrEmpty(s.Selection); cut.Click += (s2, e2) => { textEditWidget?.CopySelection(); textEditWidget?.DeleteSelection(); }; var copy = popupMenu.CreateMenuItem("Copy".Localize()); copy.Enabled = !string.IsNullOrEmpty(s.Selection); copy.Click += (s2, e2) => { textEditWidget?.CopySelection(); }; var paste = popupMenu.CreateMenuItem("Paste".Localize()); paste.Enabled = Clipboard.Instance.ContainsText; paste.Click += (s2, e2) => { textEditWidget?.PasteFromClipboard(); }; popupMenu.CreateSeparator(); var selectAll = popupMenu.CreateMenuItem("Select All".Localize()); selectAll.Enabled = !string.IsNullOrEmpty(textEditWidget.Text); selectAll.Click += (s2, e2) => { textEditWidget?.SelectAll(); }; textEditWidget.KeepMenuOpen = true; popupMenu.Closed += (s3, e3) => { textEditWidget.KeepMenuOpen = false; }; popupMenu.ShowMenu(s, e); }; }
public void AddNotesMenu(PopupMenu popupMenu, IEnumerable <PrintTask> printTasks, Action notesChanged) { var addNotest = popupMenu.CreateMenuItem(string.IsNullOrEmpty(printTask.Note) ? "Add Note...".Localize() : "Edit Note...".Localize()); addNotest.Enabled = printTasks.Any(); addNotest.Click += (s, e) => { var inputBoxPage = new InputBoxPage( "Print History Note".Localize(), "Note".Localize(), printTask.Note == null ? "" : printTask.Note, "Enter Note Here".Localize(), string.IsNullOrEmpty(printTask.Note) ? "Add Note".Localize() : "Update".Localize(), (newNote) => { printTask.Note = newNote; printTask.Commit(); popupMenu.Unfocus(); notesChanged(); }) { AllowEmpty = true, }; inputBoxPage.ContentRow.AddChild(CreateDefaultOptions(inputBoxPage)); DialogWindow.Show(inputBoxPage); inputBoxPage.Parent.Height += 40 * GuiWidget.DeviceScale; }; }
private void AddExportMenu(PopupMenu popupMenu, IEnumerable <PrintTask> printTasks) { var exportPrintHistory = popupMenu.CreateMenuItem("Export History".Localize() + "..."); exportPrintHistory.Enabled = printTasks.Any(); exportPrintHistory.Click += (s, e) => { if (ApplicationController.Instance.IsMatterControlPro()) { ExportToCsv(printTasks); } else // upsell MatterControl Pro { string text = "Exporting print history is a MatterControl Pro feature. Upgrade to Pro to unlock MatterControl Pro.".Localize(); WebCache.RetrieveText( "https://matterhackers.github.io/MatterControl-Docs/ProContent/Unlock_Export_Print_History.md", (markDown) => { // push the new text into the widget text = markDown; }); StyledMessageBox.ShowMessageBox(text, "Upgrade to Pro".Localize(), StyledMessageBox.MessageType.OK, useMarkdown: true, width: 540, height: 400); } }; }
private void AddNotesMenu(PopupMenu popupMenu, IEnumerable <PrintTask> printTasks) { var addNotest = popupMenu.CreateMenuItem(string.IsNullOrEmpty(printTask.Note) ? "Add Note...".Localize() : "Edit Note...".Localize()); addNotest.Enabled = printTasks.Any(); addNotest.Click += (s, e) => { DialogWindow.Show( new InputBoxPage( "Print History Note".Localize(), "Note".Localize(), printTask.Note == null ? "" : printTask.Note, "Enter Note Here".Localize(), string.IsNullOrEmpty(printTask.Note) ? "Add Note".Localize() : "Update".Localize(), (newNote) => { printTask.Note = newNote; printTask.Commit(); popupMenu.Unfocus(); printInfoWidget.Text = GetPrintInfo(); }) { AllowEmpty = true, }); }; }
public FlowLayoutWidget CreateMenuItems(PopupMenu popupMenu, IEnumerable <NamedAction> menuActions, bool emptyMenu = true) { // Retain past behavior, where menu is cleared each call. More recent callers many pass in a newly populated menu and // not require the clear if (emptyMenu) { popupMenu.CloseAllChildren(); } // Create menu items in the DropList for each element in this.menuActions foreach (var menuAction in menuActions) { if (menuAction is ActionSeparator) { popupMenu.CreateSeparator(); } else { PopupMenu.MenuItem menuItem; if (menuAction is NamedBoolAction boolAction) { menuItem = popupMenu.CreateBoolMenuItem(menuAction.Title, boolAction.GetIsActive, boolAction.SetIsActive); } else { menuItem = popupMenu.CreateMenuItem(menuAction.Title, menuAction.Icon, menuAction.Shortcut); } menuItem.Name = $"{menuAction.Title} Menu Item"; menuItem.Enabled = menuAction.Action != null && menuAction.IsEnabled?.Invoke() != false; menuItem.ClearRemovedFlag(); if (menuItem.Enabled) { menuItem.Click += (s, e) => { menuAction.Action(); }; } } } return(popupMenu); }
public FlowLayoutWidget CreateMenuItems(PopupMenu popupMenu, IEnumerable <NamedAction> menuActions) { // Create menu items in the DropList for each element in this.menuActions popupMenu.CloseAllChildren(); foreach (var menuAction in menuActions) { if (menuAction.Title == "----") { popupMenu.CreateHorizontalLine(); } else { PopupMenu.MenuItem menuItem; if (menuAction is NamedBoolAction boolAction) { menuItem = popupMenu.CreateBoolMenuItem(menuAction.Title, boolAction.GetIsActive, boolAction.SetIsActive); } else { menuItem = popupMenu.CreateMenuItem(menuAction.Title, menuAction.Icon, menuAction.Shortcut); } menuItem.Name = $"{menuAction.Title} Menu Item"; menuItem.Enabled = menuAction.Action != null && menuAction.IsEnabled?.Invoke() != false; menuItem.ClearRemovedFlag(); if (menuItem.Enabled) { menuItem.Click += (s, e) => { menuAction.Action(); }; } } } return(popupMenu); }
private void AddClearHistorMenu(PopupMenu popupMenu, IEnumerable <PrintTask> printTasks) { var clearPrintHistory = popupMenu.CreateMenuItem("Clear History".Localize()); clearPrintHistory.Enabled = printTasks.Any(); clearPrintHistory.Click += (s, e) => { // clear history StyledMessageBox.ShowMessageBox( (clearHistory) => { if (clearHistory) { PrintHistoryData.Instance.ClearHistory(); } }, "Are you sure you want to clear your print history?".Localize(), "Clear History?".Localize(), StyledMessageBox.MessageType.YES_NO, "Clear History".Localize()); }; }
public GuiWidget Create(IObject3D item, ThemeConfig theme) { var column = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.MaxFitOrStretch }; var imageObject = item as ImageObject3D; var activeImage = imageObject.Image; var imageSection = new SearchableSectionWidget("Image".Localize(), new FlowLayoutWidget(FlowDirection.TopToBottom), theme, emptyText: "Search Google".Localize()); imageSection.SearchInvoked += (s, e) => { string imageType = " silhouette"; if (item.Parent.GetType().Name.Contains("Lithophane")) { imageType = ""; } ApplicationController.Instance.LaunchBrowser($"http://www.google.com/search?q={e.Data}{imageType}&tbm=isch"); }; theme.ApplyBoxStyle(imageSection, margin: 0); column.AddChild(imageSection); ImageBuffer thumbnailImage = SetImage(theme, imageObject); ImageWidget thumbnailWidget; imageSection.ContentPanel.AddChild(thumbnailWidget = new ImageWidget(thumbnailImage) { Margin = new BorderDouble(bottom: 5), HAnchor = HAnchor.Center }); thumbnailWidget.Click += (s, e) => { if (e.Button == MouseButtons.Right) { var popupMenu = new PopupMenu(theme); var pasteMenu = popupMenu.CreateMenuItem("Paste".Localize()); pasteMenu.Click += (s2, e2) => { activeImage = Clipboard.Instance.GetImage(); thumbnailWidget.Image = activeImage; // Persist string filePath = ApplicationDataStorage.Instance.GetNewLibraryFilePath(".png"); AggContext.ImageIO.SaveImageData( filePath, activeImage); imageObject.AssetPath = filePath; imageObject.Mesh = null; thumbnailWidget.Image = SetImage(theme, imageObject); column.Invalidate(); imageObject.Invalidate(new InvalidateArgs(imageObject, InvalidateType.Image)); }; pasteMenu.Enabled = Clipboard.Instance.ContainsImage; var copyMenu = popupMenu.CreateMenuItem("Copy".Localize()); copyMenu.Click += (s2, e2) => { Clipboard.Instance.SetImage(thumbnailWidget.Image); }; var popupBounds = new RectangleDouble(e.X + 1, e.Y + 1, e.X + 1, e.Y + 1); var systemWindow = column.Parents <SystemWindow>().FirstOrDefault(); systemWindow.ShowPopup( new MatePoint(thumbnailWidget) { Mate = new MateOptions(MateEdge.Left, MateEdge.Bottom), AltMate = new MateOptions(MateEdge.Left, MateEdge.Top) }, new MatePoint(popupMenu) { Mate = new MateOptions(MateEdge.Left, MateEdge.Top), AltMate = new MateOptions(MateEdge.Left, MateEdge.Top) }, altBounds: popupBounds); } }; // add in the invert checkbox and change image button var changeButton = new TextButton("Change".Localize(), theme) { BackgroundColor = theme.MinimalShade }; changeButton.Click += (sender, e) => { UiThread.RunOnIdle(() => { // we do this using to make sure that the stream is closed before we try and insert the Picture AggContext.FileDialogs.OpenFileDialog( new OpenFileDialogParams( "Select an image file|*.jpg;*.png;*.bmp;*.gif;*.pdf", multiSelect: false, title: "Add Image".Localize()), (openParams) => { if (!File.Exists(openParams.FileName)) { return; } imageObject.AssetPath = openParams.FileName; imageObject.Mesh = null; thumbnailWidget.Image = SetImage(theme, imageObject); column.Invalidate(); imageObject.Invalidate(new InvalidateArgs(imageObject, InvalidateType.Image)); }); }); }; var row = new FlowLayoutWidget() { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, }; imageSection.ContentPanel.AddChild(row); // Invert checkbox var invertCheckbox = new CheckBox(new CheckBoxViewText("Invert".Localize(), textColor: theme.Colors.PrimaryTextColor)) { Checked = imageObject.Invert, Margin = new BorderDouble(0), }; invertCheckbox.CheckedStateChanged += (s, e) => { imageObject.Invert = invertCheckbox.Checked; }; row.AddChild(invertCheckbox); row.AddChild(new HorizontalSpacer()); row.AddChild(changeButton); imageObject.Invalidated += (s, e) => { if (e.InvalidateType == InvalidateType.Image && activeImage != imageObject.Image) { thumbnailImage = SetImage(theme, imageObject); thumbnailWidget.Image = thumbnailImage; activeImage = imageObject.Image; } }; return(column); }
private static PopupMenu CreatePopupMenu() { var menuTheme = ApplicationController.Instance.MenuTheme; var popupMenu = new PopupMenu(menuTheme) { MinimumSize = new Vector2(300, 0) }; var linkIcon = StaticData.Instance.LoadIcon("fa-link_16.png", 16, 16, menuTheme.InvertIcons); PopupMenu.MenuItem menuItem; menuItem = popupMenu.CreateMenuItem("Help".Localize(), StaticData.Instance.LoadIcon("help_page.png", 16, 16, menuTheme.InvertIcons)); menuItem.Click += (s, e) => ApplicationController.Instance.ShowApplicationHelp("Docs"); menuItem = popupMenu.CreateMenuItem("Interface Tour".Localize(), StaticData.Instance.LoadIcon("tour.png", 16, 16, menuTheme.InvertIcons)); menuItem.Click += (s, e) => { UiThread.RunOnIdle(() => { DialogWindow.Show <Tour.WelcomePage>(); }); }; if (Application.EnableNetworkTraffic) { popupMenu.CreateSeparator(); menuItem = popupMenu.CreateMenuItem("Check For Update".Localize(), StaticData.Instance.LoadIcon("update.png", 16, 16, menuTheme.InvertIcons)); menuItem.Click += (s, e) => UiThread.RunOnIdle(() => { UpdateControlData.Instance.CheckForUpdate(); DialogWindow.Show <CheckForUpdatesPage>(); }); } popupMenu.CreateSeparator(); menuItem = popupMenu.CreateMenuItem("Settings".Localize(), StaticData.Instance.LoadIcon("fa-cog_16.png", 16, 16, menuTheme.InvertIcons)); menuItem.Click += (s, e) => DialogWindow.Show <ApplicationSettingsPage>(); menuItem.Name = "Settings MenuItem"; popupMenu.CreateSeparator(); ImageBuffer indicatorIcon = null; if (IntPtr.Size == 8) { indicatorIcon = StaticData.Instance.LoadIcon("x64.png", 16, 16, menuTheme.InvertIcons); } popupMenu.CreateSubMenu("Community".Localize(), menuTheme, (modifyMenu) => { menuItem = modifyMenu.CreateMenuItem("Forums".Localize(), linkIcon); menuItem.Click += (s, e) => ApplicationController.LaunchBrowser("https://forums.matterhackers.com/category/20/mattercontrol"); menuItem = modifyMenu.CreateMenuItem("Guides and Articles".Localize(), linkIcon); menuItem.Click += (s, e) => ApplicationController.LaunchBrowser("https://www.matterhackers.com/topic/mattercontrol"); menuItem = modifyMenu.CreateMenuItem("Support".Localize(), linkIcon); menuItem.Click += (s, e) => ApplicationController.LaunchBrowser("https://www.matterhackers.com/mattercontrol/support"); menuItem = modifyMenu.CreateMenuItem("Release Notes".Localize(), linkIcon); menuItem.Click += (s, e) => ApplicationController.LaunchBrowser("https://www.matterhackers.com/mattercontrol/support/release-notes"); modifyMenu.CreateSeparator(); menuItem = modifyMenu.CreateMenuItem("Report a Bug".Localize(), StaticData.Instance.LoadIcon("feedback.png", 16, 16, menuTheme.InvertIcons)); menuItem.Click += (s, e) => ApplicationController.LaunchBrowser("https://github.com/MatterHackers/MatterControl/issues"); }, StaticData.Instance.LoadIcon("feedback.png", 16, 16, menuTheme.InvertIcons)); popupMenu.CreateSeparator(); var imageBuffer = new ImageBuffer(18, 18); // x64 indicator icon if (IntPtr.Size == 8) { var graphics = imageBuffer.NewGraphics2D(); graphics.Clear(menuTheme.BackgroundColor); graphics.Rectangle(imageBuffer.GetBoundingRect(), menuTheme.PrimaryAccentColor); graphics.DrawString("64", imageBuffer.Width / 2, imageBuffer.Height / 2, 8, Agg.Font.Justification.Center, Agg.Font.Baseline.BoundsCenter, color: menuTheme.PrimaryAccentColor); } menuItem = popupMenu.CreateMenuItem("About".Localize() + " MatterControl", imageBuffer); menuItem.Click += (s, e) => ApplicationController.Instance.ShowAboutPage(); return(popupMenu); }
public FlowLayoutWidget CreateMenuItems(PopupMenu popupMenu, IEnumerable <NamedAction> menuActions) { // Create menu items in the DropList for each element in this.menuActions foreach (var menuAction in menuActions) { if (menuAction is ActionSeparator) { popupMenu.CreateSeparator(); } else { if (menuAction is NamedActionGroup namedActionButtons) { var content = new FlowLayoutWidget() { HAnchor = HAnchor.Fit | HAnchor.Stretch }; var textWidget = new TextWidget(menuAction.Title, pointSize: this.DefaultFontSize, textColor: this.TextColor) { // Padding = MenuPadding, VAnchor = VAnchor.Center }; content.AddChild(textWidget); content.AddChild(new HorizontalSpacer()); foreach (var actionButton in namedActionButtons.Group) { var button = new TextButton(actionButton.Title, this) { Border = new BorderDouble(1, 0, 0, 0), BorderColor = this.MinimalShade, HoverColor = this.AccentMimimalOverlay, Enabled = actionButton.IsEnabled() }; content.AddChild(button); if (actionButton.IsEnabled()) { button.Click += (s, e) => { actionButton.Action(); popupMenu.Unfocus(); }; } } var menuItem = new PopupMenu.MenuItem(content, this) { HAnchor = HAnchor.Fit | HAnchor.Stretch, VAnchor = VAnchor.Fit, HoverColor = Color.Transparent, }; popupMenu.AddChild(menuItem); menuItem.Padding = new BorderDouble(menuItem.Padding.Left, menuItem.Padding.Bottom, 0, menuItem.Padding.Top); } else { PopupMenu.MenuItem menuItem; if (menuAction is NamedBoolAction boolAction) { menuItem = popupMenu.CreateBoolMenuItem(menuAction.Title, boolAction.GetIsActive, boolAction.SetIsActive); } else { menuItem = popupMenu.CreateMenuItem(menuAction.Title, menuAction.Icon, menuAction.Shortcut); } menuItem.Name = $"{menuAction.Title} Menu Item"; menuItem.Enabled = menuAction is NamedActionGroup || (menuAction.Action != null && menuAction.IsEnabled?.Invoke() != false); menuItem.ClearRemovedFlag(); if (menuItem.Enabled) { menuItem.Click += (s, e) => { menuAction.Action(); }; } } } } return(popupMenu); }
public HardwareTabPage(ThemeConfig theme) : base(FlowDirection.TopToBottom) { this.theme = theme; this.Padding = 0; this.HAnchor = HAnchor.Stretch; this.VAnchor = VAnchor.Stretch; var toolbar = new Toolbar(theme.TabbarPadding, theme.CreateSmallResetButton()) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, Padding = theme.ToolbarPadding }; theme.ApplyBottomBorder(toolbar); toolbar.AddChild(new TextButton("Inventory".Localize(), theme) { Padding = new BorderDouble(6, 0), MinimumSize = new Vector2(0, theme.ButtonHeight), Selectable = false }); this.AddChild(toolbar); var horizontalSplitter = new Splitter() { SplitterDistance = UserSettings.Instance.LibraryViewWidth, SplitterSize = theme.SplitterWidth, SplitterBackground = theme.SplitterBackground, HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, }; horizontalSplitter.DistanceChanged += (s, e) => { UserSettings.Instance.LibraryViewWidth = horizontalSplitter.SplitterDistance; }; this.AddChild(horizontalSplitter); var treeView = new HardwareTreeView(theme) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, Width = 300, Margin = 5 }; treeView.NodeMouseDoubleClick += (s, e) => { if (e is MouseEventArgs mouseEvent && s is GuiWidget clickedWidget && mouseEvent.Button == MouseButtons.Left && mouseEvent.Clicks == 2) { if (treeView?.SelectedNode.Tag is PrinterInfo printerInfo) { ApplicationController.Instance.OpenPrinter(printerInfo); } } }; treeView.NodeMouseClick += (s, e) => { if (e is MouseEventArgs mouseEvent && s is GuiWidget clickedWidget && mouseEvent.Button == MouseButtons.Right) { UiThread.RunOnIdle(() => { var popupMenu = new PopupMenu(ApplicationController.Instance.MenuTheme); var openMenuItem = popupMenu.CreateMenuItem("Open".Localize()); openMenuItem.Click += (s2, e2) => { if (treeView?.SelectedNode.Tag is PrinterInfo printerInfo) { ApplicationController.Instance.OpenPrinter(printerInfo); } }; popupMenu.CreateSeparator(); var deleteMenuItem = popupMenu.CreateMenuItem("Delete".Localize()); deleteMenuItem.Click += (s2, e2) => { if (treeView.SelectedNode.Tag is PrinterInfo printerInfo) { // Delete printer StyledMessageBox.ShowMessageBox( (deletePrinter) => { if (deletePrinter) { ProfileManager.Instance.DeletePrinter(printerInfo.ID); } }, "Are you sure you want to delete printer '{0}'?".Localize().FormatWith(printerInfo.Name), "Delete Printer?".Localize(), StyledMessageBox.MessageType.YES_NO, "Delete Printer".Localize()); } }; popupMenu.ShowMenu(clickedWidget, mouseEvent); }); } }; treeView.ScrollArea.HAnchor = HAnchor.Stretch; treeView.AfterSelect += (s, e) => { if (treeView.SelectedNode.Tag is PrinterInfo printerInfo) { horizontalSplitter.Panel2.CloseChildren(); horizontalSplitter.Panel2.AddChild(new PrinterDetails(printerInfo, theme, true) { HAnchor = HAnchor.MaxFitOrStretch, VAnchor = VAnchor.Stretch, Padding = theme.DefaultContainerPadding }); } }; horizontalSplitter.Panel1.AddChild(treeView); horizontalSplitter.Panel2.AddChild(new GuiWidget() { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, }); }
private void ExtendOverflowMenu(PopupMenu popupMenu) { popupMenu.CreateHorizontalLine(); PopupMenu.MenuItem menuItem; menuItem = popupMenu.CreateMenuItem("Import Presets".Localize()); menuItem.Click += (s, e) => UiThread.RunOnIdle(() => { AggContext.FileDialogs.OpenFileDialog( new OpenFileDialogParams("settings files|*.printer"), (dialogParams) => { if (!string.IsNullOrEmpty(dialogParams.FileName)) { DialogWindow.Show(new ImportSettingsPage(dialogParams.FileName, printer)); } }); }, .2); popupMenu.CreateHorizontalLine(); menuItem = popupMenu.CreateMenuItem("Restore Settings".Localize()); menuItem.Click += (s, e) => UiThread.RunOnIdle(() => { DialogWindow.Show <PrinterProfileHistoryPage>(); }, .2); menuItem.Enabled = !string.IsNullOrEmpty(AuthenticationData.Instance.ActiveSessionUsername); menuItem = popupMenu.CreateMenuItem("Reset to Defaults".Localize()); menuItem.Click += (s, e) => UiThread.RunOnIdle(() => { StyledMessageBox.ShowMessageBox( (revertSettings) => { if (revertSettings) { bool onlyReloadSliceSettings = true; if (printer.Settings.GetValue <bool>(SettingsKey.print_leveling_required_to_print) && printer.Settings.GetValue <bool>(SettingsKey.print_leveling_enabled)) { onlyReloadSliceSettings = false; } printer.Settings.ClearUserOverrides(); printer.Settings.Save(); if (onlyReloadSliceSettings) { printer?.Bed.GCodeRenderer?.Clear3DGCode(); } else { ApplicationController.Instance.ReloadAll(); } } }, "Resetting to default values will remove your current overrides and restore your original printer settings.\nAre you sure you want to continue?".Localize(), "Revert Settings".Localize(), StyledMessageBox.MessageType.YES_NO); }, .2); menuItem = popupMenu.CreateMenuItem("Export".Localize()); menuItem.Click += (s, e) => UiThread.RunOnIdle(() => { ActiveSliceSettings.Instance.Helpers.ExportAsMatterControlConfig(); }, .2); }
private static PopupMenu CreatePopupMenu() { var menuTheme = ApplicationController.Instance.MenuTheme; var popupMenu = new PopupMenu(menuTheme) { MinimumSize = new Vector2(300, 0) }; var linkIcon = AggContext.StaticData.LoadIcon("fa-link_16.png", 16, 16, menuTheme.InvertIcons); PopupMenu.MenuItem menuItem; menuItem = popupMenu.CreateMenuItem("Help".Localize(), AggContext.StaticData.LoadIcon("help_page.png", 16, 16, menuTheme.InvertIcons)); menuItem.Click += (s, e) => ApplicationController.Instance.ShowApplicationHelp(); popupMenu.CreateHorizontalLine(); menuItem = popupMenu.CreateMenuItem("Check For Update".Localize(), AggContext.StaticData.LoadIcon("update.png", 16, 16, menuTheme.InvertIcons)); menuItem.Click += (s, e) => UiThread.RunOnIdle(() => { UpdateControlData.Instance.CheckForUpdate(); DialogWindow.Show <CheckForUpdatesPage>(); }); popupMenu.CreateHorizontalLine(); menuItem = popupMenu.CreateMenuItem("Settings".Localize(), AggContext.StaticData.LoadIcon("fa-cog_16.png", 16, 16, menuTheme.InvertIcons)); menuItem.Click += (s, e) => DialogWindow.Show <ApplicationSettingsPage>(); menuItem.Name = "Settings MenuItem"; popupMenu.CreateHorizontalLine(); ImageBuffer indicatorIcon = null; if (IntPtr.Size == 8) { indicatorIcon = AggContext.StaticData.LoadIcon("x64.png", 16, 16, menuTheme.InvertIcons); } popupMenu.CreateSubMenu("Community".Localize(), menuTheme, (modifyMenu) => { menuItem = modifyMenu.CreateMenuItem("Forums".Localize(), linkIcon); menuItem.Click += (s, e) => ApplicationController.Instance.LaunchBrowser("https://forums.matterhackers.com/category/20/mattercontrol"); menuItem = modifyMenu.CreateMenuItem("Guides and Articles".Localize(), linkIcon); menuItem.Click += (s, e) => ApplicationController.Instance.LaunchBrowser("http://www.matterhackers.com/topic/mattercontrol"); menuItem = modifyMenu.CreateMenuItem("Support".Localize(), linkIcon); menuItem.Click += (s, e) => ApplicationController.Instance.LaunchBrowser("http://https://www.matterhackers.com/mattercontrol/support"); menuItem = modifyMenu.CreateMenuItem("Release Notes".Localize(), linkIcon); menuItem.Click += (s, e) => ApplicationController.Instance.LaunchBrowser("http://wiki.mattercontrol.com/Release_Notes"); modifyMenu.CreateHorizontalLine(); menuItem = modifyMenu.CreateMenuItem("Report a Bug".Localize(), AggContext.StaticData.LoadIcon("feedback.png", 16, 16, menuTheme.InvertIcons)); menuItem.Click += (s, e) => ApplicationController.Instance.LaunchBrowser("https://github.com/MatterHackers/MatterControl/issues"); }, AggContext.StaticData.LoadIcon("feedback.png", 16, 16, menuTheme.InvertIcons)); popupMenu.CreateHorizontalLine(); menuItem = popupMenu.CreateMenuItem("About".Localize() + " MatterControl", indicatorIcon); menuItem.Click += (s, e) => ApplicationController.Instance.ShowAboutPage(); return(popupMenu); }
public HardwareTabPage(ThemeConfig theme) { this.theme = theme; this.Padding = 0; this.AnchorAll(); var allControls = new FlowLayoutWidget(FlowDirection.TopToBottom); var horizontalSplitter = new Splitter() { SplitterDistance = UserSettings.Instance.LibraryViewWidth, SplitterSize = theme.SplitterWidth, SplitterBackground = theme.SplitterBackground }; horizontalSplitter.AnchorAll(); horizontalSplitter.DistanceChanged += (s, e) => { UserSettings.Instance.LibraryViewWidth = horizontalSplitter.SplitterDistance; }; allControls.AddChild(horizontalSplitter); treeView = new InventoryTreeView(theme) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, Width = 300, Margin = 5 }; treeView.NodeMouseDoubleClick += (s, e) => { if (e is MouseEventArgs mouseEvent && s is GuiWidget clickedWidget && mouseEvent.Button == MouseButtons.Left && mouseEvent.Clicks == 2) { if (treeView?.SelectedNode.Tag is PrinterInfo printerInfo) { // Open printer PrinterDetails.SwitchPrinters(printerInfo.ID); } } }; treeView.NodeMouseClick += (s, e) => { if (e is MouseEventArgs mouseEvent && s is GuiWidget clickedWidget && mouseEvent.Button == MouseButtons.Right) { UiThread.RunOnIdle(() => { var menu = new PopupMenu(ApplicationController.Instance.MenuTheme); var openMenuItem = menu.CreateMenuItem("Open".Localize()); openMenuItem.Click += (s2, e2) => { if (treeView?.SelectedNode.Tag is PrinterInfo printerInfo) { // Open printer PrinterDetails.SwitchPrinters(printerInfo.ID); } }; menu.CreateHorizontalLine(); var deleteMenuItem = menu.CreateMenuItem("Delete".Localize()); deleteMenuItem.Click += (s2, e2) => { // Delete printer StyledMessageBox.ShowMessageBox( (deletePrinter) => { if (deletePrinter) { if (treeView.SelectedNode.Tag is PrinterInfo printerInfo) { ProfileManager.Instance.DeletePrinter(printerInfo.ID, true); } } }, "Are you sure you want to delete your currently selected printer?".Localize(), "Delete Printer?".Localize(), StyledMessageBox.MessageType.YES_NO, "Delete Printer".Localize()); }; var systemWindow = this.Parents <SystemWindow>().FirstOrDefault(); systemWindow.ShowPopup( new MatePoint(clickedWidget) { Mate = new MateOptions(MateEdge.Left, MateEdge.Top), AltMate = new MateOptions(MateEdge.Left, MateEdge.Top) }, new MatePoint(menu) { Mate = new MateOptions(MateEdge.Left, MateEdge.Top), AltMate = new MateOptions(MateEdge.Right, MateEdge.Top) }, altBounds: new RectangleDouble(mouseEvent.X + 1, mouseEvent.Y + 1, mouseEvent.X + 1, mouseEvent.Y + 1)); }); } }; treeView.ScrollArea.HAnchor = HAnchor.Stretch; treeView.AfterSelect += async(s, e) => { if (treeView.SelectedNode.Tag is PrinterInfo printerInfo) { horizontalSplitter.Panel2.CloseAllChildren(); horizontalSplitter.Panel2.AddChild(new PrinterDetails(printerInfo, theme) { HAnchor = HAnchor.MaxFitOrStretch, VAnchor = VAnchor.Stretch, Padding = theme.DefaultContainerPadding }); } }; horizontalSplitter.Panel1.AddChild(treeView); horizontalSplitter.Panel2.AddChild(new GuiWidget() { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, }); allControls.AnchorAll(); this.AddChild(allControls); }
public HardwareTabPage(ThemeConfig theme) : base(FlowDirection.TopToBottom) { this.theme = theme; this.Padding = 0; this.HAnchor = HAnchor.Stretch; this.VAnchor = VAnchor.Stretch; var toolbar = new Toolbar(theme) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, Padding = theme.ToolbarPadding }; theme.ApplyBottomBorder(toolbar); toolbar.AddChild(new TextButton("Inventory".Localize(), theme) { Padding = new BorderDouble(6, 0), MinimumSize = new Vector2(0, theme.ButtonHeight), Selectable = false }); this.AddChild(toolbar); var horizontalSplitter = new Splitter() { SplitterDistance = UserSettings.Instance.LibraryViewWidth, SplitterSize = theme.SplitterWidth, SplitterBackground = theme.SplitterBackground, HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, }; horizontalSplitter.DistanceChanged += (s, e) => { UserSettings.Instance.LibraryViewWidth = horizontalSplitter.SplitterDistance; }; this.AddChild(horizontalSplitter); var treeView = new HardwareTreeView(theme) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, Width = 300, Margin = 5 }; treeView.NodeMouseDoubleClick += (s, e) => { if (e is MouseEventArgs mouseEvent && s is GuiWidget clickedWidget && mouseEvent.Button == MouseButtons.Left && mouseEvent.Clicks == 2) { if (treeView?.SelectedNode.Tag is PrinterInfo printerInfo) { if (ApplicationController.Instance.ActivePrinters.FirstOrDefault(p => p.Settings.ID == printerInfo.ID) is PrinterConfig printer && ApplicationController.Instance.MainView.TabControl.AllTabs.FirstOrDefault(t => t.TabContent is PrinterTabPage printerTabPage && printerTabPage.printer == printer) is ITab tab) { // Switch to existing printer tab ApplicationController.Instance.MainView.TabControl.ActiveTab = tab; } else { // Open new printer tab ApplicationController.Instance.OpenPrinter(printerInfo.ID).ConfigureAwait(false); } } } }; treeView.NodeMouseClick += (s, e) => { if (e is MouseEventArgs mouseEvent && s is GuiWidget clickedWidget && mouseEvent.Button == MouseButtons.Right) { UiThread.RunOnIdle(() => { var menu = new PopupMenu(ApplicationController.Instance.MenuTheme); var openMenuItem = menu.CreateMenuItem("Open".Localize()); openMenuItem.Click += (s2, e2) => { if (treeView?.SelectedNode.Tag is PrinterInfo printerInfo) { // Open printer ApplicationController.Instance.OpenPrinter(printerInfo.ID).ConfigureAwait(false); } }; menu.CreateSeparator(); var deleteMenuItem = menu.CreateMenuItem("Delete".Localize()); deleteMenuItem.Click += (s2, e2) => { // Delete printer StyledMessageBox.ShowMessageBox( (deletePrinter) => { if (deletePrinter) { if (treeView.SelectedNode.Tag is PrinterInfo printerInfo) { ProfileManager.Instance.DeletePrinter(printerInfo.ID); } } }, "Are you sure you want to delete your currently selected printer?".Localize(), "Delete Printer?".Localize(), StyledMessageBox.MessageType.YES_NO, "Delete Printer".Localize()); }; var systemWindow = this.Parents <SystemWindow>().FirstOrDefault(); systemWindow.ShowPopup( new MatePoint(clickedWidget) { Mate = new MateOptions(MateEdge.Left, MateEdge.Top), AltMate = new MateOptions(MateEdge.Left, MateEdge.Top) }, new MatePoint(menu) { Mate = new MateOptions(MateEdge.Left, MateEdge.Top), AltMate = new MateOptions(MateEdge.Right, MateEdge.Top) }, altBounds: new RectangleDouble(mouseEvent.X + 1, mouseEvent.Y + 1, mouseEvent.X + 1, mouseEvent.Y + 1)); }); } }; treeView.ScrollArea.HAnchor = HAnchor.Stretch; treeView.AfterSelect += async(s, e) => { if (treeView.SelectedNode.Tag is PrinterInfo printerInfo) { horizontalSplitter.Panel2.CloseAllChildren(); horizontalSplitter.Panel2.AddChild(new PrinterDetails(printerInfo, theme) { HAnchor = HAnchor.MaxFitOrStretch, VAnchor = VAnchor.Stretch, Padding = theme.DefaultContainerPadding }); } }; horizontalSplitter.Panel1.AddChild(treeView); horizontalSplitter.Panel2.AddChild(new GuiWidget() { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Stretch, }); }