2024-06-20 02:02:12 -07:00
|
|
|
using Avalonia.Controls;
|
|
|
|
using Avalonia.Input;
|
|
|
|
using Avalonia.Interactivity;
|
|
|
|
|
|
|
|
namespace SourceGit.Views
|
|
|
|
{
|
|
|
|
public partial class InteractiveRebase : ChromelessWindow
|
|
|
|
{
|
|
|
|
public InteractiveRebase()
|
|
|
|
{
|
|
|
|
InitializeComponent();
|
|
|
|
}
|
|
|
|
|
2024-07-14 00:55:15 -07:00
|
|
|
private void BeginMoveWindow(object _, PointerPressedEventArgs e)
|
2024-06-20 02:02:12 -07:00
|
|
|
{
|
|
|
|
BeginMoveDrag(e);
|
|
|
|
}
|
|
|
|
|
2024-07-14 00:55:15 -07:00
|
|
|
private void CloseWindow(object _1, RoutedEventArgs _2)
|
2024-06-20 02:02:12 -07:00
|
|
|
{
|
|
|
|
Close();
|
|
|
|
}
|
|
|
|
|
2024-07-09 21:11:51 -07:00
|
|
|
private void OnMoveItemUp(object sender, RoutedEventArgs e)
|
2024-06-20 02:02:12 -07:00
|
|
|
{
|
|
|
|
if (sender is Control control && DataContext is ViewModels.InteractiveRebase vm)
|
|
|
|
{
|
|
|
|
vm.MoveItemUp(control.DataContext as ViewModels.InteractiveRebaseItem);
|
|
|
|
e.Handled = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void OnMoveItemDown(object sender, RoutedEventArgs e)
|
|
|
|
{
|
|
|
|
if (sender is Control control && DataContext is ViewModels.InteractiveRebase vm)
|
|
|
|
{
|
|
|
|
vm.MoveItemDown(control.DataContext as ViewModels.InteractiveRebaseItem);
|
|
|
|
e.Handled = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-09 21:11:51 -07:00
|
|
|
private void OnDataGridKeyDown(object sender, KeyEventArgs e)
|
2024-06-20 02:02:12 -07:00
|
|
|
{
|
2024-07-14 00:55:15 -07:00
|
|
|
var item = (sender as DataGrid)?.SelectedItem as ViewModels.InteractiveRebaseItem;
|
2024-06-20 02:02:12 -07:00
|
|
|
if (item == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (e.Key == Key.P)
|
|
|
|
item.SetAction(Models.InteractiveRebaseAction.Pick);
|
|
|
|
else if (e.Key == Key.E)
|
|
|
|
item.SetAction(Models.InteractiveRebaseAction.Edit);
|
|
|
|
else if (e.Key == Key.R)
|
|
|
|
item.SetAction(Models.InteractiveRebaseAction.Reword);
|
|
|
|
else if (e.Key == Key.S)
|
|
|
|
item.SetAction(Models.InteractiveRebaseAction.Squash);
|
|
|
|
else if (e.Key == Key.F)
|
|
|
|
item.SetAction(Models.InteractiveRebaseAction.Fixup);
|
|
|
|
else if (e.Key == Key.D)
|
|
|
|
item.SetAction(Models.InteractiveRebaseAction.Drop);
|
|
|
|
}
|
|
|
|
|
2024-07-14 00:55:15 -07:00
|
|
|
private async void StartJobs(object _1, RoutedEventArgs _2)
|
2024-06-20 02:02:12 -07:00
|
|
|
{
|
2024-07-14 00:55:15 -07:00
|
|
|
var vm = DataContext as ViewModels.InteractiveRebase;
|
|
|
|
if (vm == null)
|
|
|
|
return;
|
|
|
|
|
2024-06-20 02:02:12 -07:00
|
|
|
Running.IsVisible = true;
|
|
|
|
Running.IsIndeterminate = true;
|
|
|
|
await vm.Start();
|
|
|
|
Running.IsIndeterminate = false;
|
|
|
|
Running.IsVisible = false;
|
|
|
|
Close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|