/// <summary> /// Constructor /// </summary> /// <param name="path">Path of the menu item</param> /// <param name="content">Text of the menu item itself</param> /// <param name="action">The action to be executed on click</param> /// <param name="userData">Data to be passed to the callback</param> public GUIParamDelegateMenuItem(string path, GUIContent content, MenuItemAction action, object userData = null) : base(path, content) { Callback = action; UserData = userData; }
private void Button_Click(object sender, RoutedEventArgs e) { if (!(sender is Button)) { return; } var package = (PackageModel)((Button)sender).Tag; MenuItemAction action = MenuItemAction.Install; if (package.PackageState == State.Installed) { action = MenuItemAction.Uninstall; } else if (package.PackageState == State.NeedsUpdate) { action = MenuItemAction.Update; } else { action = MenuItemAction.Install; } if (MenuItemClicked != null) { MenuItemClicked(sender, new MenuItemEventArgs { Packages = new List <PackageModel>() { package }, Action = action }); } }
/** <summary> Constructs a menu item with the specified text, action, and hotkey. </summary> */ public DebugMenuItem(string text, HotKey hotkey, MenuItemAction action) { this.root = null; this.text = text; this.index = 0; this.hotkey = hotkey ?? new HotKey(); this.action = action; this.items = new List <DebugMenuItem>(); }
//========= CONSTRUCTORS ========= #region Constructors /** <summary> Constructs a menu item with the specified text. </summary> */ public DebugMenuItem(string text) { this.root = null; this.text = text; this.index = 0; this.hotkey = new HotKey(); this.action = null; this.items = new List <DebugMenuItem>(); }
/** <summary> Constructs a menu item with the specified text. </summary> */ public DebugMenuItem(string text) { this.root = null; this.text = text; this.index = 0; this.hotkey = new HotKey(); this.action = null; this.items = new List<DebugMenuItem>(); }
/** <summary> Constructs a menu item with the specified text, action, and hotkey. </summary> */ public DebugMenuItem(string text, HotKey hotkey, MenuItemAction action) { this.root = null; this.text = text; this.index = 0; this.hotkey = hotkey ?? new HotKey(); this.action = action; this.items = new List<DebugMenuItem>(); }
public MenuItem(string text, MenuItemType type = MenuItemType.Text, MenuItemAction action = MenuItemAction.None) { if (type == MenuItemType.Checkbox && action == MenuItemAction.Refresh) { action = MenuItemAction.Refresh; } Text = text; Type = type; Action = action; }
public MenuItem(string text, MenuItemType type = MenuItemType.Text, MenuItemAction action = MenuItemAction.None) { if (type == MenuItemType.Checkbox && action == MenuItemAction.Refresh) { action = MenuItemAction.Refresh; } Text = text; Type = type; Action = action; }
// ================== CONSTRUCTORS ================== // public ToggleMenuItem(string text, HotKey hotkey, bool startsEnabled, MenuItemToggleAction toggleAction, MenuItemAction enableAction, MenuItemAction disableAction) : base(text, hotkey, null) { this.isEnabled = startsEnabled; this.toggleAction = toggleAction; this.enableAction = enableAction; this.disableAction = disableAction; Action = delegate() { Toggle(); }; }
// ================== CONSTRUCTORS ================== // public ToggleMenuItem(string text, HotKey hotkey, bool startsEnabled, MenuItemToggleAction toggleAction, MenuItemAction enableAction, MenuItemAction disableAction) : base(text, hotkey, null) { this.isEnabled = startsEnabled; this.toggleAction = toggleAction; this.enableAction = enableAction; this.disableAction = disableAction; Action = delegate() { Toggle(); }; }
MenuItem CreateMenuItem(string text, MenuItemAction action, params object[] args) { MenuItem item = new MenuItem(text); item.Click += (sender, e) => { if (action != null) { action(args); } }; return(item); }
private void AddMenuItem(string[] segments, MenuItemAction action, int depth = 0, MenuItem menuItem = null) { var segment = segments[depth].Replace(@"\", ""); dynamic menuItm = (object)menuItem ?? mainMenu; var childMenu = GetChildMenuItem(menuItm, segment); if (childMenu != null && depth + 1 < segments.Length) { AddMenuItem(segments, action, depth + 1, childMenu); return; } else { var newItem = new MenuItem { Header = segment, DataContext = action }; if (depth + 1 < segments.Length) { menuItm.Items.Add(newItem); // newItem.Items.SortDescriptions.Add() AddMenuItem(segments, action, depth + 1, newItem); } else { int addedIndex = -1; int itemCount = menuItm.Items.Count; // int itidx = (int)(action.order.GetValue(0) ?? 0); // var idx = itemCount < itidx ? -1 : action.order[0]; // if (idx > -1) menuItm.Items.Insert(idx, newItem); // else addedIndex = menuItm.Items.Add(newItem); // if (itemCount > 1) { // var separatorAttr = Attribute.GetCustomAttribute(action.action, typeof(MenuItemSeparatorAttribute)); // if (separatorAttr != null) { // var separator = new Separator(); // // menuItm.Items.Insert(addedIndex > -1 ? addedIndex : idx, separator); // } // } newItem.Click += (sender, evt) => { var menuItem = (MenuItemAction)((MenuItem)sender).DataContext; var instance = (Action)Activator.CreateInstance(menuItem.action); SelectedLayer.actions.Add(instance); SelectedLayer.ApplyActions(); EventBus.OnLayerActionAdded(this); }; } } }
public void CanvasMenuItemClick(object a) { MenuItemAction action = (MenuItemAction)a; if (action == MenuItemAction.AddTerrainNode) { CreateNewNode(); } else if (action == MenuItemAction.NewCanvas) { NewCanvas(); } else if (action == MenuItemAction.Save && CurrentCanvas != null) { SaveCanvas(CurrentCanvas.Path); } }
public void NodeMenuItemClicked(object a) { MenuItemAction action = (MenuItemAction)a; if (action == MenuItemAction.DeleteNode && uNodeEditorState.focusedNode != null) { DeleteNode(uNodeEditorState.focusedNode); } else if (action == MenuItemAction.DuplicateNode && uNodeEditorState.focusedNode != null) { DuplicateNode(uNodeEditorState.focusedNode); } else if (action == MenuItemAction.DuplicateWithChildren && uNodeEditorState.focusedNode != null) { DuplicateNodeWithChildren(uNodeEditorState.focusedNode); } }
private void BuildMenu() { m_MainMenu = new MainMenu(0, "Main Menu", null, new List <MenuItem>()); SubMenu showDateAndTimeSubMenu = new SubMenu(1, "Show Date/Time", m_MainMenu, new List <MenuItem>()); SubMenu showVersionAndCapitalsSubMenu = new SubMenu(1, "Version and Capitals", m_MainMenu, new List <MenuItem>()); MenuItemAction showDate = new MenuItemAction("Show Date", showDateAndTimeSubMenu, new Functions.ShowDateHelper()); MenuItemAction showTime = new MenuItemAction("Show Time", showDateAndTimeSubMenu, new Functions.ShowTimeHelper()); MenuItemAction showVersion = new MenuItemAction("Show Version", showVersionAndCapitalsSubMenu, new Functions.ShowVersionHelper()); MenuItemAction countCapitals = new MenuItemAction("Count Capitals", showVersionAndCapitalsSubMenu, new Functions.CountCapitals()); m_MainMenu.MenuItems.Add(showDateAndTimeSubMenu); m_MainMenu.MenuItems.Add(showVersionAndCapitalsSubMenu); showDateAndTimeSubMenu.MenuItems.Add(showDate); showDateAndTimeSubMenu.MenuItems.Add(showTime); showVersionAndCapitalsSubMenu.MenuItems.Add(showVersion); showVersionAndCapitalsSubMenu.MenuItems.Add(countCapitals); }
// ================== CONSTRUCTORS ================== // public RadioButtonMenuItem(string text, HotKey hotkey, RadioButtonGroup group, bool startsEnabled, MenuItemToggleAction toggleAction, MenuItemAction enableAction, MenuItemAction disableAction) : base(text, hotkey, startsEnabled, toggleAction, enableAction, disableAction) { this.group = group; group.Items.Add(this); Action = delegate() { if (!IsEnabled) { Enable(); for (int i = 0; i < group.Items.Count; ++i) { if (group.Items[i] != this && group.Items[i].IsEnabled) group.Items[i].Disable(); } } }; }
// ================== CONSTRUCTORS ================== // public RadioButtonMenuItem(string text, HotKey hotkey, RadioButtonGroup group, bool startsEnabled, MenuItemToggleAction toggleAction, MenuItemAction enableAction, MenuItemAction disableAction) : base(text, hotkey, startsEnabled, toggleAction, enableAction, disableAction) { this.group = group; group.Items.Add(this); Action = delegate() { if (!IsEnabled) { Enable(); for (int i = 0; i < group.Items.Count; ++i) { if (group.Items[i] != this && group.Items[i].IsEnabled) { group.Items[i].Disable(); } } } }; }
private static MainMenu BuildMenu() { MainMenu mainMenu = new MainMenu(0, "Main Menu", null, new List <MenuItem>()); SubMenu showDateAndTimeSubMenu = new SubMenu(1, "Show Date/Time", mainMenu, new List <MenuItem>()); SubMenu showVersionAndCapitalsSubMenu = new SubMenu(1, "Version and Capitals", mainMenu, new List <MenuItem>()); MenuItemAction showDate = new MenuItemAction("Show Date", showDateAndTimeSubMenu); MenuItemAction showTime = new MenuItemAction("Show Time", showDateAndTimeSubMenu); MenuItemAction showVersion = new MenuItemAction("Show Version", showVersionAndCapitalsSubMenu); MenuItemAction countCapitals = new MenuItemAction("Count Capitals", showVersionAndCapitalsSubMenu); mainMenu.MenuItems.Add(showDateAndTimeSubMenu); mainMenu.MenuItems.Add(showVersionAndCapitalsSubMenu); showDateAndTimeSubMenu.MenuItems.Add(showDate); showDateAndTimeSubMenu.MenuItems.Add(showTime); showVersionAndCapitalsSubMenu.MenuItems.Add(showVersion); showVersionAndCapitalsSubMenu.MenuItems.Add(countCapitals); countCapitals.Clicked += Functions.CountCapitalLetters; showVersion.Clicked += Functions.ShowVersion; showDate.Clicked += Functions.ShowDate; showTime.Clicked += Functions.ShowTime; return(mainMenu); }
public MenuItem(GetTextHandler getTextCallback, MenuItemType type = MenuItemType.Text, MenuItemAction action = MenuItemAction.None) : this(String.Empty, type, action) { this.getTextCallback = getTextCallback; }
public void AddAction(String label, MenuItemAction action) { menuActions.Add(label, action); }
public MenuItem(string text, MenuItemType type = MenuItemType.Text, MenuItemAction action = MenuItemAction.None) { Text = text; Type = type; Action = action; }
/** <summary> Adds the specified menu item to the list of menu items. </summary> */ public DebugMenuItem AddItem(string text, HotKey hotkey, MenuItemAction action) { return AddItem(new DebugMenuItem(text, hotkey, action)); }
public MenuItem(GetTextHandler getTextCallback, MenuItemEventHandler callback, MenuItemType type = MenuItemType.Button, MenuItemAction action = MenuItemAction.None) : this(getTextCallback, type, action) { Clicked += callback; }
public MenuItem(GetTextHandler getTextCallback, MenuItemEventHandler callback, MenuItemType type = MenuItemType.Button, MenuItemAction action = MenuItemAction.None) : this(getTextCallback, type, action) { Clicked += callback; }
public MenuItem(string text, MenuItemEventHandler callback, MenuItemType type = MenuItemType.Button, MenuItemAction action = MenuItemAction.None) : this(text, type, action) { Clicked += callback; }
public MenuItem(GetTextHandler getTextCallback, MenuItemType type = MenuItemType.Text, MenuItemAction action = MenuItemAction.None) : this(String.Empty, type, action) { this.getTextCallback = getTextCallback; }
/** <summary> Adds the specified menu item to the list of menu items. </summary> */ public DebugMenuItem AddItem(string text, HotKey hotkey, MenuItemAction action) { return(AddItem(new DebugMenuItem(text, hotkey, action))); }
public GUIDelegateMenuItem(string path, GUIContent content, MenuItemAction action) : base(path, content) { Callback = action; }
/// <summary> /// Constructor /// </summary> /// <param name="path">Path of the menu item</param> /// <param name="content">Text of the menu item itself</param> /// <param name="action">The action to be executed on click</param> public GUIGroupMenuItem(string path, GUIContent content, MenuItemAction action) : base(path, content, action) { }
public MenuItem(string text, MenuItemEventHandler callback, MenuItemType type = MenuItemType.Button, MenuItemAction action = MenuItemAction.None) : this(text, type, action) { Clicked += callback; }
public MenuItemSingle(string text, char selectionChar = '>') { Text = text; SelectAction = new MenuItemAction(DefaultAction); SelectionChar = selectionChar; }
public MenuItemBase() { SelectAction = new MenuItemAction(DefaultAction); }
public MenuItemSingle(string text, MenuItemAction onClickAction, char selectionChar = '>') { Text = text; SelectAction = new MenuItemAction(onClickAction); SelectionChar = selectionChar; }