Ejemplo n.º 1
0
        public void RegisterRecentRepository(RepositoryLink repository)
        {
            Verify.Argument.IsNotNull(repository, "repository");

            int id = -1;

            for (int i = 0; i < _recent.Count; ++i)
            {
                if (string.Compare(_recent[i].Path, repository.Path, true) == 0)
                {
                    id = i;
                    break;
                }
            }
            if (id == 0)
            {
                return;
            }
            if (id != -1)
            {
                _recent.RemoveAt(id);
            }
            _recent.Insert(0, repository);
            var diff = _recent.Count - _maxRecentREpositories;

            if (diff > 0)
            {
                _recent.RemoveRange(_recent.Count - diff, diff);
            }
        }
Ejemplo n.º 2
0
        private static void SaveRepositoryTo(RepositoryLink repository, Section section)
        {
            Assert.IsNotNull(repository);
            Assert.IsNotNull(section);

            repository.SaveTo(section);
        }
Ejemplo n.º 3
0
        public void RegisterRecentRepository(string repositoryPath)
        {
            if (string.IsNullOrWhiteSpace(repositoryPath))
            {
                return;
            }
            if (repositoryPath.EndsWith(Path.DirectorySeparatorChar) || repositoryPath.EndsWith(Path.AltDirectorySeparatorChar))
            {
                repositoryPath = repositoryPath.Substring(0, repositoryPath.Length - 1);
            }
            var repository = new RepositoryLink(repositoryPath, @"");

            RegisterRecentRepository(repository);
        }
Ejemplo n.º 4
0
 public void RegisterRecentRepository(string repositoryPath)
 {
     if(string.IsNullOrWhiteSpace(repositoryPath))
     {
         return;
     }
     if(repositoryPath.EndsWith(Path.DirectorySeparatorChar) || repositoryPath.EndsWith(Path.AltDirectorySeparatorChar))
     {
         repositoryPath = repositoryPath.Substring(0, repositoryPath.Length - 1);
     }
     var repository = new RepositoryLink(repositoryPath, @"");
     RegisterRecentRepository(repository);
 }
Ejemplo n.º 5
0
        private static void SaveRepositoryTo(RepositoryLink repository, Section section)
        {
            Assert.IsNotNull(repository);
            Assert.IsNotNull(section);

            repository.SaveTo(section);
        }
Ejemplo n.º 6
0
        public void RegisterRecentRepository(RepositoryLink repository)
        {
            Verify.Argument.IsNotNull(repository, "repository");

            int id = -1;
            for(int i = 0; i < _recent.Count; ++i)
            {
                if(string.Compare(_recent[i].Path, repository.Path, true) == 0)
                {
                    id = i;
                    break;
                }
            }
            if(id == 0)
            {
                return;
            }
            if(id != -1)
            {
                _recent.RemoveAt(id);
            }
            _recent.Insert(0, repository);
            var diff = _recent.Count - _maxRecentREpositories;
            if(diff > 0)
            {
                _recent.RemoveRange(_recent.Count - diff, diff);
            }
        }
Ejemplo n.º 7
0
 public RepositoryLinkEventArgs(RepositoryLink repository)
 {
     Repository = repository;
 }
Ejemplo n.º 8
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);
         }
     }
 }
Ejemplo n.º 9
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();
     }
 }
Ejemplo n.º 10
0
 public RepositoryLinkEventArgs(RepositoryLink repository)
 {
     _repository = repository;
 }