本文整理汇总了C#中System.Windows.Forms.ToolStripItemCollection.IndexOf方法的典型用法代码示例。如果您正苦于以下问题:C# ToolStripItemCollection.IndexOf方法的具体用法?C# ToolStripItemCollection.IndexOf怎么用?C# ToolStripItemCollection.IndexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.ToolStripItemCollection
的用法示例。
在下文中一共展示了ToolStripItemCollection.IndexOf方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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
//.........这里部分代码省略.........
示例2: 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());
}
}
}
示例3: 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();
}
示例4: 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);
}
}
示例5: 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);
}
}
示例6: 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);
}
示例7: ClearHelpers
private void ClearHelpers(ToolStripItemCollection dropdown, ToolStripItem tss, string prefix)
{
int i = dropdown.IndexOf(tss) + 1;
while (true)
{
if (i >= dropdown.Count) break;
if (!dropdown[i].Name.StartsWith(prefix)) break;
dropdown.RemoveAt(i);
}
}
示例8: newLoadingListToolStripItem
private ToolStripItem newLoadingListToolStripItem(long listId, String index)
{
ToolStripMenuItem item = new ToolStripMenuItem(LL_DeserializeName(index), WarehouseApp.Properties.Resources.table, null, "l" + listId);
item.Tag = listId;
item.Click += new System.EventHandler(LoadingList_MoveToSelected_Click);
Events_LoadingListButton(item);
if (cmsLoadingLists.Tag != null)
{
ToolStripItemCollection col2 = new ToolStripItemCollection(cmsLoadingLists, ((ToolStripItem[])cmsLoadingLists.Tag));
if (col2.IndexOfKey(item.Name) == -1)
{
col2.Insert(col2.IndexOf(tsmiNewLL), item);
cmsLoadingLists.Tag = new ToolStripItem[col2.Count];
col2.CopyTo((ToolStripItem[])cmsLoadingLists.Tag, 0);
}
}
return item;
}