public void Update(MDMenu parent, ref NSMenuItem lastSeparator, ref int index) { var info = manager.GetCommandInfo(ce.CommandId, new CommandTargetRoute(initialCommandTarget)); if (!isArrayItem) { SetItemValues(this, info); if (!Hidden) { MDMenu.ShowLastSeparator(ref lastSeparator); } return; } Hidden = true; if (index < parent.Count - 1) { for (int i = index + 1; i < parent.Count; i++) { var nextItem = parent.ItemAt(i); if (nextItem == null || nextItem.Target != this) { break; } parent.RemoveItemAt(i); i--; } } PopulateArrayItems(info.ArrayInfo, parent, ref lastSeparator, ref index); }
void PopulateArrayItems(CommandArrayInfo infos, NSMenu parent, ref NSMenuItem lastSeparator, ref int index) { if (infos == null) { return; } foreach (CommandInfo ci in infos) { if (ci.IsArraySeparator) { var n = NSMenuItem.SeparatorItem; n.Hidden = true; n.Target = this; lastSeparator = n; if (parent.Count > index) { parent.InsertItem(n, index); } else { parent.AddItem(n); } index++; continue; } var item = new MDExpandedArrayItem { Info = ci, Target = this, Action = ActionSel, }; if (ci is CommandInfoSet) { item.Submenu = new NSMenu(); int i = 0; NSMenuItem sep = null; PopulateArrayItems(((CommandInfoSet)ci).CommandInfos, item.Submenu, ref sep, ref i); } SetItemValues(item, ci, true); if (!item.Hidden) { MDMenu.ShowLastSeparator(ref lastSeparator); } if (parent.Count > index) { parent.InsertItem(item, index); } else { parent.AddItem(item); } index++; } index--; }
public void Update(MDMenu parent, ref NSMenuItem lastSeparator, ref int index) { Enabled = true; Hidden = Submenu != NSApplication.SharedApplication.ServicesMenu; if (!Hidden) { MDMenu.ShowLastSeparator(ref lastSeparator); } }
public void Update(MDMenu parent, ref NSMenuItem lastSeparator, ref int index) { if (ces.AutoHide) { ((MDMenu)Submenu).UpdateCommands(); Hidden = Submenu.ItemArray().All(item => item.Hidden); } if (!Hidden) { MDMenu.ShowLastSeparator(ref lastSeparator); } }
public void Update(MDMenu parent, ref NSMenuItem lastSeparator, ref int index) { MDMenu.ShowLastSeparator(ref lastSeparator); }