Example #1
0
        public override void ToWorldSpace(ViewPort vp)
        {
            if (worldPoints == null)
            {
                worldPoints = new List <Point>();
            }
            else
            {
                worldPoints.Clear();
            }

            for (int i = 0; i < points.Count; i++)
            {
                var point = new Point((points[i].X - vp.StartPoint.X) * vp.Scale,
                                      (points[i].Y - vp.StartPoint.Y) * vp.Scale);
                worldPoints.Add(point);
            }
        }
Example #2
0
        override public void Draw(DrawingContext drawingContext, ViewPort vp)
        {
            var geometry = new StreamGeometry();

            using (StreamGeometryContext ctx = geometry.Open())
            {
                ctx.BeginFigure(worldPoints[0], true, false);
                foreach (var point in worldPoints)
                {
                    ctx.LineTo(point, true, true);
                }
            }

            var center = new Point(geometry.Bounds.X + geometry.Bounds.Width / 2, geometry.Bounds.Y + geometry.Bounds.Height / 2);

            drawingContext.PushTransform(new RotateTransform(rotationAngle, center.X, center.Y));
            drawingContext.PushTransform(new ScaleTransform(scale, scale, center.X, center.Y));
            drawingContext.PushTransform(new TranslateTransform(offsetX, offsetY));
            drawingContext.DrawGeometry(brush, p, geometry);
        }
Example #3
0
 public override void MouseRightUpHandler(ViewPort vp, Point point)
 {
     StartPoint = point;
     if (vp.Scale > 0.1)
     {
         double NewWidth  = (vp.EndPoint.X - vp.StartPoint.X) * 2;
         double NewHeight = (vp.EndPoint.Y - vp.StartPoint.Y) * 2;
         vp.StartPoint = new Point()
         {
             X = StartPoint.X / vp.Scale + vp.StartPoint.X - NewWidth / 2,
             Y = StartPoint.Y / vp.Scale + vp.StartPoint.Y - NewHeight / 2
         };
         vp.EndPoint = new Point()
         {
             X = vp.StartPoint.X + NewWidth,
             Y = vp.StartPoint.Y + NewHeight
         };
         vp.Scale /= 2;
     }
 }
Example #4
0
        public override void MouseUpHandler(ViewPort vp)
        {
            currentState = States.initial;
            PaintController.figures.RemoveLast();
            if (vp.Scale > 50)
            {
                return;
            }

            if (Point.Subtract(StartPoint, EndPoint).Length > 2)
            {
                double scaleX = (vp.EndPoint.X - vp.StartPoint.X) / (EndPoint.X - StartPoint.X);
                double scaleY = (vp.EndPoint.Y - vp.StartPoint.Y) / (EndPoint.Y - StartPoint.Y);
                double scale  = (scaleX + scaleY) / 2;

                vp.Scale     *= scale;
                vp.StartPoint = StartPoint;
                vp.EndPoint   = EndPoint;
            }
            else
            {
                double NewWidth  = (vp.EndPoint.X - vp.StartPoint.X) / 2;
                double NewHeight = (vp.EndPoint.Y - vp.StartPoint.Y) / 2;
                vp.StartPoint = new Point()
                {
                    X = StartPoint.X - NewWidth / 2,
                    Y = StartPoint.Y - NewHeight / 2
                };
                vp.EndPoint = new Point()
                {
                    X = vp.StartPoint.X + NewWidth,
                    Y = vp.StartPoint.Y + NewHeight
                };
                vp.Scale *= 2;
            }
        }
Example #5
0
 public virtual void EditSize(Point point, ViewPort vp)
 {
     point       = ToLocalSpace(point, vp);
     secondPoint = point;
 }
Example #6
0
 public Point ToLocalSpace(Point point, ViewPort vp) => new Point(point.X / vp.Scale + vp.StartPoint.X, point.Y / vp.Scale + vp.StartPoint.Y);
Example #7
0
 public abstract void Draw(DrawingContext drawingContext, ViewPort vp);
Example #8
0
 public override void MouseDownHandler(Point point1, ViewPort vp)
 {
     StartPoint   = point1;
     currentState = States.mouseClick;
 }
Example #9
0
 override abstract public void Draw(DrawingContext drawingContext, ViewPort vp);
Example #10
0
 public override void EditSize(Point point, ViewPort vp)
 {
     point = ToLocalSpace(point, vp);
     points.Add(point);
 }
Example #11
0
 public virtual void MouseRightUpHandler(ViewPort vp, Point point)
 {
 }
Example #12
0
 public virtual void MouseUpHandler(ViewPort vp)
 {
     currentState = States.initial;
 }
Example #13
0
 public abstract void MouseMoveHandler(Point secondPoint, ViewPort vp);
Example #14
0
 public abstract void MouseDownHandler(Point firstPoint, ViewPort vp);