forked from gdevic/GitForce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FormNewRepoStep2.cs
97 lines (87 loc) · 3.11 KB
/
FormNewRepoStep2.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
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 FormNewRepoStep2 : Form
{
/// <summary>
/// Destination directory to create a new repo
/// </summary>
public string Destination = "";
public string Extra = "";
public bool IsBare;
private bool CloneOperation;
public FormNewRepoStep2()
{
InitializeComponent();
ClassWinGeometry.Restore(this);
}
/// <summary>
/// Form is closing.
/// </summary>
private void FormNewRepoStep2FormClosing(object sender, FormClosingEventArgs e)
{
ClassWinGeometry.Save(this);
}
/// <summary>
/// Show or hide project name edit box if we are doing a clone operation
/// </summary>
public void SetForCloneOperation(bool isClone)
{
textBoxProjectName.Enabled = CloneOperation = labelCloneOperation.Enabled = isClone;
}
/// <summary>
/// Browse for the final path to the directory to init
/// </summary>
private void BtBrowseClick(object sender, EventArgs e)
{
if (folderDlg.ShowDialog() == DialogResult.OK)
textBoxRepoPath.Text = folderDlg.SelectedPath;
}
/// <summary>
/// Text changed in the destination path, validate it.
/// </summary>
private void TextBoxRepoPathTextChanged(object sender, EventArgs e)
{
try
{
btOK.Enabled = Path.IsPathRooted(textBoxRepoPath.Text) && Directory.Exists(textBoxRepoPath.Text);
// Additional check for clone operation:
// If a project name is not present, the root needs to exist and be an empty directory
// (the check for 'exist' is already made in the step above)
if (CloneOperation && textBoxProjectName.Text.Trim().Length == 0)
{
btOK.Enabled &= (Directory.GetFiles(textBoxRepoPath.Text).Length == 0) &&
(Directory.GetDirectories(textBoxRepoPath.Text).Length == 0);
}
}
catch (Exception ex)
{
App.PrintLogMessage(ex.Message);
btOK.Enabled = false;
}
Destination = Path.Combine(textBoxRepoPath.Text, textBoxProjectName.Text.Trim());
}
/// <summary>
/// Copy the bare checked state into a public variable that is exposed
/// </summary>
private void CheckBoxBareCheckedChanged(object sender, EventArgs e)
{
IsBare = checkBoxBare.Checked;
}
/// <summary>
/// Copy the extra string into a public variable that is exposed
/// </summary>
private void TextBoxExtraArgsTextChanged(object sender, EventArgs e)
{
Extra = textBoxExtraArgs.Text;
}
}
}