forked from gdevic/GitForce
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFormNewRepoScanAdd.cs
More file actions
77 lines (70 loc) · 2.25 KB
/
Copy pathFormNewRepoScanAdd.cs
File metadata and controls
77 lines (70 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading;
using System.Windows.Forms;
namespace GitForce
{
/// <summary>
/// Add a set of repositories to the workspace
/// </summary>
public partial class FormNewRepoScanAdd : Form
{
private readonly List<string> _dirs;
private bool _enableAdd;
public FormNewRepoScanAdd(List<string> dirs)
{
InitializeComponent();
_dirs = dirs;
// If there are 5 repos or more, display the progress bar
progressBar.Visible = _dirs.Count() >= 5;
progressBar.Maximum = _dirs.Count();
progressBar.Value = 0;
}
/// <summary>
/// Start scanning at the time the form is first shown
/// </summary>
private void FormNewRepoScanAddShown(object sender, EventArgs e)
{
_enableAdd = true;
int count = 1;
// Create each of the repos for the selected directories
foreach (var d in _dirs)
{
if (_enableAdd == false)
return;
try
{
// Update progress bar and make sure it gets painted
progressBar.Value = count++;
Thread.Sleep(1);
textRepo.Text = d;
Application.DoEvents();
Directory.SetCurrentDirectory(d);
if (ClassGit.Run("init").Success() == false)
throw new ClassException("init failed.");
App.Repos.Add(d);
}
catch (Exception ex)
{
App.PrintLogMessage("Unable to add repo: " + ex.Message);
App.PrintStatusMessage(ex.Message);
}
}
DialogResult = DialogResult.OK;
}
/// <summary>
/// Cancel adding repos
/// </summary>
private void BtCancelClick(object sender, EventArgs e)
{
_enableAdd = false;
DialogResult = DialogResult.OK;
}
}
}