Exemplo n.º 1
0
 protected override Size ArrangeOverride(Size finalSize)
 {
     foreach (UIElement child in Children)
     {
         var finalRect         = new Rect(0.0, 0.0, _ViewportSize.Width, _ViewportSize.Height);
         var positionRectangle = GetPositionRectangle(child);
         if (positionRectangle is object)
         {
             finalRect = MapMath.LocationToViewportPoint(ref _NormalizedMercatorToViewport, positionRectangle);
         }
         else
         {
             var position = GetPosition(child);
             if (position is object && MapMath.TryLocationToViewportPoint(ref _NormalizedMercatorToViewport, position, out var viewportPosition))
             {
                 var positionOrigin = GetPositionOrigin(child);
                 viewportPosition.X -= positionOrigin.X * child.DesiredSize.Width;
                 viewportPosition.Y -= positionOrigin.Y * child.DesiredSize.Height;
                 finalRect           = new Rect(viewportPosition.X, viewportPosition.Y, child.DesiredSize.Width, child.DesiredSize.Height);
             }
         }
         var positionOffset = GetPositionOffset(child);
         finalRect.X += positionOffset.X;
         finalRect.Y += positionOffset.Y;
         child.Arrange(finalRect);
     }
     return(_ViewportSize);
 }
Exemplo n.º 2
0
 protected override Size MeasureOverride(Size availableSize)
 {
     foreach (UIElement child1 in Children)
     {
         var positionRectangle = GetPositionRectangle(child1);
         if (positionRectangle is object)
         {
             var viewportPoint = MapMath.LocationToViewportPoint(ref _NormalizedMercatorToViewport, positionRectangle);
             child1.Measure(new Size(viewportPoint.Width, viewportPoint.Height));
         }
         else
         {
             if (child1 is ContentPresenter && VisualTreeHelper.GetChildrenCount(child1) > 0)
             {
                 if (VisualTreeHelper.GetChild(child1, 0) is IProjectable child2)
                 {
                     child2.SetView(_ViewportSize, _NormalizedMercatorToViewport, _ViewportToNormalizedMercator);
                     (child2 as UIElement)?.InvalidateMeasure();
                 }
             }
             (child1 as IProjectable)?.SetView(_ViewportSize, _NormalizedMercatorToViewport, _ViewportToNormalizedMercator);
             child1.Measure(_ViewportSize);
         }
     }
     return(_ViewportSize);
 }