/// <summary> /// Creates PtfPropertyView /// </summary> /// <param name="hideProperties">Hide properties.</param> /// <returns>An instance of PtfPropertyView</returns> public PtfPropertyView CreatePtfPropertyView(List <string> hideProperties) { List <PtfProperty> hide = new List <PtfProperty>(); foreach (string name in hideProperties) { PtfProperty p = GetPropertyNodeByName(name); if (p != null) { hide.Add(p); } } // Root Group PtfPropertyRoot.ValueType = PtfPropertyType.Group; PtfPropertyView propertyView = new PtfPropertyView(PtfPropertyRoot); Stack <TreeStackItem> propertyStack = new Stack <TreeStackItem>(); propertyStack.Push(new TreeStackItem(PtfPropertyRoot, propertyView)); while (propertyStack.Count > 0) { TreeStackItem p = propertyStack.Pop(); if (p.PropertyNode.ValueType != PtfPropertyType.Group) { if (hide.Contains(p.PropertyNode)) { continue; } var view = new PtfPropertyView(p.PropertyNode, p.PathFrom(3)); p.PropertyView.Add(view); } else { PtfPropertyView view; if (p.Path.Count <= 2) { view = new PtfPropertyView(p.PropertyNode); p.PropertyView.Add(view); } else { view = p.PropertyView; } for (int i = p.PropertyNode.Count - 1; i >= 0; i--) { var child = p.PropertyNode[i]; TreeStackItem c = new TreeStackItem( child, view); c.Path.InsertRange(0, p.Path); c.Path.Add(p.PropertyNode.Name); propertyStack.Push(c); } } } var v = propertyView[0]; // Remove empty view for (int i = 0; i < v.Count; i++) { if (v[i].IsEmptyGroup) { v.RemoveAt(i); i--; continue; } var childv = v[i]; for (int ii = 0; ii < childv.Count; ii++) { if (childv[ii].IsEmptyGroup) { childv.RemoveAt(ii); ii--; } } } return(v); }
/// <summary> /// Creates PtfPropertyView /// </summary> /// <param name="hideProperties">Hide properties.</param> /// <returns>An instance of PtfPropertyView</returns> public PtfPropertyView CreatePtfPropertyView(List<string> hideProperties) { List<PtfProperty> hide = new List<PtfProperty>(); foreach (string name in hideProperties) { PtfProperty p = GetPropertyNodeByName(name); if (p != null) hide.Add(p); } // Root Group PtfPropertyRoot.ValueType = PtfPropertyType.Group; PtfPropertyView propertyView = new PtfPropertyView(PtfPropertyRoot); Stack<TreeStackItem> propertyStack = new Stack<TreeStackItem>(); propertyStack.Push(new TreeStackItem(PtfPropertyRoot, propertyView)); while (propertyStack.Count > 0) { TreeStackItem p = propertyStack.Pop(); if (p.PropertyNode.ValueType != PtfPropertyType.Group) { if (hide.Contains(p.PropertyNode)) continue; var view = new PtfPropertyView(p.PropertyNode, p.PathFrom(3)); p.PropertyView.Add(view); } else { PtfPropertyView view; if (p.Path.Count <= 2) { view = new PtfPropertyView(p.PropertyNode); p.PropertyView.Add(view); } else view = p.PropertyView; for (int i = p.PropertyNode.Count - 1; i >= 0; i--) { var child = p.PropertyNode[i]; TreeStackItem c = new TreeStackItem( child, view); c.Path.InsertRange(0, p.Path); c.Path.Add(p.PropertyNode.Name); propertyStack.Push(c); } } } var v = propertyView[0]; // Remove empty view for (int i = 0; i < v.Count; i++) { if (v[i].IsEmptyGroup) { v.RemoveAt(i); i--; continue; } var childv = v[i]; for (int ii = 0; ii < childv.Count; ii++) { if (childv[ii].IsEmptyGroup) { childv.RemoveAt(ii); ii--; } } } return v; }