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); }
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; } } }