當前位置: 首頁>>代碼示例>>C#>>正文


C# CommandEntrySet.ToList方法代碼示例

本文整理匯總了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));
			}
		}
開發者ID:RainsSoft,項目名稱:playscript-monodevelop,代碼行數:56,代碼來源:MacMainMenu.cs


注:本文中的MonoDevelop.Components.Commands.CommandEntrySet.ToList方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。