2024-02-05 23:08:37 -08:00
|
|
|
using Avalonia.Controls;
|
|
|
|
using Avalonia.Input;
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
namespace SourceGit.Views
|
|
|
|
{
|
|
|
|
public partial class RevisionCompare : UserControl
|
|
|
|
{
|
|
|
|
public RevisionCompare()
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
InitializeComponent();
|
|
|
|
}
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
private void OnDataGridSelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
|
{
|
|
|
|
if (sender is DataGrid datagrid && datagrid.IsVisible)
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
datagrid.ScrollIntoView(datagrid.SelectedItem, null);
|
|
|
|
}
|
|
|
|
e.Handled = true;
|
|
|
|
}
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
private void OnDataGridContextRequested(object sender, ContextRequestedEventArgs e)
|
|
|
|
{
|
|
|
|
if (sender is DataGrid datagrid && datagrid.SelectedItem != null)
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
var compare = DataContext as ViewModels.RevisionCompare;
|
|
|
|
var menu = compare.CreateChangeContextMenu(datagrid.SelectedItem as Models.Change);
|
2024-05-23 06:24:22 -07:00
|
|
|
datagrid.OpenContextMenu(menu);
|
2024-02-05 23:08:37 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
e.Handled = true;
|
|
|
|
}
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
private void OnTreeViewContextRequested(object sender, ContextRequestedEventArgs e)
|
|
|
|
{
|
|
|
|
if (sender is TreeView view && view.SelectedItem != null)
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
var compare = DataContext as ViewModels.RevisionCompare;
|
|
|
|
var node = view.SelectedItem as ViewModels.FileTreeNode;
|
2024-03-17 18:37:06 -07:00
|
|
|
if (node != null && !node.IsFolder)
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
var menu = compare.CreateChangeContextMenu(node.Backend as Models.Change);
|
2024-05-23 06:24:22 -07:00
|
|
|
view.OpenContextMenu(menu);
|
2024-02-05 23:08:37 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
e.Handled = true;
|
|
|
|
}
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
private void OnPressedSHA(object sender, PointerPressedEventArgs e)
|
|
|
|
{
|
|
|
|
if (sender is TextBlock block)
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
var compare = DataContext as ViewModels.RevisionCompare;
|
|
|
|
compare.NavigateTo(block.Text);
|
|
|
|
}
|
|
|
|
|
|
|
|
e.Handled = true;
|
|
|
|
}
|
|
|
|
}
|
2024-03-31 01:54:29 -07:00
|
|
|
}
|