private void OnGroupsChanged(object sender, NotifyCollectionEventArgs e) { switch (e.Event) { case NotifyEvent.Insert: for (int i = e.StartIndex; i <= e.EndIndex; ++i) { var group = _group.Groups[i]; var item = new RepositoryGroupListItem(group); _groupsMapping.Add(group, item); _items.Insert(i, item); } break; case NotifyEvent.Remove: for (int i = e.StartIndex; i <= e.EndIndex; ++i) { var item = _items[i] as RepositoryGroupListItem; if (item != null) { _groupsMapping.Remove(item.DataContext); } } _items.RemoveRange(e.StartIndex, e.ModifiedItems); break; case NotifyEvent.Set: for (int i = e.StartIndex; i <= e.EndIndex; ++i) { var item = _items[i] as RepositoryGroupListItem; if (item != null) { _groupsMapping.Remove(item.DataContext); } var group = _group.Groups[i]; item = new RepositoryGroupListItem(group); _groupsMapping.Add(group, item); _items[i] = item; } break; case NotifyEvent.Clear: _groupsMapping.Clear(); _items.RemoveRange(0, e.ModifiedItems); break; } }
private void OnRepositoriesChanged(object sender, NotifyCollectionEventArgs e) { switch (e.Event) { case NotifyEvent.Insert: for (int i = e.StartIndex; i <= e.EndIndex; ++i) { var repo = _group.Respositories[i]; var item = new RepositoryListItem(repo); _repositoriesMapping.Add(repo, item); _items.Insert(i + _groupsMapping.Count, item); } break; case NotifyEvent.Remove: for (int i = e.StartIndex; i <= e.EndIndex; ++i) { var item = _items[i + _groupsMapping.Count] as RepositoryListItem; if (item != null) { _repositoriesMapping.Remove(item.DataContext); } } _items.RemoveRange(e.StartIndex + _groupsMapping.Count, e.ModifiedItems); break; case NotifyEvent.Set: for (int i = e.StartIndex; i <= e.EndIndex; ++i) { var item = _items[i + _groupsMapping.Count] as RepositoryListItem; if (item != null) { _repositoriesMapping.Remove(item.DataContext); } var repo = _group.Respositories[i]; item = new RepositoryListItem(repo); _repositoriesMapping.Add(repo, item); _items[i + _groupsMapping.Count] = item; } break; case NotifyEvent.Clear: _repositoriesMapping.Clear(); _items.RemoveRange(_groupsMapping.Count, e.ModifiedItems); break; } }
private void OnRecentRepositoriesChanged(object sender, NotifyCollectionEventArgs e) { UpdateRecentRepositoriesMenu(); }