mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-01 17:24:59 +00:00
refactor<*>: rewrite all codes...
This commit is contained in:
parent
89ff8aa744
commit
30ab8ae954
342 changed files with 17208 additions and 19633 deletions
50
src/Views/Popups/Apply.xaml.cs
Normal file
50
src/Views/Popups/Apply.xaml.cs
Normal file
|
@ -0,0 +1,50 @@
|
|||
using Microsoft.Win32;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace SourceGit.Views.Popups {
|
||||
/// <summary>
|
||||
/// 应用补丁
|
||||
/// </summary>
|
||||
public partial class Apply : Controls.PopupWidget {
|
||||
private string repo = null;
|
||||
public string File { get; set; }
|
||||
|
||||
public Apply(string repo) {
|
||||
this.repo = repo;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public override string GetTitle() {
|
||||
return App.Text("Apply.Title");
|
||||
}
|
||||
|
||||
public override Task<bool> Start() {
|
||||
txtPath.GetBindingExpression(TextBox.TextProperty).UpdateSource();
|
||||
if (Validation.GetHasError(txtPath)) return null;
|
||||
|
||||
var ignoreWS = chkIngoreWS.IsChecked == true;
|
||||
var wsMode = (cmbWSOption.SelectedItem as Models.WhitespaceOption).Arg;
|
||||
|
||||
return Task.Run(() => {
|
||||
Models.Watcher.SetEnabled(repo, false);
|
||||
var succ = new Commands.Apply(repo, File, ignoreWS, wsMode).Exec();
|
||||
Models.Watcher.SetEnabled(repo, true);
|
||||
return succ;
|
||||
});
|
||||
}
|
||||
|
||||
private void OpenFileBrowser(object sender, System.Windows.RoutedEventArgs e) {
|
||||
var dialog = new OpenFileDialog();
|
||||
dialog.Filter = "Patch File|*.patch";
|
||||
dialog.Title = App.Text("Apply.File.Placeholder");
|
||||
dialog.InitialDirectory = repo;
|
||||
dialog.CheckFileExists = true;
|
||||
|
||||
if (dialog.ShowDialog() == true) {
|
||||
File = dialog.FileName;
|
||||
txtPath.GetBindingExpression(TextBox.TextProperty).UpdateTarget();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue