forked from gdevic/GitForce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FormNewRepoStep1.cs
101 lines (92 loc) · 3.28 KB
/
FormNewRepoStep1.cs
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace GitForce
{
public partial class FormNewRepoStep1 : Form
{
/// <summary>
/// Describes the source for the new repo: "empty", "local" or "remote"
/// </summary>
public string Type = "empty";
public string Local = "";
public ClassRemotes.Remote Remote;
public FormNewRepoStep1()
{
InitializeComponent();
ClassWinGeometry.Restore(this);
// Set the default remote name
Remote.Name = "origin";
Remote.PushCmd = "";
remoteDisplay.Set(Remote);
remoteDisplay.AnyTextChanged += SomeTextChanged;
}
/// <summary>
/// Form is closing.
/// </summary>
private void FormNewRepoStep1FormClosing(object sender, FormClosingEventArgs e)
{
ClassWinGeometry.Save(this);
}
/// <summary>
/// Browse for the local path to directory to clone
/// </summary>
private void BtBrowseClick(object sender, EventArgs e)
{
if (folderDlg.ShowDialog() == DialogResult.OK)
textBoxLocal.Text = folderDlg.SelectedPath;
}
/// <summary>
/// User changed the radio button source for the repo
/// </summary>
private void RbSourceCheckedChanged(object sender, EventArgs e)
{
RadioButton rb = sender as RadioButton;
if (rb.Checked)
{
textBoxLocal.ReadOnly = true;
btNext.Enabled = btBrowse.Enabled = remoteDisplay.Enabled = false;
remoteDisplay.Enable(false, false);
switch (Type = rb.Tag.ToString())
{
case "empty":
btNext.Enabled = true;
break;
case "local":
textBoxLocal.ReadOnly = false;
btBrowse.Enabled = true;
btNext.Enabled = Path.IsPathRooted(textBoxLocal.Text) && Directory.Exists(Path.Combine(textBoxLocal.Text, ".git"));
Local = textBoxLocal.Text;
break;
case "remote":
remoteDisplay.Enabled = true;
remoteDisplay.Enable(true, true);
btNext.Enabled = remoteDisplay.IsValid();
break;
}
}
}
/// <summary>
/// Text in the local directory path changed. Validate the entry.
/// </summary>
private void TextBoxLocalTextChanged(object sender, EventArgs e)
{
btNext.Enabled = Path.IsPathRooted(textBoxLocal.Text) && Directory.Exists(Path.Combine(textBoxLocal.Text, ".git"));
Local = textBoxLocal.Text;
}
/// <summary>
/// Callback function called when text in the remote repo editing has changed.
/// </summary>
private void SomeTextChanged(bool valid)
{
btNext.Enabled = valid;
Remote = remoteDisplay.Get();
}
}
}