@@ -466,27 +466,24 @@ private void CreateModuloExpression(ScrollViewer scrollViewer, double imageWidth
466
466
expressionX . SetReferenceParameter ( pParam , propertySetModulo ) ;
467
467
expressionY . SetReferenceParameter ( pParam , propertySetModulo ) ;
468
468
469
+ string Thing ( string common , string diemtion )
470
+ => string . Format (
471
+ "{0} == 0 " +
472
+ "? 0 " +
473
+ ": {0} < 0 " +
474
+ "? -(Abs({0} - (Ceil({0} / {1}) * {1})) % {1}) " +
475
+ ": -({1} - ({0} % {1}))" ,
476
+ common ,
477
+ diemtion ) ;
478
+
469
479
string expressionXVal ;
470
480
string expressionYVal ;
471
481
if ( scrollViewer == null )
472
482
{
473
- var xCommon = "Ceil(" + offsetXParam + ")" ;
474
- var yCommon = "Ceil(" + offsetYParam + ")" ;
475
-
476
483
// expressions are created to simulate a positive and negative modulo with the size of the image and the offset
477
- expressionXVal =
478
- $ "{ xCommon } == 0 " +
479
- $ "? 0 " +
480
- $ ": { xCommon } < 0 " +
481
- $ "? -(Abs({ xCommon } - (Ceil({ xCommon } / { imageWidthParam } ) * { imageWidthParam } )) % { imageWidthParam } ) " +
482
- $ ": -({ imageWidthParam } - ({ xCommon } % { imageWidthParam } ))";
483
-
484
- expressionYVal =
485
- $ "{ yCommon } == 0 " +
486
- $ "? 0 " +
487
- $ ": { yCommon } < 0 " +
488
- $ "? -(Abs({ yCommon } - (Ceil({ yCommon } / { imageHeightParam } ) * { imageHeightParam } )) % { imageHeightParam } ) " +
489
- $ ": -({ imageHeightParam } - ({ yCommon } % { imageHeightParam } ))";
484
+ expressionXVal = Thing ( "Ceil(" + offsetXParam + ")" , imageHeightParam ) ;
485
+
486
+ expressionYVal = Thing ( "Ceil(" + offsetYParam + ")" , imageWidthParam ) ;
490
487
}
491
488
else
492
489
{
@@ -495,21 +492,12 @@ private void CreateModuloExpression(ScrollViewer scrollViewer, double imageWidth
495
492
expressionX . SetReferenceParameter ( "s" , scrollProperties ) ;
496
493
expressionY . SetReferenceParameter ( "s" , scrollProperties ) ;
497
494
498
- var xCommon = $ "Ceil((s.Translation.X * { speedParam } ) + { offsetXParam } )";
499
- expressionXVal =
500
- $ "{ xCommon } == 0 " +
501
- "? 0 " +
502
- $ ": { xCommon } < 0 " +
503
- $ "? -(Abs({ xCommon } - (Ceil({ xCommon } / { imageWidthParam } ) * { imageWidthParam } )) % { imageWidthParam } ) " +
504
- $ ": -({ imageWidthParam } - ({ xCommon } % { imageWidthParam } ))";
495
+ string LocalThing ( string scroll , string speed , string offset , string dimention )
496
+ => Thing ( string . Format ( "Ceil(({0} * {1}) + {2})" , scroll , speed , offset ) , dimention ) ;
505
497
506
- var yCommon = $ "Ceil((s.Translation.Y * { speedParam } ) + { offsetYParam } )";
507
- expressionYVal =
508
- $ "{ yCommon } == 0 " +
509
- "? 0 " +
510
- $ ": { yCommon } < 0 " +
511
- $ "? -(Abs({ yCommon } - (Ceil({ yCommon } / { imageHeightParam } ) * { imageHeightParam } )) % { imageHeightParam } ) " +
512
- $ ": -({ imageHeightParam } - ({ yCommon } % { imageHeightParam } ))";
498
+ expressionXVal = LocalThing ( "s.Translation.X" , speedParam , offsetXParam , imageWidthParam ) ;
499
+
500
+ expressionYVal = LocalThing ( "s.Translation.Y" , speedParam , offsetYParam , imageHeightParam ) ;
513
501
}
514
502
515
503
if ( scrollOrientation == ScrollOrientation . Horizontal || scrollOrientation == ScrollOrientation . Both )
0 commit comments