コード例 #1
0
 private void EditButtonClick(object sender, EventArgs e)
 {
     if (listAddonsList.SelectedItems.Count > 1)
     {
         MessageBox.Show(Resources.editTooManySelected, Resources.editErrorHeader);
         return;
     }
     var addonDir = _installDir + "\\" + listAddonsList.SelectedItems[0].Text;
     var answer = Microsoft.VisualBasic.Interaction.InputBox("Give the new url of the repository");
     if (!string.IsNullOrEmpty(answer))
     {
         if (MessageBox.Show(@"Are you sure you want to relocate addon to " + answer, @"Continue?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
         {
             return;
         }
         if (Directory.Exists(addonDir + "\\.git"))
         {
             if (answer.IndexOf(".git") != 0)
             {
                 var process = Process.Start("git", "remote rm origin");
                 process.WaitForExit();
                 process.StartInfo.Arguments = "remote add origin " + answer;
                 process.Start();
             }
             else
             {
                 MessageBox.Show(@"Url cannot be resolved", @"Cannot resolve Url");
             }
         }
         else
         {
             Uri newUrl;
             try
             {
                 newUrl = new Uri(answer);
             }
             catch (Exception)
             {
                 MessageBox.Show(@"Url cannot be resolved", @"Cannot resolve Url");
                 return;
             }
             var svnClient = new SvnClient();
             var sourceUrl = svnClient.GetRepositoryRoot(addonDir);
             svnClient.Relocate(addonDir, sourceUrl, newUrl);
         }
     }
 }