Menu

[38707f]: / FormNewRepoStep1.cs  Maximize  Restore  History

Download this file

123 lines (109 with data), 4.0 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
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
using System;
using System.Windows.Forms;
namespace GitForce
{
public partial class FormNewRepoStep1 : Form
{
/// <summary>
/// Describes source for a new repo: "empty", "local" or "remote"
/// </summary>
public string Type { get { return type; }
set { type = value;
if (type.Equals("empty")) rbEmpty.Checked = true;
if (type.Equals("local")) rbLocal.Checked = true;
if (type.Equals("remote")) rbRemote.Checked = true;
}}
private string type;
/// <summary>
/// Path to a local git repo
/// </summary>
public string Local {
get { return textBoxLocal.Text.Trim(); }
set { textBoxLocal.Text = value; }
}
/// <summary>
/// ClassRemote structure of a new repo
/// </summary>
public ClassRemotes.Remote Remote;
/// <summary>
/// Call this method to properly set the remote structure that is going to be used by this dialog
/// </summary>
public void SetRemote(ClassRemotes.Remote remote)
{
Remote = remote;
remoteEdit.Set(Remote);
}
public FormNewRepoStep1()
{
InitializeComponent();
ClassWinGeometry.Restore(this);
Type = "empty";
Local = String.Empty;
// Set the default remote name
Remote.Name = "origin";
Remote.PushCmd = "";
remoteEdit.Set(Remote);
remoteEdit.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)
{
folder.Description = @"Select a folder containing the root of a repository to clone:";
if (folder.ShowDialog() == DialogResult.OK)
Local = folder.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 = remoteEdit.Enabled = false;
remoteEdit.Enable(false, false);
switch (Type = rb.Tag.ToString())
{
case "empty":
btNext.Enabled = true;
break;
case "local":
textBoxLocal.ReadOnly = false;
btBrowse.Enabled = true;
btNext.Enabled = ClassUtils.DirStat(Local) == ClassUtils.DirStatType.Git;
break;
case "remote":
remoteEdit.Enabled = true;
remoteEdit.Enable(true, true);
btNext.Enabled = remoteEdit.IsValid();
break;
}
}
}
/// <summary>
/// Text in the local directory path changed. Validate the entry.
/// </summary>
private void TextBoxLocalTextChanged(object sender, EventArgs e)
{
btNext.Enabled = ClassUtils.DirStat(Local) == ClassUtils.DirStatType.Git;
}
/// <summary>
/// Callback function called when text in the remote repo editing has changed.
/// </summary>
private void SomeTextChanged(bool valid)
{
btNext.Enabled = valid;
Remote = remoteEdit.Get();
}
}
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.