public void AddNode(UITreeViewEntity item) { List <string> paths = new List <string>(Regex.Split(@item.GetPath(), @"\\")); if (TreeNodeLevel > paths.Count - 1) { return; } string id = paths[TreeNodeLevel]; bool found = false; foreach (var p in TaskCollection) { if (p.ToString() == id) { found = true; p.AddNode(item); return; } } if (!found) { UITreeViewEntity addItem = item.GetParentItemByLevel(TreeNodeLevel + 1); //item.Parent = addItem ; TaskCollection.Add(addItem); this.OnPropertyChanged("HasChildNodes"); } }
public UITreeViewEntity FindChildNode(int taskID, int objectID) { if (TaskID == taskID && ObjectID == objectID) { return(this); } else { foreach (var p in TaskCollection) { if (p.TaskID == taskID && p.ObjectID == objectID) { return(p); } { foreach (var x in p.TaskCollection) { UITreeViewEntity returnObject = p.FindChildNode(taskID, objectID); if (returnObject != null) { return(returnObject); } } } } } return(null); }
public UITreeViewEntity(string name, string image, int ID, int objectID, UITreeViewEntity parent) { TaskName = name; Image = image; TaskID = ID; ObjectID = objectID; Parent = parent; TaskCollection = new ObservableCollection <UITreeViewEntity>(); }
public UITreeViewEntity GetParentChildItem(int taskID, int objectID) { UITreeViewEntity returnObject = GetParentItem(taskID); if (returnObject == null) { return(null); } return(returnObject.TaskCollection.Where(p => p.ObjectID == objectID).FirstOrDefault()); }
private UITreeViewEntity GetParentItemByLevel(int levelID, UITreeViewEntity item) { UITreeViewEntity returnObject = null; if (item.TreeNodeLevel == (int)levelID) { returnObject = item; } else { if (item.Parent != null) { returnObject = GetParentItem(levelID, item.Parent); } } return(returnObject); }
public UITreeViewEntity GetParentItemByLevel(int levelID) { UITreeViewEntity returnObject = null; if (TreeNodeLevel == (int)levelID) { returnObject = this; } else { if (Parent != null) { returnObject = GetParentItemByLevel(levelID, Parent); } } return(returnObject); }
private UITreeViewEntity GetParentItem(int taskID, UITreeViewEntity item) { UITreeViewEntity returnObject = null; if (item.TaskID == (int)taskID) { returnObject = item; } else { if (item.Parent != null) { returnObject = GetParentItem(taskID, item.Parent); } } return(returnObject); }
public UITreeViewEntity GetParentItem(int taskID) { UITreeViewEntity returnObject = null; if (TaskID == (int)taskID) { returnObject = this; } else { if (Parent != null) { returnObject = Parent.GetParentItem(taskID); } } return(returnObject); }
private int GetParentObjectID(int taskID, UITreeViewEntity item) { int objectID = 0; if (item.TaskID == (int)taskID) { objectID = item.ObjectID; } else { if (item.Parent != null) { objectID = GetParentObjectID(taskID, item.Parent); } } return(objectID); }
public UITreeViewEntity GetNetParentItem(int taskID, int objectID) { UITreeViewEntity returnObject = GetParentItemByLevel(0); if (returnObject.TaskID == taskID && returnObject.ObjectID == objectID) { return(returnObject); } else { foreach (var p in returnObject.TaskCollection) { returnObject = p.FindChildNode(taskID, objectID); if (returnObject != null) { return(returnObject); } } } return(null); }