예제 #1
0
        public static void Show <PanelType>() where PanelType : DialogPage, new()
        {
            DialogWindow wizardWindow = GetWindow(typeof(PanelType));
            var          newPanel     = wizardWindow.ChangeToPage <PanelType>();

            wizardWindow.Title = newPanel.WindowTitle;

            SetSizeAndShow(wizardWindow, newPanel);
        }
예제 #2
0
        public static DialogWindow Show(DialogPage wizardPage)
        {
            DialogWindow wizardWindow = GetWindow(wizardPage.GetType());

            wizardWindow.Title = wizardPage.WindowTitle;

            SetSizeAndShow(wizardWindow, wizardPage);

            wizardWindow.ChangeToPage(wizardPage);

            return(wizardWindow);
        }
예제 #3
0
        public void ShowNextPage(DialogWindow dialogWindow)
        {
            UiThread.RunOnIdle(() =>
            {
                // Shutdown active page
                pages.Current?.PageIsBecomingInactive();
                pages.Current?.Close();

                // Advance
                pages.MoveNext();

                pages.Current?.PageIsBecomingActive();

                dialogWindow.ChangeToPage(pages.Current);
            });
        }
예제 #4
0
        public static DialogWindow Show(ISetupWizard setupWizard)
        {
            DialogWindow wizardWindow = GetWindow(setupWizard.GetType());

            wizardWindow.Title = setupWizard.Title;

            if (setupWizard.WindowSize != Vector2.Zero)
            {
                wizardWindow.Size = setupWizard.WindowSize;
            }

            SetSizeAndShow(wizardWindow, setupWizard.Current);

            wizardWindow.ChangeToPage(setupWizard.Current);

            // Set focus to ensure Enter/Esc key handlers are caught
            setupWizard.Current.Focus();

            EventHandler windowClosed = null;
            EventHandler <KeyEventArgs> windowKeyDown = null;

            windowClosed = (s, e) =>
            {
                setupWizard.Dispose();
                wizardWindow.Closed  -= windowClosed;
                wizardWindow.KeyDown -= windowKeyDown;
            };

            windowKeyDown = (s, e) =>
            {
                switch (e.KeyCode)
                {
                // Auto-advance to next page on enter key
                case Keys.Enter:
                    if (setupWizard.Current is WizardPage currentPage && currentPage.NextButton.Enabled)
                    {
                        UiThread.RunOnIdle(() => currentPage.NextButton.InvokeClick());
                    }
                    break;
                }
            };

            wizardWindow.Closed  += windowClosed;
            wizardWindow.KeyDown += windowKeyDown;

            return(wizardWindow);
        }
예제 #5
0
        public static DialogWindow Show(ISetupWizard setupWizard)
        {
            DialogWindow wizardWindow = GetWindow(setupWizard.GetType());

            wizardWindow.Title = setupWizard.WindowTitle;

            SetSizeAndShow(wizardWindow, setupWizard.CurrentPage);

            wizardWindow.ChangeToPage(setupWizard.CurrentPage);

            EventHandler windowClosed = null;

            windowClosed = (s, e) =>
            {
                setupWizard.Dispose();
                wizardWindow.Closed -= windowClosed;
            };

            wizardWindow.Closed += windowClosed;

            return(wizardWindow);
        }
예제 #6
0
        public ImportSettingsPage(string settingsFilePath, PrinterConfig printer)
        {
            this.WindowTitle = "Import Wizard";
            this.HeaderText  = "Select What to Import".Localize();

            // TODO: Need to handle load failures for import attempts
            var settingsToImport = PrinterSettings.LoadFile(settingsFilePath);

            // if there are no settings to import
            if (settingsToImport.QualityLayers.Count == 0 && settingsToImport.MaterialLayers.Count == 0)
            {
                // Only main setting so don't ask what to merge just do it.
                UiThread.RunOnIdle(() =>
                {
                    DisplayFailedToImportMessage(settingsFilePath);
                    this.Parents <SystemWindow>().First().Close();
                });
            }

            this.settingsFilePath = settingsFilePath;

            var scrollWindow = new ScrollableWidget()
            {
                AutoScroll = true,
                HAnchor    = HAnchor.Stretch,
                VAnchor    = VAnchor.Stretch,
            };

            scrollWindow.ScrollArea.HAnchor = HAnchor.Stretch;
            contentRow.AddChild(scrollWindow);

            var container = new FlowLayoutWidget(FlowDirection.TopToBottom)
            {
                HAnchor = HAnchor.Stretch,
            };

            scrollWindow.AddChild(container);

            if (settingsToImport.QualityLayers.Count > 0)
            {
                container.AddChild(new TextWidget("Quality Presets:")
                {
                    TextColor = theme.TextColor,
                    Margin    = new BorderDouble(0, 3),
                });

                int buttonIndex = 0;
                foreach (var qualitySetting in settingsToImport.QualityLayers)
                {
                    var qualityButton = new RadioButton(string.IsNullOrEmpty(qualitySetting.Name) ? "no name" : qualitySetting.Name)
                    {
                        TextColor = theme.TextColor,
                        Margin    = new BorderDouble(5, 0, 0, 0),
                        HAnchor   = HAnchor.Left,
                    };
                    container.AddChild(qualityButton);

                    int localButtonIndex = buttonIndex;
                    qualityButton.CheckedStateChanged += (s, e) =>
                    {
                        if (qualityButton.Checked)
                        {
                            selectedQuality = localButtonIndex;
                        }
                        else
                        {
                            selectedQuality = -1;
                        }
                    };

                    buttonIndex++;
                }
            }

            if (settingsToImport.MaterialLayers.Count > 0)
            {
                container.AddChild(new TextWidget("Material Presets:")
                {
                    TextColor = theme.TextColor,
                    Margin    = new BorderDouble(0, 3, 0, 15),
                });

                int buttonIndex = 0;
                foreach (var materialSetting in settingsToImport.MaterialLayers)
                {
                    var materialButton = new RadioButton(string.IsNullOrEmpty(materialSetting.Name) ? "no name" : materialSetting.Name)
                    {
                        TextColor = theme.TextColor,
                        Margin    = new BorderDouble(5, 0),
                        HAnchor   = HAnchor.Left,
                    };

                    container.AddChild(materialButton);

                    int localButtonIndex = buttonIndex;
                    materialButton.CheckedStateChanged += (s, e) =>
                    {
                        if (materialButton.Checked)
                        {
                            selectedMaterial = localButtonIndex;
                        }
                        else
                        {
                            selectedMaterial = -1;
                        }
                    };

                    buttonIndex++;
                }
            }

            var mergeButton = theme.CreateDialogButton("Import".Localize());

            mergeButton.Name   = "Merge Profile";
            mergeButton.Click += (s, e) => UiThread.RunOnIdle(() =>
            {
                bool copyName = false;
                PrinterSettingsLayer sourceLayer = null;
                bool destIsMaterial = true;
                if (selectedMaterial > -1)
                {
                    sourceLayer = settingsToImport.MaterialLayers[selectedMaterial];
                    copyName    = true;
                }
                else if (selectedQuality > -1)
                {
                    destIsMaterial = false;
                    sourceLayer    = settingsToImport.QualityLayers[selectedQuality];
                    copyName       = true;
                }

                List <PrinterSettingsLayer> sourceFilter;

                if (selectedQuality == -1 && selectedMaterial == -1)
                {
                    sourceFilter = new List <PrinterSettingsLayer>()
                    {
                        settingsToImport.OemLayer,
                        settingsToImport.UserLayer
                    };
                }
                else
                {
                    sourceFilter = new List <PrinterSettingsLayer>()
                    {
                        sourceLayer
                    };
                }

                if (File.Exists(settingsFilePath))
                {
                    if (Path.GetExtension(settingsFilePath).ToLower() == ProfileManager.ProfileExtension)
                    {
                        var printerSettingsLayer = new PrinterSettingsLayer();
                        printer.Settings.Merge(printerSettingsLayer, settingsToImport, sourceFilter, copyName);

                        var layerName = (printerSettingsLayer.ContainsKey(SettingsKey.layer_name)) ? printerSettingsLayer[SettingsKey.layer_name] : "none";

                        string sectionName = destIsMaterial ? "Material".Localize() : "Quality".Localize();

                        string importSettingSuccessMessage = string.Format("You have successfully imported a new {0} setting. You can find '{1}' in your list of {0} settings.".Localize(), sectionName, layerName);

                        DialogWindow.ChangeToPage(
                            new ImportSucceeded(importSettingSuccessMessage)
                        {
                            DialogWindow = this.DialogWindow,
                        });

                        if (destIsMaterial)
                        {
                            printer.Settings.MaterialLayers.Add(printerSettingsLayer);
                        }
                        else
                        {
                            printer.Settings.QualityLayers.Add(printerSettingsLayer);
                        }
                    }
                    else
                    {
                        // Inform of unexpected extension type
                        StyledMessageBox.ShowMessageBox(
                            "Oops! Unable to recognize settings file '{0}'.".Localize().FormatWith(Path.GetFileName(settingsFilePath)),
                            "Unable to Import".Localize());
                    }
                }
            });

            this.AddPageAction(mergeButton);
        }
		public AndroidConnectDevicePage()
		{
			TextWidget printerNameLabel = new TextWidget("Connect Your Device".Localize() + ":", 0, 0, labelFontSize)
			{
				TextColor = ActiveTheme.Instance.PrimaryTextColor,
				Margin = new BorderDouble(bottom: 10)
			};
			contentRow.AddChild(printerNameLabel);

			contentRow.AddChild(new TextWidget("Instructions".Localize() + ":", 0, 0, 12,textColor:ActiveTheme.Instance.PrimaryTextColor));
			contentRow.AddChild(new TextWidget("1. Power on your 3D Printer.".Localize(), 0, 0, 12,textColor:ActiveTheme.Instance.PrimaryTextColor));
			contentRow.AddChild(new TextWidget("2. Attach your 3D Printer via USB.".Localize(), 0, 0, 12,textColor:ActiveTheme.Instance.PrimaryTextColor));
			contentRow.AddChild(new TextWidget("3. Press 'Connect'.".Localize(), 0, 0, 12,textColor:ActiveTheme.Instance.PrimaryTextColor));

			//Add inputs to main container
			ApplicationController.Instance.ActivePrinter.Connection.CommunicationStateChanged.RegisterEvent(communicationStateChanged, ref unregisterEvents);

			connectButtonContainer = new FlowLayoutWidget()
			{
				HAnchor = HAnchor.Stretch,
				Margin = new BorderDouble(0, 6)
			};

			//Construct buttons
			connectButton = theme.WhiteButtonFactory.Generate("Connect".Localize());
			connectButton.Margin = new BorderDouble(0,0,10,0);
			connectButton.Click += ConnectButton_Click;

			skipButton = theme.WhiteButtonFactory.Generate("Skip".Localize());
			skipButton.Click += NextButton_Click;

			connectButtonContainer.AddChild(connectButton);
			connectButtonContainer.AddChild(skipButton);
			connectButtonContainer.AddChild(new HorizontalSpacer());
			contentRow.AddChild(connectButtonContainer);

			skipMessage = new TextWidget("(Press 'Skip' to setup connection later)".Localize(), 0, 0, 10, textColor: ActiveTheme.Instance.PrimaryTextColor);
			contentRow.AddChild(skipMessage);

			generalError = new TextWidget("", 0, 0, errorFontSize)
			{
				TextColor = ActiveTheme.Instance.PrimaryAccentColor,
				HAnchor = HAnchor.Stretch,
				Visible = false,
				Margin = new BorderDouble(top: 20),
			};
			contentRow.AddChild(generalError);

			//Construct buttons
			retryButton = theme.WhiteButtonFactory.Generate("Retry".Localize());
			retryButton.Click += ConnectButton_Click;
			retryButton.Margin = new BorderDouble(0,0,10,0);

			//Construct buttons
			troubleshootButton = theme.WhiteButtonFactory.Generate("Troubleshoot".Localize());
			troubleshootButton.Click += (s, e) => UiThread.RunOnIdle(() =>
			{
				DialogWindow.ChangeToPage<SetupWizardTroubleshooting>();
			});

			retryButtonContainer = new FlowLayoutWidget()
			{
				HAnchor = HAnchor.Stretch,
				Margin = new BorderDouble(0, 6),
				Visible = false
			};

			retryButtonContainer.AddChild(retryButton);
			retryButtonContainer.AddChild(troubleshootButton);
			retryButtonContainer.AddChild(new HorizontalSpacer());

			contentRow.AddChild(retryButtonContainer);

			//Construct buttons
			nextButton = theme.ButtonFactory.Generate("Continue".Localize());
			nextButton.Click += NextButton_Click;
			nextButton.Visible = false;

			GuiWidget hSpacer = new GuiWidget();
			hSpacer.HAnchor = HAnchor.Stretch;

			this.AddPageAction(nextButton);

			updateControls(true);
		}