/// <summary>
        /// Generates the points and segments of the arrow Figure object.
        /// </summary>
        protected override void BuildFiguresOverride()
        {
            double headLength = _formatRatio * _headLengthRatio;
            double bodyLength = _formatRatio - headLength;
            double bodyHeight = _headWidthRatio != 0.0 ? 1.0 / _headWidthRatio : 1.0;
            double bodyTop    = 0.5 - bodyHeight / 2;
            double bodyBottom = 0.5 + bodyHeight / 2;

            _points.Clear();
            _points.Add(new Point(0.0, bodyTop));
            _points.Add(new Point(0.0, bodyBottom));
            _points.Add(new Point(bodyLength, bodyBottom));
            _points.Add(new Point(bodyLength, 1.0));
            _points.Add(new Point(_formatRatio, 0.5));
            _points.Add(new Point(bodyLength, 0.0));
            _points.Add(new Point(bodyLength, bodyTop));

            bool           scaling   = false;
            ScaleTransform transform = new ScaleTransform();

            if (!Double.IsNaN(Width))
            {
                transform.ScaleX = _formatRatio != 0.0 ? (Width - 2 * StrokeThickness) / _formatRatio : 1.0;
                scaling          = true;
            }
            if (!Double.IsNaN(Height))
            {
                transform.ScaleY = Height - 2 * StrokeThickness;
                scaling          = true;
            }

            _figure.Segments.Clear();
            if (scaling)
            {
                _points[0] = transform.Transform(_points[0]);
            }
            _figure.StartPoint = _points[0];
            for (int i = 0; i < _points.Count; i++)
            {
                if (i < _points.Count - 1)
                {
                    if (scaling)
                    {
                        _points[i + 1] = transform.Transform(_points[i + 1]);
                    }
                    LineSegment segment = new LineSegment();
                    segment.Point = _points[i + 1];
                    _figure.Segments.Add(segment);
                }
            }
            Figures.Add(_figure);
        }
示例#2
0
        public override bool Display()
        {
            if (Lifetime <= 0)
            {
                return(false);
            }

            Transform       translate = new TranslateTransform(OffsetX, OffsetY);
            Polyline        pl        = (Polyline)Geometry;
            PointCollection p         = new PointCollection();

            foreach (Point vert in pl.Points)
            {
                p.Add(translate.Transform(vert));
            }
            pl.Points = p;

            Transform scale = new ScaleTransform(.998, .998, Center.X, Center.Y);

            p = new PointCollection();
            foreach (Point vert in pl.Points)
            {
                p.Add(scale.Transform(vert));
            }
            pl.Points = p;

            OffsetX -= .002;

            Lifetime--;
            return(true);
        }
示例#3
0
        public static void ScaleGeom(ref IGeom geom, double scaleX, double scaleY, Point refer)
        {
            Matrix mx = new ScaleTransform(scaleX, scaleY, refer.X, refer.Y).Value;

            Point[] pots = geom.ToPoints();
            mx.Transform(pots);
            geom.SetByPoints(pots);
        }
示例#4
0
        /// <summary>
        /// transforming mouse position invers to transformation of image object
        /// </summary>
        /// <param name="mousePos">initial position to be transformed</param>
        /// <returns>transformed position</returns>
        private Point transformMouse(Point mousePos)
        {
            var rt = new RotateTransform(-90, image.ActualWidth / 2.0, image.ActualHeight / 2.0);
            var st = new ScaleTransform(-1, 1, image.ActualWidth / 2.0, image.ActualHeight / 2.0);

            mousePos = st.Transform(mousePos);
            mousePos = rt.Transform(mousePos);
            return(mousePos);
        }
示例#5
0
        public static Point[] Scale(this Point[] points, double scale)
        {
            ScaleTransform?scaleTransform = new ScaleTransform(scale, scale);
            List <Point>?  result         = new List <Point>();

            foreach (Point point in points)
            {
                result.Add(scaleTransform.Transform(point));
            }
            return(result.ToArray());
        }
        public System.Windows.Point Transform(Navigation.Point point)
        {
            float minX = _corner1.X;
            float minY = _corner1.Y;
            float maxX = _corner2.X;
            float maxY = _corner2.Y;

            var transform = new TranslateTransform(0 - minX, 0 - minY);
            var scale     = new ScaleTransform((_actualWidth - 10) / Math.Abs(maxX - minX), (_actualHeight - 50) / Math.Abs(maxY - minY));

            return(scale.Transform(transform.Transform(
                                       new System.Windows.Point(point.X, -1 * point.Y))));
        }
示例#7
0
        private void Scale(double scaleX, double scaleY, double centerX, double centerY)
        {
            //Adjust for the zoom level.
            var t = new ScaleTransform(scaleX, scaleY, centerX, centerY);

            foreach (var previewPixel in PropPixels)
            {
                var point = t.Transform(new Point(previewPixel.Location.X, previewPixel.Location.Y));
                previewPixel.Location = point;
            }

            Layout();
        }
示例#8
0
        void UpdateMarkersOffset()
        {
            if (MapCanvas != null)
            {
                if (MapScaleTransform != null)
                {
                    var tp = MapScaleTransform.Transform(new System.Windows.Point(Core.renderOffset.X, Core.renderOffset.Y));
                    MapOverlayTranslateTransform.X = tp.X;
                    MapOverlayTranslateTransform.Y = tp.Y;

                    // map is scaled already
                    MapTranslateTransform.X = Core.renderOffset.X;
                    MapTranslateTransform.Y = Core.renderOffset.Y;
                }
                else
                {
                    MapTranslateTransform.X = Core.renderOffset.X;
                    MapTranslateTransform.Y = Core.renderOffset.Y;

                    MapOverlayTranslateTransform.X = MapTranslateTransform.X;
                    MapOverlayTranslateTransform.Y = MapTranslateTransform.Y;
                }
            }
        }
示例#9
0
        private void ZoomAdd(Point p)
        {
            // Point nowp = transform.Transform(p);
            transform.ScaleX   *= 1.1;
            transform.ScaleY   *= 1.1;
            ink.LayoutTransform = transform;
            var v = new Vector(scrollViewer.HorizontalOffset, scrollViewer.VerticalOffset);

            Point point     = p + v;
            Point newCenter = _transform.Transform(point);
            var   newp      = newCenter - v;

            scrollViewer.ScrollToHorizontalOffset(scrollViewer.HorizontalOffset + newp.X - p.X);
            scrollViewer.ScrollToVerticalOffset(scrollViewer.VerticalOffset + newp.Y - p.Y);
        }
示例#10
0
        /// <summary>
        /// Arranges the override.
        /// </summary>
        /// <param name="arrangeSize">Size of the arrange.</param>
        /// <returns>Size.</returns>
        /// <inheritdoc />
        protected override Size ArrangeOverride(Size arrangeSize)
        {
            foreach (FrameworkElement child in Children)
            {
                child.RenderTransform = _scale;

                var position = GetPosition(child);
                position = _scale.Transform(position);

                position.X += Shift.X;
                position.Y += Shift.Y;

                child.Arrange(new Rect(position, child.DesiredSize));
            }
            return(arrangeSize);
        }
示例#11
0
        /// <summary>
        /// Calculate actual layout Rect of Rectangle relative to Viewbox.
        /// </summary>
        /// <param name="vb">Containing Viewbox.</param>
        /// <param name="r">Contained Rectangle.</param>
        /// <returns>Actual layout Rect of contained Rectangle relative to containing Viewbox.</returns>
        private static Rect CalculateActualLayout(Viewbox vb, Rectangle r)
        {
            Assert.AreEqual(VisualTreeHelper.GetChildrenCount(vb), 1, "Viewbox template changed!");
            Assert.IsInstanceOfType(VisualTreeHelper.GetChild(vb, 0), typeof(ContentPresenter), "Viewbox template changed!");

            ContentPresenter container = VisualTreeHelper.GetChild(vb, 0) as ContentPresenter;
            ScaleTransform   scale     = container.RenderTransform as ScaleTransform;

            Assert.IsNotNull(scale, "Viewbox implementation changed!");

            Point offset = r.TransformToVisual(vb).Transform(new Point(0, 0));

            offset = scale.Transform(offset);
            Rect actual = new Rect(offset.X, offset.Y, r.ActualWidth * scale.ScaleX, r.ActualHeight * scale.ScaleY);

            return(actual);
        }
示例#12
0
        public void BranchLabelToMouse(BranchLabelModel branch, Point mouse)
        {
            Vector mouseRelativeToGraph = new Vector(mouse.X, mouse.Y) - new Vector(Position.X, Position.Y);
            Matrix mat = ZoomAndPanCanvasModel.TransformMatrix;
            Matrix inv = mat;

            inv.Invert();
            Point          loc   = branch.Location;
            Point          tloc  = mat.Transform(NodeTransform.Transform(loc));
            Point          diff  = new Point(mouseRelativeToGraph.X - tloc.X, mouseRelativeToGraph.Y - tloc.Y);
            ScaleTransform scale = new ScaleTransform(inv.M11, inv.M22);

            diff = scale.Transform(diff);
            Matrix m = NodeTransform.Matrix;

            m.Translate(diff.X, diff.Y);
            NodeTransform.Matrix = m;
        }
示例#13
0
        public override bool Display()
        {
            if (Lifetime <= 0)
            {
                return(false);
            }
            Transform       scale = new ScaleTransform(.91, .91, Center.X, Center.Y);
            Polyline        pl    = (Polyline)Geometry;
            PointCollection p     = new PointCollection();

            foreach (Point vert in pl.Points)
            {
                p.Add(scale.Transform(vert));
            }
            pl.Points = p;
            Geometry  = pl;
            Lifetime--;
            return(true);
        }
示例#14
0
 public static Point Transform(double latdec, double londec)
 {
     return(ScaleTransform.Transform(TranslateTransform.Transform(new Point(londec, -LatitudeToY(latdec)))));
 }