private void InsertMenuItemsToMenuTree(IDropInfo dropInfo, List <MenuTreeNodeViewModel> SourceMenuItems, MenuTreeNodeViewModel TargetMenuItem, ObservableCollection <MenuTreeNodeViewModel> Targets) { List <MenuTreeNodeViewModel> InsertItems = new List <MenuTreeNodeViewModel>(); foreach (var SourceItem in SourceMenuItems) { foreach (var Node in RegistedMenuTreeNodes) { RemoveMenuNodeReclusive(Node, SourceItem); } RegistedMenuTreeNodes.Remove(SourceItem); InsertItems.Add(SourceItem); } if (InsertItems.Count > 0) { if (dropInfo.InsertIndex >= Targets.Count) { foreach (var InsertItem in InsertItems) { Targets.Add(InsertItem); } } else { foreach (var InsertItem in InsertItems.Select((item, index) => new { item, index })) { Targets.Insert(dropInfo.InsertIndex + InsertItem.index, InsertItem.item); } } } }
private void AddMenuItemsToMenuTree(IDropInfo dropInfo, List <MenuTreeNodeViewModel> SourceMenuItems, MenuTreeNodeViewModel TargetMenuItem, ObservableCollection <MenuTreeNodeViewModel> Targets) { foreach (var SourceItem in SourceMenuItems) { foreach (var Node in RegistedMenuTreeNodes) { RemoveMenuNodeReclusive(Node, SourceItem); } RegistedMenuTreeNodes.Remove(SourceItem); if (TargetMenuItem != null) { if (!TargetMenuItem.HasExecutableNode) { TargetMenuItem.Children.Add(SourceItem); } } else { RegistedMenuTreeNodes.Add(SourceItem); } } }
private void AddCommandItemsToMenuTree(IDropInfo dropInfo, List <LauncherCommandInfoViewModel> SourceCommandItems, MenuTreeNodeViewModel TargetMenuItem, ObservableCollection <MenuTreeNodeViewModel> Targets) { if (TargetMenuItem != null) { if (!TargetMenuItem.HasExecutableNode) { foreach (var SourceItem in SourceCommandItems) { TargetMenuItem.Children.Add(new MenuTreeNodeViewModel( new MenuTreeNode() { Name = SourceItem.Name, IsVisible = true, Type = MenuType.Menu, CommandInfoID = SourceItem.CommandInfo.UID, Children = new ObservableCollection <MenuTreeNode>() })); } } } else { foreach (var SourceItem in SourceCommandItems) { RegistedMenuTreeNodes.Add(new MenuTreeNodeViewModel( new MenuTreeNode() { Name = SourceItem.Name, IsVisible = true, Type = MenuType.Menu, CommandInfoID = SourceItem.CommandInfo.UID, Children = new ObservableCollection <MenuTreeNode>() })); } } }