/// <summary> /// create TreeNode representing a SyncElement /// and update its visual representation /// </summary> /// <param name="elementInfo">element info</param> public SyncElementTreeViewNode(MyElementInfo elementInfo) : base(elementInfo.Name) { elementInfo.ElementTreeViewNode = this; ElementInfo = elementInfo; Name = elementInfo.Name; Update(); }
/// <summary> /// create SyncElementInfo /// </summary> /// <param name="syncInfo">synchronisation info</param> /// <param name="elementInfo">element info</param> /// <param name="initStatus">if true: SyncStatus is set to ElementFound</param> public SyncElementInfo(SyncInfo syncInfo, MyElementInfo elementInfo, bool initStatus) { SyncInfo = syncInfo; ElementInfo = elementInfo; ElementInfo.SyncElementInfo = this; if (initStatus) SyncStatus = SyncElementStatus.ElementFound; }
/// <summary> /// create SyncElementInfo /// </summary> /// <param name="syncInfo">synchronisation info</param> /// <param name="elementInfo">element info</param> /// <param name="initStatus">if true: SyncStatus is set to ElementFound</param> public SyncElementInfo(SyncInfo syncInfo, MyElementInfo elementInfo, bool initStatus) { SyncInfo = syncInfo; ElementInfo = elementInfo; ElementInfo.SyncElementInfo = this; if (initStatus) { SyncStatus = SyncElementStatus.ElementFound; } }
private TreeNode getTreeNode(MyElementInfo ei) { TreeNodeCollection tnc = treeView1.Nodes; TreeNode treeNode; for (int i = 0; i < ei.TreePath.Count; i++) { treeNode = tnc[ei.TreePath[i].Info.Name]; if (treeNode == null) return null; tnc = treeNode.Nodes; } return tnc[ei.Name]; }
/// <summary> /// update or create treenode if it is visible /// </summary> /// <param name="ei">element info</param> /// <param name="invoke">if the operations on treeview should be invoked</param> private void UpdateTreeNodeIfVisible(MyElementInfo ei, bool invoke) { TreeNodeCollection tnc = treeView1.Nodes; SyncDirTreeViewNode treeNode = null; for (int i = 1; i < ei.TreePath.Count; i++) { treeNode = (SyncDirTreeViewNode)tnc[ei.TreePath[i].Info.Name]; if (treeNode == null) return; //check if treenode is visible bool expanded = false; Action ae = new Action(() => expanded = treeNode.IsExpanded); if (invoke) treeView1.Invoke(ae); else ae(); if (!expanded) return; //update tree node (according to the status of ei) treeNode.ChildStatus = ei.SyncElementInfo.SyncStatus; Action a = new Action(treeNode.Update); if (invoke) treeView1.Invoke(a); else a(); tnc = treeNode.Nodes; } if (ei.ElementTreeViewNode == null) { //create treenode if (ei.GetType() == typeof(MyFileInfo)) ei.ElementTreeViewNode = new SyncFileTreeViewNode((MyFileInfo)ei); else ei.ElementTreeViewNode = new SyncDirTreeViewNode((MyDirInfo)ei); Action aa = new Action(() => tnc.Add(ei.ElementTreeViewNode)); if (invoke) treeView1.Invoke(aa); else aa(); } //update result tree node Action au = new Action(ei.ElementTreeViewNode.Update); if (invoke) treeView1.Invoke(au); else au(); }