@@ -1334,6 +1334,8 @@ static TextDiffViewMinimap()
1334
1334
1335
1335
public override void Render ( DrawingContext context )
1336
1336
{
1337
+ context . DrawRectangle ( Brushes . Transparent , null , new Rect ( 0 , 0 , Bounds . Width , Bounds . Height ) ) ;
1338
+
1337
1339
var total = 0 ;
1338
1340
if ( DataContext is ViewModels . TwoSideTextDiff twoSideDiff )
1339
1341
{
@@ -1371,6 +1373,42 @@ protected override void OnDataContextChanged(EventArgs e)
1371
1373
InvalidateVisual ( ) ;
1372
1374
}
1373
1375
1376
+ protected override void OnPointerPressed ( PointerPressedEventArgs e )
1377
+ {
1378
+ base . OnPointerPressed ( e ) ;
1379
+
1380
+ var range = DisplayRange ;
1381
+ if ( range == null || range . End == 0 )
1382
+ return ;
1383
+
1384
+ var total = 0 ;
1385
+ if ( DataContext is ViewModels . TwoSideTextDiff twoSideDiff )
1386
+ {
1387
+ var halfWidth = Bounds . Width * 0.5 ;
1388
+ total = Math . Max ( twoSideDiff . Old . Count , twoSideDiff . New . Count ) ;
1389
+ }
1390
+ else if ( DataContext is ViewModels . CombinedTextDiff combined )
1391
+ {
1392
+ var data = combined . Data ;
1393
+ total = data . Lines . Count ;
1394
+ }
1395
+ else
1396
+ {
1397
+ return ;
1398
+ }
1399
+
1400
+ var height = Bounds . Height ;
1401
+ var startY = range . Start / ( total * 1.0 ) * height ;
1402
+ var endY = range . End / ( total * 1.0 ) * height ;
1403
+ var pressedY = e . GetPosition ( this ) . Y ;
1404
+ if ( pressedY >= startY && pressedY <= endY )
1405
+ return ;
1406
+
1407
+ var line = Math . Max ( 1 , Math . Min ( total , ( int ) Math . Ceiling ( pressedY * total / height ) ) ) ;
1408
+ this . FindAncestorOfType < TextDiffView > ( ) ? . ScrollToLine ( line ) ;
1409
+ e . Handled = true ;
1410
+ }
1411
+
1374
1412
private void RenderSingleSide ( DrawingContext context , List < Models . TextDiffLine > lines , double x , double width )
1375
1413
{
1376
1414
var total = lines . Count ;
@@ -1414,11 +1452,17 @@ public ViewModels.TextDiffSelectedChunk SelectedChunk
1414
1452
get => GetValue ( SelectedChunkProperty ) ;
1415
1453
set => SetValue ( SelectedChunkProperty , value ) ;
1416
1454
}
1455
+
1417
1456
public TextDiffView ( )
1418
1457
{
1419
1458
InitializeComponent ( ) ;
1420
1459
}
1421
1460
1461
+ public void ScrollToLine ( int line )
1462
+ {
1463
+ this . FindDescendantOfType < ThemedTextDiffPresenter > ( ) ? . ScrollToLine ( line ) ;
1464
+ }
1465
+
1422
1466
protected override void OnPropertyChanged ( AvaloniaPropertyChangedEventArgs change )
1423
1467
{
1424
1468
base . OnPropertyChanged ( change ) ;
0 commit comments