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); }
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 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 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; }
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 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; }
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()); }