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;
        }
Exemple #2
0
        public RepositoryMenu(RepositoryListItem repository)
        {
            Verify.Argument.IsNotNull(repository, "repository");

            _repository = repository;

            Items.Add(new ToolStripMenuItem(Resources.StrOpen, null, (s, e) => _repository.Activate()));
            Items.Add(GuiItemFactory.GetOpenUrlItem<ToolStripMenuItem>(Resources.StrOpenInWindowsExplorer, null, _repository.DataContext.Path));
            Items.Add(GuiItemFactory.GetOpenCmdAtItem<ToolStripMenuItem>(Resources.StrOpenCommandLine, null, _repository.DataContext.Path));

            var actions = GuiItemFactory.GetRepositoryActions<ToolStripMenuItem>(repository.DataContext.Path);
            if(actions.Count != 0)
            {
                Items.Add(new ToolStripSeparator());
                foreach(var item in actions)
                {
                    Items.Add(item);
                }
            }

            Items.Add(new ToolStripSeparator());
            Items.Add(GuiItemFactory.GetRemoveRepositoryItem<ToolStripMenuItem>(_repository));
        }
Exemple #3
0
 public bool Execute()
 {
     var path = _txtPath.Text.Trim();
     if(path.Length == 0)
     {
         NotificationService.NotifyInputError(_txtPath,
             Resources.ErrInvalidPath,
             Resources.ErrPathCannotBeEmpty);
         return false;
     }
     var prov = _environment.FindProviderForDirectory(path);
     if(prov == null)
     {
         NotificationService.NotifyInputError(_txtPath,
             Resources.ErrInvalidPath,
             Resources.ErrPathIsNotValidRepository.UseAsFormat(path));
         return false;
     }
     var item = new RepositoryListItem(new RepositoryLink(path, prov.Name) { Description = _txtDescription.Text });
     _repositoryList.Items.Add(item);
     return true;
 }
Exemple #4
0
 private void _btnAddLocalRepo_LinkClicked(object sender, EventArgs e)
 {
     var path = Utility.ShowPickFolderDialog(this);
     if(!string.IsNullOrWhiteSpace(path))
     {
         var prov = WorkingEnvironment.FindProviderForDirectory(path);
         if(prov == null)
         {
             GitterApplication.MessageBoxService.Show(
                 this,
                 Resources.ErrPathIsNotValidRepository.UseAsFormat(path),
                 Resources.ErrInvalidPath,
                 MessageBoxButton.Close,
                 MessageBoxIcon.Error);
             return;
         }
         var item = new RepositoryListItem(new RepositoryLink(path, prov.Name));
         _lstLocalRepositories.Items.Add(item);
     }
 }
Exemple #5
0
 private void OnLocalRepositoriesDragDrop(object sender, DragEventArgs e)
 {
     if(e.Effect != DragDropEffects.None)
     {
         if(e.Data.GetDataPresent(DataFormats.FileDrop))
         {
             var data = (string[])(e.Data.GetData(DataFormats.FileDrop));
             for(int i = 0; i < data.Length; ++i)
             {
                 var di =  new DirectoryInfo(data[i]);
                 if(di.Exists)
                 {
                     var path = di.FullName;
                     if(!IsPresentInLocalRepositoryList(path))
                     {
                         var provider = WorkingEnvironment.FindProviderForDirectory(data[i]);
                         if(provider != null)
                         {
                             var link = new RepositoryLink(path, provider.Name);
                             var point = _lstLocalRepositories.PointToClient(new Point(e.X, e.Y));
                             CustomListBoxItemsCollection itemsCollection;
                             var index = _lstLocalRepositories.GetInsertIndexFormPoint(point.X, point.Y, false, out itemsCollection);
                             if(index != -1)
                             {
                                 itemsCollection.Insert(index, new RepositoryListItem(link));
                             }
                         }
                     }
                 }
             }
         }
         else if(e.Data.GetDataPresent(typeof(RepositoryListItem)))
         {
             var itemToMove = (RepositoryListItem)e.Data.GetData(typeof(RepositoryListItem));
             var point = _lstLocalRepositories.PointToClient(new Point(e.X, e.Y));
             CustomListBoxItemsCollection itemsCollection;
             var index = _lstLocalRepositories.GetInsertIndexFormPoint(point.X, point.Y, false, out itemsCollection);
             if(index == -1) return;
             var currentIndex = _lstLocalRepositories.Items.IndexOf(itemToMove);
             if(index == currentIndex) return;
             if(currentIndex == -1)
             {
                 itemsCollection.Insert(index, itemToMove);
             }
             else
             {
                 if(index > _lstLocalRepositories.Items.Count - 1)
                 {
                     --index;
                 }
                 itemToMove.Remove();
                 itemsCollection.Insert(index, itemToMove);
             }
         }
         else if(e.Data.GetDataPresent(typeof(RecentRepositoryListItem)))
         {
             var itemToMove = (RecentRepositoryListItem)e.Data.GetData(typeof(RecentRepositoryListItem));
             var path = itemToMove.DataContext.Path;
             if(IsPresentInLocalRepositoryList(path)) return;
             var point = _lstLocalRepositories.PointToClient(new Point(e.X, e.Y));
             CustomListBoxItemsCollection itemsCollection;
             var index = _lstLocalRepositories.GetInsertIndexFormPoint(point.X, point.Y, false, out itemsCollection);
             if(index == -1) return;
             var itemToInsert = new RepositoryListItem(new RepositoryLink(path, string.Empty));
             itemsCollection.Insert(index, itemToInsert);
         }
     }
 }
Exemple #6
0
 protected override void LoadMoreViewFrom(Section section)
 {
     base.LoadMoreViewFrom(section);
     var listNode = section.TryGetSection("RepositoryList");
     if(listNode != null)
     {
         _lstLocalRepositories.LoadViewFrom(listNode);
         _lstLocalRepositories.BeginUpdate();
         _lstLocalRepositories.Items.Clear();
         _lstLocalRepositories.LoadViewFrom(listNode);
         var itemsNode = listNode.TryGetSection("Items");
         if(itemsNode != null)
         {
             foreach(var s in itemsNode.Sections)
             {
                 var link = new RepositoryLink(s);
                 var item = new RepositoryListItem(link);
                 _lstLocalRepositories.Items.Add(item);
             }
         }
         _lstLocalRepositories.EndUpdate();
     }
 }
 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;
     }
 }