本文整理汇总了C#中System.Windows.Controls.ItemCollection.Insert方法的典型用法代码示例。如果您正苦于以下问题:C# ItemCollection.Insert方法的具体用法?C# ItemCollection.Insert怎么用?C# ItemCollection.Insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.ItemCollection
的用法示例。
在下文中一共展示了ItemCollection.Insert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InsertScore
public static void InsertScore(VisualScoreInfo boxWithScore, List<VisualScoreInfo> scores, ItemCollection list)
{
for (int i = 0; i < scores.Count; i++)
{
var item = scores[i];
if (boxWithScore.SortValue > item.SortValue)
{
list.Insert(i, boxWithScore.ToVisual());
scores.Insert(i, boxWithScore);
return;
}
}
// If we hit this point, it goes at the end
list.Add(boxWithScore.ToVisual());
scores.Add(boxWithScore);
}
示例2: AddMenuItemIntoMenu
protected void AddMenuItemIntoMenu(ConnectionPointContainer container,
ItemCollection menuItemCollection,
PluginConfigItem theItem,
PluginMenuPath thePath,
IList<PluginMenuItemPart> thePaths, ExecutePluginCallback callback)
{
if (thePaths.Count < 1) return;
PluginMenuItemPart firstPart = thePaths[0];
PluginMenuPartStruct menuStruct = GetMenuItemIndex(firstPart, menuItemCollection);
IList<PluginMenuItemPart> otherParts = GetLeavesMenuItemParts(thePaths);
if (!menuStruct.IsCreate)
{
AddMenuItemIntoMenu(container,
(menuItemCollection[menuStruct.Index] as MenuItem).Items,
theItem,
thePath,
otherParts, callback);
}
else
{
if (firstPart.TextStyle.Text.Trim() == "-")
{
menuItemCollection.Insert(menuStruct.Index, new Separator());
return;
}
MenuItem theMenuItem = new MenuItem() { Header = firstPart.TextStyle.Text };
CreateMenuEndItem(firstPart, theMenuItem, GetImageList(container, thePath.MenuImageIndex));
menuItemCollection.Insert(menuStruct.Index, theMenuItem);
if (thePaths.Count > 1)
{
AddMenuItemIntoMenu(container, theMenuItem.Items, 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 -= TheMenuItem_MouseMove;
theMenuItem.MouseMove += TheMenuItem_MouseMove;
break;
}
}
return;
}
}
}