public virtual FlowLayoutWidget GetPulldownContainer()
        {
            DropDownList = CreateDropdown();

            FlowLayoutWidget container = new FlowLayoutWidget();

            container.HAnchor = HAnchor.ParentLeftRight;
            container.Padding = new BorderDouble(6, 0);

            editButton = imageButtonFactory.Generate("icon_edit_white.png", "icon_edit_gray.png");

            editButton.VAnchor = VAnchor.ParentCenter;
            editButton.Margin  = new BorderDouble(right: 6);
            editButton.Click  += (sender, e) =>
            {
                if (ApplicationWidget.Instance.EditSlicePresetsWindow == null)
                {
                    ApplicationWidget.Instance.EditSlicePresetsWindow         = new SlicePresetsWindow(ReloadOptions, filterLabel, filterTag);
                    ApplicationWidget.Instance.EditSlicePresetsWindow.Closed += (popupWindowSender, popupWindowSenderE) => { ApplicationWidget.Instance.EditSlicePresetsWindow = null; };
                }
                else
                {
                    ApplicationWidget.Instance.EditSlicePresetsWindow.BringToFront();
                }
            };

            container.AddChild(editButton);
            container.AddChild(DropDownList);
            return(container);
        }
        public virtual FlowLayoutWidget GetPulldownContainer()
        {
            DropDownList = CreateDropdown();

            FlowLayoutWidget container = new FlowLayoutWidget();

            container.HAnchor = HAnchor.ParentLeftRight;
            container.Padding = new BorderDouble(6, 0);

            editButton = imageButtonFactory.Generate("icon_edit_white.png", "icon_edit_gray.png");

            editButton.VAnchor = VAnchor.ParentCenter;
            editButton.Margin  = new BorderDouble(right: 6);
            editButton.Click  += (sender, e) =>
            {
#if DO_IN_PLACE_EDIT
                if (filterTag == "quality")
                {
                    SliceSettingsWidget.SettingsIndexBeingEdited = 2;
                }
                else
                {
                    SliceSettingsWidget.SettingsIndexBeingEdited = 3;
                }
                // If there is a setting selected then reload the silce setting widget with the presetIndex to edit.
                ApplicationController.Instance.ReloadAdvancedControlsPanel();
                // If no setting selected then call onNewItemSelect(object sender, EventArgs e)
#else
                if (filterTag == "material")
                {
                    if (ApplicationController.Instance.EditMaterialPresetsWindow == null)
                    {
                        ApplicationController.Instance.EditMaterialPresetsWindow         = new SlicePresetsWindow(ReloadOptions, filterLabel, filterTag);
                        ApplicationController.Instance.EditMaterialPresetsWindow.Closed += (popupWindowSender, popupWindowSenderE) => { ApplicationController.Instance.EditMaterialPresetsWindow = null; };
                    }
                    else
                    {
                        ApplicationController.Instance.EditMaterialPresetsWindow.BringToFront();
                    }
                }

                if (filterTag == "quality")
                {
                    if (ApplicationController.Instance.EditQualityPresetsWindow == null)
                    {
                        ApplicationController.Instance.EditQualityPresetsWindow         = new SlicePresetsWindow(ReloadOptions, filterLabel, filterTag);
                        ApplicationController.Instance.EditQualityPresetsWindow.Closed += (popupWindowSender, popupWindowSenderE) => { ApplicationController.Instance.EditQualityPresetsWindow = null; };
                    }
                    else
                    {
                        ApplicationController.Instance.EditQualityPresetsWindow.BringToFront();
                    }
                }
#endif
            };

            container.AddChild(editButton);
            container.AddChild(DropDownList);
            return(container);
        }
        AnchoredDropDownList CreateSliceEngineDropdown()
        {
            AnchoredDropDownList engineMenuDropList = new AnchoredDropDownList("Engine   ");

            engineMenuDropList.Margin = new BorderDouble(0, 3);
            {
                MenuItem slic3rMenuItem = engineMenuDropList.AddItem(ActivePrinterProfile.SlicingEngineTypes.Slic3r.ToString());
                slic3rMenuItem.Selected += (sender, e) =>
                {
                    ActivePrinterProfile.Instance.ActiveSliceEngineType = ActivePrinterProfile.SlicingEngineTypes.Slic3r;
                    ApplicationWidget.Instance.ReloadAdvancedControlsPanel();
                };

                MenuItem curaEnginMenuItem = engineMenuDropList.AddItem(ActivePrinterProfile.SlicingEngineTypes.CuraEngine.ToString());
                curaEnginMenuItem.Selected += (sender, e) =>
                {
                    ActivePrinterProfile.Instance.ActiveSliceEngineType = ActivePrinterProfile.SlicingEngineTypes.CuraEngine;
                    ApplicationWidget.Instance.ReloadAdvancedControlsPanel();
                };

                MenuItem matterSliceMenuItem = engineMenuDropList.AddItem(ActivePrinterProfile.SlicingEngineTypes.MatterSlice.ToString());
                matterSliceMenuItem.Selected += (sender, e) =>
                {
                    ActivePrinterProfile.Instance.ActiveSliceEngineType = ActivePrinterProfile.SlicingEngineTypes.MatterSlice;
                    ApplicationWidget.Instance.ReloadAdvancedControlsPanel();
                };

                engineMenuDropList.SelectedLabel = ActivePrinterProfile.Instance.ActiveSliceEngineType.ToString();
            }
            engineMenuDropList.MinimumSize = new Vector2(engineMenuDropList.LocalBounds.Width, engineMenuDropList.LocalBounds.Height);
            return(engineMenuDropList);
        }
        public override FlowLayoutWidget GetPulldownContainer()
        {
            EngineMenuDropList = CreateSliceEngineDropdown();

            FlowLayoutWidget container = new FlowLayoutWidget();

            container.HAnchor = HAnchor.ParentLeftRight;
            container.Padding = new BorderDouble(6, 0);

            container.AddChild(EngineMenuDropList);
            return(container);
        }
Esempio n. 5
0
        private AnchoredDropDownList CreateDropdown()
        {
            AnchoredDropDownList dropDownList = new AnchoredDropDownList("- default -", maxHeight: 300);

            dropDownList.Margin      = new BorderDouble(0, 3);
            dropDownList.MinimumSize = new Vector2(dropDownList.LocalBounds.Width, dropDownList.LocalBounds.Height);
            MenuItem defaultMenuItem = dropDownList.AddItem("- default -", "0");

            defaultMenuItem.Selected += new EventHandler(onItemSelect);

            IEnumerable <DataStorage.SliceSettingsCollection> collections = GetCollections();

            foreach (DataStorage.SliceSettingsCollection collection in collections)
            {
                MenuItem menuItem = dropDownList.AddItem(collection.Name, collection.Id.ToString());
                menuItem.Selected += new EventHandler(onItemSelect);
            }

            MenuItem addNewPreset = dropDownList.AddItem("<< Add >>", "new");

            addNewPreset.Selected += new EventHandler(onNewItemSelect);

            if (filterTag == "material")
            {
                try
                {
                    dropDownList.SelectedValue = ActivePrinterProfile.Instance.GetMaterialSetting(presetIndex).ToString();
                }
                catch (Exception e)
                {
                    Debug.Print(e.Message);
                    GuiWidget.BreakInDebugger();
                    //Unable to set selected value
                }
            }
            else if (filterTag == "quality")
            {
                try
                {
                    dropDownList.SelectedValue = ActivePrinterProfile.Instance.ActiveQualitySettingsID.ToString();
                }
                catch (Exception e)
                {
                    Debug.Print(e.Message);
                    GuiWidget.BreakInDebugger();
                    //Unable to set selected value
                }
            }

            return(dropDownList);
        }
        AnchoredDropDownList CreateSliceEngineDropdown()
        {
            AnchoredDropDownList engineMenuDropList = new AnchoredDropDownList("Engine   ");

            engineMenuDropList.Margin = new BorderDouble(0, 3);
            {
                //Add Each SliceEngineInfo Objects to DropMenu
                foreach (SliceEngineInfo engineMenuItem in SlicingQueue.AvailableSliceEngines)
                {
                    MenuItem item = engineMenuDropList.AddItem(engineMenuItem.Name);
                    ActivePrinterProfile.SlicingEngineTypes itemEngineType = engineMenuItem.GetSliceEngineType();
                    item.Selected += (sender, e) =>
                    {
                        ActivePrinterProfile.Instance.ActiveSliceEngineType = itemEngineType;
                        ApplicationController.Instance.ReloadAdvancedControlsPanel();
                    };

                    //Set item as selected if it matches the active slice engine
                    if (engineMenuItem.GetSliceEngineType() == ActivePrinterProfile.Instance.ActiveSliceEngineType)
                    {
                        engineMenuDropList.SelectedLabel = engineMenuItem.Name;
                    }
                }

                //If nothing is selected (ie selected engine is not available) set to
                if (engineMenuDropList.SelectedLabel == "")
                {
                    try
                    {
                        engineMenuDropList.SelectedLabel = MatterSliceInfo.DisplayName;
                    }
                    catch
                    {
                        throw new Exception("MatterSlice is not available, for some strange reason");
                    }
                }
            }
            engineMenuDropList.MinimumSize = new Vector2(engineMenuDropList.LocalBounds.Width, engineMenuDropList.LocalBounds.Height);
            return(engineMenuDropList);
        }
		public virtual FlowLayoutWidget GetPulldownContainer()
		{
			DropDownList = CreateDropdown();

			FlowLayoutWidget container = new FlowLayoutWidget();
			container.HAnchor = HAnchor.ParentLeftRight;
			container.Padding = new BorderDouble(6, 0);

			ImageBuffer normalImage = StaticData.Instance.LoadIcon("icon_edit_white_32x32.png");
			int iconSize = (int)(16 * TextWidget.GlobalPointSizeScaleRatio);
			normalImage = ImageBuffer.CreateScaledImage(normalImage, iconSize, iconSize);

			editButton = imageButtonFactory.Generate(normalImage, WhiteToColor.CreateWhiteToColor(normalImage, RGBA_Bytes.Gray));

			editButton.VAnchor = VAnchor.ParentCenter;
			editButton.Margin = new BorderDouble(right: 6);
			editButton.Click += (sender, e) =>
			{
#if DO_IN_PLACE_EDIT
                if (filterTag == "quality")
                {
                    SliceSettingsWidget.SettingsIndexBeingEdited = 2;
                }
                else
                {
                    SliceSettingsWidget.SettingsIndexBeingEdited = 3;
                }
                // If there is a setting selected then reload the slice setting widget with the presetIndex to edit.
                ApplicationController.Instance.ReloadAdvancedControlsPanel();
                // If no setting selected then call onNewItemSelect(object sender, EventArgs e)
#else
				if (filterTag == "material")
				{
					if (ApplicationController.Instance.EditMaterialPresetsWindow == null)
					{
						ApplicationController.Instance.EditMaterialPresetsWindow = new SlicePresetsWindow(ReloadOptions, filterLabel, filterTag);
						ApplicationController.Instance.EditMaterialPresetsWindow.Closed += (popupWindowSender, popupWindowSenderE) => { ApplicationController.Instance.EditMaterialPresetsWindow = null; };
					}
					else
					{
						ApplicationController.Instance.EditMaterialPresetsWindow.BringToFront();
					}
				}

				if (filterTag == "quality")
				{
					if (ApplicationController.Instance.EditQualityPresetsWindow == null)
					{
						ApplicationController.Instance.EditQualityPresetsWindow = new SlicePresetsWindow(ReloadOptions, filterLabel, filterTag);
						ApplicationController.Instance.EditQualityPresetsWindow.Closed += (popupWindowSender, popupWindowSenderE) => { ApplicationController.Instance.EditQualityPresetsWindow = null; };
					}
					else
					{
						ApplicationController.Instance.EditQualityPresetsWindow.BringToFront();
					}
				}
#endif
			};

			container.AddChild(editButton);
			container.AddChild(DropDownList);

			return container;
		}
		private AnchoredDropDownList CreateDropdown()
		{
			AnchoredDropDownList dropDownList = new AnchoredDropDownList("- default -", maxHeight: 300);
			dropDownList.Margin = new BorderDouble(0, 3);
			dropDownList.MinimumSize = new Vector2(dropDownList.LocalBounds.Width, dropDownList.LocalBounds.Height);

			MenuItem defaultMenuItem = dropDownList.AddItem("- default -", "0");
			defaultMenuItem.Selected += new EventHandler(onItemSelect);

			var listSource = (filterTag == "material") ? ActiveSliceSettings.Instance.AllMaterialKeys() : ActiveSliceSettings.Instance.AllQualityKeys();
			foreach (var presetName in listSource)
			{
				MenuItem menuItem = dropDownList.AddItem(presetName, presetName);
				menuItem.Selected += onItemSelect;
			}

			// put in a small bottom region
			{
				FlowLayoutWidget container = new FlowLayoutWidget();
				container.HAnchor = HAnchor.ParentLeftRight;

				TextImageButtonFactory buttonFactory = new TextImageButtonFactory();
				buttonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor;
				buttonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor;
				buttonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryTextColor;
				buttonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor;
				buttonFactory.borderWidth = 0;

				Button addPresetButton = buttonFactory.Generate(LocalizedString.Get("Add"), "icon_circle_plus.png");
				addPresetButton.ToolTipText = "Add a new Settings Preset".Localize();
				addPresetButton.Click += (sender, e) =>
				{
					onNewItemSelect(sender, e);
				};
				container.AddChild(addPresetButton);

				Button importPresetButton = buttonFactory.Generate(LocalizedString.Get("Import"));
				importPresetButton.ToolTipText = "Import an existing Settings Preset".Localize();
				importPresetButton.Click += (sender, e) =>
				{
				};
				container.AddChild(importPresetButton);

				dropDownList.MenuItems.Add(new MenuItem(container));
			}

			try
			{
				string settingsKey;

				if (filterTag == "material")
				{
					settingsKey = ActiveSliceSettings.Instance.GetMaterialPresetKey(extruderIndex);
				}
				else
				{
					settingsKey = ActiveSliceSettings.Instance.ActiveQualityKey;
				}

				if (!string.IsNullOrEmpty(settingsKey))
				{
					dropDownList.SelectedValue = settingsKey;
				}
			}
			catch (Exception ex)
			{
				GuiWidget.BreakInDebugger(ex.Message);
			}
		
			return dropDownList;
		}
		private AnchoredDropDownList CreateDropdown()
		{
			AnchoredDropDownList dropDownList = new AnchoredDropDownList("- default -", maxHeight: 300);
			dropDownList.Margin = new BorderDouble(0, 3);
			dropDownList.MinimumSize = new Vector2(dropDownList.LocalBounds.Width, dropDownList.LocalBounds.Height);
			MenuItem defaultMenuItem = dropDownList.AddItem("- default -", "0");
			defaultMenuItem.Selected += new EventHandler(onItemSelect);

			IEnumerable<DataStorage.SliceSettingsCollection> collections = GetCollections();
			foreach (DataStorage.SliceSettingsCollection collection in collections)
			{
				MenuItem menuItem = dropDownList.AddItem(collection.Name, collection.Id.ToString());
				menuItem.Selected += new EventHandler(onItemSelect);
			}

			MenuItem addNewPreset = dropDownList.AddItem("<< Add >>", "new");
			addNewPreset.Selected += new EventHandler(onNewItemSelect);

			if (filterTag == "material")
			{
				try
				{
					dropDownList.SelectedValue = ActivePrinterProfile.Instance.GetMaterialSetting(presetIndex).ToString();
				}
				catch(Exception e)
				{
					Debug.Print(e.Message);
					GuiWidget.BreakInDebugger();
					//Unable to set selected value
				}
			}
			else if (filterTag == "quality")
			{
				try
				{
					dropDownList.SelectedValue = ActivePrinterProfile.Instance.ActiveQualitySettingsID.ToString();
				}
				catch(Exception e)
				{
					Debug.Print(e.Message);
					GuiWidget.BreakInDebugger();
					//Unable to set selected value
				}
			}

			return dropDownList;
		}
        public virtual FlowLayoutWidget GetPulldownContainer()
        {
            DropDownList = CreateDropdown();

            FlowLayoutWidget container = new FlowLayoutWidget();
            container.HAnchor = HAnchor.ParentLeftRight;
            container.Padding = new BorderDouble(6, 0);

            editButton = imageButtonFactory.Generate("icon_edit_white.png", "icon_edit_gray.png");
            
            editButton.VAnchor = VAnchor.ParentCenter;
            editButton.Margin = new BorderDouble(right:6);
            editButton.Click += (sender, e) =>
            {
				if (filterTag == "material")
				{
					if (ApplicationWidget.Instance.EditMaterialPresetsWindow == null)
                	{
						ApplicationWidget.Instance.EditMaterialPresetsWindow = new SlicePresetsWindow(ReloadOptions, filterLabel, filterTag);
						ApplicationWidget.Instance.EditMaterialPresetsWindow.Closed += (popupWindowSender, popupWindowSenderE) => { ApplicationWidget.Instance.EditMaterialPresetsWindow = null; };
					}
                	else
                	{
							ApplicationWidget.Instance.EditMaterialPresetsWindow.BringToFront();
                	}
				}

				if (filterTag == "quality")
				{
					if(ApplicationWidget.Instance.EditQualityPresetsWindow == null)
					{
						ApplicationWidget.Instance.EditQualityPresetsWindow = new SlicePresetsWindow(ReloadOptions, filterLabel, filterTag);
						ApplicationWidget.Instance.EditQualityPresetsWindow.Closed += (popupWindowSender, popupWindowSenderE) => {ApplicationWidget.Instance.EditQualityPresetsWindow = null; };
					}
					else
					{
						ApplicationWidget.Instance.EditQualityPresetsWindow.BringToFront();
					}
				}
            };

            container.AddChild(editButton);
            container.AddChild(DropDownList);
            return container;
		}
        AnchoredDropDownList CreateSliceEngineDropdown()
        {
            AnchoredDropDownList engineMenuDropList = new AnchoredDropDownList("Engine   ");
            engineMenuDropList.Margin = new BorderDouble(0,3);
			{
				//Add Each SliceEngineInfo Objects to DropMenu
                foreach (SliceEngineInfo engineMenuItem in SlicingQueue.AvailableSliceEngines)
				{                    
                    MenuItem item = engineMenuDropList.AddItem(engineMenuItem.Name);
                    ActivePrinterProfile.SlicingEngineTypes itemEngineType = engineMenuItem.GetSliceEngineType();
                    item.Selected += (sender, e) =>
                    {
                        ActivePrinterProfile.Instance.ActiveSliceEngineType = itemEngineType;
                        ApplicationWidget.Instance.ReloadAdvancedControlsPanel();
                    };

                    //Set item as selected if it matches the active slice engine
                    if (engineMenuItem.GetSliceEngineType() == ActivePrinterProfile.Instance.ActiveSliceEngineType)
                    {
                        engineMenuDropList.SelectedLabel = engineMenuItem.Name;
                    }
				}

                //If nothing is selected (ie selected engine is not available) set to 
                if (engineMenuDropList.SelectedLabel == "")
                {
                    try
                    {
                        engineMenuDropList.SelectedLabel = MatterSliceInfo.DisplayName;
                    }
                    catch
                    {
                        throw new Exception("MatterSlice is not available, for some strange reason");
                    }

                }				
			}        
            engineMenuDropList.MinimumSize = new Vector2(engineMenuDropList.LocalBounds.Width, engineMenuDropList.LocalBounds.Height);
            return engineMenuDropList;
        }
 public override FlowLayoutWidget GetPulldownContainer()
 {
     EngineMenuDropList = CreateSliceEngineDropdown();
     
     FlowLayoutWidget container = new FlowLayoutWidget();
     container.HAnchor = HAnchor.ParentLeftRight;
     container.Padding = new BorderDouble(6, 0);
     
     container.AddChild(EngineMenuDropList);
     return container;
 }