Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
 public void Dispose()
 {
     Repository.Refs.Heads.ObjectAdded   -= OnBranchCreated;
     Repository.Refs.Remotes.ObjectAdded -= OnRemoteBranchCreated;
     Repository.Refs.Tags.ObjectAdded    -= OnTagCreated;
     _itemHost.Clear();
 }
Exemplo n.º 3
0
 public void Dispose()
 {
     _groupsMapping.Clear();
     _repositoriesMapping.Clear();
     _group.Groups.Changed        -= OnGroupsChanged;
     _group.Respositories.Changed -= OnRepositoriesChanged;
     _items.Clear();
 }
Exemplo n.º 4
0
 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;
     }
 }
Exemplo n.º 5
0
        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);
            }
        }
Exemplo n.º 6
0
 public void Dispose()
 {
     _collection.ObjectAdded -= OnObjectAdded;
     _itemHost.Clear();
 }
Exemplo n.º 7
0
        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);
            }
        }