private void InsertFiles(TreeDirectory directory, bool oneLevel) { if(!oneLevel) { foreach(var subFolder in directory.Directories) { InsertFiles(subFolder, false); } } foreach(var commit in directory.Commits) { var item = new TreeCommitListItem(commit, true); item.Activated += OnItemActivated; item.ContextMenuRequested += OnItemContextMenuRequested; _itemHost.AddSafe(item); } foreach(var file in directory.Files) { var item = new TreeFileListItem(file, true); item.Activated += OnItemActivated; item.ContextMenuRequested += OnItemContextMenuRequested; _itemHost.AddSafe(item); } _trackedDirectories.Add(directory); if(!oneLevel) { directory.DirectoryAdded += OnDirectoryAdded2; } directory.FileAdded += OnFileAdded; directory.CommitAdded += OnCommitAdded; directory.Deleted += OnDirectoryDeleted; }
private void OnFileAdded(object sender, TreeFileEventArgs e) { var item = new TreeFileListItem(e.File, _plain); item.Activated += OnItemActivated; item.ContextMenuRequested += OnItemContextMenuRequested; _itemHost.AddSafe(item); }
private void InitTree(bool oneLevel) { _itemHost.Clear(); _itemHost.Comparison = TreeItemListItem.CompareByName; foreach(var folder in _root.Directories) { var item = new TreeDirectoryListItem( folder, oneLevel ? TreeDirectoryListItemType.ShowNothing : TreeDirectoryListItemType.ShowFilesAndFolders, OnSubItemActivated, OnItemContextMenuRequested); item.Activated += OnItemActivated; item.ContextMenuRequested += OnItemContextMenuRequested; _itemHost.Add(item); } foreach(var commit in _root.Commits) { var item = new TreeCommitListItem(commit, false); item.Activated += OnItemActivated; item.ContextMenuRequested += OnItemContextMenuRequested; _itemHost.Add(item); } foreach(var file in _root.Files) { var item = new TreeFileListItem(file, false); item.Activated += OnItemActivated; item.ContextMenuRequested += OnItemContextMenuRequested; _itemHost.Add(item); } _root.DirectoryAdded += OnDirectoryAdded; _root.CommitAdded += OnCommitAdded; _root.FileAdded += OnFileAdded; }