public TreeViewModel Clone(TreeViewModel treeViewModel) { TreeViewModel newTreeViewModel = (TreeViewModel)treeViewModel.Clone(); newTreeViewModel.Id = ++this.MaxTreeId; this.treeViewModels.Add(newTreeViewModel); TreeLayout layout = new TreeLayout(newTreeViewModel); layout.ExcuteLayout(); return newTreeViewModel; }
public TreeViewModel Clone(TreeViewModel treeViewModel) { TreeViewModel newTreeViewModel = (TreeViewModel)treeViewModel.Clone(); newTreeViewModel.Id = ++this.MaxTreeId; this.treeViewModels.Add(newTreeViewModel); TreeLayout layout = new TreeLayout(newTreeViewModel); layout.ExcuteLayout(); return(newTreeViewModel); }
public TreeViewModel(List <TreeNodeData> treeNodeDatas) { foreach (TreeNodeData treeNodeData in treeNodeDatas) { TreeNodeViewModel treeNodeViewModel = new TreeNodeViewModel(this, treeNodeData); this.treeNodes.Add(treeNodeViewModel); this.treeNodeDict[treeNodeViewModel.Id] = treeNodeViewModel; } var treeLayout = new TreeLayout(this); treeLayout.ExcuteLayout(); }
public TreeViewModel(AllTreeViewModel allTreeViewModel) { this.AllTreeViewModel = allTreeViewModel; this.TreeId = ++allTreeViewModel.MaxTreeId; TreeNodeViewModel treeNodeViewModel = new TreeNodeViewModel(this, 300, 100); this.treeNodes.Add(treeNodeViewModel); this.treeNodeDict[treeNodeViewModel.Id] = treeNodeViewModel; var treeLayout = new TreeLayout(this); treeLayout.ExcuteLayout(); }
/// <summary> /// 折叠节点 /// </summary> /// <param name="treeNodeViewModel"></param> public void Fold(TreeNodeViewModel treeNodeViewModel) { var allChild = new List <TreeNodeViewModel>(); this.GetAllChildrenId(treeNodeViewModel, allChild); foreach (TreeNodeViewModel child in allChild) { this.allNodes.Remove(child); } treeNodeViewModel.IsFold = true; TreeLayout treeLayout = new TreeLayout(this); treeLayout.ExcuteLayout(); }
/// <summary> /// 展开节点,一级一级展开,一次只展开下层子节点,比如下层节点是折叠的,那下下层节点不展开 /// </summary> /// <param name="treeNodeViewModel"></param> public void UnFold(TreeNodeViewModel treeNodeViewModel) { treeNodeViewModel.IsFold = false; var allChild = new List <TreeNodeViewModel>(); this.GetAllChildrenId(treeNodeViewModel, allChild); foreach (TreeNodeViewModel child in allChild) { this.allNodes.Add(child); } TreeLayout treeLayout = new TreeLayout(this); treeLayout.ExcuteLayout(); }
/// <summary> /// 折叠节点 /// </summary> /// <param name="treeNodeViewModel"></param> public void Fold(TreeNodeViewModel treeNodeViewModel) { List <int> allChildId = new List <int>(); this.GetAllChildrenId(treeNodeViewModel, allChildId); foreach (int childId in allChildId) { TreeNodeViewModel child = this.Get(childId); this.treeNodes.Remove(child); } treeNodeViewModel.IsFold = true; var treeLayout = new TreeLayout(this); treeLayout.ExcuteLayout(); }
/// <summary> /// 展开节点,一级一级展开,一次只展开下层子节点,比如下层节点是折叠的,那下下层节点不展开 /// </summary> /// <param name="treeNodeViewModel"></param> public void UnFold(TreeNodeViewModel treeNodeViewModel) { treeNodeViewModel.IsFold = false; List <int> allChildId = new List <int>(); this.GetAllChildrenId(treeNodeViewModel, allChildId); foreach (int childId in allChildId) { TreeNodeViewModel child = this.Get(childId); this.treeNodes.Add(child); } var treeLayout = new TreeLayout(this); treeLayout.ExcuteLayout(); }
public void MoveRight(TreeNodeViewModel treeNodeViewModel) { if (treeNodeViewModel.IsRoot) { return; } TreeNodeViewModel parent = treeNodeViewModel.Parent; int index = parent.Children.IndexOf(treeNodeViewModel); if (index == parent.Children.Count - 1) { return; } parent.Children.Remove(treeNodeViewModel); parent.Children.Insert(index + 1, treeNodeViewModel); TreeLayout treeLayout = new TreeLayout(this); treeLayout.ExcuteLayout(); }
public void Open(string file) { this.treeViewModels.Clear(); string content = File.ReadAllText(file); foreach (string line in content.Split(new[] { "\r\n" }, StringSplitOptions.None)) { if (line.Trim() == "") { continue; } TreeViewModel treeViewModel = MongoHelper.FromJson<TreeViewModel>(line); this.treeViewModels.Add(treeViewModel); TreeLayout layout = new TreeLayout(treeViewModel); layout.ExcuteLayout(); if (treeViewModel.Id > this.MaxTreeId) { this.MaxTreeId = treeViewModel.Id; } } }
public void Add(TreeNodeViewModel treeNode, TreeNodeViewModel parent) { // 如果父节点是折叠的,需要先展开父节点 if (parent != null && parent.IsFold) { this.UnFold(parent); } this.treeNodes.Add(treeNode); this.treeNodeDict[treeNode.Id] = treeNode; if (parent != null) { parent.Children.Add(treeNode.Id); } var treeLayout = new TreeLayout(this); treeLayout.ExcuteLayout(); }
public void MoveLeft(TreeNodeViewModel treeNodeViewModel) { if (treeNodeViewModel.IsRoot) { return; } var parent = treeNodeViewModel.Parent; int index = parent.Children.IndexOf(treeNodeViewModel.Id); if (index == 0) { return; } parent.Children.Remove(treeNodeViewModel.Id); parent.Children.Insert(index - 1, treeNodeViewModel.Id); var treeLayout = new TreeLayout(this); treeLayout.ExcuteLayout(); }
public void Open(string file) { this.treeViewModels.Clear(); string content = File.ReadAllText(file); foreach (string line in content.Split(new[] { "\r\n" }, StringSplitOptions.None)) { if (line.Trim() == "") { continue; } TreeViewModel treeViewModel = MongoHelper.FromJson <TreeViewModel>(line); this.treeViewModels.Add(treeViewModel); TreeLayout layout = new TreeLayout(treeViewModel); layout.ExcuteLayout(); if (treeViewModel.Id > this.MaxTreeId) { this.MaxTreeId = treeViewModel.Id; } } }
public void Remove(TreeNodeViewModel treeNodeViewModel) { var all = new List <TreeNodeViewModel>(); this.GetChildrenIdAndSelf(treeNodeViewModel, all); foreach (TreeNodeViewModel child in all) { this.allNodes.Remove(child); } TreeNodeViewModel parent = treeNodeViewModel.Parent; if (parent != null) { parent.Children.Remove(treeNodeViewModel); } TreeLayout treeLayout = new TreeLayout(this); treeLayout.ExcuteLayout(); }
public void Remove(TreeNodeViewModel treeNodeViewModel) { List <int> allId = new List <int>(); this.GetChildrenIdAndSelf(treeNodeViewModel, allId); foreach (int childId in allId) { TreeNodeViewModel child = this.Get(childId); this.treeNodes.Remove(child); this.treeNodes.Remove(treeNodeViewModel); } TreeNodeViewModel parent = treeNodeViewModel.Parent; if (parent != null) { parent.Children.Remove(treeNodeViewModel.Id); } var treeLayout = new TreeLayout(this); treeLayout.ExcuteLayout(); }
public void Add(TreeNodeViewModel treeNode, TreeNodeViewModel parent) { // 如果父节点是折叠的,需要先展开父节点 if (parent != null) { if (parent.IsFold) { this.UnFold(parent); } treeNode.Parent = parent; parent.Children.Add(treeNode); } else { this.root = treeNode; } treeNode.TreeViewModel = this; allNodes.Add(treeNode); TreeLayout treeLayout = new TreeLayout(this); treeLayout.ExcuteLayout(); }
/// <summary> /// 折叠节点 /// </summary> /// <param name="treeNodeViewModel"></param> public void Fold(TreeNodeViewModel treeNodeViewModel) { var allChild = new List<TreeNodeViewModel>(); this.GetAllChildrenId(treeNodeViewModel, allChild); foreach (TreeNodeViewModel child in allChild) { this.allNodes.Remove(child); } treeNodeViewModel.IsFold = true; TreeLayout treeLayout = new TreeLayout(this); treeLayout.ExcuteLayout(); }
public void Remove(TreeNodeViewModel treeNodeViewModel) { var all = new List<TreeNodeViewModel>(); this.GetChildrenIdAndSelf(treeNodeViewModel, all); foreach (TreeNodeViewModel child in all) { this.allNodes.Remove(child); } TreeNodeViewModel parent = treeNodeViewModel.Parent; if (parent != null) { parent.Children.Remove(treeNodeViewModel); } TreeLayout treeLayout = new TreeLayout(this); treeLayout.ExcuteLayout(); }
public void MoveToNode(TreeNodeViewModel from, TreeNodeViewModel to) { // from节点不能是to节点的父级节点 TreeNodeViewModel tmpNode = to; while (tmpNode != null) { if (tmpNode.IsRoot) { break; } if (tmpNode.Id == from.Id) { return; } tmpNode = tmpNode.Parent; } if (from.IsFold) { this.UnFold(from); } if (to.IsFold) { this.UnFold(to); } from.Parent.Children.Remove(from); to.Children.Add(from); from.Parent = to; TreeLayout treeLayout = new TreeLayout(this); treeLayout.ExcuteLayout(); }
/// <summary> /// 展开节点,一级一级展开,一次只展开下层子节点,比如下层节点是折叠的,那下下层节点不展开 /// </summary> /// <param name="treeNodeViewModel"></param> public void UnFold(TreeNodeViewModel treeNodeViewModel) { treeNodeViewModel.IsFold = false; var allChild = new List<TreeNodeViewModel>(); this.GetAllChildrenId(treeNodeViewModel, allChild); foreach (TreeNodeViewModel child in allChild) { this.allNodes.Add(child); } TreeLayout treeLayout = new TreeLayout(this); treeLayout.ExcuteLayout(); }