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


C# Forms.ToolStripItemCollection類代碼示例

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


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

示例1: PopulateItems

        private static void PopulateItems(ToolStripItemCollection items, IEnumerable<CommandMenuGroup> groups, CommandRegistry registry)
        {
            List<CommandMenuGroup> groupList = groups as List<CommandMenuGroup>;
            if (groupList == null)
                groupList = new List<CommandMenuGroup>(groups);

            foreach (CommandMenuGroup group in groupList) {
                if (group != groupList[0])
                    items.Add(new ToolStripSeparator());

                foreach (CommandMenuEntry entry in group) {
                    if (entry.SubMenu != null)
                        items.Add(BuildToolStripMenu(entry.SubMenu, registry));
                    else {
                        CommandRecord record = registry.Lookup(entry.Key);
                        if (record != null) {
                            ToolStripMenuItem menuItem = new ToolStripMenuItem() {
                                Tag = new CommandMenuTag(entry.Key, entry.Param),
                                Text = record.DisplayName,
                                Image = record.Image,
                                ShortcutKeys = record.Shortcut,
                                ShortcutKeyDisplayString = record.ShortcutDisplay,
                                ToolTipText = record.Description,
                            };

                            if (entry.Default)
                                menuItem.Font = new Font(menuItem.Font, menuItem.Font.Style | FontStyle.Bold);

                            items.Add(menuItem);
                        }
                    }
                }
            }
        }
開發者ID:Elof3,項目名稱:Treefrog,代碼行數:34,代碼來源:CommandRegistry.cs

示例2: SetToolStripState

        //////////////////////////////////////////////////////////////////////////
        public void SetToolStripState(ToolStripItemCollection Items)
        {
            foreach(ToolStripItem Item in Items)
            {
                string ActName = Item.Tag as string;
                if (ActName != null)
                {
                    Action.State St = ActContext.GetState(ActName);

                    Item.Enabled = ((St & Action.State.Disabled) != Action.State.Disabled);
                    Item.Visible = ((St & Action.State.Hidden) != Action.State.Hidden);

                    if (Item is ToolStripButton)
                        ((ToolStripButton)Item).Checked = ((St & Action.State.Checked) == Action.State.Checked);
                    else if (Item is ToolStripMenuItem)
                        ((ToolStripMenuItem)Item).Checked = ((St & Action.State.Checked) == Action.State.Checked);

                }

                if(Item is ToolStripDropDownItem)
                {
                    SetToolStripState(((ToolStripDropDownItem)Item).DropDownItems);
                }
            }
        }
開發者ID:segafan,項目名稱:wme1_jankavan_tlc_edition-repo,代碼行數:26,代碼來源:ActionStripBuilder.cs

示例3: FillMenuItems

 private static void FillMenuItems(List<MySQL.Base.MenuItem> itemsBE, ToolStripItemCollection itemsFE)
 {
     foreach (MySQL.Base.MenuItem itemBE in itemsBE)
       {
     switch (itemBE.get_type())
     {
       case MySQL.Base.MenuItemType.MenuSeparator:
     {
       itemsFE.Add(new ToolStripSeparator());
     }
     break;
       default:
     {
       ToolStripMenuItem itemFE = new ToolStripMenuItem();
       itemFE.Tag = itemBE.get_name();
       itemFE.Text = itemBE.get_caption();
       itemFE.Enabled = itemBE.get_enabled();
       if (MySQL.Base.MenuItemType.MenuCascade == itemBE.get_type())
       {
         FillMenuItems(itemBE.get_subitems(), itemFE.DropDownItems);
       }
       else
       {
         itemFE.Click += new EventHandler(OnMenuItemClick);
       }
       itemsFE.Add(itemFE);
     }
     break;
     }
       }
 }
開發者ID:abibell,項目名稱:mysql-workbench,代碼行數:31,代碼來源:WorkbenchToolbarManager.cs

示例4: ToolController

 public ToolController(ToolStripItemCollection collection, Viewport viewport, Project project)
 {
     Tools = collection;
     Viewport = viewport;
     Viewport.Input.MouseClick += ViewportClick;
     Project = project;
 }
開發者ID:Stg3orge,項目名稱:P2-Simulering,代碼行數:7,代碼來源:ToolController.cs

示例5: BuildMenuContentsForGroup

        private static int BuildMenuContentsForGroup(int index, ICommandTarget target, ToolStripItemCollection children, IPoderosaMenuGroup grp) {
            int count = 0;
            foreach (IPoderosaMenu m in grp.ChildMenus) {
                ToolStripMenuItem mi = new ToolStripMenuItem();
                children.Insert(index++, mi); //途中挿入のことも
                mi.DropDownOpening += new EventHandler(OnPopupMenu);
                mi.Enabled = m.IsEnabled(target);
                mi.Checked = mi.Enabled ? m.IsChecked(target) : false;
                mi.Text = m.Text; //Enabledを先に
                mi.Tag = new MenuItemTag(grp, m, target);

                IPoderosaMenuFolder folder;
                IPoderosaMenuItem leaf;
                if ((folder = m as IPoderosaMenuFolder) != null) {
                    BuildMenuContents(mi, folder);
                }
                else if ((leaf = m as IPoderosaMenuItem) != null) {
                    mi.Click += new EventHandler(OnClickMenu);
                    IGeneralCommand gc = leaf.AssociatedCommand as IGeneralCommand;
                    if (gc != null)
                        mi.ShortcutKeyDisplayString = WinFormsUtil.FormatShortcut(CommandManagerPlugin.Instance.CurrentKeyBinds.GetKey(gc));
                }

                count++;
            }

            return count;
        }
開發者ID:Ricordanza,項目名稱:poderosa,代碼行數:28,代碼來源:MenuUtil.cs

示例6: DoHasSeparators

    /// <summary>
    /// Recherche une suite de séparateurs consécutifs
    /// </summary>
    /// <param name="items">collection d'éléments de menus où s'effectue la recherche</param>
    /// <param name="from">index du premier élément à considérer</param>
    /// <param name="start">index du premier séparateur de la suite</param>
    /// <param name="end">index du dernier séparateur de la suite</param>
    /// <returns>true si au moins un séparateur a été trouvé</returns>
    private static bool DoHasSeparators( ToolStripItemCollection items, int from, ref int start, ref int end ) {
      start = from;
      end = start - 1;
      bool found = false;

      // rechercher le premier séparateur
      for (int ix = from ; ix < items.Count ; ix++) {
        if (!(items[ ix ] is ToolStripSeparator)) continue;
        start = ix;
        found = true;
        break;
      }

      // pas de séparateur trouvé
      if (!found) return false;

      // rechercher le dernier séparateur de la suite
      end = start;
      for (int ix = start + 1 ; ix < items.Count ; ix++) {
        if (!(items[ ix ] is ToolStripSeparator)) break;
        end = ix;
      }

      return true;
    }
開發者ID:NicolasR,項目名稱:Composants,代碼行數:33,代碼來源:RegistryStrip.cs

示例7: BuildMenu

 public static void BuildMenu(ToolStripItemCollection items, IEnumerable<IEditorScript> scripts, Func<IEditorScript, Task> callback)
 {
   foreach (var script in scripts)
   {
     if (script.Name.StartsWith("----"))
     {
       items.Add(new ToolStripSeparator());
     }
     else if (script.Children.Any())
     {
       var item = new ToolStripMenuItem(script.Name);
       BuildMenu(item.DropDownItems, script.Children, callback);
       items.Add(item);
     }
     else
     {
       items.Add(new ToolStripMenuItem(script.Name, null, async (s, ev) =>
       {
         var text = await script.GetScript(); // Trigger execution
         if (!string.IsNullOrEmpty(text))
         {
           await callback(script);
         }
       }));
     }
   }
 }
開發者ID:rneuber1,項目名稱:InnovatorAdmin,代碼行數:27,代碼來源:EditorScript.cs

示例8: BuildMenu

 public static void BuildMenu(ToolStripItemCollection items, IEnumerable<IEditorScript> scripts, Action<IEditorScript> callback)
 {
   foreach (var script in scripts)
   {
     if (script.Name.StartsWith("----"))
     {
       items.Add(new ToolStripSeparator());
     }
     else if (script.Children.Any())
     {
       var item = new ToolStripMenuItem(script.Name);
       BuildMenu(item.DropDownItems, script.Children, callback);
       items.Add(item);
     }
     else
     {
       items.Add(new ToolStripMenuItem(script.Name, null, (s, ev) =>
       {
         var query = script.Script; // Trigger execution
         if (!string.IsNullOrEmpty(query))
         {
           callback(script);
         }
       }));
     }
   }
 }
開發者ID:cornelius90,項目名稱:InnovatorAdmin,代碼行數:27,代碼來源:EditorScript.cs

示例9: WireItems

 internal void WireItems(ToolStripItemCollection collection)
 {
     foreach (System.Windows.Forms.ToolStripItem item in collection)
     {
         ItemAdded(null, new ToolStripItemEventArgs(item));
     }
 }
開發者ID:dbremner,項目名稱:cecilstudio,代碼行數:7,代碼來源:BarControl.cs

示例10: AddMenuItem

 public void AddMenuItem(ToolStripItemCollection collection, int index, String fileName, EventHandler handler)
 {
     ToolStripMenuItem item = new ToolStripMenuItem ();
     item.Text = fileName;
     item.Click += new EventHandler (handler);
     collection.Insert (index, item);
 }
開發者ID:kovacsv,項目名稱:RayTracer,代碼行數:7,代碼來源:History.cs

示例11: 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

示例12: Initialize

 public void Initialize(IMyGenerationMDI mdi, ToolStripItemCollection menuItems)
 {
     this.scintilla.AddShortcuts(menuItems);
     this._fileId = Guid.NewGuid().ToString();
     _mdi = mdi;
     RefreshConnectionInfo();
 }
開發者ID:nguyenhuuhuy,項目名稱:mygeneration,代碼行數:7,代碼來源:SqlToolUserControl.cs

示例13: CreateButton

 private static void CreateButton(ToolStripItemCollection items, string title, EventHandler handler,
     Workitem item)
 {
     var button = new ToolStripMenuItem(title, null, handler);
     items.Add(button);
     button.Tag = item;
 }
開發者ID:versionone,項目名稱:V1TaskManager,代碼行數:7,代碼來源:MainForm.cs

示例14: UpdateControlsForLanguage

 internal static void UpdateControlsForLanguage(ToolStripItemCollection toolStripItems)
 {
     foreach (ToolStripItem i in toolStripItems)
     {
         if (!String.IsNullOrEmpty(Lang.ResourceManager.GetString(i.Name, Lang.Culture)))
             i.Text = Lang.ResourceManager.GetString(i.Name, Lang.Culture);
     }
 }
開發者ID:Jopie64,項目名稱:redmine-desktop-client,代碼行數:8,代碼來源:LangTools.cs

示例15: ToolStripDropDownItem

        protected ToolStripDropDownItem()
            : base()
        {
            _dropDownItems = new ToolStripItemCollection(Parent, null);

            ArrowColor = Color.Black;
            ArrowImage = ApplicationBehaviour.Resources.Images.DropDownRightArrow;
        }
開發者ID:Meragon,項目名稱:Unity-WinForms,代碼行數:8,代碼來源:ToolStripItem.cs


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