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; }
public TreeDirectoriesBinding(CustomListBoxItemsCollection itemHost, TreeDirectory root, bool showRoot) { Verify.Argument.IsNotNull(itemHost, "itemHost"); Verify.Argument.IsNotNull(root, "root"); _itemHost = itemHost; _root = root; InitTree(showRoot); }
/// <summary>Initializes a new instance of the <see cref="CustomListBoxItem"/> class.</summary> public CustomListBoxItem() { _cachedLevel = -1; _items = new CustomListBoxItemsCollection(null, this); _checkedState = CheckedState.Unchecked; _items.Changing += OnItemsChanging; _items.Changed += OnItemsChanged; }
public TreeBinding(CustomListBoxItemsCollection itemHost, TreeDirectory root, bool filesOnly, bool oneLevel) { Verify.Argument.IsNotNull(itemHost, "itemHost"); Verify.Argument.IsNotNull(root, "root"); _itemHost = itemHost; _root = root; _plain = filesOnly; if(filesOnly) { InitPlain(oneLevel); } else { InitTree(oneLevel); } }
public TagListBinding(CustomListBoxItemsCollection itemHost, Repository repository) : base(itemHost, repository.Refs.Tags) { }
public int GetInsertIndexFormPoint(int x, int y, bool insertBetween, out CustomListBoxItemsCollection collection) { if(x < ClientRectangle.X || x >= ClientRectangle.Right) { collection = null; return - 1; } y -= ClientRectangle.Y; if(HeaderStyle != HeaderStyle.Hidden) { y -= _headersArea.Height; } y += VScrollPos; if(insertBetween) { y += ItemHeight / 2; } else { y += 0; } int index = y / ItemHeight; if(index > _itemPlainList.Count) { index = _itemPlainList.Count; } if(index < 0) { collection = Items; return 0; } if(index > 0) { var item = _itemPlainList[index == _itemPlainList.Count ? index - 1: index]; if(item.Parent != null) { collection = item.Parent.Items; index = collection.IndexOf(item); return index; } else { collection = Items; return index; } } else { collection = Items; return index; } }
private void RemoveItems(CustomListBoxItemsCollection items, int startIndex, int endIndex) { var start = _itemPlainList.IndexOf(items[startIndex]); if(start == -1) return; var endItem = items[endIndex]; var end = (startIndex == endIndex)?(start + 1):(_itemPlainList.IndexOf(endItem) + 1); if(endItem.IsExpanded && endItem.Items.Count != 0) { int level = endItem.Level; while(end < _itemPlainList.Count && _itemPlainList[end].Level > level) { ++end; } } if(_itemFocus.IsTracked) { if(_itemFocus.Index >= startIndex) { if(_itemFocus.Index > endIndex) { _itemFocus.ResetIndex(_itemFocus.Index - (endIndex - startIndex + 1)); } else { _itemFocus.Drop(); } } } if(_itemHover.IsTracked) { if(_itemHover.Index >= startIndex) { if(_itemHover.Index > endIndex) { _itemHover.ResetIndex(_itemHover.Index - (endIndex - startIndex + 1)); } else { _itemHover.Drop(); } } } int selected = _selectedItems.Count; if(selected != 0) { for(int i = start; i < end; ++i) { if(_itemPlainList[i].IsSelected) { _selectedItems.Remove(_itemPlainList[i]); --selected; if(selected == 0) break; } } } _itemPlainList.RemoveRange(start, end - start); NotifyContentSizeChanged(); }
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); } }
public SubmoduleListBinding(CustomListBoxItemsCollection itemHost, SubmodulesCollection submodules) : base(itemHost, submodules) { }
public RemoteListBinding(CustomListBoxItemsCollection itemHost, Repository repository) : base(itemHost, repository.Remotes) { }
public UserListBinding(CustomListBoxItemsCollection itemHost, UsersCollection users) : base(itemHost, users) { }
public UserListBinding(CustomListBoxItemsCollection itemHost, Repository repository) : base(itemHost, repository.Users) { }
public TreeBinding(CustomListBoxItemsCollection itemHost, TreeDirectory root, bool filesOnly) : this(itemHost, root, filesOnly, false) { }
public RemoteBranchListBinding(CustomListBoxItemsCollection itemHost, RefsRemotesCollection branches) : base(itemHost, branches) { }
public TagListBinding(CustomListBoxItemsCollection itemHost, RefsTagsCollection tags) : base(itemHost, 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); } }
public RemoteListBinding(CustomListBoxItemsCollection itemHost, RemotesCollection remotes) : base(itemHost, remotes) { }
public SubmoduleListBinding(CustomListBoxItemsCollection itemHost, Repository repository) : base(itemHost, repository.Submodules) { }
public BranchListBinding(CustomListBoxItemsCollection itemHost, Repository repository) : base(itemHost, repository.Refs.Heads) { }
public BranchListBinding(CustomListBoxItemsCollection itemHost, RefsHeadsCollection branches) : base(itemHost, branches) { }
/// <summary>Create <see cref="CustomListBox"/>.</summary> public CustomListBox() { _items = new CustomListBoxItemsCollection(this, null); _items.Changing += OnItemsChanging; _items.Changed += OnItemsChanged; _columns = new CustomListBoxColumnsCollection(this); _columns.Changed += OnColumnsChanged; _selectedItems = new CustomListBoxSelectedItemsCollection(this); _selectedItems.Changed += OnSelectedItemsChanged; _itemPlainList = new List<CustomListBoxItem>(); _processOverlay = new ProcessOverlay(this); _processOverlay.Renderer = Style.OverlayRenderer; _itemHover = new TrackingService<CustomListBoxItem>(OnItemHoverChanged); _itemFocus = new TrackingService<CustomListBoxItem>(OnItemFocusChanged); _headerHover = new TrackingService<CustomListBoxColumn>(OnHeaderHoverChanged); _headerDragHelper = new DragHelper(); _showRootTreeLines = true; _allowColumnReorder = true; _integralScroll = true; _lastClickedItemIndex = -1; _draggedHeaderIndex = -1; _columnHeaderHeight = DEFAULT_ITEM_HEIGHT; _itemHeight = DEFAULT_ITEM_HEIGHT; _renderer = Style.ListBoxRenderer; BackColor = Renderer.BackColor; ForeColor = Renderer.ForeColor; _tooltip = new ToolTip() { InitialDelay = 350, }; }
private void UpdateCheckStatuses(CustomListBoxItemsCollection items) { foreach(var item in items) { var refItem = item as IRevisionPointerListItem; if(refItem != null) { var reference = refItem.RevisionPointer as Reference; if(reference != null) { item.IsChecked = _logOptions.AllowedReferences.Contains(reference); } } UpdateCheckStatuses(item.Items); } }