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; }
public RepositoryGroupBinding(CustomListBoxItemsCollection items, RepositoryGroup group) { Verify.Argument.IsNotNull(items, nameof(items)); Verify.Argument.IsNotNull(group, nameof(group)); _items = items; _group = group; _groupsMapping = new Dictionary <RepositoryGroup, RepositoryGroupListItem>(); _repositoriesMapping = new Dictionary <RepositoryLink, RepositoryListItem>(); foreach (var subGroup in group.Groups) { var item = new RepositoryGroupListItem(subGroup); _groupsMapping.Add(subGroup, item); items.Add(item); } foreach (var repository in group.Respositories) { var item = new RepositoryListItem(repository); _repositoriesMapping.Add(repository, item); items.Add(item); } group.Groups.Changed += OnGroupsChanged; group.Respositories.Changed += OnRepositoriesChanged; }
public RepositoryGroupBinding(CustomListBoxItemsCollection items, RepositoryGroup group) { Verify.Argument.IsNotNull(items, "items"); Verify.Argument.IsNotNull(group, "group"); _items = items; _group = group; _groupsMapping = new Dictionary<RepositoryGroup, RepositoryGroupListItem>(); _repositoriesMapping = new Dictionary<RepositoryLink, RepositoryListItem>(); foreach(var subGroup in group.Groups) { var item = new RepositoryGroupListItem(subGroup); _groupsMapping.Add(subGroup, item); items.Add(item); } foreach(var repository in group.Respositories) { var item = new RepositoryListItem(repository); _repositoriesMapping.Add(repository, item); items.Add(item); } group.Groups.Changed += OnGroupsChanged; group.Respositories.Changed += OnRepositoriesChanged; }
private void InitTree(bool showRoot) { _itemHost.Clear(); _itemHost.Comparison = TreeItemListItem.CompareByName; if (showRoot) { _rootItem = new TreeDirectoryListItem( _root, TreeDirectoryListItemType.ShowNothing, OnSubItemActivated); _rootItem.Expand(); foreach (var folder in _root.Directories) { var item = new TreeDirectoryListItem( folder, TreeDirectoryListItemType.ShowFoldersOnly, OnSubItemActivated); item.Activated += OnItemActivated; _rootItem.Items.Add(item); } _itemHost.Add(_rootItem); _root.DirectoryAdded += OnNewFolderAddedRooted; } else { foreach (var folder in _root.Directories) { var item = new TreeDirectoryListItem( folder, TreeDirectoryListItemType.ShowFoldersOnly, OnSubItemActivated); item.Activated += OnItemActivated; _itemHost.Add(item); } _root.DirectoryAdded += OnNewFolderAdded; } }
protected BaseListBinding(CustomListBoxItemsCollection itemHost, GitObjectsCollection <TObject, TEventArgs> collection) { Verify.Argument.IsNotNull(itemHost, nameof(itemHost)); Verify.Argument.IsNotNull(collection, nameof(collection)); _itemHost = itemHost; _collection = collection; _itemHost.Comparison = GetComparison(); _itemHost.SortOrder = GetSortOrder(); lock (collection.SyncRoot) { foreach (var obj in collection) { var item = RepresentObject(obj); item.Activated += OnItemActivated; _itemHost.Add(item); } collection.ObjectAdded += OnObjectAdded; } }
public ReferenceTreeBinding(CustomListBoxItemsCollection itemHost, Repository repository, bool groupItems, bool groupRemoteBranches, Predicate <IRevisionPointer> predicate, ReferenceType referenceTypes) { Verify.Argument.IsNotNull(itemHost, nameof(itemHost)); Verify.Argument.IsNotNull(repository, nameof(repository)); _itemHost = itemHost; Repository = repository; _groupItems = groupItems; _groupRemotes = groupRemoteBranches; _predicate = predicate; _referenceTypes = referenceTypes; _itemHost.Clear(); if (groupItems) { Heads = new ReferenceGroupListItem(repository, ReferenceType.LocalBranch); Heads.Items.Comparison = BranchListItem.CompareByName; Remotes = new ReferenceGroupListItem(repository, ReferenceType.RemoteBranch); if (groupRemoteBranches) { Remotes.Items.Comparison = RemoteListItem.CompareByName; } else { Remotes.Items.Comparison = RemoteBranchListItem.CompareByName; } Tags = new ReferenceGroupListItem(repository, ReferenceType.Tag); Tags.Items.Comparison = TagListItem.CompareByName; _itemHost.Comparison = null; } else { Heads = null; Remotes = null; Tags = null; _itemHost.Comparison = ReferenceListItemBase.UniversalComparer; } _remotes = groupRemoteBranches ? new List <RemoteListItem>(repository.Remotes.Count) : null; if ((referenceTypes & ReferenceType.LocalBranch) == ReferenceType.LocalBranch) { var refs = Repository.Refs.Heads; lock (refs.SyncRoot) { foreach (var branch in refs) { if (predicate != null && !predicate(branch)) { continue; } var item = new BranchListItem(branch); item.Activated += OnItemActivated; CustomListBoxItemsCollection host; if (groupItems) { host = Heads.Items; } else { host = _itemHost; } host.Add(item); } refs.ObjectAdded += OnBranchCreated; } } if ((referenceTypes & ReferenceType.RemoteBranch) == ReferenceType.RemoteBranch) { var refs = repository.Refs.Remotes; lock (refs.SyncRoot) { foreach (var branch in refs) { if (predicate != null && !predicate(branch)) { continue; } var host = groupItems ? Remotes.Items : _itemHost; var item = new RemoteBranchListItem(branch); item.Activated += OnItemActivated; if (groupRemoteBranches) { var ritem = GetRemoteListItem(branch); if (ritem != null) { host = ritem.Items; } } host.Add(item); } refs.ObjectAdded += OnRemoteBranchCreated; } } if ((referenceTypes & ReferenceType.Tag) == ReferenceType.Tag) { var refs = repository.Refs.Tags; lock (refs.SyncRoot) { foreach (var tag in refs) { if (predicate != null && !predicate(tag)) { continue; } var item = new TagListItem(tag); item.Activated += OnItemActivated; CustomListBoxItemsCollection host; if (groupItems) { host = Tags.Items; } else { host = _itemHost; } host.Add(item); } refs.ObjectAdded += OnTagCreated; } } if (groupItems) { _itemHost.Add(Heads); _itemHost.Add(Remotes); _itemHost.Add(Tags); } }
public ReferenceTreeBinding(CustomListBoxItemsCollection itemHost, Repository repository, bool groupItems, bool groupRemoteBranches, Predicate<IRevisionPointer> predicate, ReferenceType referenceTypes) { Verify.Argument.IsNotNull(itemHost, "itemHost"); Verify.Argument.IsNotNull(repository, "repository"); _itemHost = itemHost; _repository = repository; _groupItems = groupItems; _groupRemotes = groupRemoteBranches; _predicate = predicate; _referenceTypes = referenceTypes; _itemHost.Clear(); if(groupItems) { _refsHeads = new ReferenceGroupListItem(repository, ReferenceType.LocalBranch); _refsHeads.Items.Comparison = BranchListItem.CompareByName; _refsRemotes = new ReferenceGroupListItem(repository, ReferenceType.RemoteBranch); if(groupRemoteBranches) { _refsRemotes.Items.Comparison = RemoteListItem.CompareByName; } else { _refsRemotes.Items.Comparison = RemoteBranchListItem.CompareByName; } _refsTags = new ReferenceGroupListItem(repository, ReferenceType.Tag); _refsTags.Items.Comparison = TagListItem.CompareByName; _itemHost.Comparison = null; } else { _refsHeads = null; _refsRemotes = null; _refsTags = null; _itemHost.Comparison = ReferenceListItemBase.UniversalComparer; } _remotes = groupRemoteBranches ? new List<RemoteListItem>(repository.Remotes.Count) : null; if((referenceTypes & ReferenceType.LocalBranch) == ReferenceType.LocalBranch) { var refs = _repository.Refs.Heads; lock(refs.SyncRoot) { foreach(var branch in refs) { if(predicate != null && !predicate(branch)) continue; var item = new BranchListItem(branch); item.Activated += OnItemActivated; CustomListBoxItemsCollection host; if(groupItems) { host = _refsHeads.Items; } else { host = _itemHost; } host.Add(item); } refs.ObjectAdded += OnBranchCreated; } } if((referenceTypes & ReferenceType.RemoteBranch) == ReferenceType.RemoteBranch) { var refs = repository.Refs.Remotes; lock(refs.SyncRoot) { foreach(var branch in refs) { if(predicate != null && !predicate(branch)) continue; var host = groupItems ? _refsRemotes.Items : _itemHost; var item = new RemoteBranchListItem(branch); item.Activated += OnItemActivated; if(groupRemoteBranches) { var ritem = GetRemoteListItem(branch); if(ritem != null) { host = ritem.Items; } } host.Add(item); } refs.ObjectAdded += OnRemoteBranchCreated; } } if((referenceTypes & ReferenceType.Tag) == ReferenceType.Tag) { var refs = repository.Refs.Tags; lock(refs.SyncRoot) { foreach(var tag in refs) { if(predicate != null && !predicate(tag)) continue; var item = new TagListItem(tag); item.Activated += OnItemActivated; CustomListBoxItemsCollection host; if(groupItems) { host = _refsTags.Items; } else { host = _itemHost; } host.Add(item); } refs.ObjectAdded += OnTagCreated; } } if(groupItems) { _itemHost.Add(_refsHeads); _itemHost.Add(_refsRemotes); _itemHost.Add(_refsTags); } }