private void m_treeListView_SelectionChanged(object sender, EventArgs e) { m_frmMain.myDocViewer1.UnloadMyDoc(); m_treeListView2.GetColumn(0).Text = "Process Entities"; Object selObj = m_treeListView1.SelectedObject; if (selObj is Process) { Process process = (Process)selObj; m_treeListView2.RemoveObjects((ICollection)m_treeListView2.Objects); m_treeListView2.ClearObjects(); m_treeListView2.AddObject(process.Inputs); m_treeListView2.AddObject(process.OutputsCreated); //m_treeListView2.AddObject(process.OutputsUpdated); if (process.OutputsUpdated.Items.Count > 0) { process.OutputsCreated.Name = "Outputs Created"; process.OutputsUpdated.Name = "Outputs Updated"; m_treeListView2.AddObject(process.OutputsUpdated); } m_treeListView2.AddObject(process.Tools); m_treeListView2.ExpandAll(); m_frmMain.ClearStatusStrip2(); } else { m_treeListView2.RemoveObjects((ICollection)m_treeListView2.Objects); m_frmMain.ClearStatusStrip2(); } }
/// <summary> /// Move the given collection of model objects so that they become roots of the target tree /// </summary> /// <param name="targetTree"></param> /// <param name="sourceTree"></param> /// <param name="toMove"></param> private static void MoveObjectsToRoots(TreeListView targetTree, TreeListView sourceTree, IList toMove) { if (sourceTree == targetTree) { foreach (ModelWithChildren x in toMove) { if (x.Parent != null) { x.Parent.Children.Remove(x); x.Parent = null; sourceTree.AddObject(x); } } } else { foreach (ModelWithChildren x in toMove) { if (x.Parent == null) { sourceTree.RemoveObject(x); } else { x.Parent.Children.Remove(x); } x.Parent = null; targetTree.AddObject(x); } } }
public static void MakeTreeViewSource(MST.MES.Data_structures.DevToolsModelStructure dtModel) { treeProductStructure.Objects = null; if (dtModel != null) { treeProductStructure.CanExpandGetter = delegate(object x) { return(((MST.MES.Data_structures.DevToolsModelStructure)x).children.Count > 0); }; treeProductStructure.ChildrenGetter = delegate(object x) { return(((MST.MES.Data_structures.DevToolsModelStructure)x).children); }; treeProductStructure.AddObject(dtModel); treeProductStructure.ExpandAll(); } }
private void HandleDropped(object sender, OlvDropEventArgs e) { // This will only be triggered if HandleModelDropped doesn't set Handled to true. // In practice, this will only be called when the source of the drag is not an ObjectListView DataObject data = e.DataObject as DataObject; if (data == null || String.IsNullOrEmpty(data.GetText())) { return; } TreeListView treeListView = e.ListView as TreeListView; if (treeListView == null) { return; } ModelWithChildren newModel = new ModelWithChildren { Label = data.GetText(), DataForChildren = new ArrayList { "A", "B ", "C", "D", "E" } }; switch (e.DropTargetLocation) { case DropTargetLocation.AboveItem: break; case DropTargetLocation.BelowItem: break; case DropTargetLocation.Background: treeListView.AddObject(newModel); break; case DropTargetLocation.Item: ModelWithChildren targetModel = e.DropTargetItem.RowObject as ModelWithChildren; if (targetModel != null) { newModel.Parent = targetModel; targetModel.Children.Add(newModel); treeListView.RefreshObject(targetModel); } break; default: return; } }
private void RefreshObject(object o, bool exists) { //or from known descendancy var knownDescendancy = _activator.CoreChildProvider.GetDescendancyListIfAnyFor(o); //if it is a root object maintained by this tree and it exists if (MaintainRootObjects != null && MaintainRootObjects.Contains(o.GetType()) && exists) { //if tree doesn't yet contain the object if (!Tree.Objects.Cast <object>().Contains(o)) { Tree.AddObject(o); //add it return; } } if (!exists) { //remove it Tree.RemoveObject(o); } if (!IsHiddenByFilter(o)) { //By preference refresh the parent that way we deal with hierarchy changes if (knownDescendancy != null) { var lastParent = knownDescendancy.Parents.LastOrDefault(p => Tree.IndexOf(p) != -1); //does tree have parent? if (lastParent != null) { Tree.RefreshObject(lastParent); //refresh parent } else //Tree has object but not parent, bad times, maybe BetterRouteExists? Refresh the object if it exists if (exists) { Tree.RefreshObject(o); } } else //if we have the object if (Tree.IndexOf(o) != -1 && exists) { Tree.RefreshObject(o); //it exists so refresh it! } } }
private void RefreshObject(object o, bool exists) { //or from known descendancy var knownDescendancy = _activator.CoreChildProvider.GetDescendancyListIfAnyFor(o); //if it is a root object maintained by this tree and it exists if (MaintainRootObjects != null && MaintainRootObjects.Contains(o.GetType()) && exists) { //if tree doesn't yet contain the object if (!Tree.Objects.Cast <object>().Contains(o)) { Tree.AddObject(o); //add it return; } } if (ShouldClearPinFilterOnRefresh(o, exists)) { _pinFilter.UnApplyToTree(); } if (!exists) { //clear the current selection (if the object to be deleted is selected) if (Tree.IsSelected(o)) { Tree.SelectedObject = null; Tree.SelectedObjects = null; } //remove it from tree Tree.RemoveObject(o); } if (!IsHiddenByFilter(o)) { //By preference refresh the parent that way we deal with hierarchy changes if (knownDescendancy != null) { var lastParent = knownDescendancy.Parents.LastOrDefault(p => Tree.IndexOf(p) != -1); //does tree have parent? if (lastParent != null) { Tree.RefreshObject(lastParent); //refresh parent } else if (Tree.IndexOf(o) != -1) { //Tree has object but not parent, bad times, maybe BetterRouteExists? Tree.RebuildAll(true); } } else //if we have the object if (Tree.IndexOf(o) != -1 && exists) { Tree.RefreshObject(o); //it exists so refresh it! } } }