sourcegit/src/Views/CommitDetail.axaml.cs

42 lines
1.3 KiB
C#
Raw Normal View History

using Avalonia.Controls;
using Avalonia.Interactivity;
namespace SourceGit.Views
{
public partial class CommitDetail : UserControl
{
public CommitDetail()
{
InitializeComponent();
}
private void OnChangeListContextRequested(object sender, ContextRequestedEventArgs e)
{
if (DataContext is ViewModels.CommitDetail vm && sender is ChangeCollectionView view)
{
var selected = view.SelectedChanges;
if (selected != null && selected.Count == 1)
{
var menu = vm.CreateChangeContextMenu(selected[0]);
view.OpenContextMenu(menu);
}
}
e.Handled = true;
}
private void OnChangeDoubleTapped(object sender, RoutedEventArgs e)
{
if (DataContext is ViewModels.CommitDetail vm && sender is ChangeCollectionView view)
{
var selected = view.SelectedChanges;
if (selected != null && selected.Count == 1)
{
vm.ActivePageIndex = 1;
vm.SelectedChanges = new() { selected[0] };
}
}
e.Handled = true;
}
}
}