public SlicePresetsPage(PrinterConfig printer, PresetsContext presetsContext) : base("Close".Localize()) { this.presetsContext = presetsContext; this.printer = printer; this.AlwaysOnTopOfMain = true; this.WindowTitle = "Slice Presets Editor".Localize(); this.WindowSize = new Vector2(640, 480); this.AnchorAll(); this.headerRow.Visible = false; this.contentRow.Padding = 0; contentRow.BackgroundColor = Color.Transparent; var inlineNameEdit = new InlineStringEdit(presetsContext.PersistenceLayer.Name, theme, presetsContext.LayerType.ToString() + " Name", boldFont: true); inlineNameEdit.ValueChanged += (s, e) => { printer.Settings.SetValue(SettingsKey.layer_name, inlineNameEdit.Text, presetsContext.PersistenceLayer); }; contentRow.AddChild(inlineNameEdit); var sliceSettingsWidget = CreateSliceSettingsWidget(printer, presetsContext.PersistenceLayer); contentRow.AddChild(sliceSettingsWidget); var duplicateButton = theme.CreateDialogButton("Duplicate".Localize()); duplicateButton.Click += (s, e) => { string sanitizedName = numberMatch.Replace(inlineNameEdit.Text, "").Trim(); string newProfileName = agg_basics.GetNonCollidingName(sanitizedName, presetsContext.PresetLayers.Select(preset => preset.ValueOrDefault(SettingsKey.layer_name))); var clonedLayer = presetsContext.PersistenceLayer.Clone(); clonedLayer.Name = newProfileName; presetsContext.PresetLayers.Add(clonedLayer); presetsContext.SetAsActive(clonedLayer.LayerID); presetsContext.PersistenceLayer = clonedLayer; sliceSettingsWidget.Close(); sliceSettingsWidget = CreateSliceSettingsWidget(printer, clonedLayer); contentRow.AddChild(sliceSettingsWidget); inlineNameEdit.Text = newProfileName; }; this.AddPageAction(duplicateButton); var deleteButton = theme.CreateDialogButton("Delete".Localize()); deleteButton.Click += (s, e) => { presetsContext.DeleteLayer(); this.DialogWindow.Close(); }; this.AddPageAction(deleteButton); }
public SlicePresetsWindow(PresetsContext presetsContext) : base(641, 481) { this.presetsContext = presetsContext; this.AlwaysOnTopOfMain = true; this.Title = LocalizedString.Get("Slice Presets Editor"); this.MinimumSize = new Vector2(640, 480); this.AnchorAll(); var linkButtonFactory = new LinkButtonFactory() { fontSize = 8, textColor = ActiveTheme.Instance.SecondaryAccentColor }; var buttonFactory = new TextImageButtonFactory() { normalTextColor = ActiveTheme.Instance.PrimaryTextColor, hoverTextColor = ActiveTheme.Instance.PrimaryTextColor, disabledTextColor = ActiveTheme.Instance.PrimaryTextColor, pressedTextColor = ActiveTheme.Instance.PrimaryTextColor, borderWidth = 0 }; FlowLayoutWidget mainContainer = new FlowLayoutWidget(FlowDirection.TopToBottom) { Padding = new BorderDouble(3) }; mainContainer.AnchorAll(); middleRow = new GuiWidget(); middleRow.AnchorAll(); middleRow.AddChild(CreateSliceSettingsWidget(presetsContext.PersistenceLayer)); mainContainer.AddChild(GetTopRow()); mainContainer.AddChild(middleRow); mainContainer.AddChild(GetBottomRow(buttonFactory)); this.AddChild(mainContainer); BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; }
public FlowLayoutWidget GetPulldownContainer() { DropDownList = CreateDropdown(); var container = new FlowLayoutWidget() { HAnchor = createAsFit ? HAnchor.Fit : HAnchor.MaxFitOrStretch, Name = "Preset Pulldown Container" }; editButton = new IconButton(AggContext.StaticData.LoadIcon("icon_edit.png", 16, 16, theme.InvertIcons), theme) { ToolTipText = "Edit Selected Setting".Localize(), Enabled = DropDownList.SelectedIndex != -1, VAnchor = VAnchor.Center, Margin = new BorderDouble(left: 6) }; editButton.Click += (sender, e) => { if (layerType == NamedSettingsLayers.Material) { if (ApplicationController.Instance.EditMaterialPresetsPage == null) { string presetsID = printer.Settings.ActiveMaterialKey; if (string.IsNullOrEmpty(presetsID)) { return; } var layerToEdit = printer.Settings.MaterialLayers.Where(layer => layer.LayerID == presetsID).FirstOrDefault(); var presetsContext = new PresetsContext(printer.Settings.MaterialLayers, layerToEdit) { LayerType = NamedSettingsLayers.Material, SetAsActive = (materialKey) => printer.Settings.ActiveMaterialKey = materialKey, DeleteLayer = () => { printer.Settings.ActiveMaterialKey = ""; printer.Settings.MaterialLayers.Remove(layerToEdit); printer.Settings.Save(); } }; var editMaterialPresetsPage = new SlicePresetsPage(printer, presetsContext); editMaterialPresetsPage.Closed += (s, e2) => { ApplicationController.Instance.EditMaterialPresetsPage = null; }; ApplicationController.Instance.EditMaterialPresetsPage = editMaterialPresetsPage; DialogWindow.Show(editMaterialPresetsPage); } else { ApplicationController.Instance.EditMaterialPresetsPage.DialogWindow.BringToFront(); } } if (layerType == NamedSettingsLayers.Quality) { if (ApplicationController.Instance.EditQualityPresetsWindow == null) { string presetsID = printer.Settings.ActiveQualityKey; if (string.IsNullOrEmpty(presetsID)) { return; } var layerToEdit = printer.Settings.QualityLayers.Where(layer => layer.LayerID == presetsID).FirstOrDefault(); var presetsContext = new PresetsContext(printer.Settings.QualityLayers, layerToEdit) { LayerType = NamedSettingsLayers.Quality, SetAsActive = (qualityKey) => printer.Settings.ActiveQualityKey = qualityKey, DeleteLayer = () => { printer.Settings.QualityLayers.Remove(layerToEdit); printer.Settings.Save(); // Clear QualityKey after removing layer to ensure listeners see update printer.Settings.ActiveQualityKey = ""; } }; var editQualityPresetsWindow = new SlicePresetsPage(printer, presetsContext); editQualityPresetsWindow.Closed += (s, e2) => { ApplicationController.Instance.EditQualityPresetsWindow = null; }; ApplicationController.Instance.EditQualityPresetsWindow = editQualityPresetsWindow; DialogWindow.Show(editQualityPresetsWindow); } else { ApplicationController.Instance.EditQualityPresetsWindow.DialogWindow.BringToFront(); } } }; container.AddChild(DropDownList); container.AddChild(editButton); return(container); }
public virtual FlowLayoutWidget GetPulldownContainer() { dropDownList = CreateDropdown(); FlowLayoutWidget container = new FlowLayoutWidget(); container.HAnchor = HAnchor.ParentLeftRight; container.Padding = new BorderDouble(6, 0); editButton = TextImageButtonFactory.GetThemedEditButton(); editButton.ToolTipText = "Edit Selected Setting".Localize(); editButton.VAnchor = VAnchor.ParentCenter; editButton.Margin = new BorderDouble(left: 6); editButton.Click += (sender, e) => { if (layerType == NamedSettingsLayers.Material) { if (ApplicationController.Instance.EditMaterialPresetsWindow == null) { string presetsKey = ActiveSliceSettings.Instance.MaterialPresetKey(extruderIndex); if (string.IsNullOrEmpty(presetsKey)) { return; } var presetsContext = new PresetsContext(ActiveSliceSettings.Instance.MaterialLayers, presetsKey) { LayerType = NamedSettingsLayers.Material, SetAsActive = (materialKey) => { ActiveSliceSettings.Instance.ActiveMaterialKey = materialKey; ActiveSliceSettings.Instance.SetMaterialPreset(this.extruderIndex, materialKey); } }; ApplicationController.Instance.EditMaterialPresetsWindow = new SlicePresetsWindow(presetsContext); ApplicationController.Instance.EditMaterialPresetsWindow.Closed += (s, e2) => { ApplicationController.Instance.EditMaterialPresetsWindow = null; ApplicationController.Instance.ReloadAdvancedControlsPanel(); }; ApplicationController.Instance.EditMaterialPresetsWindow.ShowAsSystemWindow(); } else { ApplicationController.Instance.EditMaterialPresetsWindow.BringToFront(); } } if (layerType == NamedSettingsLayers.Quality) { if (ApplicationController.Instance.EditQualityPresetsWindow == null) { string presetsKey = ActiveSliceSettings.Instance.ActiveQualityKey; if (string.IsNullOrEmpty(presetsKey)) { return; } var presetsContext = new PresetsContext(ActiveSliceSettings.Instance.QualityLayers, presetsKey) { LayerType = NamedSettingsLayers.Quality, SetAsActive = (qualityKey) => ActiveSliceSettings.Instance.ActiveQualityKey = qualityKey }; ApplicationController.Instance.EditQualityPresetsWindow = new SlicePresetsWindow(presetsContext); ApplicationController.Instance.EditQualityPresetsWindow.Closed += (s, e2) => { ApplicationController.Instance.EditQualityPresetsWindow = null; ApplicationController.Instance.ReloadAdvancedControlsPanel(); }; ApplicationController.Instance.EditQualityPresetsWindow.ShowAsSystemWindow(); } else { ApplicationController.Instance.EditQualityPresetsWindow.BringToFront(); } } }; container.AddChild(dropDownList); container.AddChild(editButton); return(container); }
public FlowLayoutWidget GetPulldownContainer() { var dropDownList = CreateDropdown(); FlowLayoutWidget container = new FlowLayoutWidget(); container.HAnchor = HAnchor.ParentLeftRight; container.Padding = new BorderDouble(6, 0); editButton = TextImageButtonFactory.GetThemedEditButton(); editButton.ToolTipText = "Edit Selected Setting".Localize(); editButton.Enabled = dropDownList.SelectedIndex != -1; editButton.VAnchor = VAnchor.ParentCenter; editButton.Margin = new BorderDouble(left: 6); editButton.Click += (sender, e) => { if (layerType == NamedSettingsLayers.Material) { if (ApplicationController.Instance.EditMaterialPresetsWindow == null) { string presetsID = ActiveSliceSettings.Instance.GetMaterialPresetKey(extruderIndex); if (string.IsNullOrEmpty(presetsID)) { return; } var layerToEdit = ActiveSliceSettings.Instance.MaterialLayers.Where(layer => layer.LayerID == presetsID).FirstOrDefault(); var presetsContext = new PresetsContext(ActiveSliceSettings.Instance.MaterialLayers, layerToEdit) { LayerType = NamedSettingsLayers.Material, SetAsActive = (materialKey) => { ActiveSliceSettings.Instance.SetMaterialPreset(this.extruderIndex, materialKey); }, DeleteLayer = () => { var materialKeys = ActiveSliceSettings.Instance.MaterialSettingsKeys; for (var i = 0; i < materialKeys.Count; i++) { if (materialKeys[i] == presetsID) { materialKeys[i] = ""; } } ActiveSliceSettings.Instance.SetMaterialPreset(extruderIndex, ""); ActiveSliceSettings.Instance.MaterialLayers.Remove(layerToEdit); ActiveSliceSettings.Instance.Save(); UiThread.RunOnIdle(() => ApplicationController.Instance.ReloadAdvancedControlsPanel()); } }; ApplicationController.Instance.EditMaterialPresetsWindow = new SlicePresetsWindow(presetsContext); ApplicationController.Instance.EditMaterialPresetsWindow.Closed += (s, e2) => { ApplicationController.Instance.EditMaterialPresetsWindow = null; ApplicationController.Instance.ReloadAdvancedControlsPanel(); }; ApplicationController.Instance.EditMaterialPresetsWindow.ShowAsSystemWindow(); } else { ApplicationController.Instance.EditMaterialPresetsWindow.BringToFront(); } } if (layerType == NamedSettingsLayers.Quality) { if (ApplicationController.Instance.EditQualityPresetsWindow == null) { string presetsID = ActiveSliceSettings.Instance.ActiveQualityKey; if (string.IsNullOrEmpty(presetsID)) { return; } var layerToEdit = ActiveSliceSettings.Instance.QualityLayers.Where(layer => layer.LayerID == presetsID).FirstOrDefault(); var presetsContext = new PresetsContext(ActiveSliceSettings.Instance.QualityLayers, layerToEdit) { LayerType = NamedSettingsLayers.Quality, SetAsActive = (qualityKey) => ActiveSliceSettings.Instance.ActiveQualityKey = qualityKey, DeleteLayer = () => { ActiveSliceSettings.Instance.ActiveQualityKey = ""; ActiveSliceSettings.Instance.QualityLayers.Remove(layerToEdit); ActiveSliceSettings.Instance.Save(); UiThread.RunOnIdle(() => ApplicationController.Instance.ReloadAdvancedControlsPanel()); } }; ApplicationController.Instance.EditQualityPresetsWindow = new SlicePresetsWindow(presetsContext); ApplicationController.Instance.EditQualityPresetsWindow.Closed += (s, e2) => { ApplicationController.Instance.EditQualityPresetsWindow = null; ApplicationController.Instance.ReloadAdvancedControlsPanel(); }; ApplicationController.Instance.EditQualityPresetsWindow.ShowAsSystemWindow(); } else { ApplicationController.Instance.EditQualityPresetsWindow.BringToFront(); } } }; container.AddChild(dropDownList); container.AddChild(editButton); return container; }
public FlowLayoutWidget GetPulldownContainer() { var dropDownList = CreateDropdown(); FlowLayoutWidget container = new FlowLayoutWidget(); container.HAnchor = HAnchor.ParentLeftRight; container.Padding = new BorderDouble(6, 0); editButton = TextImageButtonFactory.GetThemedEditButton(); editButton.ToolTipText = "Edit Selected Setting".Localize(); editButton.Enabled = dropDownList.SelectedIndex != -1; editButton.VAnchor = VAnchor.ParentCenter; editButton.Margin = new BorderDouble(left: 6); editButton.Click += (sender, e) => { if (layerType == NamedSettingsLayers.Material) { if (ApplicationController.Instance.EditMaterialPresetsWindow == null) { string presetsID = ActiveSliceSettings.Instance.GetMaterialPresetKey(extruderIndex); if (string.IsNullOrEmpty(presetsID)) { return; } var layerToEdit = ActiveSliceSettings.Instance.MaterialLayers.Where(layer => layer.LayerID == presetsID).FirstOrDefault(); var presetsContext = new PresetsContext(ActiveSliceSettings.Instance.MaterialLayers, layerToEdit) { LayerType = NamedSettingsLayers.Material, SetAsActive = (materialKey) => { ActiveSliceSettings.Instance.SetMaterialPreset(this.extruderIndex, materialKey); }, DeleteLayer = () => { var materialKeys = ActiveSliceSettings.Instance.MaterialSettingsKeys; for (var i = 0; i < materialKeys.Count; i++) { if (materialKeys[i] == presetsID) { materialKeys[i] = ""; } } ActiveSliceSettings.Instance.SetMaterialPreset(extruderIndex, ""); ActiveSliceSettings.Instance.MaterialLayers.Remove(layerToEdit); ActiveSliceSettings.Instance.Save(); UiThread.RunOnIdle(() => ApplicationController.Instance.ReloadAdvancedControlsPanel()); } }; ApplicationController.Instance.EditMaterialPresetsWindow = new SlicePresetsWindow(presetsContext); ApplicationController.Instance.EditMaterialPresetsWindow.Closed += (s, e2) => { ApplicationController.Instance.EditMaterialPresetsWindow = null; ApplicationController.Instance.ReloadAdvancedControlsPanel(); }; ApplicationController.Instance.EditMaterialPresetsWindow.ShowAsSystemWindow(); } else { ApplicationController.Instance.EditMaterialPresetsWindow.BringToFront(); } } if (layerType == NamedSettingsLayers.Quality) { if (ApplicationController.Instance.EditQualityPresetsWindow == null) { string presetsID = ActiveSliceSettings.Instance.ActiveQualityKey; if (string.IsNullOrEmpty(presetsID)) { return; } var layerToEdit = ActiveSliceSettings.Instance.QualityLayers.Where(layer => layer.LayerID == presetsID).FirstOrDefault(); var presetsContext = new PresetsContext(ActiveSliceSettings.Instance.QualityLayers, layerToEdit) { LayerType = NamedSettingsLayers.Quality, SetAsActive = (qualityKey) => ActiveSliceSettings.Instance.ActiveQualityKey = qualityKey, DeleteLayer = () => { ActiveSliceSettings.Instance.ActiveQualityKey = ""; ActiveSliceSettings.Instance.QualityLayers.Remove(layerToEdit); ActiveSliceSettings.Instance.Save(); UiThread.RunOnIdle(() => ApplicationController.Instance.ReloadAdvancedControlsPanel()); } }; ApplicationController.Instance.EditQualityPresetsWindow = new SlicePresetsWindow(presetsContext); ApplicationController.Instance.EditQualityPresetsWindow.Closed += (s, e2) => { ApplicationController.Instance.EditQualityPresetsWindow = null; ApplicationController.Instance.ReloadAdvancedControlsPanel(); }; ApplicationController.Instance.EditQualityPresetsWindow.ShowAsSystemWindow(); } else { ApplicationController.Instance.EditQualityPresetsWindow.BringToFront(); } } }; container.AddChild(dropDownList); container.AddChild(editButton); return(container); }