mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-24 21:54:59 +00:00
parent
65a9406c9a
commit
9aba737d9e
5 changed files with 206 additions and 20 deletions
|
@ -1,6 +1,9 @@
|
|||
using System.Collections.Generic;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Platform.Storage;
|
||||
using SourceGit.Models;
|
||||
|
||||
namespace SourceGit.Views
|
||||
{
|
||||
|
@ -38,5 +41,46 @@ namespace SourceGit.Views
|
|||
NotifyDonePanel.IsVisible = false;
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void OnRowSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (DataContext is ViewModels.FileHistories vm && sender is ListBox { SelectedItems: IList<object> commits })
|
||||
{
|
||||
var selectedCommits = new List<Models.Commit>();
|
||||
foreach (var commit in commits)
|
||||
{
|
||||
if (commit is Models.Commit modelCommit)
|
||||
{
|
||||
selectedCommits.Add(modelCommit);
|
||||
}
|
||||
}
|
||||
vm.SelectedCommits = selectedCommits;
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private async void OnSaveAsPatch(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var topLevel = TopLevel.GetTopLevel(this);
|
||||
if (topLevel == null)
|
||||
return;
|
||||
|
||||
var vm = DataContext as ViewModels.FileHistories;
|
||||
if (vm == null)
|
||||
return;
|
||||
|
||||
var options = new FilePickerSaveOptions();
|
||||
options.Title = App.Text("FileCM.SaveAsPatch");
|
||||
options.DefaultExtension = ".patch";
|
||||
options.FileTypeChoices = [new FilePickerFileType("Patch File") { Patterns = ["*.patch"] }];
|
||||
|
||||
var storageFile = await topLevel.StorageProvider.SaveFilePickerAsync(options);
|
||||
if (storageFile != null)
|
||||
await vm.SaveAsPatch(storageFile.Path.LocalPath);
|
||||
NotifyDonePanel.IsVisible = true;
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue