public static void Show(string uri, string title, WizardPage wizardPage) { WizardWindow wizardWindow = GetWindow(uri); wizardWindow.Title = title; wizardWindow.ChangeToPage(wizardPage); }
private void ImportSettingsFile(string settingsFilePath) { if (newPrinterButton.Checked) { if (ProfileManager.ImportFromExisting(settingsFilePath)) { WizardWindow.ChangeToPage(new ImportSucceeded(importPrinterSuccessMessage.FormatWith(Path.GetFileNameWithoutExtension(settingsFilePath))) { WizardWindow = this.WizardWindow, }); } else { displayFailedToImportMessage(settingsFilePath); } } else if (mergeButton.Checked) { MergeSettings(settingsFilePath); } else if (newQualityPresetButton.Checked) { ImportToPreset(settingsFilePath); } else if (newMaterialPresetButton.Checked) { ImportToPreset(settingsFilePath); } }
public static void Show <PanelType>(string uri, string title) where PanelType : WizardPage, new() { WizardWindow wizardWindow = GetWindow(uri); wizardWindow.Title = title; wizardWindow.ChangeToPage <PanelType>(); }
private void MergeSettings(string settingsFilePath) { if (!string.IsNullOrEmpty(settingsFilePath) && File.Exists(settingsFilePath)) { string importType = Path.GetExtension(settingsFilePath).ToLower(); switch (importType) { case ProfileManager.ProfileExtension: WizardWindow.ChangeToPage(new SelectPartsOfPrinterToImport(settingsFilePath, ActiveSliceSettings.Instance.UserLayer)); break; case ".slice": // old presets format case ".ini": // create a scope for variables { var settingsToImport = PrinterSettingsLayer.LoadFromIni(settingsFilePath); bool containsValidSetting = false; var activeSettings = ActiveSliceSettings.Instance; foreach (var keyName in PrinterSettings.KnownSettings) { if (activeSettings.Contains(keyName)) { containsValidSetting = true; string currentValue = activeSettings.GetValue(keyName).Trim(); string newValue; // Compare the value to import to the layer cascade value and only set if different if (settingsToImport.TryGetValue(keyName, out newValue) && currentValue != newValue) { activeSettings.UserLayer[keyName] = newValue; } } } if (containsValidSetting) { activeSettings.Save(); UiThread.RunOnIdle(ApplicationController.Instance.ReloadAdvancedControlsPanel); } else { displayFailedToImportMessage(settingsFilePath); } WizardWindow.Close(); } break; default: WizardWindow.Close(); // Did not figure out what this file is, let the user know we don't understand it StyledMessageBox.ShowMessageBox(null, "Oops! Unable to recognize settings file '{0}'.".Localize().FormatWith(Path.GetFileName(settingsFilePath)), "Unable to Import".Localize()); break; } } Invalidate(); }
public static void ShowComPortSetup() { WizardWindow wizardWindow = GetWindow("PrinterSetup"); wizardWindow.Title = "Setup Wizard".Localize(); wizardWindow.ChangeToPage <SetupStepComPortOne>(); }
private void MergeSettings(string settingsFilePath) { if (!string.IsNullOrEmpty(settingsFilePath) && File.Exists(settingsFilePath)) { string importType = Path.GetExtension(settingsFilePath).ToLower(); switch (importType) { case ".printer": WizardWindow.ChangeToPage(new SelectPartsOfPrinterToImport(settingsFilePath, ActiveSliceSettings.Instance.UserLayer)); break; case ".slice": // old presets format case ".ini": var settingsToImport = PrinterSettingsLayer.LoadFromIni(settingsFilePath); string layerHeight; bool isSlic3r = settingsToImport.TryGetValue(SettingsKey.layer_height, out layerHeight); if (isSlic3r) { var activeSettings = ActiveSliceSettings.Instance; foreach (var item in settingsToImport) { // Compare the value to import to the layer cascade value and only set if different string currentValue = activeSettings.GetValue(item.Key, null).Trim(); if (currentValue != item.Value) { activeSettings.UserLayer[item.Key] = item.Value; } } activeSettings.SaveChanges(); UiThread.RunOnIdle(ApplicationController.Instance.ReloadAdvancedControlsPanel); } else { // looks like a cura file throw new NotImplementedException("need to import from 'cure.ini' files"); } WizardWindow.Close(); break; default: WizardWindow.Close(); // Did not figure out what this file is, let the user know we don't understand it StyledMessageBox.ShowMessageBox(null, "Oops! Unable to recognize settings file '{0}'.".Localize().FormatWith(Path.GetFileName(settingsFilePath)), "Unable to Import".Localize()); break; } } Invalidate(); }
public static void ShowPrinterSetup(bool userRequestedNewPrinter = false) { WizardWindow wizardWindow = GetWindow("PrinterSetup"); wizardWindow.Title = "Setup Wizard".Localize(); // Do the printer setup logic // Todo - detect wifi connectivity bool WifiDetected = MatterControlApplication.Instance.IsNetworkConnected(); if (!WifiDetected) { wizardWindow.ChangeToPage <SetupWizardWifi>(); } else { wizardWindow.ChangeToSetupPrinterForm(userRequestedNewPrinter); } }
public SelectPartsOfPrinterToImport(string settingsFilePath, PrinterSettingsLayer destinationLayer, string sectionName = null) : base(unlocalizedTextForTitle: "Import Wizard") { this.isMergeIntoUserLayer = destinationLayer == ActiveSliceSettings.Instance.UserLayer; this.destinationLayer = destinationLayer; this.sectionName = sectionName; // TODO: Need to handle load failures for import attempts settingsToImport = PrinterSettings.LoadFile(settingsFilePath); this.headerLabel.Text = "Select What to Import".Localize(); this.settingsFilePath = settingsFilePath; var scrollWindow = new ScrollableWidget() { AutoScroll = true, HAnchor = HAnchor.ParentLeftRight, VAnchor = VAnchor.ParentBottomTop, }; scrollWindow.ScrollArea.HAnchor = HAnchor.ParentLeftRight; contentRow.AddChild(scrollWindow); var container = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.ParentLeftRight, }; scrollWindow.AddChild(container); if (isMergeIntoUserLayer) { container.AddChild(new WrappedTextWidget(importMessage, textColor: ActiveTheme.Instance.PrimaryTextColor)); } // add in the check boxes to select what to import container.AddChild(new TextWidget("Main Settings:") { TextColor = ActiveTheme.Instance.PrimaryTextColor, Margin = new BorderDouble(0, 3, 0, isMergeIntoUserLayer ? 10 : 0), }); var mainProfileRadioButton = new RadioButton("Printer Profile") { TextColor = ActiveTheme.Instance.PrimaryTextColor, Margin = new BorderDouble(5, 0), HAnchor = HAnchor.ParentLeft, Checked = true, }; container.AddChild(mainProfileRadioButton); if (settingsToImport.QualityLayers.Count > 0) { container.AddChild(new TextWidget("Quality Presets:") { TextColor = ActiveTheme.Instance.PrimaryTextColor, Margin = new BorderDouble(0, 3, 0, 15), }); int buttonIndex = 0; foreach (var qualitySetting in settingsToImport.QualityLayers) { RadioButton qualityButton = new RadioButton(qualitySetting.Name) { TextColor = ActiveTheme.Instance.PrimaryTextColor, Margin = new BorderDouble(5, 0, 0, 0), HAnchor = HAnchor.ParentLeft, }; 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 = ActiveTheme.Instance.PrimaryTextColor, Margin = new BorderDouble(0, 3, 0, 15), }); int buttonIndex = 0; foreach (var materialSetting in settingsToImport.MaterialLayers) { RadioButton materialButton = new RadioButton(materialSetting.Name) { TextColor = ActiveTheme.Instance.PrimaryTextColor, Margin = new BorderDouble(5, 0), HAnchor = HAnchor.ParentLeft, }; container.AddChild(materialButton); int localButtonIndex = buttonIndex; materialButton.CheckedStateChanged += (s, e) => { if (materialButton.Checked) { selectedMaterial = localButtonIndex; } else { selectedMaterial = -1; } }; buttonIndex++; } } var mergeButtonTitle = this.isMergeIntoUserLayer ? "Merge".Localize() : "Import".Localize(); var mergeButton = textImageButtonFactory.Generate(mergeButtonTitle); mergeButton.Name = "Merge Profile"; mergeButton.Click += (s, e) => UiThread.RunOnIdle(() => { bool copyName = false; PrinterSettingsLayer sourceLayer = null; if (selectedMaterial > -1) { sourceLayer = settingsToImport.MaterialLayers[selectedMaterial]; copyName = true; } else if (selectedQuality > -1) { 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 }; } ActiveSliceSettings.Instance.Merge(destinationLayer, settingsToImport, sourceFilter, copyName); this.Parents <SystemWindow>().FirstOrDefault()?.CloseOnIdle(); }); footerRow.AddChild(mergeButton); footerRow.AddChild(new HorizontalSpacer()); footerRow.AddChild(cancelButton); if (settingsToImport.QualityLayers.Count == 0 && settingsToImport.MaterialLayers.Count == 0) { // Only main setting so don't ask what to merge just do it. UiThread.RunOnIdle(() => { var sourceFilter = new List <PrinterSettingsLayer>() { settingsToImport.OemLayer ?? new PrinterSettingsLayer(), settingsToImport.UserLayer ?? new PrinterSettingsLayer() }; ActiveSliceSettings.Instance.Merge(destinationLayer, settingsToImport, sourceFilter, false); UiThread.RunOnIdle(ApplicationController.Instance.ReloadAdvancedControlsPanel); string successMessage = importPrinterSuccessMessage.FormatWith(Path.GetFileNameWithoutExtension(settingsFilePath)); if (!isMergeIntoUserLayer) { string sourceName = isMergeIntoUserLayer ? Path.GetFileNameWithoutExtension(settingsFilePath) : destinationLayer[SettingsKey.layer_name]; string importSettingSuccessMessage = "You have successfully imported a new {1} setting. You can find '{0}' in your list of {1} settings.".Localize(); successMessage = importSettingSuccessMessage.FormatWith(sourceName, sectionName); } WizardWindow.ChangeToPage(new ImportSucceeded(successMessage) { WizardWindow = this.WizardWindow, }); }); } }
private void ImportToPreset(string settingsFilePath) { if (!string.IsNullOrEmpty(settingsFilePath) && File.Exists(settingsFilePath)) { PrinterSettingsLayer newLayer; string sectionName = (newMaterialPresetButton.Checked) ? "Material".Localize() : "Quality".Localize(); string importType = Path.GetExtension(settingsFilePath).ToLower(); switch (importType) { case ProfileManager.ProfileExtension: newLayer = new PrinterSettingsLayer(); newLayer[SettingsKey.layer_name] = Path.GetFileNameWithoutExtension(settingsFilePath); if (newQualityPresetButton.Checked) { ActiveSliceSettings.Instance.QualityLayers.Add(newLayer); } else { // newMaterialPresetButton.Checked ActiveSliceSettings.Instance.MaterialLayers.Add(newLayer); } // open a wizard to ask what to import to the preset WizardWindow.ChangeToPage(new SelectPartsOfPrinterToImport(settingsFilePath, newLayer, sectionName)); break; case ".slice": // legacy presets file extension case ".ini": var settingsToImport = PrinterSettingsLayer.LoadFromIni(settingsFilePath); bool containsValidSetting = false; { newLayer = new PrinterSettingsLayer(); newLayer.Name = Path.GetFileNameWithoutExtension(settingsFilePath); // Only be the base and oem layers (not the user, quality or material layer) var baseAndOEMCascade = new List <PrinterSettingsLayer> { ActiveSliceSettings.Instance.OemLayer, ActiveSliceSettings.Instance.BaseLayer }; foreach (var keyName in PrinterSettings.KnownSettings) { if (ActiveSliceSettings.Instance.Contains(keyName)) { containsValidSetting = true; string currentValue = ActiveSliceSettings.Instance.GetValue(keyName, baseAndOEMCascade).Trim(); string newValue; // Compare the value to import to the layer cascade value and only set if different if (settingsToImport.TryGetValue(keyName, out newValue) && currentValue != newValue) { newLayer[keyName] = newValue; } } } if (containsValidSetting) { if (newMaterialPresetButton.Checked) { ActiveSliceSettings.Instance.MaterialLayers.Add(newLayer); } else { ActiveSliceSettings.Instance.QualityLayers.Add(newLayer); } ActiveSliceSettings.Instance.Save(); WizardWindow.ChangeToPage(new ImportSucceeded(importSettingSuccessMessage.FormatWith(Path.GetFileNameWithoutExtension(settingsFilePath), sectionName)) { WizardWindow = this.WizardWindow, }); } else { displayFailedToImportMessage(settingsFilePath); } } break; default: // Did not figure out what this file is, let the user know we don't understand it StyledMessageBox.ShowMessageBox(null, "Oops! Unable to recognize settings file '{0}'.".Localize().FormatWith(Path.GetFileName(settingsFilePath)), "Unable to Import".Localize()); break; } } Invalidate(); }
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 PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(communicationStateChanged, ref unregisterEvents); connectButtonContainer = new FlowLayoutWidget() { HAnchor = HAnchor.ParentLeftRight, Margin = new BorderDouble(0, 6) }; //Construct buttons connectButton = whiteImageButtonFactory.Generate("Connect".Localize(), centerText: true); connectButton.Margin = new BorderDouble(0, 0, 10, 0); connectButton.Click += new EventHandler(ConnectButton_Click); skipButton = whiteImageButtonFactory.Generate("Skip".Localize(), centerText: true); skipButton.Click += new EventHandler(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.SecondaryAccentColor, HAnchor = HAnchor.ParentLeftRight, Visible = false, Margin = new BorderDouble(top: 20), }; contentRow.AddChild(generalError); //Construct buttons retryButton = whiteImageButtonFactory.Generate("Retry".Localize(), centerText: true); retryButton.Click += ConnectButton_Click; retryButton.Margin = new BorderDouble(0, 0, 10, 0); //Construct buttons troubleshootButton = whiteImageButtonFactory.Generate("Troubleshoot".Localize(), centerText: true); troubleshootButton.Click += (s, e) => WizardWindow.ChangeToPage <SetupWizardTroubleshooting>(); retryButtonContainer = new FlowLayoutWidget() { HAnchor = HAnchor.ParentLeftRight, Margin = new BorderDouble(0, 6), Visible = false }; retryButtonContainer.AddChild(retryButton); retryButtonContainer.AddChild(troubleshootButton); retryButtonContainer.AddChild(new HorizontalSpacer()); contentRow.AddChild(retryButtonContainer); //Construct buttons nextButton = textImageButtonFactory.Generate("Continue".Localize()); nextButton.Click += NextButton_Click; nextButton.Visible = false; GuiWidget hSpacer = new GuiWidget(); hSpacer.HAnchor = HAnchor.ParentLeftRight; //Add buttons to buttonContainer footerRow.AddChild(nextButton); footerRow.AddChild(hSpacer); footerRow.AddChild(cancelButton); updateControls(true); }
void Merge() { var activeSettings = ActiveSliceSettings.Instance; var layerCascade = new List <PrinterSettingsLayer> { ActiveSliceSettings.Instance.OemLayer, ActiveSliceSettings.Instance.BaseLayer, destinationLayer, }; PrinterSettingsLayer layerToImport = settingsToImport.BaseLayer; if (selectedMaterial > -1) { var material = settingsToImport.MaterialLayers[selectedMaterial]; foreach (var item in material) { if (!skipKeys.Contains(item.Key)) { destinationLayer[item.Key] = item.Value; } } if (!isMergeIntoUserLayer && material.ContainsKey(SettingsKey.layer_name)) { destinationLayer[SettingsKey.layer_name] = material[SettingsKey.layer_name]; } } else if (selectedQuality > -1) { var quality = settingsToImport.QualityLayers[selectedQuality]; foreach (var item in quality) { if (!skipKeys.Contains(item.Key)) { destinationLayer[item.Key] = item.Value; } } if (!isMergeIntoUserLayer && quality.ContainsKey(SettingsKey.layer_name)) { destinationLayer[SettingsKey.layer_name] = quality[SettingsKey.layer_name]; } } else { foreach (var item in layerToImport) { // Compare the value to import to the layer cascade value and only set if different string currentValue = activeSettings.GetValue(item.Key, layerCascade).Trim(); string importValue = settingsToImport.GetValue(item.Key, layerCascade).Trim(); if (currentValue != item.Value) { destinationLayer[item.Key] = item.Value; } } } activeSettings.Save(); UiThread.RunOnIdle(ApplicationController.Instance.ReloadAdvancedControlsPanel); string successMessage = importPrinterSuccessMessage.FormatWith(Path.GetFileNameWithoutExtension(settingsFilePath)); if (!isMergeIntoUserLayer) { string sourceName = isMergeIntoUserLayer ? Path.GetFileNameWithoutExtension(settingsFilePath) : destinationLayer[SettingsKey.layer_name]; successMessage = ImportSettingsPage.importSettingSuccessMessage.FormatWith(sourceName, sectionName); } WizardWindow.ChangeToPage(new ImportSucceeded(successMessage) { WizardWindow = this.WizardWindow, }); }
private void ImportToPreset(string settingsFilePath) { if (!string.IsNullOrEmpty(settingsFilePath) && File.Exists(settingsFilePath)) { PrinterSettingsLayer newLayer; string sectionName = (newMaterialPresetButton.Checked) ? "Material".Localize() : "Quality".Localize(); string importType = Path.GetExtension(settingsFilePath).ToLower(); switch (importType) { case ".printer": newLayer = new PrinterSettingsLayer(); newLayer["layer_name"] = Path.GetFileNameWithoutExtension(settingsFilePath); if (newQualityPresetButton.Checked) { ActiveSliceSettings.Instance.QualityLayers.Add(newLayer); } else { // newMaterialPresetButton.Checked ActiveSliceSettings.Instance.MaterialLayers.Add(newLayer); } // open a wizard to ask what to import to the preset WizardWindow.ChangeToPage(new SelectPartsOfPrinterToImport(settingsFilePath, newLayer, sectionName)); break; case ".slice": // legacy presets file extension case ".ini": var settingsToImport = PrinterSettingsLayer.LoadFromIni(settingsFilePath); string layerHeight; bool isSlic3r = importType == ".slice" || settingsToImport.TryGetValue(SettingsKey.layer_height, out layerHeight); if (isSlic3r) { newLayer = new PrinterSettingsLayer(); newLayer.Name = Path.GetFileNameWithoutExtension(settingsFilePath); // Only be the base and oem layers (not the user, quality or material layer) var baseAndOEMCascade = new List <PrinterSettingsLayer> { ActiveSliceSettings.Instance.OemLayer, ActiveSliceSettings.Instance.BaseLayer }; foreach (var item in settingsToImport) { string currentValue = ActiveSliceSettings.Instance.GetValue(item.Key, baseAndOEMCascade).Trim(); // Compare the value to import to the layer cascade value and only set if different if (currentValue != item.Value) { newLayer[item.Key] = item.Value; } } if (newMaterialPresetButton.Checked) { ActiveSliceSettings.Instance.MaterialLayers.Add(newLayer); } else { ActiveSliceSettings.Instance.QualityLayers.Add(newLayer); } ActiveSliceSettings.Instance.SaveChanges(); WizardWindow.ChangeToPage(new ImportSucceeded(importSettingSuccessMessage.FormatWith(Path.GetFileNameWithoutExtension(settingsFilePath), sectionName)) { WizardWindow = this.WizardWindow, }); } else { // looks like a cura file #if DEBUG throw new NotImplementedException("need to import from 'cure.ini' files"); #endif } break; default: // Did not figure out what this file is, let the user know we don't understand it StyledMessageBox.ShowMessageBox(null, "Oops! Unable to recognize settings file '{0}'.".Localize().FormatWith(Path.GetFileName(settingsFilePath)), "Unable to Import".Localize()); break; } } Invalidate(); }