private void TrimUnselected_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show("This will remove all unchecked components from the object's 3D Graphics->Vector list. \n Do you wish to continue?", "Warning", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { string parentStr = null; int index; IAgStkObject obj; dynamic vo; foreach (TreeNode item in AvailableVectorList.Nodes) { index = _data.IndexOf(_data.Where(p => p.SimpleName == item.Text).FirstOrDefault()); parentStr = _data[index].SimplePath; obj = CommonData.StkRoot.GetObjectFromPath(parentStr); vo = SmartViewFunctions.GetObjectVO(obj); if (vo != null) { IAgVORefCrdnCollection crdns = vo.Vector.RefCrdns; foreach (TreeNode child in item.Nodes) { if (!child.Checked) { crdns.RemoveByName(dict[child.Text], child.Text); } } } } PopulateList(); } }
private void PopulateList() { AvailableVectorList.Nodes.Clear(); string parentStr = null; string parentSimpleName = null; int parentCount = 0; int childCount = 0; string name = null; for (int i = 0; i < _data.Count; i++) { parentStr = _data[i].SimplePath; IAgStkObject obj = CommonData.StkRoot.GetObjectFromPath(parentStr); dynamic vo = SmartViewFunctions.GetObjectVO(obj); //Only populate objects that have valid vo properties if (vo != null) { IAgVORefCrdnCollection vgtComponents = vo.Vector.RefCrdns; //Only populate objects with valid vgt components in object properties list (i.e. 3D Graphics->Vector) if (vgtComponents.Count > 0) { AvailableVectorList.Nodes.Add(_data[i].SimpleName); parentCount++; childCount = 0; //Display all vgt components for the parent object. Add key value pairs into local dictionary and cross reference with existing options in saved view for (int j = 0; j < vgtComponents.Count; j++) { name = vgtComponents[j].Name; AvailableVectorList.Nodes[parentCount - 1].Nodes.Add(name); if (!dict.ContainsKey(name)) { dict.Add(name, vgtComponents[j].TypeID); } if (_data[i].ActiveVgtComponents.Keys.Contains(name)) { AvailableVectorList.Nodes[parentCount - 1].Nodes[childCount].Checked = true; } else { AvailableVectorList.Nodes[parentCount - 1].Nodes[childCount].Checked = false; } childCount++; } } } } }