void CreateTreeForList(TreeViewItem root, IAutosarTreeList list) { /* */ bool needAdd = false; TreeViewItem newTreeItem; if (list.CreateRoot() || (root == null)) { newTreeItem = new TreeViewItem(); newTreeItem.Header = list.GetName(); newTreeItem.FontWeight = FontWeights.Normal; newTreeItem.Tag = list; needAdd = true; } else { needAdd = false; newTreeItem = root; } /* Create items for all properties */ List <IGUID> guids = list.GetItems(); if (guids != null) { foreach (IGUID guid in guids) { TreeViewItem item = CreateItemsForGuid(newTreeItem, guid); /* Create leafes for the lists*/ List <IAutosarTreeList> lists = guid.GetLists(); if (lists != null) { if (lists.Count > 0) { foreach (IAutosarTreeList treeList in lists) { CreateTreeForList(item, treeList); } } } } } if (needAdd) { if (root != null) { root.Items.Add(newTreeItem); } else { newTreeItem.FontWeight = FontWeights.Bold; this.Items.Add(newTreeItem); } } }
//public TreeViewItem FindItem(TreeViewItem root, IGUID guidObject) //{ // if (root == null) // { // foreach (TreeViewItem treeViewItem in Items) // { // /* Item is not found. Try to find in their children */ // return FindItem(treeViewItem, guidObject); // } // } // else // { // IGUID treeGuidObj = root.Tag as IGUID; // if (treeGuidObj != null) // { // if (treeGuidObj.GUID.Equals(guidObject.GUID)) // { // return root; // } // } // foreach (TreeViewItem treeViewItem in root.Items) // { // treeGuidObj = treeViewItem.Tag as IGUID; // if (treeGuidObj != null) // { // if (treeGuidObj.GUID.Equals(guidObject.GUID)) // { // return treeViewItem; // } // } // /* Item is not found. Try to find in their children */ // return FindItem(treeViewItem, guidObject); // } // } // return null; //} public bool DoesGuidExistInProperties(List <PropertyInfo> properties, IGUID guidObject) { foreach (PropertyInfo property in properties) { IAutosarTreeList treeList = property.GetValue(AutosarApplication.GetInstance()) as IAutosarTreeList; foreach (IGUID guid in treeList.GetItems()) { if (DoesGuidExists(treeList, guidObject) == true) { return(true); } } } return(false); }
bool DoesGuidExists(IAutosarTreeList treeList, IGUID guidToBeFound) { foreach (IGUID guid in treeList.GetItems()) { if (guid.Equals(guidToBeFound)) { return(true); } else { List <IAutosarTreeList> lists = guid.GetLists(); foreach (IAutosarTreeList list in lists) { if (DoesGuidExists(list, guidToBeFound) == true) { return(true); } } } } return(false); }