Пример #1
0
        ////////////////////////////////////////////////////////////////////////////////////////////
        private void PerformRotate(double angle, Point?rotatePoint = null)
        {
            // Obtain the current map transformation
            Matrix transformMatrix = Map.RenderTransform.Value;

            // Rotate the map by the given angle around the specified position
            rotatePoint = rotatePoint ?? MapContainer.TransformToVisual(Map).Transform(new Point(MapContainer.ActualWidth / 2, MapContainer.ActualHeight / 2));
            transformMatrix.RotateAtPrepend(angle, rotatePoint.Value.X, rotatePoint.Value.Y);

            // Update the transform for the map
            Map.RenderTransform = new MatrixTransform(transformMatrix);

            TextRotateTransform.Angle -= angle;
            NotifyPropertyChanged(nameof(TextRotateTransform));
        }
Пример #2
0
        ////////////////////////////////////////////////////////////////////////////////////////////
        private void PerformZoom(double scaleFactor, Point?zoomPoint = null)
        {
            // Obtain the current map transformation
            Matrix transformMatrix = Map.RenderTransform.Value;

            // Limit the scale to a specified maximum and minimum value
            double currentScale = Math.Sqrt((transformMatrix.M11 * transformMatrix.M11) + (transformMatrix.M12 * transformMatrix.M12));

            if (((scaleFactor > 1.0) && (currentScale >= _maxZoom)) || ((scaleFactor < 1.0) && (currentScale <= _minZoom)))
            {
                return;
            }

            // Scale the map transformation by the given factor at the specified position
            zoomPoint = zoomPoint ?? MapContainer.TransformToVisual(Map).Transform(new Point(MapContainer.ActualWidth / 2, MapContainer.ActualHeight / 2));
            transformMatrix.ScaleAtPrepend(scaleFactor, scaleFactor, zoomPoint.Value.X, zoomPoint.Value.Y);

            // Update the transform for the map
            Map.RenderTransform = new MatrixTransform(transformMatrix);
            UpdateResizeControlTransforms();
        }