Skip to content

Commit c9b46c0

Browse files
committed
simplified constants
1 parent 687137d commit c9b46c0

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

Microsoft.Toolkit.Uwp.UI.Controls/TileControl/TileControl.cs

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -438,12 +438,12 @@ private async Task CreateModuloExpression(ScrollViewer scrollViewer = null)
438438
/// <param name="scrollOrientation">The ScrollOrientation</param>
439439
private void CreateModuloExpression(ScrollViewer scrollViewer, double imageWidth, double imageHeight, ScrollOrientation scrollOrientation)
440440
{
441-
const string pParam = "p";
442-
const string offsetXParam = pParam + ".offsetX";
443-
const string offsetYParam = pParam + ".offsetY";
444-
const string imageWidthParam = pParam + ".imageWidth";
445-
const string imageHeightParam = pParam + ".imageHeight";
446-
const string speedParam = pParam + ".speed";
441+
const string propSetParam = "p";
442+
const string offsetXParam = "offsetX";
443+
const string offsetYParam = "offsetY";
444+
const string imageWidthParam = "imageWidth";
445+
const string imageHeightParam = "imageHeight";
446+
const string speedParam = "speed";
447447

448448
if (_containerVisual == null)
449449
{
@@ -457,14 +457,14 @@ private void CreateModuloExpression(ScrollViewer scrollViewer, double imageWidth
457457
var expressionY = compositor.CreateExpressionAnimation();
458458

459459
var propertySetModulo = compositor.CreatePropertySet();
460-
propertySetModulo.InsertScalar("imageHeight", (float)imageWidth);
461-
propertySetModulo.InsertScalar("offsetX", (float)OffsetX);
462-
propertySetModulo.InsertScalar("imageWidth", (float)imageHeight);
463-
propertySetModulo.InsertScalar("offsetY", (float)OffsetY);
464-
propertySetModulo.InsertScalar("speed", (float)ParallaxSpeedRatio);
460+
propertySetModulo.InsertScalar(imageHeightParam, (float)imageWidth);
461+
propertySetModulo.InsertScalar(offsetXParam, (float)OffsetX);
462+
propertySetModulo.InsertScalar(imageWidthParam, (float)imageHeight);
463+
propertySetModulo.InsertScalar(offsetYParam, (float)OffsetY);
464+
propertySetModulo.InsertScalar(speedParam, (float)ParallaxSpeedRatio);
465465

466-
expressionX.SetReferenceParameter(pParam, propertySetModulo);
467-
expressionY.SetReferenceParameter(pParam, propertySetModulo);
466+
expressionX.SetReferenceParameter(propSetParam, propertySetModulo);
467+
expressionY.SetReferenceParameter(propSetParam, propertySetModulo);
468468

469469
string Thing(string common, string diemtion)
470470
=> string.Format(
@@ -481,23 +481,24 @@ string Thing(string common, string diemtion)
481481
if (scrollViewer == null)
482482
{
483483
// expressions are created to simulate a positive and negative modulo with the size of the image and the offset
484-
expressionXVal = Thing("Ceil(" + offsetXParam + ")", imageHeightParam);
484+
expressionXVal = Thing("Ceil(" + propSetParam + "." + offsetXParam + ")", propSetParam + "." + imageHeightParam);
485485

486-
expressionYVal = Thing("Ceil(" + offsetYParam + ")", imageWidthParam);
486+
expressionYVal = Thing("Ceil(" + propSetParam + "." + offsetYParam + ")", propSetParam + "." + imageWidthParam);
487487
}
488488
else
489489
{
490490
// expressions are created to simulate a positive and negative modulo with the size of the image and the offset and the ScrollViewer offset (Translation)
491491
var scrollProperties = ElementCompositionPreview.GetScrollViewerManipulationPropertySet(scrollViewer);
492-
expressionX.SetReferenceParameter("s", scrollProperties);
493-
expressionY.SetReferenceParameter("s", scrollProperties);
492+
const string scrollParam = "s";
493+
expressionX.SetReferenceParameter(scrollParam, scrollProperties);
494+
expressionY.SetReferenceParameter(scrollParam, scrollProperties);
494495

495496
string LocalThing(string scroll, string speed, string offset, string dimention)
496497
=> Thing(string.Format("Ceil(({0} * {1}) + {2})", scroll, speed, offset), dimention);
497498

498-
expressionXVal = LocalThing("s.Translation.X", speedParam, offsetXParam, imageWidthParam);
499+
expressionXVal = LocalThing(scrollParam + ".Translation.X", propSetParam + "." + speedParam, propSetParam + "." + offsetXParam, propSetParam + "." + imageWidthParam);
499500

500-
expressionYVal = LocalThing("s.Translation.Y", speedParam, offsetYParam, imageHeightParam);
501+
expressionYVal = LocalThing(scrollParam + ".Translation.Y", propSetParam + "." + speedParam, propSetParam + "." + offsetYParam, propSetParam + "." + imageHeightParam);
501502
}
502503

503504
if (scrollOrientation == ScrollOrientation.Horizontal || scrollOrientation == ScrollOrientation.Both)

0 commit comments

Comments
 (0)