Exemple #1
0
        private void GeneratePrinterOverflowMenu(PopupMenu popupMenu, ThemeConfig theme)
        {
            var menuActions = new List <NamedAction>()
            {
                new NamedAction()
                {
                    Icon      = AggContext.StaticData.LoadIcon("memory_16x16.png", 16, 16, theme.InvertIcons),
                    Title     = "Configure EEProm".Localize(),
                    Action    = configureEePromButton_Click,
                    IsEnabled = () => printer.Connection.IsConnected
                },
                new NamedBoolAction()
                {
                    Title       = "Configure Printer".Localize(),
                    Action      = () => { },
                    GetIsActive = () => printer.ViewState.ConfigurePrinterVisible,
                    SetIsActive = (value) => printer.ViewState.ConfigurePrinterVisible = value
                },
                new NamedAction()
                {
                    Title = "----"
                },
                new NamedAction()
                {
                    Title  = "Delete Printer".Localize(),
                    Action = () =>
                    {
                        StyledMessageBox.ShowMessageBox(
                            (doDelete) =>
                        {
                            if (doDelete)
                            {
                                printer.Settings.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());
                    }
                }
            };

            theme.CreateMenuItems(popupMenu, menuActions);
        }
Exemple #2
0
        private void GeneratePrinterOverflowMenu(PopupMenu popupMenu, ThemeConfig theme)
        {
            var menuActions = new List <NamedAction>()
            {
                new NamedAction()
                {
                    Icon      = AggContext.StaticData.LoadIcon("memory_16x16.png", 16, 16, theme.InvertIcons),
                    Title     = "Configure EEProm".Localize(),
                    Action    = configureEePromButton_Click,
                    IsEnabled = () => printer.Connection.IsConnected
                },
                new NamedBoolAction()
                {
                    Title       = "Show Controls".Localize(),
                    Action      = () => { },
                    GetIsActive = () => printer.ViewState.ControlsVisible,
                    SetIsActive = (value) => printer.ViewState.ControlsVisible = value
                },
                new NamedBoolAction()
                {
                    Title       = "Show Terminal".Localize(),
                    Action      = () => { },
                    GetIsActive = () => printer.ViewState.TerminalVisible,
                    SetIsActive = (value) => printer.ViewState.TerminalVisible = value
                },
                new NamedBoolAction()
                {
                    Title       = "Configure Printer".Localize(),
                    Action      = () => { },
                    GetIsActive = () => printer.ViewState.ConfigurePrinterVisible,
                    SetIsActive = (value) => printer.ViewState.ConfigurePrinterVisible = value
                },
                new ActionSeparator(),
                new NamedAction()
                {
                    Title  = "Import Presets".Localize(),
                    Action = () =>
                    {
                        AggContext.FileDialogs.OpenFileDialog(
                            new OpenFileDialogParams("settings files|*.printer"),
                            (dialogParams) =>
                        {
                            if (!string.IsNullOrEmpty(dialogParams.FileName))
                            {
                                DialogWindow.Show(new ImportSettingsPage(dialogParams.FileName, printer));
                            }
                        });
                    }
                },
                new NamedAction()
                {
                    Title  = "Export Printer".Localize(),
                    Action = () => UiThread.RunOnIdle(() =>
                    {
                        ApplicationController.Instance.ExportAsMatterControlConfig(printer);
                    }),
                    Icon = AggContext.StaticData.LoadIcon("cube_export.png", 16, 16, theme.InvertIcons),
                },
                new ActionSeparator(),

                new NamedAction()
                {
                    Title  = "Calibrate Printer".Localize(),
                    Action = () => UiThread.RunOnIdle(() =>
                    {
                        UiThread.RunOnIdle(() =>
                        {
                            DialogWindow.Show(new PrinterCalibrationWizard(printer, theme));
                        });
                    }),
                    Icon = AggContext.StaticData.LoadIcon("compass.png", theme.InvertIcons)
                },
                new ActionSeparator(),
                new NamedAction()
                {
                    Title  = "Restore Settings".Localize(),
                    Action = () =>
                    {
                        DialogWindow.Show(new PrinterProfileHistoryPage(printer));
                    }
                },
                new NamedAction()
                {
                    Title  = "Reset to Defaults".Localize(),
                    Action = () =>
                    {
                        StyledMessageBox.ShowMessageBox(
                            (revertSettings) =>
                        {
                            if (revertSettings)
                            {
                                printer.Settings.ClearUserOverrides();
                                printer.Settings.ClearBlackList();
                                // this is user driven
                                printer.Settings.Save();
                                printer.Settings.Helpers.PrintLevelingData.SampledPositions.Clear();

                                ApplicationController.Instance.ReloadAll().ConfigureAwait(false);
                            }
                        },
                            "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);
                    }
                },
                new ActionSeparator(),
                new NamedAction()
                {
                    Title  = "Delete Printer".Localize(),
                    Action = () =>
                    {
                        StyledMessageBox.ShowMessageBox(
                            (doDelete) =>
                        {
                            if (doDelete)
                            {
                                ProfileManager.Instance.DeletePrinter(printer.Settings.ID);
                            }
                        },
                            "Are you sure you want to delete printer '{0}'?".Localize().FormatWith(printer.Settings.GetValue(SettingsKey.printer_name)),
                            "Delete Printer?".Localize(),
                            StyledMessageBox.MessageType.YES_NO,
                            "Delete Printer".Localize());
                    },
                }
            };

            theme.CreateMenuItems(popupMenu, menuActions);
        }
Exemple #3
0
        private void GeneratePrinterOverflowMenu(PopupMenu popupMenu, ThemeConfig theme)
        {
            var menuActions = new List <NamedAction>()
            {
                new NamedAction()
                {
                    Icon      = AggContext.StaticData.LoadIcon("memory_16x16.png", 16, 16, theme.InvertIcons),
                    Title     = "Configure EEProm".Localize(),
                    Action    = configureEePromButton_Click,
                    IsEnabled = () => printer.Connection.IsConnected
                },
                new NamedBoolAction()
                {
                    Title       = "Show Controls".Localize(),
                    Action      = () => { },
                    GetIsActive = () => printer.ViewState.ControlsVisible,
                    SetIsActive = (value) => printer.ViewState.ControlsVisible = value
                },
                new NamedBoolAction()
                {
                    Title       = "Show Terminal".Localize(),
                    Action      = () => { },
                    GetIsActive = () => printer.ViewState.TerminalVisible,
                    SetIsActive = (value) => printer.ViewState.TerminalVisible = value
                },
                new NamedBoolAction()
                {
                    Title       = "Configure Printer".Localize(),
                    Action      = () => { },
                    GetIsActive = () => printer.ViewState.ConfigurePrinterVisible,
                    SetIsActive = (value) => printer.ViewState.ConfigurePrinterVisible = value
                },
                new ActionSeparator(),
                new NamedAction()
                {
                    Title  = "Import Presets".Localize(),
                    Action = () =>
                    {
                        AggContext.FileDialogs.OpenFileDialog(
                            new OpenFileDialogParams("settings files|*.printer"),
                            (dialogParams) =>
                        {
                            if (!string.IsNullOrEmpty(dialogParams.FileName))
                            {
                                DialogWindow.Show(new ImportSettingsPage(dialogParams.FileName, printer));
                            }
                        });
                    }
                },
                new NamedAction()
                {
                    Title  = "Export All Settings".Localize(),
                    Action = () =>
                    {
                        printer.Settings.Helpers.ExportAsMatterControlConfig();
                    }
                },
                new ActionSeparator(),
                new NamedAction()
                {
                    Title  = "Restore Settings".Localize(),
                    Action = () =>
                    {
                        DialogWindow.Show <PrinterProfileHistoryPage>();
                    }
                },
                new NamedAction()
                {
                    Title  = "Reset to Defaults".Localize(),
                    Action = () =>
                    {
                        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);
                    }
                },
                new ActionSeparator(),
                new NamedAction()
                {
                    Title  = "Delete Printer".Localize(),
                    Action = () =>
                    {
                        StyledMessageBox.ShowMessageBox(
                            (doDelete) =>
                        {
                            if (doDelete)
                            {
                                ProfileManager.Instance.DeleteActivePrinter(true);
                            }
                        },
                            "Are you sure you want to delete your currently selected printer?".Localize(),
                            "Delete Printer?".Localize(),
                            StyledMessageBox.MessageType.YES_NO,
                            "Delete Printer".Localize());
                    }
                }
            };

            theme.CreateMenuItems(popupMenu, menuActions);
        }