当前位置: 首页>>代码示例>>C#>>正文


C# ToolStripItemCollection.Insert方法代码示例

本文整理汇总了C#中System.Windows.Forms.ToolStripItemCollection.Insert方法的典型用法代码示例。如果您正苦于以下问题:C# ToolStripItemCollection.Insert方法的具体用法?C# ToolStripItemCollection.Insert怎么用?C# ToolStripItemCollection.Insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.ToolStripItemCollection的用法示例。


在下文中一共展示了ToolStripItemCollection.Insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

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

示例2: Remove_StandAlone

		public void Remove_StandAlone ()
		{
			ToolStrip toolStrip = CreateToolStrip ();
			ToolStripItemCollection items = new ToolStripItemCollection (
				toolStrip, new ToolStripItem [0]);

			MockToolStripButton buttonA = new MockToolStripButton ("A");
			MockToolStripButton buttonB = new MockToolStripButton ("B");
			MockToolStripButton buttonC = new MockToolStripButton ("B");
			items.Insert (0, buttonA);
			items.Insert (0, buttonB);

			items.Remove (buttonB);
			Assert.AreEqual (1, items.Count, "#A1");
			Assert.AreEqual (0, itemsRemoved.Count, "#A2");
			Assert.AreSame (buttonA, items [0], "#A3");

			items.Remove ((ToolStripItem) null);
			Assert.AreEqual (1, items.Count, "#B1");
			Assert.AreEqual (0, itemsRemoved.Count, "#B2");
			Assert.AreSame (buttonA, items [0], "#B3");

			items.Remove (buttonC);
			Assert.AreEqual (1, items.Count, "#C1");
			Assert.AreEqual (0, itemsRemoved.Count, "#C2");
			Assert.AreSame (buttonA, items [0], "#C3");

			items.Remove (buttonA);
			Assert.AreEqual (0, items.Count, "#D1");
			Assert.AreEqual (0, itemsRemoved.Count, "#D2");

			items.Remove (buttonA);
			Assert.AreEqual (0, items.Count, "#E1");
			Assert.AreEqual (0, itemsRemoved.Count, "#E2");

			// remove item owned by other toolstrip
			ToolStrip otherToolStrip = new ToolStrip ();
			MockToolStripButton buttonD = new MockToolStripButton ("B");
			otherToolStrip.Items.Add (buttonD);
			Assert.AreSame (otherToolStrip, buttonD.Owner, "#F1");
			Assert.IsNull (buttonD.ParentToolStrip, "#F2");
			items.Remove (buttonD);
			Assert.AreEqual (0, items.Count, "#F3");
			Assert.AreEqual (0, itemsRemoved.Count, "#F4");
			Assert.AreSame (otherToolStrip, buttonD.Owner, "#F5");
			Assert.IsNull (buttonD.ParentToolStrip, "#F6");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:47,代码来源:ToolStripItemCollectionTest.cs

示例3: Insert_Item_Null

		public void Insert_Item_Null ()
		{
			ToolStrip toolStrip = CreateToolStrip ();
			ToolStripItemCollection items = new ToolStripItemCollection (
				toolStrip, new ToolStripItem [0]);
			try {
				items.Insert (0, (ToolStripItem) null);
				Assert.Fail ("#1");
			} catch (ArgumentNullException ex) {
				Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
				Assert.IsNull (ex.InnerException, "#3");
				Assert.IsNotNull (ex.Message, "#4");
				Assert.AreEqual ("value", ex.ParamName, "#5");
			}
		}
开发者ID:Profit0004,项目名称:mono,代码行数:15,代码来源:ToolStripItemCollectionTest.cs

示例4: Insert_Index_OutOfRange

		public void Insert_Index_OutOfRange ()
		{
			ToolStrip toolStrip = CreateToolStrip ();
			ToolStripItemCollection items = new ToolStripItemCollection (
				toolStrip, new ToolStripItem [0]);

			try {
				items.Insert (-1, new ToolStripButton ());
				Assert.Fail ("#A1");
			} catch (ArgumentOutOfRangeException ex) {
				Assert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "#A2");
				Assert.IsNull (ex.InnerException, "#A3");
				Assert.IsNotNull (ex.Message, "#A4");
				Assert.AreEqual ("index", ex.ParamName, "#A5");
			}

			try {
				items.Insert (1, new ToolStripButton ());
				Assert.Fail ("#B1");
			} catch (ArgumentOutOfRangeException ex) {
				Assert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "#B2");
				Assert.IsNull (ex.InnerException, "#B3");
				Assert.IsNotNull (ex.Message, "#B4");
				Assert.AreEqual ("index", ex.ParamName, "#B5");
			}
		}
开发者ID:Profit0004,项目名称:mono,代码行数:26,代码来源:ToolStripItemCollectionTest.cs

示例5: Insert_StandAlone

		public void Insert_StandAlone ()
		{
			ToolStrip toolStrip = CreateToolStrip ();
			ToolStripItemCollection items = new ToolStripItemCollection (
				toolStrip, new ToolStripItem [0]);

			MockToolStripButton buttonA = new MockToolStripButton ("A");
			items.Insert (0, buttonA);
			Assert.AreEqual (1, items.Count, "#A1");
			Assert.AreEqual (0, itemsAdded.Count, "#A2");
			Assert.AreSame (buttonA, items [0], "#A3");
			Assert.IsNull (buttonA.Owner, "#A4");
			Assert.IsNull (buttonA.ParentToolStrip, "#A5");

			MockToolStripButton buttonB = new MockToolStripButton ("B");
			items.Insert (0, buttonB);
			Assert.AreEqual (2, items.Count, "#B1");
			Assert.AreEqual (0, itemsAdded.Count, "#B2");
			Assert.AreSame (buttonB, items [0], "#B3");
			Assert.AreSame (buttonA, items [1], "#B4");
			Assert.IsNull (buttonB.Owner, "#B5");
			Assert.IsNull (buttonB.ParentToolStrip, "#B6");

			MockToolStripButton buttonC = new MockToolStripButton ("C");
			items.Insert (1, buttonC);
			Assert.AreEqual (3, items.Count, "#C1");
			Assert.AreEqual (0, itemsAdded.Count, "#C2");
			Assert.AreSame (buttonB, items [0], "#C3");
			Assert.AreSame (buttonC, items [1], "#C4");
			Assert.AreSame (buttonA, items [2], "#C5");
			Assert.IsNull (buttonC.Owner, "#C6");
			Assert.IsNull (buttonC.ParentToolStrip, "#C7");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:33,代码来源:ToolStripItemCollectionTest.cs

示例6: MergeRecursive

        private static void MergeRecursive(ToolStripItem source, ToolStripItemCollection destinationItems, Stack<MergeHistoryItem> history)
        {
            MergeHistoryItem item;
            ToolStripItem item2;
            switch (source.MergeAction)
            {
                case MergeAction.Append:
                {
                    item = new MergeHistoryItem(MergeAction.Remove) {
                        PreviousIndexCollection = source.Owner.Items,
                        PreviousIndex = item.PreviousIndexCollection.IndexOf(source),
                        TargetItem = source
                    };
                    int num8 = destinationItems.Add(source);
                    item.Index = num8;
                    item.IndexCollection = destinationItems;
                    history.Push(item);
                    return;
                }
                case MergeAction.Insert:
                    if (source.MergeIndex > -1)
                    {
                        item = new MergeHistoryItem(MergeAction.Remove) {
                            PreviousIndexCollection = source.Owner.Items,
                            PreviousIndex = item.PreviousIndexCollection.IndexOf(source),
                            TargetItem = source
                        };
                        int num7 = Math.Min(destinationItems.Count, source.MergeIndex);
                        destinationItems.Insert(num7, source);
                        item.IndexCollection = destinationItems;
                        item.Index = num7;
                        history.Push(item);
                    }
                    return;

                case MergeAction.Replace:
                case MergeAction.Remove:
                case MergeAction.MatchOnly:
                    item2 = FindMatch(source, destinationItems);
                    if (item2 != null)
                    {
                        switch (source.MergeAction)
                        {
                            case MergeAction.MatchOnly:
                            {
                                ToolStripDropDownItem item3 = item2 as ToolStripDropDownItem;
                                ToolStripDropDownItem item4 = source as ToolStripDropDownItem;
                                if (((item3 == null) || (item4 == null)) || (item4.DropDownItems.Count == 0))
                                {
                                    return;
                                }
                                int count = item4.DropDownItems.Count;
                                if (count <= 0)
                                {
                                    return;
                                }
                                int num2 = count;
                                item4.DropDown.SuspendLayout();
                                try
                                {
                                    int num3 = 0;
                                    int num4 = 0;
                                    while (num3 < count)
                                    {
                                        MergeRecursive(item4.DropDownItems[num4], item3.DropDownItems, history);
                                        int num5 = num2 - item4.DropDownItems.Count;
                                        num4 = (num5 > 0) ? num4 : (num4 + 1);
                                        num2 = item4.DropDownItems.Count;
                                        num3++;
                                    }
                                    return;
                                }
                                finally
                                {
                                    item4.DropDown.ResumeLayout();
                                }
                                goto Label_0108;
                            }
                        }
                    }
                    return;

                default:
                    return;
            }
        Label_0108:
            item = new MergeHistoryItem(MergeAction.Insert);
            item.TargetItem = item2;
            int index = destinationItems.IndexOf(item2);
            destinationItems.RemoveAt(index);
            item.Index = index;
            item.IndexCollection = destinationItems;
            item.TargetItem = item2;
            history.Push(item);
            if (source.MergeAction == MergeAction.Replace)
            {
                item = new MergeHistoryItem(MergeAction.Remove) {
                    PreviousIndexCollection = source.Owner.Items,
                    PreviousIndex = item.PreviousIndexCollection.IndexOf(source),
                    TargetItem = source
//.........这里部分代码省略.........
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:ToolStripManager.cs

示例7: shadingModes_ensureToolStripItems

        private ToolStripItemCollection shadingModes_ensureToolStripItems(ToolStripItemCollection items, int minCount = 1, int toolStipInsertionIndex = 0)
        {
            Debug.Assert(items != null);

              // First time - Third Item is separator
              if (items.Count < minCount)
              {
            // Insert normal shading mode
            ShadingEffectMenuItem item = new ShadingEffectMenuItem(
              ShadingEffectMenuItem.NORMAL_SHADING_STRING, ShadingEffectMenuItem.NORMAL_SHADING_INDEX, ToolStripSplitButton_Rendering);

            item.BeforeChangingShadingMode += normalShadingItem_BeforeChangingShadingMode;
            items.Insert(toolStipInsertionIndex, item);

            // Add all rendering effects that are loaded by the engine manager for this purpose:
            VisionEngineManager em = (VisionEngineManager)EditorManager.EngineManager;
            StringCollection names = new StringCollection();
            em.GetReplacementRenderLoopEffects(names);

            // Insert shading items
            for (int i = 0; i < names.Count; i++)
            {
              ShadingEffectMenuItem shadingMenuItem = new ShadingEffectMenuItem(
            names[i], ShadingEffectMenuItem.NORMAL_SHADING_INDEX + 1 + i, ToolStripSplitButton_Rendering);
              items.Insert(i + toolStipInsertionIndex + 1, shadingMenuItem);
            }
              }

              return items;
        }
开发者ID:RexBaribal,项目名称:projectanarchy,代码行数:30,代码来源:EnginePanel.cs

示例8: AddMenuItemIntoMenu

        protected void AddMenuItemIntoMenu(ConnectionPointContainer container, ToolStripItemCollection toolStripItemCollection, PluginConfigItem theItem, PluginMenuPath thePath, IList<PluginMenuItemPart> thePaths, ExecutePluginCallback callback)
        {
            if (thePaths.Count < 1) return;

            PluginMenuItemPart firstPart = thePaths[0];
            PluginMenuPartStruct menuStruct = GetMenuItemIndex(firstPart, toolStripItemCollection);
            IList<PluginMenuItemPart> otherParts = GetLeavesMenuItemParts(thePaths);

            if (!menuStruct.IsCreate)
            {
                AddMenuItemIntoMenu(container, (toolStripItemCollection[menuStruct.Index] as
                    ToolStripMenuItem).DropDownItems,
                    theItem, thePath, otherParts, callback);

            }
            else
            {
                if (firstPart.TextStyle.Text.Trim() == "-")
                {
                    toolStripItemCollection.Insert(
                        menuStruct.Index,
                        new ToolStripSeparator()
                    );
                    return;
                }
                ToolStripMenuItem theMenuItem = new ToolStripMenuItem(firstPart.TextStyle.Text);

                CreateMenuEndItem(firstPart, theMenuItem, GetImageList(container, thePath.MenuImageIndex));
                toolStripItemCollection.Insert(
                    menuStruct.Index,
                    theMenuItem
                );

                if (thePaths.Count > 1)
                {
                    AddMenuItemIntoMenu(container, theMenuItem.DropDownItems, theItem, thePath, otherParts, callback);
                }
                else
                {
                    theMenuItem.Name = theItem.Url;
                    theMenuItem.Tag = new object[] { theItem, callback };
                    string[] behaviors = theItem.Behavior.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string action in behaviors)
                    {
                        PluginConfigItemBehaviorMode theBehavior = (PluginConfigItemBehaviorMode)Enum.Parse(typeof(PluginConfigItemBehaviorMode), action, true);
                        switch (theBehavior)
                        {
                            case PluginConfigItemBehaviorMode.Click:
                                theMenuItem.Click -= TheMenuItem_Click;
                                theMenuItem.Click += TheMenuItem_Click;
                                break;
                            case PluginConfigItemBehaviorMode.MouseOver:
                                theMenuItem.MouseMove -= new MouseEventHandler(TheMenuItem_MouseMove);
                                theMenuItem.MouseMove += new MouseEventHandler(TheMenuItem_MouseMove);
                                break;
                        }
                    }
                    return;
                }
            }
        }
开发者ID:nateliu,项目名称:StarSharp,代码行数:61,代码来源:PluginMenuItemBuilder.cs

示例9: MergeRecursive

        private static void MergeRecursive(ToolStripItem source, ToolStripItemCollection destinationItems, Stack<MergeHistoryItem> history) {
            Debug.Indent();
            MergeHistoryItem maction;
            switch (source.MergeAction) {
                case MergeAction.MatchOnly:
                case MergeAction.Replace:
                case MergeAction.Remove:
                    ToolStripItem item = FindMatch(source, destinationItems);
                    if (item != null) {
                        switch (source.MergeAction) {
                            case MergeAction.MatchOnly:
                                //Debug.WriteLine("matchonly");
                                ToolStripDropDownItem tsddownDest = item as ToolStripDropDownItem;
                                ToolStripDropDownItem tsddownSrc = source as ToolStripDropDownItem;
                                if (tsddownDest != null && tsddownSrc != null && tsddownSrc.DropDownItems.Count != 0) {

                                    int originalCount = tsddownSrc.DropDownItems.Count;

                                    if (originalCount > 0) {
                                        int lastCount = originalCount;
                                        tsddownSrc.DropDown.SuspendLayout();

                                        try {
                                            // the act of walking through this collection removes items from
                                            // the dropdown.
                                            for (int i = 0, itemToLookAt = 0; i < originalCount; i++) {

                                                MergeRecursive(tsddownSrc.DropDownItems[itemToLookAt], tsddownDest.DropDownItems, history);

                                                int numberOfItemsMerged = lastCount - tsddownSrc.DropDownItems.Count;
                                                itemToLookAt = (numberOfItemsMerged > 0) ? itemToLookAt : itemToLookAt + 1;
                                                lastCount = tsddownSrc.DropDownItems.Count;
                                            }
                                        }
                                        finally {
                                            tsddownSrc.DropDown.ResumeLayout();
                                        }
                                    }
                                }
                                break;
                            case MergeAction.Replace:
                            case MergeAction.Remove:
                                //Debug.WriteLine("remove");
                                maction = new MergeHistoryItem(MergeAction.Insert);
                                maction.TargetItem = item;
                                int indexOfDestinationItem = destinationItems.IndexOf(item);
                                destinationItems.RemoveAt(indexOfDestinationItem);
                                maction.Index = indexOfDestinationItem;
                                maction.IndexCollection = destinationItems;
                                maction.TargetItem = item;
                                history.Push(maction);
                                //Debug.WriteLine(maction.ToString());
                                if (source.MergeAction == MergeAction.Replace) {
                                    //Debug.WriteLine("replace");
                                    //ToolStripItem clonedItem = source.Clone();
                                    maction = new MergeHistoryItem(MergeAction.Remove);
                                    maction.PreviousIndexCollection = source.Owner.Items;
                                    maction.PreviousIndex = maction.PreviousIndexCollection.IndexOf(source);
                                    maction.TargetItem = source;
                                    destinationItems.Insert(indexOfDestinationItem, source);
                                    maction.Index = indexOfDestinationItem;
                                    maction.IndexCollection = destinationItems;
                                    history.Push(maction);
                                    //Debug.WriteLine(maction.ToString());
                                }
                                break;
                        }
                    }
                    break;
                case MergeAction.Insert:
                    if (source.MergeIndex > -1) {
                        maction = new MergeHistoryItem(MergeAction.Remove);
                        maction.PreviousIndexCollection = source.Owner.Items;
                        maction.PreviousIndex = maction.PreviousIndexCollection.IndexOf(source);
                        maction.TargetItem = source;
                        int insertIndex = Math.Min(destinationItems.Count, source.MergeIndex);
                        destinationItems.Insert(insertIndex, source);
                        maction.IndexCollection = destinationItems;
                        maction.Index = insertIndex;
                        history.Push(maction);
                        //Debug.WriteLine(maction.ToString());
                    }
                    break;
                case MergeAction.Append:
                    maction = new MergeHistoryItem(MergeAction.Remove);
                    maction.PreviousIndexCollection = source.Owner.Items;
                    maction.PreviousIndex = maction.PreviousIndexCollection.IndexOf(source);
                    maction.TargetItem = source;
                    int index = destinationItems.Add(source);
                    maction.Index = index;
                    maction.IndexCollection = destinationItems;
                    history.Push(maction);
                    //Debug.WriteLine(maction.ToString());
                    break;
            }
            Debug.Unindent();
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:97,代码来源:ToolStripManager.cs

示例10: MaintainSeparateGroups

        // Maintains separators between different command groups
        private void MaintainSeparateGroups(ToolStripItemCollection commands, ToolStripItem item, object groupTag)
        {
            int index = commands.IndexOf(item);
            if (index > 0) // look for previous item
            {
                ToolStripItem prevItem = commands[index - 1];
                object prevTag = prevItem.Tag;
                while (prevTag == null)
                {
                    ToolStripMenuItem prevMenuItem = prevItem as ToolStripMenuItem;
                    if (prevMenuItem == null)
                        break;
                    ToolStripItemCollection prevItems = prevMenuItem.DropDownItems;
                    prevItem = prevItems[prevItems.Count - 1];
                    prevTag = prevItem.Tag;
                }

                // add a separator if the new command is from a different group
                CommandInfo prevInfo = GetCommandInfo(prevTag);
                if (prevInfo != null &&
                    !TagsEqual(groupTag, prevInfo.GroupTag))
                {
                    commands.Insert(index, new ToolStripSeparator());
                }
            }
        }
开发者ID:JanDeHud,项目名称:LevelEditor,代码行数:27,代码来源:CommandService.cs

示例11: SetPreviewControlItems

 private void SetPreviewControlItems(ToolStripItemCollection dropdown, ToolStripItem tss, string prefix, IEnumerable<ToolStripItem> items)
 {
     int i = dropdown.Count - 1;
     int j = dropdown.Count - dropdown.IndexOf(tss);
     foreach (var item in items)
     {
         item.Name = prefix + (++j);
         dropdown.Insert(++i, item);
     }
 }
开发者ID:dd-dk,项目名称:sims3tools,代码行数:10,代码来源:MenuBarWidget.cs

示例12: SetHelpers

        private void SetHelpers(ToolStripItemCollection dropdown, ToolStripItem tss, string prefix, IEnumerable<s3pi.Helpers.HelperManager.Helper> helpers)
        {
            if (helpers.Count() == 0) return;

            int i = dropdown.IndexOf(tss);
            int j = 0;

            dropdown.Insert(++i, new ToolStripSeparator() { Name = prefix + j, });

            foreach (var helper in helpers)
            {
                ToolStripMenuItem tsiHelper = new ToolStripMenuItem(helper.label, null, tsHelper_Click) { Name = prefix + j, Tag = j++, };
                dropdown.Insert(++i, tsiHelper);
            }
        }
开发者ID:dd-dk,项目名称:sims3tools,代码行数:15,代码来源:MenuBarWidget.cs

示例13: AddHelper

 private void AddHelper(ToolStripItemCollection dropdown, ToolStripItem tss, string prefix, int helper, string value)
 {
     ToolStripMenuItem tsiHelper = new ToolStripMenuItem(value, null, tsHelper_Click) { Name = prefix + helper, Tag = helper, };
     int i = dropdown.IndexOf(tss);
     while (true)
     {
         i++;
         if (i >= dropdown.Count) break;
         if (!dropdown[i].Name.StartsWith(prefix)) break;
     }
     dropdown.Insert(i, tsiHelper);
 }
开发者ID:dd-dk,项目名称:sims3tools,代码行数:12,代码来源:MenuBarWidget.cs

示例14: 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:FNKGino,项目名称:poderosa,代码行数:29,代码来源:MenuUtil.cs

示例15: DoMergeItem

    /// <summary>
    /// Immerge l'itemReport dans la collection cible source
    /// </summary>
    /// <param name="target">collection cible de l'immersion</param>
    /// <param name="sourceItem">élément à immerger dans la collection cible</param>
    /// <param name="kept">true si l'élément à immerger a été retenu</param>
    private static void DoMergeItem( ToolStripItemCollection target, ToolStripItem sourceItem, out bool kept ) {
      int targetMatch;  // -1 ou index de l'itemReport cible mis en correspondance avec l'itemReport source
      int targetAnchor; // -1 ou index d'insertion éventuel dans la collection cible

      // recherche d'un match
      kept = false;
      targetMatch = IndexOfMatch( target, sourceItem );

      switch (sourceItem.MergeAction) {

        // adjonction en fin de collection
        case MergeAction.Append:
          target.Add( sourceItem );
          break;

        // insertion
        case MergeAction.Insert:
          targetAnchor = IndexOfAnchor( target, targetMatch, sourceItem.MergeIndex );
          target.Insert( targetAnchor, sourceItem );
          break;

        // fusion
        case MergeAction.MatchOnly:
          if (targetMatch != -1 && target[ targetMatch ] is ToolStripMenuItem && sourceItem is ToolStripMenuItem) {
            kept = true;
            DoMergeItems( (target[ targetMatch ] as ToolStripMenuItem).DropDownItems, (sourceItem as ToolStripMenuItem).DropDownItems );
          }
          else {
            targetAnchor = IndexOfAnchor( target, targetMatch, sourceItem.MergeIndex );
            target.Insert( targetAnchor, sourceItem );
          }
          break;

        // suppression
        case MergeAction.Remove:
          kept = true;
          if (targetMatch == -1) break;
          target.RemoveAt( targetMatch );
          break;

        // remplacement
        case MergeAction.Replace:
          if (targetMatch == -1)
            target.Add( sourceItem );
          else {
            target.RemoveAt( targetMatch );
            target.Insert( targetMatch, sourceItem );
          }
          break;
      }
    }
开发者ID:NicolasR,项目名称:Composants,代码行数:57,代码来源:RegistryStrip.cs


注:本文中的System.Windows.Forms.ToolStripItemCollection.Insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。