2024-02-05 23:08:37 -08:00
|
|
|
using Avalonia.Controls;
|
2024-11-15 22:54:50 -08:00
|
|
|
using Avalonia.Interactivity;
|
|
|
|
using Avalonia.VisualTree;
|
2024-02-05 23:08:37 -08:00
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
namespace SourceGit.Views
|
|
|
|
{
|
|
|
|
public partial class DiffView : UserControl
|
|
|
|
{
|
|
|
|
public DiffView()
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
InitializeComponent();
|
|
|
|
}
|
2024-11-15 22:54:50 -08:00
|
|
|
|
|
|
|
private void OnGotoPrevChange(object _, RoutedEventArgs e)
|
|
|
|
{
|
2024-12-08 01:50:33 -08:00
|
|
|
if (ViewModels.Preference.Instance.EnableChangeBlocks)
|
|
|
|
{
|
|
|
|
if (DataContext is ViewModels.DiffContext diffCtx)
|
|
|
|
diffCtx.PrevChange();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var textDiff = this.FindDescendantOfType<ThemedTextDiffPresenter>();
|
|
|
|
if (textDiff == null)
|
|
|
|
return;
|
2024-11-15 22:54:50 -08:00
|
|
|
|
2024-12-08 01:50:33 -08:00
|
|
|
textDiff.GotoPrevChange();
|
|
|
|
if (textDiff is SingleSideTextDiffPresenter presenter)
|
|
|
|
presenter.ForceSyncScrollOffset();
|
2024-11-15 22:54:50 -08:00
|
|
|
|
2024-12-08 01:50:33 -08:00
|
|
|
e.Handled = true;
|
|
|
|
}
|
2024-11-15 22:54:50 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
private void OnGotoNextChange(object _, RoutedEventArgs e)
|
|
|
|
{
|
2024-12-08 01:50:33 -08:00
|
|
|
if (ViewModels.Preference.Instance.EnableChangeBlocks)
|
|
|
|
{
|
|
|
|
if (DataContext is ViewModels.DiffContext diffCtx)
|
|
|
|
diffCtx.NextChange();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var textDiff = this.FindDescendantOfType<ThemedTextDiffPresenter>();
|
|
|
|
if (textDiff == null)
|
|
|
|
return;
|
2024-11-15 22:54:50 -08:00
|
|
|
|
2024-12-08 01:50:33 -08:00
|
|
|
textDiff.GotoNextChange();
|
|
|
|
if (textDiff is SingleSideTextDiffPresenter presenter)
|
|
|
|
presenter.ForceSyncScrollOffset();
|
2024-11-15 22:54:50 -08:00
|
|
|
|
2024-12-08 01:50:33 -08:00
|
|
|
e.Handled = true;
|
|
|
|
}
|
2024-11-15 22:54:50 -08:00
|
|
|
}
|
2024-02-05 23:08:37 -08:00
|
|
|
}
|
2024-03-31 01:54:29 -07:00
|
|
|
}
|