2024-02-05 23:08:37 -08:00
|
|
|
using Avalonia.Controls;
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
namespace SourceGit.Views
|
|
|
|
{
|
|
|
|
public partial class CommitChanges : UserControl
|
|
|
|
{
|
|
|
|
public CommitChanges()
|
|
|
|
{
|
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 && datagrid.SelectedItem != null)
|
|
|
|
{
|
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 detail = DataContext as ViewModels.CommitDetail;
|
|
|
|
var menu = detail.CreateChangeContextMenu(datagrid.SelectedItem as Models.Change);
|
|
|
|
menu.Open(datagrid);
|
|
|
|
}
|
|
|
|
|
|
|
|
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 detail = DataContext as ViewModels.CommitDetail;
|
|
|
|
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 = detail.CreateChangeContextMenu(node.Backend as Models.Change);
|
|
|
|
menu.Open(view);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
e.Handled = true;
|
|
|
|
}
|
|
|
|
}
|
2024-03-17 18:37:06 -07:00
|
|
|
}
|