Beispiel #1
0
		public MenuBase(string menuName)
		{
			MenuDropList = new DropDownMenu(menuName.ToUpper(), Direction.Down, pointSize: 10);
			MenuDropList.MenuItemsPadding = new BorderDouble(0);
			MenuDropList.Margin = new BorderDouble(0);
			MenuDropList.Padding = new BorderDouble(0);

			MenuDropList.DrawDirectionalArrow = false;
			MenuDropList.MenuAsWideAsItems = false;

			menuItems = GetMenuItems();
			BorderDouble padding = MenuDropList.MenuItemsPadding;
			//Add the menu items to the menu itself
			foreach (Tuple<string, Func<bool>> item in menuItems)
			{
				MenuDropList.MenuItemsPadding = new BorderDouble(8, 4, 8, 4) * TextWidget.GlobalPointSizeScaleRatio;
				MenuDropList.AddItem(item.Item1, pointSize: 10);
			}
			MenuDropList.Padding = padding;


			AddChild(MenuDropList);
			this.Width = GetChildrenBoundsIncludingMargins().Width;
			this.Height = 22 * TextWidget.GlobalPointSizeScaleRatio;
			this.Margin = new BorderDouble(0);
			this.Padding = new BorderDouble(0);
			this.VAnchor = Agg.UI.VAnchor.ParentCenter;
			this.MenuDropList.SelectionChanged += new EventHandler(MenuDropList_SelectionChanged);
			this.MenuDropList.OpenOffset = new Vector2(0, 0);
		}
Beispiel #2
0
		public MenuBase(string menuName)
		{
			MenuDropList = new DropDownMenu(menuName.ToUpper(), Direction.Down, pointSize: 10);
			MenuDropList.MenuItemsPadding = new BorderDouble(0);
			MenuDropList.Margin = new BorderDouble(0);
			MenuDropList.Padding = new BorderDouble(0);

			MenuDropList.DrawDirectionalArrow = false;
			MenuDropList.MenuAsWideAsItems = false;

			menuItems = new List<MenuItemAction>(GetMenuItems());
			BorderDouble padding = MenuDropList.MenuItemsPadding;
			//Add the menu items to the menu itself
			foreach (MenuItemAction item in menuItems)
			{
				MenuDropList.MenuItemsPadding = new BorderDouble(8, 6, 8, 6) * TextWidget.GlobalPointSizeScaleRatio;
				MenuItem newItem = MenuDropList.AddItem(item.Title, pointSize: 11);
				if (item.Action == null)
				{
					newItem.Enabled = false;
				}
			}
			MenuDropList.Padding = padding;

			AddChild(MenuDropList);
			this.Width = GetChildrenBoundsIncludingMargins().Width;
			this.Height = 22 * TextWidget.GlobalPointSizeScaleRatio;
			this.Margin = new BorderDouble(0);
			this.Padding = new BorderDouble(0);
			this.VAnchor = Agg.UI.VAnchor.ParentCenter;
			this.MenuDropList.SelectionChanged += MenuDropList_SelectionChanged;
			this.MenuDropList.OpenOffset = new Vector2(0, 0);
		}
		public QueueOptionsMenu()
		{
			MenuDropList = new DropDownMenu("Options   ".Localize(), Direction.Up);
			MenuDropList.VAnchor = VAnchor.ParentBottomTop;
			MenuDropList.BorderWidth = 1;
			MenuDropList.MenuAsWideAsItems = false;
			MenuDropList.BorderColor = ActiveTheme.Instance.SecondaryTextColor;
			MenuDropList.Margin = new BorderDouble(4, 0, 1, 0);
			MenuDropList.AlignToRightEdge = true;

			SetMenuItems();
			this.MenuDropList.SelectionChanged += new EventHandler(MenuDropList_SelectionChanged);
		}
        public QueueOptionsMenu()
        {
			MenuDropList = new DropDownMenu(LocalizedString.Get("Queue Options"), Direction.Up);
            MenuDropList.HAnchor |= HAnchor.ParentLeft;
            MenuDropList.VAnchor |= VAnchor.ParentTop;
            SetMenuItems();

            AddChild(MenuDropList);
            this.Width = MenuDropList.Width;
            this.Height = MenuDropList.Height;
            this.Margin = new BorderDouble(4,0);
            this.Padding = new BorderDouble(0);
            this.MenuDropList.SelectionChanged += new EventHandler(MenuDropList_SelectionChanged);
        }
        public MenuOptionFile()
        {
            MenuDropList = new DropDownMenu("File".Localize().ToUpper(), Direction.Down,pointSize:10);        
            MenuDropList.MenuItemsPadding = new BorderDouble(0);
            MenuDropList.Margin = new BorderDouble(0);
            MenuDropList.Padding = new BorderDouble(0);

            SetMenuItems();

            AddChild(MenuDropList);
            this.Width = 44;
            this.Height = 22;
            this.Margin = new BorderDouble(0);
            this.Padding = new BorderDouble(0);
            this.VAnchor = Agg.UI.VAnchor.ParentCenter;
            this.MenuDropList.SelectionChanged += new EventHandler(MenuDropList_SelectionChanged);
            this.MenuDropList.OpenOffset = new Vector2(0, 0);
        }
		private DropDownMenu GetSliceOptionsMenuDropList()
		{
			if (sliceOptionsMenuDropList == null)
			{
				sliceOptionsMenuDropList = new DropDownMenu("Options".Localize() + "... ");
				sliceOptionsMenuDropList.HoverColor = new RGBA_Bytes(0, 0, 0, 50);
				sliceOptionsMenuDropList.NormalColor = new RGBA_Bytes(0, 0, 0, 0);
				sliceOptionsMenuDropList.BorderColor = new RGBA_Bytes(ActiveTheme.Instance.SecondaryTextColor, 100);
				sliceOptionsMenuDropList.BackgroundColor = new RGBA_Bytes(0, 0, 0, 0);
				sliceOptionsMenuDropList.BorderWidth = 1;
				sliceOptionsMenuDropList.VAnchor |= VAnchor.ParentCenter;
				sliceOptionsMenuDropList.SelectionChanged += new EventHandler(MenuDropList_SelectionChanged);

				SetMenuItems();
			}

			return sliceOptionsMenuDropList;
		}
		public MenuBase(string menuName)
		{
			MenuDropList = new DropDownMenu(menuName.ToUpper(), Direction.Down, pointSize: 10);
			MenuDropList.TextColor = ActiveTheme.Instance.PrimaryTextColor;

			MenuDropList.Margin = new BorderDouble(0);
			MenuDropList.Padding = new BorderDouble(4, 4, 0, 4);
			MenuDropList.MenuItemsPadding = new BorderDouble(8, 4);

			MenuDropList.DrawDirectionalArrow = false;
			MenuDropList.MenuAsWideAsItems = false;

			menuActions = new List<MenuItemAction>(GetMenuActions());
			//Add the menu items to the menu itself
			foreach (MenuItemAction item in menuActions)
			{
				if (item.Title.StartsWith("-----"))
				{
					MenuDropList.AddHorizontalLine();
				}
				else
				{
					MenuItem newItem = MenuDropList.AddItem(item.Title, pointSize: 11);
					if (item.Action == null)
					{
						newItem.Enabled = false;
					}
				}
			}

			AddChild(MenuDropList);
			this.Width = GetChildrenBoundsIncludingMargins().Width;
			this.Height = 22 * GuiWidget.DeviceScale;
			this.Margin = new BorderDouble(0);
			this.Padding = new BorderDouble(0);
			this.VAnchor = Agg.UI.VAnchor.ParentCenter;
			this.MenuDropList.SelectionChanged += MenuDropList_SelectionChanged;
			this.MenuDropList.OpenOffset = new Vector2(0, 0);
		}
		private GuiWidget CreateActionsMenu()
		{
			var actionMenu = new DropDownMenu("Actions".Localize() + "... ");
			actionMenu.AlignToRightEdge = true;
			actionMenu.NormalColor = new RGBA_Bytes();
			actionMenu.BorderWidth = 1;
			actionMenu.BorderColor = new RGBA_Bytes(ActiveTheme.Instance.SecondaryTextColor, 100);
			actionMenu.MenuAsWideAsItems = false;
			actionMenu.VAnchor = VAnchor.ParentBottomTop;
			actionMenu.Margin = new BorderDouble(3);
			actionMenu.Padding = new BorderDouble(10);
			actionMenu.Name = "LibraryActionMenu";

			CreateActionMenuItems(actionMenu);
			return actionMenu;
		}
		public QueueDataWidget(QueueDataView queueDataView)
		{
			this.queueDataView = queueDataView;

			SetDisplayAttributes();

			textImageButtonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor;
			textImageButtonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor;
			textImageButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor;
			textImageButtonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryTextColor;
			textImageButtonFactory.borderWidth = 0;

			editButtonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor;
			editButtonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor;
			editButtonFactory.disabledTextColor = ActiveTheme.Instance.TabLabelUnselected;
			editButtonFactory.disabledFillColor = new RGBA_Bytes();
			editButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor;
			editButtonFactory.borderWidth = 0;
			editButtonFactory.Margin = new BorderDouble(10, 0);
			editButtonFactory.Margin *= TextWidget.GlobalPointSizeScaleRatio;

			FlowLayoutWidget allControls = new FlowLayoutWidget(FlowDirection.TopToBottom);
			{
				enterEditModeButton = editButtonFactory.Generate("Edit".Localize(), centerText: true);
				enterEditModeButton.Click += enterEditModeButtonClick;

				leaveEditModeButton = editButtonFactory.Generate("Done".Localize(), centerText: true);
				leaveEditModeButton.Click += leaveEditModeButtonClick;

				// make sure the buttons are the same size even when localized
				if (leaveEditModeButton.Width < enterEditModeButton.Width)
				{
					editButtonFactory.FixedWidth = enterEditModeButton.Width;
					leaveEditModeButton = editButtonFactory.Generate("Done".Localize(), centerText: true);
					leaveEditModeButton.Click += leaveEditModeButtonClick;
				}
				else
				{
					editButtonFactory.FixedWidth = leaveEditModeButton.Width;
					enterEditModeButton = editButtonFactory.Generate("Edit".Localize(), centerText: true);
					enterEditModeButton.Click += enterEditModeButtonClick;
				}

				CreateEditBarButtons();
				leaveEditModeButton.Visible = false;

				FlowLayoutWidget topBarContainer = new FlowLayoutWidget();
				topBarContainer.BackgroundColor = ActiveTheme.Instance.TransparentDarkOverlay;
				topBarContainer.HAnchor = HAnchor.ParentLeftRight;
				topBarContainer.Padding = new BorderDouble(0);

				topBarContainer.AddChild(enterEditModeButton);

				topBarContainer.AddChild(leaveEditModeButton);
				topBarContainer.AddChild(new HorizontalSpacer());
				topBarContainer.AddChild(itemOperationButtons);

				// put in the itme edit menu
				{
					moreMenu = new DropDownMenu("More".Localize() + "... ");
					moreMenu.NormalColor = new RGBA_Bytes();
					moreMenu.BorderWidth = 1;
					moreMenu.BorderColor = ActiveTheme.Instance.SecondaryTextColor;
					moreMenu.MenuAsWideAsItems = false;
					moreMenu.VAnchor = VAnchor.ParentBottomTop;
					moreMenu.Margin = new BorderDouble(3, 3);
					moreMenu.AlignToRightEdge = true;

					topBarContainer.AddChild(moreMenu);
					SetMenuItems(moreMenu);
					moreMenu.SelectionChanged += new EventHandler(ItemMenu_SelectionChanged);
				}

				allControls.AddChild(topBarContainer);

				{
					// Ensure the form opens with no rows selected.
					//ActiveQueueList.Instance.ClearSelected();

					allControls.AddChild(queueDataView);
				}

				FlowLayoutWidget buttonPanel1 = new FlowLayoutWidget();
				buttonPanel1.HAnchor = HAnchor.ParentLeftRight;
				buttonPanel1.Padding = new BorderDouble(0, 3);
				buttonPanel1.MinimumSize = new Vector2(0, 46);
				{
					addToQueueButton = textImageButtonFactory.Generate(LocalizedString.Get("Add"), "icon_circle_plus.png");
					buttonPanel1.AddChild(addToQueueButton);
					addToQueueButton.Margin = new BorderDouble(0, 0, 3, 0);
					addToQueueButton.Click += new EventHandler(addToQueueButton_Click);

					// put in the creator button
					{
						createButton = textImageButtonFactory.Generate(LocalizedString.Get("Create"), "icon_creator_white_32x32.png");
						buttonPanel1.AddChild(createButton);
						createButton.Margin = new BorderDouble(0, 0, 3, 0);
						createButton.Click += (sender, e) =>
						{
							OpenPluginChooserWindow();
						};
					}

					bool touchScreenMode = ActiveTheme.Instance.IsTouchScreen;

					if (!touchScreenMode)
					{
						if (OemSettings.Instance.ShowShopButton)
						{
							shopButton = textImageButtonFactory.Generate(LocalizedString.Get("Buy Materials"), "icon_shopping_cart_32x32.png");
							buttonPanel1.AddChild(shopButton);
							shopButton.Margin = new BorderDouble(0, 0, 3, 0);
							shopButton.Click += (sender, e) =>
							{
								double activeFilamentDiameter = 0;
								if (ActivePrinterProfile.Instance.ActivePrinter != null)
								{
									activeFilamentDiameter = 3;
									if (ActiveSliceSettings.Instance.FilamentDiameter < 2)
									{
										activeFilamentDiameter = 1.75;
									}
								}

								MatterControlApplication.Instance.LaunchBrowser("http://www.matterhackers.com/mc/store/redirect?d={0}&clk=mcs&a={1}".FormatWith(activeFilamentDiameter, OemSettings.Instance.AffiliateCode));
							};
						}
					}

					buttonPanel1.AddChild(new HorizontalSpacer());

					queueMenuContainer = new FlowLayoutWidget();
					queueMenuContainer.VAnchor = Agg.UI.VAnchor.ParentBottomTop;
					queueMenu = new QueueOptionsMenu();
					queueMenuContainer.AddChild(queueMenu.MenuDropList);
					if (!touchScreenMode)
					{
						buttonPanel1.AddChild(queueMenuContainer);
					}

					ActivePrinterProfile.Instance.ActivePrinterChanged.RegisterEvent((object sender, EventArgs e) =>
					{
						queueMenuContainer.RemoveAllChildren();
						// the printer changed reload the queueMenue
						queueMenu = new QueueOptionsMenu();
						queueMenuContainer.AddChild(queueMenu.MenuDropList);
					}, ref unregisterEvents);
				}
				allControls.AddChild(buttonPanel1);
			}
			allControls.AnchorAll();

			this.AddChild(allControls);
			AddHandlers();

			//enterEditModeButtonClick(null, null);
		}
		private void SetMenuItems(DropDownMenu dropDownMenu)
		{
			menuItems = new TupleList<string, Func<bool>>();

			if (ActiveTheme.Instance.IsTouchScreen)
			{
				menuItems.Add(new Tuple<string, Func<bool>>("Remove All".Localize(), clearAllMenu_Select));
			}

			menuItems.Add(new Tuple<string, Func<bool>>("Send".Localize(), sendMenu_Selected));
			menuItems.Add(new Tuple<string, Func<bool>>("Add To Library".Localize(), addToLibraryMenu_Selected));

			BorderDouble padding = dropDownMenu.MenuItemsPadding;
			//Add the menu items to the menu itself
			foreach (Tuple<string, Func<bool>> item in menuItems)
			{
				if (item.Item2 == null)
				{
					dropDownMenu.MenuItemsPadding = new BorderDouble(5, 0, padding.Right, 3);
				}
				else
				{
					dropDownMenu.MenuItemsPadding = new BorderDouble(10, 5, padding.Right, 5);
				}

				dropDownMenu.AddItem(item.Item1);
			}

			dropDownMenu.Padding = padding;
		}
		private void SetMenuItems(DropDownMenu dropDownMenu)
		{
			menuItems = new List<PrintItemAction>();

			if (ActiveTheme.Instance.IsTouchScreen)
			{
				menuItems.Add(new PrintItemAction()
				{
					Title = "Remove All".Localize(),
					Action = (items, queueDataView) => clearAllButton_Click(null, null)
				});
			}

			menuItems.Add(new PrintItemAction()
			{
				Title = "Send".Localize(),
				Action = (items, queueDataView) => sendButton_Click(null, null)
			});

			menuItems.Add(new PrintItemAction()
			{
				Title = "Add To Library".Localize(),
				Action = (items, queueDataView) => addToLibraryButton_Click(null, null)
			});

			// Extension point for plugins to hook into selected item actions
			var pluginFinder = new PluginFinder<PrintItemMenuExtension>();
			foreach (var menuExtensionPlugin in pluginFinder.Plugins)
			{
				foreach(var menuItem in menuExtensionPlugin.GetMenuItems())
				{
					menuItems.Add(menuItem);
				}
			}

			BorderDouble padding = dropDownMenu.MenuItemsPadding;

			//Add the menu items to the menu itself
			foreach (PrintItemAction item in menuItems)
			{
				if (item.Action == null)
				{
					dropDownMenu.MenuItemsPadding = new BorderDouble(5, 0, padding.Right, 3);
				}
				else
				{
					if(item.SingleItemOnly)
					{
						singleSelectionMenuItems.Add(item.Title);
					}
					dropDownMenu.MenuItemsPadding = new BorderDouble(10, 5, padding.Right, 5);
				}

				dropDownMenu.AddItem(item.Title);
			}

			dropDownMenu.Padding = padding;
		}
        void AddChildElements()
        {
            FlowLayoutWidget settingsStatusLabelContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
            settingsStatusLabelContainer.VAnchor |= VAnchor.ParentTop;
            settingsStatusLabelContainer.Margin = new BorderDouble(0);
            {
				string activeSettingsLabelText = new LocalizedString ("Active Settings").Translated;
				string activeSettingsLabelTextFull = string.Format ("{0}:", activeSettingsLabelText);


				TextWidget settingsStatusLabel = new TextWidget(string.Format(activeSettingsLabelTextFull), pointSize: 10);
                settingsStatusLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;

                settingsStatusDescription = new TextWidget("", pointSize: 14);
                settingsStatusDescription.Margin = new BorderDouble(top: 4);
                settingsStatusDescription.AutoExpandBoundsToText = true;
                settingsStatusDescription.TextColor = ActiveTheme.Instance.PrimaryTextColor;

				string unsavedChangesTxtBeg = new  LocalizedString("unsaved changes").Translated;
				string unsavedChangesTxtFull = string.Format ("({0})", unsavedChangesTxtBeg);
				unsavedChangesIndicator = new TextWidget(unsavedChangesTxtFull, pointSize: 10);
                unsavedChangesIndicator.AutoExpandBoundsToText = true;
                unsavedChangesIndicator.Visible = false;
                unsavedChangesIndicator.Margin = new BorderDouble(left: 4);
                unsavedChangesIndicator.TextColor = ActiveTheme.Instance.PrimaryTextColor;

                settingsStatusLabelContainer.AddChild(settingsStatusLabel);
                settingsStatusLabelContainer.AddChild(settingsStatusDescription);
                settingsStatusLabelContainer.AddChild(unsavedChangesIndicator);
            }

			saveButton = textImageButtonFactory.Generate(new LocalizedString("Save").Translated);
            saveButton.VAnchor = VAnchor.ParentTop;
            saveButton.Visible = false;
            saveButton.Margin = new BorderDouble(0, 0, 0, 10);
            saveButton.Click += new ButtonBase.ButtonEventHandler(saveButton_Click);

			revertbutton = textImageButtonFactory.Generate(new LocalizedString("Revert").Translated);
            revertbutton.VAnchor = VAnchor.ParentTop;
            revertbutton.Visible = false;
            revertbutton.Margin = new BorderDouble(0,0,0,10);
            revertbutton.Click += new ButtonBase.ButtonEventHandler(revertbutton_Click);

			SliceOptionsMenuDropList = new DropDownMenu(new LocalizedString("Options   ").Translated);
            SliceOptionsMenuDropList.Margin = new BorderDouble(top: 11);
            SliceOptionsMenuDropList.VAnchor |= VAnchor.ParentTop;
            SliceOptionsMenuDropList.HoverColor = new RGBA_Bytes(0, 0, 0, 50);
            SliceOptionsMenuDropList.NormalColor = new RGBA_Bytes(0, 0, 0, 0);
            SliceOptionsMenuDropList.BorderColor = new RGBA_Bytes(0, 0, 0, 0);
            SliceOptionsMenuDropList.BackgroundColor = new RGBA_Bytes(0, 0, 0, 0);
            this.SliceOptionsMenuDropList.SelectionChanged += new EventHandler(MenuDropList_SelectionChanged);

            SetMenuItems();

            FlowLayoutWidget sliceEngineContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
            sliceEngineContainer.Margin = new BorderDouble(0,0,10,0);
            sliceEngineContainer.VAnchor |= VAnchor.ParentTop;
            {
				string sliceEngineLabelText = new LocalizedString ("Slice Engine").Translated;
				string sliceEngineLabelTextFull = string.Format ("{0}:", sliceEngineLabelText);
				TextWidget sliceEngineLabel = new TextWidget(string.Format(sliceEngineLabelTextFull), pointSize: 10);
                sliceEngineLabel.Margin = new BorderDouble(0);
                sliceEngineLabel.HAnchor = HAnchor.ParentLeft;
                sliceEngineLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
                
                EngineMenuDropList = CreateSliceEngineDropdown();                

                sliceEngineContainer.AddChild(sliceEngineLabel);
                sliceEngineContainer.AddChild(EngineMenuDropList);
            }

            this.AddChild(sliceEngineContainer);
            this.AddChild(settingsStatusLabelContainer);

            GuiWidget spacer = new GuiWidget(HAnchor.ParentLeftRight);
            this.AddChild(spacer);

            this.AddChild(saveButton);
            this.AddChild(revertbutton);
            this.AddChild(SliceOptionsMenuDropList);

            SetStatusDisplay();
        }
		private DropDownMenu GetSliceOptionsMenuDropList()
		{
			DropDownMenu sliceOptionsMenuDropList;
			sliceOptionsMenuDropList = new DropDownMenu("Profile".Localize() + "... ")
			{
				HoverColor = new RGBA_Bytes(0, 0, 0, 50),
				NormalColor = new RGBA_Bytes(0, 0, 0, 0),
				BorderColor = new RGBA_Bytes(ActiveTheme.Instance.SecondaryTextColor, 100),
				BackgroundColor = new RGBA_Bytes(0, 0, 0, 0),
				BorderWidth = 1,
				MenuAsWideAsItems = false,
				AlignToRightEdge = true,
			};
			sliceOptionsMenuDropList.Name = "Slice Settings Options Menu";
			sliceOptionsMenuDropList.VAnchor |= VAnchor.ParentCenter;

			sliceOptionsMenuDropList.AddItem("Import".Localize()).Selected += (s, e) => { ImportSettingsMenu_Click(); };
			sliceOptionsMenuDropList.AddItem("Export".Localize()).Selected += (s, e) => { WizardWindow.Show<ExportSettingsPage>("ExportSettingsPage", "Export Settings"); };

			MenuItem settingsHistory = sliceOptionsMenuDropList.AddItem("Settings History".Localize());
			settingsHistory.Selected += (s, e) => { WizardWindow.Show<PrinterProfileHistoryPage>("PrinterProfileHistory", "Settings History"); };

			settingsHistory.Enabled = !string.IsNullOrEmpty(AuthenticationData.Instance.ActiveSessionUsername);

			sliceOptionsMenuDropList.AddItem("Reset to defaults".Localize()).Selected += (s, e) => { UiThread.RunOnIdle(ResetToDefaults); };

			return sliceOptionsMenuDropList;
		}
        private void AddScaleControls(FlowLayoutWidget buttonPanel)
        {
            List<GuiWidget> scaleControls = new List<GuiWidget>();
            transformControls.Add("Scale", scaleControls);

            FlowLayoutWidget scaleRatioContainer = new FlowLayoutWidget(FlowDirection.LeftToRight);
            scaleRatioContainer.HAnchor = HAnchor.ParentLeftRight;
            scaleRatioContainer.Padding = new BorderDouble(5);

			string scaleRatioLblTxt = new LocalizedString("Ratio").Translated;
			string scaleRatioLblTxtFull = string.Format("{0}:", scaleRatioLblTxt);
			TextWidget scaleRatioLabel = new TextWidget(scaleRatioLblTxtFull, textColor: RGBA_Bytes.White);
            scaleRatioLabel.VAnchor = VAnchor.ParentCenter;
            scaleRatioContainer.AddChild(scaleRatioLabel);

            GuiWidget horizontalSpacer = new GuiWidget();
            horizontalSpacer.HAnchor = HAnchor.ParentLeftRight;
            scaleRatioContainer.AddChild(horizontalSpacer);

            scaleRatioControl = new MHNumberEdit(1, pixelWidth: 50, allowDecimals: true, increment: .05);
            scaleRatioContainer.AddChild(scaleRatioControl);
            scaleRatioControl.ActuallNumberEdit.KeyPressed += (sender, e) =>
            {
                double scale = scaleRatioControl.ActuallNumberEdit.Value;
                if (scale != MeshExtraData[SelectedMeshIndex].currentScale)
                {
                    applyScaleButton.Visible = true;
                }
                else
                {
                    applyScaleButton.Visible = false;
                }
            };

            buttonPanel.AddChild(scaleRatioContainer);

            scaleControls.Add(scaleRatioControl);
            scaleRatioControl.ActuallNumberEdit.EnterPressed += (object sender, KeyEventArgs keyEvent) =>
            {
                ApplyScaleFromEditField();
            };

			DropDownMenu presetScaleMenu = new DropDownMenu(new LocalizedString("Conversions").Translated, Direction.Down);
            RectangleDouble presetBounds = presetScaleMenu.LocalBounds;
            presetBounds.Inflate(new BorderDouble(5, 10, 10, 10));
            presetScaleMenu.LocalBounds = presetBounds;
            presetScaleMenu.MenuAsWideAsItems = false;
            presetScaleMenu.HAnchor |= HAnchor.ParentLeftRight;

            presetScaleMenu.AddItem("mm to in (.03937)");
            presetScaleMenu.AddItem("in to mm (25.4)");
            presetScaleMenu.AddItem("mm to cm (.1)");
            presetScaleMenu.AddItem("cm to mm (10)");
			string resetLbl = new LocalizedString ("reset").Translated;
			string resetLblFull = string.Format("{0} (1)",resetLbl);
			presetScaleMenu.AddItem(resetLblFull);


            presetScaleMenu.SelectionChanged += (sender, e) =>
            {
                double scale = 1;
                switch (presetScaleMenu.SelectedIndex)
                {
                    case 0:
                        scale = 1.0 / 25.4;
                        break;
                    case 1:
                        scale = 25.4;
                        break;
                    case 2:
                        scale = .1;
                        break;
                    case 3:
                        scale = 10;
                        break;
                    case 4:
                        scale = 1;
                        break;
                }

                scaleRatioControl.ActuallNumberEdit.Value = scale;
                ApplyScaleFromEditField();
            };

            buttonPanel.AddChild(presetScaleMenu);

			applyScaleButton = whiteButtonFactory.Generate(new LocalizedString("Apply Scale").Translated, centerText: true);
            applyScaleButton.Visible = false;
            applyScaleButton.Cursor = Cursors.Hand;
            buttonPanel.AddChild(applyScaleButton);

            scaleControls.Add(applyScaleButton);
            applyScaleButton.Click += (object sender, MouseEventArgs mouseEvent) =>
            {
                ApplyScaleFromEditField();
            };

            buttonPanel.AddChild(generateHorizontalRule());
        }
		public QueueDataWidget(QueueDataView queueDataView)
		{
			this.queueDataView = queueDataView;

			SetDisplayAttributes();

			textImageButtonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor;
			textImageButtonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor;
			textImageButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor;
			textImageButtonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryTextColor;
			textImageButtonFactory.borderWidth = 0;

			editButtonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor;
			editButtonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor;
			editButtonFactory.disabledTextColor = ActiveTheme.Instance.TabLabelUnselected;
			editButtonFactory.disabledFillColor = new RGBA_Bytes();
			editButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor;
			editButtonFactory.borderWidth = 0;
			editButtonFactory.Margin = new BorderDouble(10, 0);

			FlowLayoutWidget allControls = new FlowLayoutWidget(FlowDirection.TopToBottom);
			{
				enterEditModeButton = editButtonFactory.Generate("Edit".Localize(), centerText: true);
				enterEditModeButton.ToolTipText = "Enter Multi Select mode".Localize();
				enterEditModeButton.Click += enterEditModeButtonClick;

				leaveEditModeButton = editButtonFactory.Generate("Done".Localize(), centerText: true);
				leaveEditModeButton.Name = "Queue Done Button";
				leaveEditModeButton.Click += leaveEditModeButtonClick;

				// make sure the buttons are the same size even when localized
				if (leaveEditModeButton.Width < enterEditModeButton.Width)
				{
					editButtonFactory.FixedWidth = enterEditModeButton.Width;
					leaveEditModeButton = editButtonFactory.Generate("Done".Localize(), centerText: true);
					leaveEditModeButton.Click += leaveEditModeButtonClick;
				}
				else
				{
					editButtonFactory.FixedWidth = leaveEditModeButton.Width;
					enterEditModeButton = editButtonFactory.Generate("Edit".Localize(), centerText: true);
					enterEditModeButton.Name = "Queue Edit Button";
					enterEditModeButton.Click += enterEditModeButtonClick;
				}

				multiSelectionMenuItems.Add("Merge...");

				CreateEditBarButtons();
				leaveEditModeButton.Visible = false;

				FlowLayoutWidget topBarContainer = new FlowLayoutWidget();
				topBarContainer.BackgroundColor = ActiveTheme.Instance.TransparentDarkOverlay;
				topBarContainer.HAnchor = HAnchor.ParentLeftRight;
				topBarContainer.Padding = new BorderDouble(0);

				topBarContainer.AddChild(enterEditModeButton);

				topBarContainer.AddChild(leaveEditModeButton);
				topBarContainer.AddChild(new HorizontalSpacer());
				topBarContainer.AddChild(itemOperationButtons);

				// put in the item edit menu
				{
					moreMenu = new DropDownMenu("More".Localize() + "... ");
					moreMenu.NormalColor = new RGBA_Bytes();
					moreMenu.BorderWidth = (int)(1 * GuiWidget.DeviceScale + .5);
					moreMenu.BorderColor = new RGBA_Bytes(ActiveTheme.Instance.SecondaryTextColor,100);
					moreMenu.MenuAsWideAsItems = false;
					moreMenu.VAnchor = VAnchor.ParentBottomTop;
					moreMenu.Margin = new BorderDouble(3, 3);
					moreMenu.AlignToRightEdge = true;

					topBarContainer.AddChild(moreMenu);
					SetMenuItems(moreMenu);
					moreMenu.SelectionChanged += new EventHandler(ItemMenu_SelectionChanged);
				}

				allControls.AddChild(topBarContainer);

				{
					// Ensure the form opens with no rows selected.
					//ActiveQueueList.Instance.ClearSelected();

					allControls.AddChild(queueDataView);
				}

				FlowLayoutWidget buttonPanel1 = new FlowLayoutWidget();
				buttonPanel1.HAnchor = HAnchor.ParentLeftRight;
				buttonPanel1.Padding = new BorderDouble(0, 3);
				buttonPanel1.MinimumSize = new Vector2(0, 46);
				{
					addToQueueButton = textImageButtonFactory.Generate(LocalizedString.Get("Add"), StaticData.Instance.LoadIcon("icon_plus.png", 32, 32));
					addToQueueButton.ToolTipText = "Add an .stl, .amf, .gcode or .zip file to the Queue".Localize();
					buttonPanel1.AddChild(addToQueueButton);
					addToQueueButton.Margin = new BorderDouble(0, 0, 3, 0);
					addToQueueButton.Click += new EventHandler(addToQueueButton_Click);
					addToQueueButton.Name = "Queue Add Button";

					// put in the creator button
					{
						createButton = textImageButtonFactory.Generate(LocalizedString.Get("Create"), StaticData.Instance.LoadIcon("icon_creator.png", 32, 32));
						createButton.ToolTipText = "Choose a Create Tool to generate custom designs".Localize();
						createButton.Name = "Design Tool Button";
						buttonPanel1.AddChild(createButton);
						createButton.Margin = new BorderDouble(0, 0, 3, 0);
						createButton.Click += (sender, e) =>
						{
							OpenPluginChooserWindow();
						};
					}

					bool touchScreenMode = UserSettings.Instance.IsTouchScreen;

					if (OemSettings.Instance.ShowShopButton)
					{
						shopButton = textImageButtonFactory.Generate(LocalizedString.Get("Buy Materials"), StaticData.Instance.LoadIcon("icon_shopping_cart_32x32.png", 32,32));
						shopButton.ToolTipText = "Shop online for printing materials".Localize();
						shopButton.Name = "Buy Materials Button";
						buttonPanel1.AddChild(shopButton);
						shopButton.Margin = new BorderDouble(0, 0, 3, 0);
						shopButton.Click += (sender, e) =>
						{
							double activeFilamentDiameter = 0;
							if (ActiveSliceSettings.Instance != null)
							{
								activeFilamentDiameter = 3;
								if (ActiveSliceSettings.Instance.GetValue<double>(SettingsKey.filament_diameter) < 2)
								{
									activeFilamentDiameter = 1.75;
								}
							}

							MatterControlApplication.Instance.LaunchBrowser("http://www.matterhackers.com/mc/store/redirect?d={0}&clk=mcs&a={1}".FormatWith(activeFilamentDiameter, OemSettings.Instance.AffiliateCode));
							};
						}


					buttonPanel1.AddChild(new HorizontalSpacer());

					queueMenuContainer = new FlowLayoutWidget();
					queueMenuContainer.VAnchor = Agg.UI.VAnchor.ParentBottomTop;
					queueMenu = new QueueOptionsMenu();
					queueMenuContainer.AddChild(queueMenu.MenuDropList);
					buttonPanel1.AddChild(queueMenuContainer);
				}
				allControls.AddChild(buttonPanel1);
			}
			allControls.AnchorAll();

			this.AddChild(allControls);

			QueueData.Instance.SelectedIndexChanged.RegisterEvent((s,e) => SetEditButtonsStates(), ref unregisterEvents);

			SetEditButtonsStates(); 
		}
		private void CreateActionMenuItems(DropDownMenu actionMenu)
		{
			actionMenu.SelectionChanged += (sender, e) =>
			{
				string menuSelection = ((DropDownMenu)sender).SelectedValue;
				foreach (var menuItem in menuItems)
				{
					if (menuItem.Title == menuSelection)
					{
						menuItem.Action?.Invoke(null, null);
					}
				}
			};

			// edit menu item
			menuItems.Add(new PrintItemAction()
			{
				Title = "Edit".Localize(),
				Action = (s, e) => editButton_Click(s, null)
			});
			actionMenuEnableData.Add(new MenuEnableData(
				actionMenu.AddItem(menuItems[menuItems.Count - 1].Title),
				false, false, false));

			actionMenu.AddHorizontalLine();

			// rename menu item
			menuItems.Add(new PrintItemAction()
			{
				Title = "Rename".Localize(),
				Action = (s, e) => renameFromLibraryButton_Click(s, null)
			});
			actionMenuEnableData.Add(new MenuEnableData(actionMenu.AddItem(menuItems[menuItems.Count - 1].Title), false, false, true));

			// move menu item
			menuItems.Add(new PrintItemAction()
			{
				Title = "Move".Localize(),
				Action = (s, e) => moveInLibraryButton_Click(s, null)
			});
			//actionMenuEnableData.Add(new MenuEnableData(actionMenu.AddItem(menuItems[menuItems.Count - 1].Title), true, false, true));

			// remove menu item
			menuItems.Add(new PrintItemAction()
			{
				Title = "Remove".Localize(),
				Action = (s, e) => deleteFromLibraryButton_Click(s, null)
			});
			actionMenuEnableData.Add(new MenuEnableData(
				actionMenu.AddItem(menuItems[menuItems.Count - 1].Title),
				true, false, true));

			actionMenu.AddHorizontalLine();

			// add to queue menu item
			menuItems.Add(new PrintItemAction()
			{
				Title = "Add to Queue".Localize(),
				Action = (s, e) => addToQueueButton_Click(s, null)
			});
			actionMenuEnableData.Add(new MenuEnableData(
				actionMenu.AddItem(menuItems[menuItems.Count - 1].Title),
				true, true, false));

			// export menu item
			menuItems.Add(new PrintItemAction()
			{
				Title = "Export".Localize(),
				Action = (s, e) => exportButton_Click(s, null)
			});
			actionMenuEnableData.Add(new MenuEnableData(
				actionMenu.AddItem(menuItems[menuItems.Count - 1].Title),
				false, false, false));

			// share menu item
			menuItems.Add(new PrintItemAction()
			{
				Title = "Share".Localize(),
				Action = (s, e) => shareFromLibraryButton_Click(s, null)
			});
			actionMenuEnableData.Add(new MenuEnableData(
				actionMenu.AddItem(menuItems[menuItems.Count - 1].Title),
				false, false, false, true));

			SetActionMenuStates();
		}
		private DropDownMenu CreateScaleDropDownMenu()
		{
			DropDownMenu presetScaleMenu = new DropDownMenu("", Direction.Down);
			presetScaleMenu.NormalArrowColor = ActiveTheme.Instance.PrimaryTextColor;
			presetScaleMenu.HoverArrowColor = ActiveTheme.Instance.PrimaryTextColor;
			presetScaleMenu.MenuAsWideAsItems = false;
			presetScaleMenu.AlignToRightEdge = true;
			//presetScaleMenu.OpenOffset = new Vector2(-50, 0);
			presetScaleMenu.HAnchor = HAnchor.AbsolutePosition;
			presetScaleMenu.VAnchor = VAnchor.AbsolutePosition;
			presetScaleMenu.Width = 25;
			presetScaleMenu.Height = scaleRatioControl.Height + 2;

			presetScaleMenu.AddItem("mm to in (.0393)");
			presetScaleMenu.AddItem("in to mm (25.4)");
			presetScaleMenu.AddItem("mm to cm (.1)");
			presetScaleMenu.AddItem("cm to mm (10)");
			string resetLable = "reset".Localize();
			string resetLableFull = "{0} (1)".FormatWith(resetLable);
			presetScaleMenu.AddItem(resetLableFull);

			presetScaleMenu.SelectionChanged += (sender, e) =>
			{
				double scale = 1;
				switch (presetScaleMenu.SelectedIndex)
				{
					case 0:
						scale = 1.0 / 25.4;
						break;

					case 1:
						scale = 25.4;
						break;

					case 2:
						scale = .1;
						break;

					case 3:
						scale = 10;
						break;

					case 4:
						scale = 1;
						break;
				}

				scaleRatioControl.ActuallNumberEdit.Value = scale;
				ApplyScaleFromEditField();
			};

			return presetScaleMenu;
		}
        DropDownMenu GetSliceOptionsMenuDropList()
        {
            if (sliceOptionsMenuDropList == null)
            {
                sliceOptionsMenuDropList = new DropDownMenu(LocalizedString.Get("Options   "));
                sliceOptionsMenuDropList.HoverColor = new RGBA_Bytes(0, 0, 0, 50);
                sliceOptionsMenuDropList.NormalColor = new RGBA_Bytes(0, 0, 0, 0);
                sliceOptionsMenuDropList.BorderColor = new RGBA_Bytes(0, 0, 0, 0);
                sliceOptionsMenuDropList.BackgroundColor = new RGBA_Bytes(0, 0, 0, 0);
                sliceOptionsMenuDropList.SelectionChanged += new EventHandler(MenuDropList_SelectionChanged);

                SetMenuItems();
            }

            return sliceOptionsMenuDropList;
        }