void duplicatePresets_Click(object sender, MouseEventArgs mouseEvent)
        {
            UiThread.RunOnIdle((state) =>
            {
                DataStorage.SliceSettingsCollection duplicateCollection = new SliceSettingsCollection();
                duplicateCollection.Name      = string.Format("{0} (copy)".FormatWith(windowController.ActivePresetLayer.settingsCollectionData.Name));
                duplicateCollection.Tag       = windowController.ActivePresetLayer.settingsCollectionData.Tag;
                duplicateCollection.PrinterId = windowController.ActivePresetLayer.settingsCollectionData.PrinterId;


                Dictionary <string, DataStorage.SliceSetting> settingsDictionary = new Dictionary <string, DataStorage.SliceSetting>();
                IEnumerable <DataStorage.SliceSetting> settingsList = this.windowController.GetCollectionSettings(windowController.ActivePresetLayer.settingsCollectionData.Id);
                foreach (DataStorage.SliceSetting s in settingsList)
                {
                    settingsDictionary[s.Name] = s;
                }
                SettingsLayer duplicateLayer       = new SettingsLayer(duplicateCollection, settingsDictionary);
                windowController.ActivePresetLayer = duplicateLayer;
                windowController.ChangeToSlicePresetDetail();
            });
        }
Exemple #2
0
            public PresetListItem(SlicePresetsWindow windowController, SliceSettingsCollection preset)
            {
                this.preset          = preset;
                this.BackgroundColor = RGBA_Bytes.White;
                this.HAnchor         = HAnchor.ParentLeftRight;
                this.Margin          = new BorderDouble(6, 0, 6, 3);
                this.Padding         = new BorderDouble(3);

                LinkButtonFactory linkButtonFactory = new LinkButtonFactory();

                linkButtonFactory.fontSize = 10;

                int        maxLabelWidth = 300;
                TextWidget materialLabel = new TextWidget(preset.Name, pointSize: 14);

                materialLabel.EllipsisIfClipped = true;
                materialLabel.VAnchor           = Agg.UI.VAnchor.ParentCenter;
                materialLabel.MinimumSize       = new Vector2(maxLabelWidth, materialLabel.Height);
                materialLabel.Width             = maxLabelWidth;

                Button materialEditLink = linkButtonFactory.Generate("edit");

                materialEditLink.VAnchor = Agg.UI.VAnchor.ParentCenter;
                materialEditLink.Click  += (sender, e) =>
                {
                    UiThread.RunOnIdle(() =>
                    {
                        windowController.ChangeToSlicePresetDetail(preset);
                    });
                };

                Button materialRemoveLink = linkButtonFactory.Generate("remove");

                materialRemoveLink.Margin  = new BorderDouble(left: 4);
                materialRemoveLink.VAnchor = Agg.UI.VAnchor.ParentCenter;
                materialRemoveLink.Click  += (sender, e) =>
                {
                    UiThread.RunOnIdle(() =>
                    {
                        //Unwind this setting if it is currently active
                        if (ActivePrinterProfile.Instance.ActivePrinter != null)
                        {
                            if (preset.Id == ActivePrinterProfile.Instance.ActiveQualitySettingsID)
                            {
                                ActivePrinterProfile.Instance.ActiveQualitySettingsID = 0;
                            }

                            string[] activeMaterialPresets = ActivePrinterProfile.Instance.ActivePrinter.MaterialCollectionIds.Split(',');
                            for (int i = 0; i < activeMaterialPresets.Count(); i++)
                            {
                                int index = 0;
                                Int32.TryParse(activeMaterialPresets[i], out index);
                                if (preset.Id == index)
                                {
                                    ActivePrinterProfile.Instance.SetMaterialSetting(i + 1, 0);
                                }
                            }
                        }
                        preset.Delete();
                        windowController.ChangeToSlicePresetList();
                        ActiveSliceSettings.Instance.LoadAllSettings();
                        ApplicationController.Instance.ReloadAdvancedControlsPanel();
                    });
                };

                this.AddChild(materialLabel);
                this.AddChild(new HorizontalSpacer());
                this.AddChild(materialEditLink);
                this.AddChild(materialRemoveLink);

                this.Height = 35;
            }
			public PresetListItem(SlicePresetsWindow windowController, SliceSettingsCollection preset)
			{
				this.preset = preset;
				this.BackgroundColor = RGBA_Bytes.White;
				this.HAnchor = HAnchor.ParentLeftRight;
				this.Margin = new BorderDouble(6, 0, 6, 3);
				this.Padding = new BorderDouble(3);

				LinkButtonFactory linkButtonFactory = new LinkButtonFactory();
				linkButtonFactory.fontSize = 10;

				int maxLabelWidth = 300;
				TextWidget materialLabel = new TextWidget(preset.Name, pointSize: 14);
				materialLabel.EllipsisIfClipped = true;
				materialLabel.VAnchor = Agg.UI.VAnchor.ParentCenter;
				materialLabel.MinimumSize = new Vector2(maxLabelWidth, materialLabel.Height);
				materialLabel.Width = maxLabelWidth;

				Button materialEditLink = linkButtonFactory.Generate("edit");
				materialEditLink.VAnchor = Agg.UI.VAnchor.ParentCenter;
				materialEditLink.Click += (sender, e) =>
				{
					UiThread.RunOnIdle(() =>
					{
						windowController.ChangeToSlicePresetDetail(preset);
					});
				};

				Button materialRemoveLink = linkButtonFactory.Generate("remove");
				materialRemoveLink.Margin = new BorderDouble(left: 4);
				this.DebugShowBounds = true;
				materialRemoveLink.VAnchor = Agg.UI.VAnchor.ParentCenter;
				materialRemoveLink.Click += (sender, e) =>
				{
					UiThread.RunOnIdle(() =>
					{
						//Unwind this setting if it is currently active
						if (ActiveSliceSettings.Instance != null)
						{
							/*
							if (preset.Id == ActivePrinterProfile.Instance.ActiveQualitySettingsID)
							{
								ActivePrinterProfile.Instance.ActiveQualitySettingsID = 0;
							}

							string[] activeMaterialPresets = ActiveSliceSettings.Instance.MaterialCollectionIds.Split(',');
							for (int i = 0; i < activeMaterialPresets.Count(); i++)
							{
								int index = 0;
								Int32.TryParse(activeMaterialPresets[i], out index);
								if (preset.Id == index)
								{
									ActiveSliceSettings.Instance.SetMaterialPreset(i, "");
								}
							} */
						}
						preset.Delete();
						windowController.ChangeToSlicePresetList();
						ApplicationController.Instance.ReloadAdvancedControlsPanel();
					});
				};

				this.AddChild(materialLabel);
				this.AddChild(new HorizontalSpacer());
				this.AddChild(materialEditLink);
				this.AddChild(materialRemoveLink);

				this.Height = 35;
			}