本文整理汇总了C#中MonoDevelop.Components.Commands.CommandEntrySet.ToList方法的典型用法代码示例。如果您正苦于以下问题:C# CommandEntrySet.ToList方法的具体用法?C# CommandEntrySet.ToList怎么用?C# CommandEntrySet.ToList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MonoDevelop.Components.Commands.CommandEntrySet
的用法示例。
在下文中一共展示了CommandEntrySet.ToList方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetAppMenuItems
public static void SetAppMenuItems (CommandManager manager, CommandEntrySet entrySet)
{
HIMenuItem mnu = HIToolbox.GetMenuItem ((uint)CarbonCommandID.Hide);
bool firstTime = appMenu == IntPtr.Zero;
appMenu = mnu.MenuRef;
var existingitems = GetMenuCommandIDs (appMenu).ToList ();
for (int i = existingitems.Count - 1; i >= 0; i--) {
var item = new HIMenuItem (appMenu, (ushort)(i + 1));
//if first time, keep all the existing items except QuitAndCloseAllWindows
if (firstTime && existingitems [i] != (uint)CarbonCommandID.QuitAndCloseAllWindows) {
//mark them so we can recognise and keep them in future
//HIToolbox.SetMenuItemReferenceConstant (item, uint.MaxValue);
continue;
}
// if it's not the first time, keep the original items we marked
if (!firstTime && HIToolbox.GetMenuItemReferenceConstant (item) == UInt32.MaxValue) {
continue;
}
//remove everything else
HIToolbox.DeleteMenuItem (item);
existingitems.RemoveAt (i);
}
// Iterate backwards over the entries. For each one, try to find a matching built-in item. If successful,
// get all the items from that point to the last item that was not yet inserted, and insert them
// at that point.
var entries = entrySet.ToList ();
int uninsertedCount = entries.Count;
for (int i = entries.Count - 1; i >= 0; i--) {
var entry = entries [i];
if (entry.CommandId == null || entry.CommandId == Command.Separator)
continue;
var id = GetMacID (entry.CommandId);
//find an existing item
int match = existingitems.IndexOf (id);
if (match >= 0) {
//if there are uninserted items *after* this one, insert them at this point
if ((uninsertedCount - i) > 0) {
var items = entries.Skip (i + 1).Take (uninsertedCount - i - 2);
var insertionPoint = new HIMenuItem (appMenu, (ushort)(match + 1));
AddMenuItems (insertionPoint, items);
}
uninsertedCount = i;
}
}
// Finally, insert any remaining items at the beginning/top of the menu.
if (uninsertedCount > 0) {
AddMenuItems (new HIMenuItem (appMenu, 0), entries.Take (uninsertedCount));
}
}