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


C# ToolStripItemCollection.Cast方法代碼示例

本文整理匯總了C#中System.Windows.Forms.ToolStripItemCollection.Cast方法的典型用法代碼示例。如果您正苦於以下問題:C# ToolStripItemCollection.Cast方法的具體用法?C# ToolStripItemCollection.Cast怎麽用?C# ToolStripItemCollection.Cast使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Windows.Forms.ToolStripItemCollection的用法示例。


在下文中一共展示了ToolStripItemCollection.Cast方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: AssertHasNoMenuWithText

		/// <summary>
		/// Assert that the strip has no menu item with the specified text.
		/// </summary>
		/// <param name="items"></param>
		/// <param name="text"></param>
		/// <returns></returns>
		private static void AssertHasNoMenuWithText(ToolStripItemCollection items, string text)
		{
			if (items.Cast<ToolStripItem>().Any(item => item is ToolStripMenuItem && (item as ToolStripMenuItem).Text == text))
			{
				Assert.Fail("item " + text + " was unexpectedly found in a context menu");
			}
		}
開發者ID:sillsdev,項目名稱:FieldWorks,代碼行數:13,代碼來源:InMemoryLogicTest.cs

示例2: ActualItems

 private IEnumerable<ToolStripItem> ActualItems(ToolStripItemCollection items)
 {
     return items.Cast<ToolStripItem>().Where(item => !(item is ToolStripSeparator));
 }
開發者ID:xeno-by,項目名稱:datavault,代碼行數:4,代碼來源:CommandMapping.cs

示例3: CloneItems

 private List<ToolStripItem> CloneItems(ToolStripItemCollection collection)
 {
     var list = new List<ToolStripItem>();
     if (collection != null)
     {
         list.Add(new ToolStripSeparator());
         var enumerable = collection.Cast<ToolStripItem>();
         foreach (var toolStripItem in enumerable)
         {
             if (toolStripItem is ToolStripSeparator)
             {
                 list.Add(new ToolStripSeparator());
             }
             else
             {
                 var toolStripMenuItem = toolStripItem as ToolStripMenuItem;
                 if (toolStripMenuItem != null)
                 {
                     var item = new ToolStripMenuItem
                     {
                         Name = toolStripMenuItem.Name,
                         Size = toolStripMenuItem.Size,
                         Text = toolStripMenuItem.Text,
                         ToolTipText = toolStripMenuItem.ToolTipText,
                         ShortcutKeys = toolStripMenuItem.ShortcutKeys,
                         ShortcutKeyDisplayString = toolStripMenuItem.ShortcutKeyDisplayString,
                         ShowShortcutKeys = toolStripMenuItem.ShowShortcutKeys
                     };
                     var events = (EventHandlerList)eventsPropertyInfo.GetValue(toolStripMenuItem, null);
                     var secret = eventClickFieldInfo.GetValue(null);
                     var handlers = events[secret];
                     events = (EventHandlerList)eventsPropertyInfo.GetValue(item, null);
                     events.AddHandler(secret, handlers);
                     list.Add(item);
                 }
             }
         }
     }
     return list;
 }
開發者ID:MWKStudios,項目名稱:ServiceBusExplorer,代碼行數:40,代碼來源:MainForm.cs

示例4: FindOrCreateAlgoMenuItem

        private static ToolStripMenuItem FindOrCreateAlgoMenuItem(ToolStripItemCollection parent, string algorithm)
        {
            ToolStripMenuItem algoItem = parent.Cast<ToolStripMenuItem>().FirstOrDefault(item => item.Text.Equals(algorithm));

            if (algoItem == null)
            {
                algoItem = new ToolStripMenuItem()
                {
                    Text = algorithm
                };
                parent.Add(algoItem);
            }

            return algoItem;
        }
開發者ID:27miller87,項目名稱:MultiMiner,代碼行數:15,代碼來源:MinerForm.cs


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