Ejemplo n.º 1
0
        /// <summary>
        /// Initialise form
        /// </summary>
        public Form1()
        {
            InitializeComponent();
            //add listerners
            lvCommits.SelectedIndexChanged += lvCommits_SelectedIndexChanged;
            tcRepositories.SelectedIndexChanged += tcRepositories_TabIndexChanged;

            startDropForm();

            //Load configuration and repositories
            mLocalRepositories = IO_Config.GetAllRepositoriesConfig();

            //foreach item in config.repositories
            if (mLocalRepositories.Count > 0) {
                foreach (RepositoryConfigElement repo in mLocalRepositories)
                {
                    addRepositoryToView(repo.LocalPath, repo.Name);
                }
                //load selected repo commits
                //TODO: Should be last selected repo on previous close if possible
                loadRepository(mLocalRepositories[0].LocalPath);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddRepository_Click(object sender, EventArgs e)
        {
            RepositoryConfigElement newRepo = new RepositoryConfigElement();
            newRepo.Name = txtRepoName.Text;
            //check if we are adding or cloning a repo
            if (txtRepoPath.Enabled)
            {
                this.UseWaitCursor = true;
                Repository.Clone(txtRepoPath.Text, txtLocalPath.Text);

                newRepo.LocalPath = txtLocalPath.Text;
                newRepo.RemoteURL = txtRepoPath.Text;
                mLocalRepositories = IO_Config.AddRepositoryConfig(newRepo);
                addRepositoryToView(newRepo.LocalPath, newRepo.Name);

                this.UseWaitCursor = false;
            }else{
                if (Repository.Discover(fbdAddRepository.SelectedPath) != null)
                {
                    //repository available here, import it
                    newRepo.LocalPath = txtRepoPath.Text;
                    mLocalRepositories = IO_Config.AddRepositoryConfig(newRepo);
                    addRepositoryToView(newRepo.LocalPath, newRepo.Name);
                }
                else
                {
                    //create new repository
                    try
                    {
                        //config.add repository
                        currentRepo = Repository.Init(txtRepoPath.Text);
                        newRepo.LocalPath = txtRepoPath.Text;
                        mLocalRepositories = IO_Config.AddRepositoryConfig(newRepo);
                        addRepositoryToView(newRepo.LocalPath, newRepo.Name);
                    }
                    catch (RepositoryNotFoundException rne)
                    {
                        MessageBox.Show(rne.Message);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }

                }
            }
            tcRepositories.SelectTab(tcRepositories.TabCount - 1);
            hideAddRepoPanel();
        }