示例#1
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);
                _repositories.Clear();
                var itemsNode = listNode.TryGetSection("Items");
                if (itemsNode != null)
                {
                    foreach (var s in itemsNode.Sections)
                    {
                        var link = new RepositoryLink(s);
                        var item = new RepositoryListItem(link);
                        _repositories.Add(item);
                        _lstLocalRepositories.Items.Add(item);
                    }
                }
                _lstLocalRepositories.EndUpdate();
            }
        }
示例#2
0
        public static T GetRemoveRecentRepositoryItem <T>(RepositoryLink repository)
            where T : ToolStripItem, new()
        {
            Verify.Argument.IsNotNull(repository, "repository");

            var item = new T()
            {
                Text  = Resources.StrRemoveRepository,
                Image = CachedResources.Bitmaps["ImgRepositoryRemove"],
                Tag   = repository,
            };

            item.Click += OnRemoveRecentRepositoryClick;
            return(item);
        }
示例#3
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);
         }
     }
 }