// Token: 0x06000ABB RID: 2747 RVA: 0x00044A48 File Offset: 0x00042C48 public void AddMenuItem(string caption, Action <CommUser> action, Func <CommUser, bool> isEnabledForUser) { PopupMenu.MenuItem item = new PopupMenu.MenuItem { Caption = caption, Callback = action, CheckItem = isEnabledForUser }; this._items.Add(item); }
// Token: 0x06000AB9 RID: 2745 RVA: 0x000449C4 File Offset: 0x00042BC4 public void AddMenuCopyPlayerName(string caption, Action <CommUser, InstantMessage> action, Func <CommUser, bool> isEnabledForUser) { PopupMenu.MenuItem item = new PopupMenu.MenuItem { Caption = caption, CopyPlayerName = action, CopyMsg = action, CheckItem = isEnabledForUser }; this._items.Add(item); }
protected override void OnClick(MouseEventArgs mouseEvent) { if (mouseEvent.Button == MouseButtons.Right) { var theme = ApplicationController.Instance.MenuTheme; var printTasks = PrintHistoryData.Instance.GetHistoryItems(1000); var popupMenu = new PopupMenu(theme); var printHistoryEditor = new PrintHistoryEditor(null, theme, printTask, printTasks); var qualityWidget = PrintHistoryEditor.GetQualityWidget(theme, printTask, () => { popupMenu.Unfocus(); printInfoWidget.Text = GetPrintInfo(); SetIndicatorColor(); }, theme.DefaultFontSize); var menuItem = new PopupMenu.MenuItem(qualityWidget, theme) { HAnchor = HAnchor.Fit | HAnchor.Stretch, VAnchor = VAnchor.Fit, HoverColor = Color.Transparent, }; popupMenu.AddChild(menuItem); printHistoryEditor.AddNotesMenu(popupMenu, printTasks, () => { printInfoWidget.Text = GetPrintInfo(); }); popupMenu.CreateSeparator(); AddExportMenu(popupMenu, printTasks); popupMenu.CreateSeparator(); AddClearHistorMenu(popupMenu, printTasks); popupMenu.ShowMenu(this, mouseEvent); } base.OnClick(mouseEvent); }
public FlowLayoutWidget CreateMenuItems(PopupMenu popupMenu, IEnumerable <NamedAction> menuActions) { // Create menu items in the DropList for each element in this.menuActions foreach (var menuAction in menuActions) { if (menuAction is ActionSeparator) { popupMenu.CreateSeparator(); } else { if (menuAction is NamedActionGroup namedActionButtons) { var content = new FlowLayoutWidget() { HAnchor = HAnchor.Fit | HAnchor.Stretch }; var textWidget = new TextWidget(menuAction.Title, pointSize: this.DefaultFontSize, textColor: this.TextColor) { // Padding = MenuPadding, VAnchor = VAnchor.Center }; content.AddChild(textWidget); content.AddChild(new HorizontalSpacer()); foreach (var actionButton in namedActionButtons.Group) { var button = new TextButton(actionButton.Title, this) { Border = new BorderDouble(1, 0, 0, 0), BorderColor = this.MinimalShade, HoverColor = this.AccentMimimalOverlay, Enabled = actionButton.IsEnabled() }; content.AddChild(button); if (actionButton.IsEnabled()) { button.Click += (s, e) => { actionButton.Action(); popupMenu.Unfocus(); }; } } var menuItem = new PopupMenu.MenuItem(content, this) { HAnchor = HAnchor.Fit | HAnchor.Stretch, VAnchor = VAnchor.Fit, HoverColor = Color.Transparent, }; popupMenu.AddChild(menuItem); menuItem.Padding = new BorderDouble(menuItem.Padding.Left, menuItem.Padding.Bottom, 0, menuItem.Padding.Top); } else { PopupMenu.MenuItem menuItem; if (menuAction is NamedBoolAction boolAction) { menuItem = popupMenu.CreateBoolMenuItem(menuAction.Title, boolAction.GetIsActive, boolAction.SetIsActive); } else { menuItem = popupMenu.CreateMenuItem(menuAction.Title, menuAction.Icon, menuAction.Shortcut); } menuItem.Name = $"{menuAction.Title} Menu Item"; menuItem.Enabled = menuAction is NamedActionGroup || (menuAction.Action != null && menuAction.IsEnabled?.Invoke() != false); menuItem.ClearRemovedFlag(); if (menuItem.Enabled) { menuItem.Click += (s, e) => { menuAction.Action(); }; } } } } return(popupMenu); }
public void AddQualityMenu(PopupMenu popupMenu, Action notesChanged) { var theme = ApplicationController.Instance.MenuTheme; var content = new FlowLayoutWidget() { HAnchor = HAnchor.Fit | HAnchor.Stretch }; var textWidget = new TextWidget("Print Quality".Localize() + ":", pointSize: theme.DefaultFontSize, textColor: theme.TextColor) { // Padding = MenuPadding, VAnchor = VAnchor.Center }; content.AddChild(textWidget); content.AddChild(new HorizontalSpacer()); var siblings = new List <GuiWidget>(); for (int i = 0; i < QualityNames.Length; i++) { var button = new RadioButton(new TextWidget(i.ToString(), pointSize: theme.DefaultFontSize, textColor: theme.TextColor)) { Enabled = printTask.PrintComplete, Checked = printTask.QualityWasSet && printTask.PrintQuality == i, ToolTipText = QualityNames[i], Margin = 0, Padding = 5, HAnchor = HAnchor.Fit, VAnchor = VAnchor.Fit, }; button.MouseEnterBounds += (s, e) => { button.BackgroundColor = theme.AccentMimimalOverlay; }; button.MouseLeaveBounds += (s, e) => { button.BackgroundColor = button.Checked ? theme.AccentMimimalOverlay : Color.Transparent; }; siblings.Add(button); if (button.Checked && button.Enabled) { button.BackgroundColor = theme.AccentMimimalOverlay; } button.SiblingRadioButtonList = siblings; content.AddChild(button); button.Click += (s, e) => { printTask.PrintQuality = siblings.IndexOf((GuiWidget)s); printTask.QualityWasSet = true; printTask.Commit(); popupMenu.Unfocus(); notesChanged(); }; } var menuItem = new PopupMenu.MenuItem(content, theme) { HAnchor = HAnchor.Fit | HAnchor.Stretch, VAnchor = VAnchor.Fit, HoverColor = Color.Transparent, }; popupMenu.AddChild(menuItem); }
public GuiWidget Create(IObject3D item, UndoBuffer undoBuffer, ThemeConfig theme) { this.injectedItem = item as SvgObject3D; if (this.injectedItem == null) { return(null); } var column = new FlowLayoutWidget(FlowDirection.TopToBottom) { VAnchor = VAnchor.Fit, HAnchor = HAnchor.Absolute, Width = 210, Padding = new BorderDouble(12), }; column.Closed += (s, e) => { //unregisterEvents?.Invoke(this, null); }; var rightPanel = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.Stretch }; var label = new TextWidget("All Paths", textColor: AppContext.Theme.TextColor) { HAnchor = HAnchor.Left, Margin = new BorderDouble(0, 0, 0, 15) }; column.AddChild(label); var row = new FlowLayoutWidget() { }; column.AddChild(row); var editButton = new TextButton("Edit".Localize(), theme) { Enabled = false, }; editButton.Click += async(s, e) => { ApplicationController.Instance.OpenIntoNewTab(new[] { new InMemoryLibraryItem(new VertexStorageObject3D(lastDPath)) }); }; int pathCount = 1; var droplist = new PopupMenu(theme) { BackgroundColor = theme.InactiveTabColor }; row.AddChild(droplist); row.AddChild(editButton); var allPaths = SvgParser.GetPaths(this.injectedItem.SvgPath); selectedItems = new HashSet <SvgParser.SvgNodeInfo>(allPaths); foreach (var pathItem in allPaths) { bool itemChecked = true; PopupMenu.MenuItem menuItem = null; menuItem = droplist.CreateBoolMenuItem( $"Path {pathCount++}", () => itemChecked, (isChecked) => { lastDPath = (pathItem as SvgParser.SvgPathInfo)?.DString; editButton.Enabled = true; if (isChecked) { selectedItems.Add(pathItem); } else { selectedItems.Remove(pathItem); } this.Rebuild(); }); } this.Rebuild(); return(column); }