Пример #1
0
        public static void PositionPoint(UIElement renderedGeometry, Point point, IStyle style, IViewport viewport)
        {
            var matrix = XamlMedia.Matrix.Identity;

            if (style is SymbolStyle)
            {
                matrix = CreatePointSymbolMatrix(viewport.Resolution, style as SymbolStyle);
            }
            else
            {
                MatrixHelper.ScaleAt(ref matrix, viewport.Resolution, viewport.Resolution);
            }
            MatrixHelper.Append(ref matrix, CreateTransformMatrix(point, viewport));
            renderedGeometry.RenderTransform = new XamlMedia.MatrixTransform {
                Matrix = matrix
            };
        }
Пример #2
0
        private static XamlMedia.Matrix CreateTransformMatrix1(IViewport viewport)
        {
            var matrix     = XamlMedia.Matrix.Identity;
            var mapCenterX = viewport.Width * 0.5;
            var mapCenterY = viewport.Height * 0.5;

            MatrixHelper.Translate(ref matrix, mapCenterX - viewport.Center.X, mapCenterY - viewport.Center.Y);
            if (viewport.IsRotated)
            {
                MatrixHelper.RotateAt(ref matrix, -viewport.Rotation);
            }
            MatrixHelper.ScaleAt(ref matrix, 1 / viewport.Resolution, 1 / viewport.Resolution, mapCenterX, mapCenterY);

            // This will invert the Y axis, but will also put images upside down
            MatrixHelper.InvertY(ref matrix, mapCenterY);
            return(matrix);
        }
Пример #3
0
        public static void PositionPoint(UIElement renderedGeometry, Point point, IStyle style, IViewport viewport)
        {
            var matrix      = XamlMedia.Matrix.Identity;
            var symbolStyle = style as SymbolStyle;

            if (symbolStyle != null)
            {
                matrix = CreatePointSymbolMatrix(viewport.Resolution, viewport.Rotation, symbolStyle, renderedGeometry.RenderSize.Width, renderedGeometry.RenderSize.Height);
            }
            else
            {
                MatrixHelper.ScaleAt(ref matrix, viewport.Resolution, viewport.Resolution);
            }
            MatrixHelper.Append(ref matrix, GeometryRenderer.CreateTransformMatrix(point, viewport));
            renderedGeometry.RenderTransform = new XamlMedia.MatrixTransform {
                Matrix = matrix
            };
        }
Пример #4
0
        public static XamlMedia.Matrix CreateTransformMatrix(IViewport viewport, Point point)
        {
            var pointOffsetFromViewPortCenterX = point.X - viewport.Center.X;
            var pointOffsetFromViewPortCenterY = point.Y - viewport.Center.Y;
            var mapCenterX = viewport.Width * 0.5;
            var mapCenterY = viewport.Height * 0.5;

            var matrix = XamlMedia.Matrix.Identity;

            MatrixHelper.Translate(ref matrix, pointOffsetFromViewPortCenterX, pointOffsetFromViewPortCenterY);
            if (viewport.IsRotated)
            {
                MatrixHelper.Rotate(ref matrix, -viewport.Rotation);
            }
            MatrixHelper.Translate(ref matrix, mapCenterX, mapCenterY);
            MatrixHelper.ScaleAt(ref matrix, 1 / viewport.Resolution, 1 / viewport.Resolution, mapCenterX, mapCenterY);
            MatrixHelper.InvertY(ref matrix, mapCenterY); // To invert Y axis, but also puts images upside down
            return(matrix);
        }
Пример #5
0
        public static XamlShapes.Shape RenderPoint(Point point, IStyle style, IViewport viewport,
                                                   SymbolCache symbolCache)
        {
            XamlShapes.Shape symbol;
            var matrix = XamlMedia.Matrix.Identity;

            var symbolStyle = style as SymbolStyle;

            if (symbolStyle != null)
            {
                if (symbolStyle.BitmapId < 0)
                {
                    symbol = CreateSymbolFromVectorStyle(symbolStyle, symbolStyle.Opacity, symbolStyle.SymbolType, symbolCache, (float)viewport.Rotation);
                }
                else
                {
                    if (symbolStyle.SymbolType == SymbolType.Svg)
                    {
                        symbol = CreateSymbolFromSvg(symbolStyle.BitmapId, symbolStyle.Opacity, symbolCache);
                    }
                    else
                    {
                        symbol = CreateSymbolFromBitmap(symbolStyle.BitmapId, symbolStyle.Opacity, symbolCache);
                    }
                }
                matrix = CreatePointSymbolMatrix(viewport.Resolution, viewport.Rotation, symbolStyle, symbol.Width, symbol.Height);
            }
            else
            {
                symbol = CreateSymbolFromVectorStyle((style as VectorStyle) ?? new VectorStyle(), symbolCache: symbolCache, rotate: (float)viewport.Rotation);
                MatrixHelper.ScaleAt(ref matrix, viewport.Resolution, viewport.Resolution);
            }

            MatrixHelper.Append(ref matrix, GeometryRenderer.CreateTransformMatrix(point, viewport));

            symbol.RenderTransform = new XamlMedia.MatrixTransform {
                Matrix = matrix
            };
            symbol.IsHitTestVisible = false;

            return(symbol);
        }
Пример #6
0
        private static XamlMedia.Matrix CreatePointSymbolMatrix(double resolution, SymbolStyle symbolStyle)
        {
            var matrix = XamlMedia.Matrix.Identity;

            MatrixHelper.InvertY(ref matrix);
            var centerX = symbolStyle.SymbolOffset.X;
            var centerY = symbolStyle.SymbolOffset.Y;

            var scale = symbolStyle.SymbolScale;

            MatrixHelper.Translate(ref matrix, centerX, centerY);
            MatrixHelper.ScaleAt(ref matrix, scale, scale);

            //for point symbols we want the size to be independent from the resolution. We do this by counter scaling first.
            if (symbolStyle.UnitType != UnitType.WorldUnit)
            {
                MatrixHelper.ScaleAt(ref matrix, resolution, resolution);
            }
            MatrixHelper.RotateAt(ref matrix, -symbolStyle.SymbolRotation);

            return(matrix);
        }