mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-24 13:45:00 +00:00
refactor<*>: rewrite all codes...
This commit is contained in:
parent
89ff8aa744
commit
30ab8ae954
342 changed files with 17208 additions and 19633 deletions
70
src/Views/Histories.xaml.cs
Normal file
70
src/Views/Histories.xaml.cs
Normal file
|
@ -0,0 +1,70 @@
|
|||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Navigation;
|
||||
|
||||
namespace SourceGit.Views {
|
||||
|
||||
/// <summary>
|
||||
/// 文件历史
|
||||
/// </summary>
|
||||
public partial class Histories : Window {
|
||||
private string repo = null;
|
||||
private string file = null;
|
||||
|
||||
public Histories(string repo, string file) {
|
||||
this.repo = repo;
|
||||
this.file = file;
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
Task.Run(() => {
|
||||
var commits = new Commands.Commits(repo, $"-n 10000 -- \"{file}\"").Result();
|
||||
Dispatcher.Invoke(() => {
|
||||
loading.IsAnimating = false;
|
||||
loading.Visibility = Visibility.Collapsed;
|
||||
commitList.ItemsSource = commits;
|
||||
commitList.SelectedIndex = 0;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
#region WINDOW_COMMANDS
|
||||
private void Minimize(object sender, RoutedEventArgs e) {
|
||||
SystemCommands.MinimizeWindow(this);
|
||||
}
|
||||
|
||||
private void MaximizeOrRestore(object sender, RoutedEventArgs e) {
|
||||
if (WindowState == WindowState.Normal) {
|
||||
SystemCommands.MaximizeWindow(this);
|
||||
} else {
|
||||
SystemCommands.RestoreWindow(this);
|
||||
}
|
||||
}
|
||||
|
||||
private void Quit(object sender, RoutedEventArgs e) {
|
||||
Close();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region EVENTS
|
||||
private void OnCommitSelectedChanged(object sender, SelectedCellsChangedEventArgs e) {
|
||||
var commit = (sender as DataGrid).SelectedItem as Models.Commit;
|
||||
if (commit == null) return;
|
||||
|
||||
var start = $"{commit.SHA}^";
|
||||
if (commit.Parents.Count == 0) start = "4b825dc642cb6eb9a060e54bf8d69288fbee4904";
|
||||
|
||||
diffViewer.Diff(repo, new Widgets.DiffViewer.Option() {
|
||||
RevisionRange = new string[] { start, commit.SHA },
|
||||
Path = file
|
||||
});
|
||||
}
|
||||
|
||||
private void GotoCommit(object sender, RequestNavigateEventArgs e) {
|
||||
Models.Watcher.Get(repo).NavigateTo(e.Uri.OriginalString);
|
||||
e.Handled = true;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue