/// <summary> /// Find parent tree node for current adding data in _nodesHierarchy. /// </summary> /// <param name="assosiatedData">Assosiated data for new tree node.</param> /// <returns>Returns tree node for which have to be added new node with assossiatedData.</returns> private TreeNode GetParentNode(FileSystemObjectData assosiatedData) { if (_lastAddedNode == null) { return(null); } if (assosiatedData.Parent == null) { _nodesHierarchy.Clear(); return(null); } if (_lastAddedNode.Tag == assosiatedData.Parent) { _nodesHierarchy.Add(_lastAddedNode); return(_lastAddedNode); } for (int i = _nodesHierarchy.Count - 1; i >= 0; i--) { if (_nodesHierarchy[i].Tag == assosiatedData.Parent) { return(_nodesHierarchy[i]); } _nodesHierarchy.RemoveAt(i); } throw new InvalidOperationException("Can't find parent node."); }
private void OnGotNewFileSystemData(FileSystemObjectData objectData) { if (_isAborted) { return; } EventHandler <FileSystemObjectEventArgs> handler = GotNewFileSystemData; if (handler != null) { handler(this, new FileSystemObjectEventArgs(objectData)); } }
public void ShowElementProperties(FileSystemObjectData data) { if (data == null) { _propertiesListBox.Items.Clear(); return; } _propertiesListBox.BeginUpdate(); _propertiesListBox.Items.Clear(); _propertiesListBox.Items.Add("Owner: " + data.Owner); _propertiesListBox.Items.Add("Size: " + BytesCountToString(data.BytesSize)); _propertiesListBox.Items.Add("Creation Time: " + data.CreationTime.ToString("g")); _propertiesListBox.Items.Add("LastWrite Time: " + data.LastWriteTime.ToString("g")); _propertiesListBox.Items.Add("LastAccess Time: " + data.LastAccessTime.ToString("g")); _propertiesListBox.EndUpdate(); }
public void AddTreeNode(FileSystemObjectData assosiatedData) { try { TreeNode parentNode = GetParentNode(assosiatedData); TreeNodeCollection nodeCollection = parentNode != null ? parentNode.Nodes : _filesTreeView.Nodes; int iconIndex = assosiatedData is FileData ? 0 : 1; var newTreeNode = new TreeNode(assosiatedData.Name, iconIndex, iconIndex) { Tag = assosiatedData }; _lastAddedNode = newTreeNode; _context.Send(s => nodeCollection.Add(newTreeNode), null); } catch (Exception ex) { OnInterfaceExceptionOccurred("Error while adding new tree node.", ex); } }
public FileSystemObjectEventArgs(FileSystemObjectData fileSystemObjectData) { _fileSystemObjectData = fileSystemObjectData; }