mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-24 13:45:00 +00:00
refactor(*): re-arrange project
This commit is contained in:
parent
7558bbd4f2
commit
5ce9cffcee
140 changed files with 4980 additions and 5003 deletions
112
src/UI/Clone.xaml.cs
Normal file
112
src/UI/Clone.xaml.cs
Normal file
|
@ -0,0 +1,112 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace SourceGit.UI {
|
||||
|
||||
/// <summary>
|
||||
/// Clone dialog.
|
||||
/// </summary>
|
||||
public partial class Clone : UserControl {
|
||||
private PopupManager popup = null;
|
||||
|
||||
/// <summary>
|
||||
/// Remote repository
|
||||
/// </summary>
|
||||
public string RemoteUri { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Parent folder.
|
||||
/// </summary>
|
||||
public string ParentFolder { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Local name.
|
||||
/// </summary>
|
||||
public string LocalName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Remote name.
|
||||
/// </summary>
|
||||
public string RemoteName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
public Clone(PopupManager mgr) {
|
||||
ParentFolder = App.Preference.GitDefaultCloneDir;
|
||||
popup = mgr;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Select parent folder.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void SelectParentFolder(object sender, RoutedEventArgs e) {
|
||||
var dialog = new System.Windows.Forms.FolderBrowserDialog();
|
||||
dialog.Description = "Git Repository URL";
|
||||
dialog.RootFolder = Environment.SpecialFolder.MyComputer;
|
||||
dialog.ShowNewFolderButton = true;
|
||||
|
||||
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
|
||||
txtParentFolder.Text = dialog.SelectedPath;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Start clone
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private async void Start(object sender, RoutedEventArgs e) {
|
||||
txtUrl.GetBindingExpression(TextBox.TextProperty).UpdateSource();
|
||||
if (Validation.GetHasError(txtUrl)) return;
|
||||
|
||||
txtParentFolder.GetBindingExpression(TextBox.TextProperty).UpdateSource();
|
||||
if (Validation.GetHasError(txtParentFolder)) return;
|
||||
|
||||
string repoName;
|
||||
if (string.IsNullOrWhiteSpace(LocalName)) {
|
||||
var from = RemoteUri.LastIndexOfAny(new char[] { '\\', '/' });
|
||||
if (from <= 0) return;
|
||||
|
||||
var name = RemoteUri.Substring(from + 1);
|
||||
repoName = name.Replace(".git", "");
|
||||
} else {
|
||||
repoName = LocalName;
|
||||
}
|
||||
|
||||
string rName;
|
||||
if (string.IsNullOrWhiteSpace(RemoteName)){
|
||||
rName = null;
|
||||
} else {
|
||||
rName = RemoteName;
|
||||
}
|
||||
|
||||
popup.Lock();
|
||||
|
||||
var repo = await Task.Run(() => {
|
||||
return Git.Repository.Clone(RemoteUri, ParentFolder, rName, repoName, popup.UpdateStatus);
|
||||
});
|
||||
|
||||
if (repo == null) {
|
||||
popup.Unlock();
|
||||
} else {
|
||||
popup.Close(true);
|
||||
repo.Open();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancel.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void Cancel(object sender, RoutedEventArgs e) {
|
||||
popup.Close();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue