Exemplo n.º 1
0
 public void Assign(Repository source)
 {
     Path = source.Path;
     Title = source.Title;
     Description = source.Description;
     RepositoryType = source.RepositoryType;
 }
Exemplo n.º 2
0
        public DashboardItem(Repository repository)
            : this()
        {
            if (repository == null)
                return;

            Bitmap icon = GetRepositoryIcon(repository);


            if (AppSettings.DashboardShowCurrentBranch)
            {
                _branchNameLoader = new AsyncLoader();
                _branchNameLoader.Load(() =>
                {
                    if (!GitCommands.GitModule.IsBareRepository(repository.Path))
                    {
                        return GitModule.GetSelectedBranchFast(repository.Path);
                    }
                    return string.Empty;
                },
                UpdateBranchName);
            }

            Initialize(icon, repository.Path, repository.Title, repository.Description);
        }
        public void AddMostRecentRepository(string repo)
        {
            repo = repo.Trim();

            if (string.IsNullOrEmpty(repo))
                return;

            repo = repo.Replace('/', '\\');
            if (!repo.EndsWith("\\") &&
                !repo.StartsWith("http", StringComparison.CurrentCultureIgnoreCase) &&
                !repo.StartsWith("git", StringComparison.CurrentCultureIgnoreCase) &&
                !repo.StartsWith("ssh", StringComparison.CurrentCultureIgnoreCase))
                repo += "\\";

            foreach (var recentRepository in Repositories)
            {
                if (!recentRepository.Path.Equals(repo, StringComparison.CurrentCultureIgnoreCase))
                    continue;
                Repositories.Remove(recentRepository);
                break;
            }

            var repository = new Repository(repo, null, null) {RepositoryType = RepositoryType.History};
            Repositories.Insert(0, repository);

            if (Repositories.Count > 30)
            {
                Repositories.RemoveAt(30);
            }
        }
Exemplo n.º 4
0
        public RecentRepoInfo(Repository aRepo, bool aMostRecent)
        {
            Repo = aRepo;
            MostRecent = aMostRecent;
            try
            {
                DirInfo = new DirectoryInfo(Repo.Path);
            }
            catch (SystemException)
            {
                DirInfo = null;
                Caption = Repo.Path;
            }

            if (Repo.Title != null)
                ShortName = Repo.Title;
            else if (DirInfo != null)
                ShortName = DirInfo.Name;
            

            if (DirInfo != null)
                DirInfo = DirInfo.Parent;

            DirName = DirInfo == null ? "" : DirInfo.FullName;
        }
Exemplo n.º 5
0
 public void Assign(Repository source)
 {
     if (source == null)
         return;
     Path = source.Path;
     Title = source.Title;
     Description = source.Description;
     RepositoryType = source.RepositoryType;
 }
Exemplo n.º 6
0
        public DashboardItem(Repository repository)
            : this()
        {
            if (repository == null)
                return;

            Bitmap icon = GetRepositoryIcon(repository);

            var branchName = GitCommands.GitCommandHelpers.GetSelectedBranch(repository.Path);
            Initialize(icon, repository.Path, repository.Title, repository.Description, branchName);
            AutoSizeMode = AutoSizeMode.GrowAndShrink;
        }
Exemplo n.º 7
0
 private static Bitmap GetRepositoryIcon(Repository repository)
 {
     switch (repository.RepositoryType)
     {
         case RepositoryType.Repository:
             return Resources._14;
         case RepositoryType.RssFeed:
             return Resources.rss.ToBitmap();
         case RepositoryType.History:
             return Resources.history.ToBitmap();
         default:
             throw new ArgumentException("Repository type is not supported.", "repository");
     }
 }
Exemplo n.º 8
0
        public DashboardItem(Repository repository)
        {
            InitializeComponent(); Translate();

            if (repository == null)
                return;

            Bitmap icon = null;
            if (repository.RepositoryType == RepositoryType.RssFeed)
                icon = Resources.rss.ToBitmap();
            if (repository.RepositoryType == RepositoryType.Repository)
                icon = Resources._14;
            if (repository.RepositoryType == RepositoryType.History)
                icon = Resources.history.ToBitmap();

            Initialize(icon, repository.Path, repository.Title, repository.Description);
            this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
        }
Exemplo n.º 9
0
        public DashboardItem(Repository repository)
            : this()
        {
            if (repository == null)
                return;

            Bitmap icon = GetRepositoryIcon(repository);

            string branchName = string.Empty;

            if (GitCommands.Settings.DashboardShowCurrentBranch)
            {
                if (!GitCommands.GitCommandHelpers.IsBareRepository(repository.Path))
                    branchName = GitCommands.GitCommandHelpers.GetSelectedBranchFast(repository.Path);
            }

            Initialize(icon, repository.Path, repository.Title, repository.Description, branchName);
        }
        public void AddMostRecentRepository(string repo)
        {
            if (string.IsNullOrEmpty(repo))
                return;

            repo = repo.Trim();

            if (string.IsNullOrEmpty(repo))
                return;

            repo = repo.Replace(Settings.PathSeparatorWrong, Settings.PathSeparator);
            if (!repo.EndsWith(Settings.PathSeparator.ToString()) &&
                !repo.StartsWith("http", StringComparison.CurrentCultureIgnoreCase) &&
                !repo.StartsWith("git", StringComparison.CurrentCultureIgnoreCase) &&
                !repo.StartsWith("ssh", StringComparison.CurrentCultureIgnoreCase))
                repo += Settings.PathSeparator.ToString();

            Repository.RepositoryAnchor anchor = Repository.RepositoryAnchor.None;
            foreach (var recentRepository in Repositories)
            {
                if (!recentRepository.Path.Equals(repo, StringComparison.CurrentCultureIgnoreCase))
                    continue;
                anchor = recentRepository.Anchor;
                Repositories.Remove(recentRepository);
                break;
            }

            var repository = new Repository(repo, null, null) {
                RepositoryType = RepositoryType.History,
                Anchor = anchor
            };
            Repositories.Insert(0, repository);

            if (Repositories.Count > 30)
            {
                Repositories.RemoveAt(30);
            }
        }
Exemplo n.º 11
0
        public void AddMostRecentRepository(string repo)
        {
            if (string.IsNullOrEmpty(repo))
                return;

            repo = repo.Trim();

            if (string.IsNullOrEmpty(repo))
                return;

            if (!Repository.PathIsUrl(repo))
            {
                repo = repo.ToNativePath().EnsureTrailingPathSeparator();
            }

            Repository.RepositoryAnchor anchor = Repository.RepositoryAnchor.None;
            foreach (var recentRepository in Repositories)
            {
                if (!recentRepository.Path.Equals(repo, StringComparison.CurrentCultureIgnoreCase))
                    continue;
                anchor = recentRepository.Anchor;
                Repositories.Remove(recentRepository);
                break;
            }

            var repository = new Repository(repo, null, null) {
                RepositoryType = RepositoryType.History,
                Anchor = anchor
            };
            Repositories.Insert(0, repository);

            while (MaxCount > 0 && Repositories.Count > MaxCount)
            {
                Repositories.RemoveAt(MaxCount);
            }
        }
Exemplo n.º 12
0
 private void repositoryRemoved(Repository repository)
 {
     if (RepositoryRemoved != null)
         RepositoryRemoved(repository);
 }
Exemplo n.º 13
0
 void contextMenu_Opening(object sender, EventArgs e)
 {
     repository = (Repository)(((ContextMenuStrip)sender).SourceControl.Tag);
 }
Exemplo n.º 14
0
 public void RemoveRepository(Repository repository)
 {
     Repositories.Remove(repository);
 }
Exemplo n.º 15
0
 public void AddRepository(Repository repo)
 {
     Repositories.Add(repo);
 }
Exemplo n.º 16
0
 public void RemoveRepository(Repository repository)
 {
     Repositories.Remove(repository);
 }
Exemplo n.º 17
0
 private void repositoryRemoved(Repository repository)
 {
     var handler = RepositoryRemoved;
     if (handler != null)
         handler(this, new RepositoryEventArgs(repository));
 }
Exemplo n.º 18
0
        private void AddWorkingdirDropDownItem(Repository repo, string caption)
        {
            ToolStripMenuItem toolStripItem = new ToolStripMenuItem(caption);
            _NO_TRANSLATE_Workingdir.DropDownItems.Add(toolStripItem);

            toolStripItem.Click += (hs, he) => ChangeWorkingDir(repo.Path);

            if (repo.Title != null || !repo.Path.Equals(caption))
                toolStripItem.ToolTipText = repo.Path;
        }
Exemplo n.º 19
0
        private void HandleFeedTag(XmlNode rssDoc, int r)
        {
            // <feed> tag found
            var nodeFeed = rssDoc.ChildNodes[r];

            //loop through all entries
            for (var i = 0; i < nodeFeed.ChildNodes.Count; i++)
            {
                var nodeItem = nodeFeed.ChildNodes[i];

                if (nodeItem.Name != "entry")
                    continue;
                // Create a new row in the ListView containing information from inside the nodes
                var repository = new Repository();
                var title = nodeItem["title"];
                if (title != null)
                    repository.Title = title.InnerText.Trim();
                //repository.Description = nodeItem["content"].InnerText.Trim();
                var link = nodeItem["link"];
                if (link != null)
                    repository.Path = link.Attributes["href"].Value;
                repository.RepositoryType = RepositoryType.RssFeed;
                Repositories.Add(repository);
            }
        }
Exemplo n.º 20
0
        public void DownloadRssFeed()
        {
            try
            {
                // Create a new XmlTextReader from the specified URL (RSS feed)
                var rssReader = new XmlTextReader(RssFeedUrl);
                var rssDoc = new XmlDocument();

                // Load the XML content into a XmlDocument
                rssDoc.Load(rssReader);

                //Clear old entries
                Repositories.Clear();

                // Loop for the <rss> or (atom) <feed> tag
                for (var r = 0; r < rssDoc.ChildNodes.Count; r++)
                {
                    // If it is the (atom) feed tag
                    if (rssDoc.ChildNodes[r].Name == "feed")
                    {
                        HandleFeedTag(rssDoc, r);
                    }

                    // If it is the rss tag
                    if (rssDoc.ChildNodes[r].Name == "rss")
                    {
                        HandleRssTag(rssDoc, r);
                    }
                }
            }
            catch (Exception ex)
            {
                Repositories.Clear();

                var repository = new Repository
                                     {
                                         Title = "Error loading rssfeed from :" + RssFeedUrl,
                                         Description = ex.Message,
                                         Path = RssFeedUrl,
                                         RepositoryType = RepositoryType.RssFeed
                                     };
                Repositories.Add(repository);
            }
        }
Exemplo n.º 21
0
 public void AddRepository(Repository repo)
 {
     Repositories.Add(repo);
 }
Exemplo n.º 22
0
        private void HandleRssTag(XmlNode rssDoc, int r)
        {
            // <rss> tag found
            var nodeRss = rssDoc.ChildNodes[r];

            // Loop for the <channel> tag
            for (var c = 0; c < nodeRss.ChildNodes.Count; c++)
            {
                // If it is the channel tag
                if (nodeRss.ChildNodes[c].Name != "channel")
                    continue;
                // <channel> tag found
                var nodeChannel = nodeRss.ChildNodes[c];

                // Set the labels with information from inside the nodes
                /*string title = nodeChannel["title"].InnerText;
                                string link = nodeChannel["link"].InnerText;
                                string description = nodeChannel["description"].InnerText;*/

                //loop through all items
                for (var i = 0; i < nodeChannel.ChildNodes.Count; i++)
                {
                    // If it is the item tag, then it has children tags which we will add as items to the ListView
                    if (nodeChannel.ChildNodes[i].Name != "item")
                        continue;
                    var nodeItem = nodeChannel.ChildNodes[i];

                    // Create a new row in the ListView containing information from inside the nodes
                    var repository = new Repository();
                    var title = nodeItem["title"];
                    if (title != null)
                        repository.Title = title.InnerText.Trim();
                    var description = nodeItem["description"];
                    if (description != null)
                        repository.Description = description.InnerText.Trim();
                    var link = nodeItem["link"];
                    if (link != null)
                        repository.Path = link.InnerText.Trim();
                    repository.RepositoryType = RepositoryType.RssFeed;
                    Repositories.Add(repository);
                }
            }
        }
Exemplo n.º 23
0
 void RecentRepositories_RepositoryRemoved(Repository repository)
 {
     if (repository != null)
         Repositories.RepositoryHistory.RemoveRepository(repository);
 }
Exemplo n.º 24
0
 public RepositoryEventArgs(Repository repository)
 {
     Repository = repository;
 }