protected override void Resize(ResizeDirection direction, Vector vector) { ElementBaseShape element = DesignerItem.Element as ElementBaseShape; if (element != null) { var rect = element.GetRectangle(); var placeholder = new Rect(rect.TopLeft, rect.Size); if ((direction & ResizeDirection.Top) == ResizeDirection.Top) { placeholder.Y += vector.Y; placeholder.Height -= vector.Y; } else if ((direction & ResizeDirection.Bottom) == ResizeDirection.Bottom) placeholder.Height += vector.Y; if ((direction & ResizeDirection.Left) == ResizeDirection.Left) { placeholder.X += vector.X; placeholder.Width -= vector.X; } else if ((direction & ResizeDirection.Right) == ResizeDirection.Right) placeholder.Width += vector.X; double kx = rect.Width == 0 ? 0 : placeholder.Width / rect.Width; double ky = rect.Height == 0 ? 0 : placeholder.Height / rect.Height; _points = new PointCollection(); foreach (var point in element.Points) _points.Add(new Point(placeholder.X + kx * (point.X - rect.X), placeholder.Y + ky * (point.Y - rect.Y))); element.Points = _points; DesignerItem.RefreshPainter(); DesignerCanvas.DesignerChanged(); } }
public static PointCollection Normalize(Point topLeftPoint, PointCollection points, double thickness) { double shift = thickness / 2; var pointCollection = new PointCollection(); foreach (var point in points) pointCollection.Add(new Point(point.X - topLeftPoint.X + shift, point.Y - topLeftPoint.Y + shift)); return pointCollection; }
public override void ResetElement() { base.ResetElement(); ElementBaseShape element = DesignerItem.Element as ElementBaseShape; _points = element == null ? new PointCollection() : element.Points; _transforms = new List<TranslateTransform>(); for (int i = 0; i < _points.Count; i++) _transforms.Add(new TranslateTransform()); }
public static PointCollection Normalize(Rect rectangle, double thickness) { double shift = thickness / 2; var pointCollection = new PointCollection(); pointCollection.Add(new Point(shift, shift)); pointCollection.Add(new Point(rectangle.Width + shift, shift)); pointCollection.Add(new Point(rectangle.Width + shift, rectangle.Height + shift)); pointCollection.Add(new Point(shift, rectangle.Height + shift)); return pointCollection; }