/// <summary> /// /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="width"></param> /// <param name="height"></param> public EllipseElement(double x, double y, double width, double height) : base() { KeyPointAmount = 2; this.ElementCursor = RectElement.ElementDefaultCursor; this.leftTopPoint = new TractionPoint(this); this.leftBottomPoint = new TractionPoint(this); this.rightTopPoint = new TractionPoint(this); this.rightBottomPoint = new TractionPoint(this); keyPoint1 = new KeyPoint(0, 0, this); keyPoint2 = new KeyPoint(0, 0, this); keyPoint1.TractionPoint = leftTopPoint; keyPoint2.TractionPoint = rightBottomPoint; keyPointList.Add(keyPoint1); keyPointList.Add(keyPoint2); this.leftTopPoint.ElementCursor = Cursors.SizeNWSE; this.leftBottomPoint.ElementCursor = Cursors.SizeNESW; this.rightBottomPoint.ElementCursor = Cursors.SizeNWSE; this.rightTopPoint.ElementCursor = Cursors.SizeNESW; this.X = x; Y = y; Z = RECTANGLE_DEFAULT_Z; this.Width = width; this.Height = height; this.leftTopPoint.OnTractionEventHandler += OnLeftTopPointTraction; this.leftBottomPoint.OnTractionEventHandler += OnLeftBottomPointTraction; this.rightTopPoint.OnTractionEventHandler += OnRightTopPointTraction; this.rightBottomPoint.OnTractionEventHandler += OnRightBottomPointTraction; Visible = true; Parent = null; }
public void OnRightBottomPointTraction(TractionPoint element, double x, double y) { leftBottomPoint.Y = y; rightTopPoint.X = x; if (this.Width < 0) { FlipHorizontal(); } if (this.Height < 0) { FlipVertical(); } OnElementChange(this); }
public void OnLeftBottomPointTraction(TractionPoint element, double x, double y) { leftTopPoint.X = x; rightBottomPoint.Y = y; if (this.Height < 0) { FlipVertical(); } if (this.Width < 0) { FlipHorizontal(); } if (Width > Height) { this.X += (Width - Height); } else { this.Height = Width; } OnElementChange(this); }
public void FlipHorizontal() { this.leftTopPoint.OnTractionEventHandler -= OnLeftTopPointTraction; this.leftBottomPoint.OnTractionEventHandler -= OnLeftBottomPointTraction; this.rightTopPoint.OnTractionEventHandler -= OnRightTopPointTraction; this.rightBottomPoint.OnTractionEventHandler -= OnRightBottomPointTraction; System.Console.WriteLine("hFlip"); TractionPoint tmp = leftTopPoint; leftTopPoint = rightTopPoint; rightTopPoint = tmp; tmp = leftBottomPoint; leftBottomPoint = rightBottomPoint; rightBottomPoint = tmp; this.leftTopPoint.OnTractionEventHandler += OnLeftTopPointTraction; this.leftBottomPoint.OnTractionEventHandler += OnLeftBottomPointTraction; this.rightTopPoint.OnTractionEventHandler += OnRightTopPointTraction; this.rightBottomPoint.OnTractionEventHandler += OnRightBottomPointTraction; this.leftTopPoint.ElementCursor = Cursors.SizeNWSE; this.leftBottomPoint.ElementCursor = Cursors.SizeNESW; this.rightBottomPoint.ElementCursor = Cursors.SizeNWSE; this.rightTopPoint.ElementCursor = Cursors.SizeNESW; }
public void FlipVertical() { this.leftTopPoint.OnTractionEventHandler -= OnLeftTopPointTraction; this.leftBottomPoint.OnTractionEventHandler -= OnLeftBottomPointTraction; this.rightTopPoint.OnTractionEventHandler -= OnRightTopPointTraction; this.rightBottomPoint.OnTractionEventHandler -= OnRightBottomPointTraction; System.Console.WriteLine("vFlip"); TractionPoint tmp = leftTopPoint; leftTopPoint = leftBottomPoint; leftBottomPoint = tmp; tmp = rightTopPoint; rightTopPoint = rightBottomPoint; rightBottomPoint = tmp; this.leftTopPoint.OnTractionEventHandler += OnLeftTopPointTraction; this.leftBottomPoint.OnTractionEventHandler += OnLeftBottomPointTraction; this.rightTopPoint.OnTractionEventHandler += OnRightTopPointTraction; this.rightBottomPoint.OnTractionEventHandler += OnRightBottomPointTraction; this.leftTopPoint.ElementCursor = Cursors.SizeNWSE; this.leftBottomPoint.ElementCursor = Cursors.SizeNESW; this.rightBottomPoint.ElementCursor = Cursors.SizeNWSE; this.rightTopPoint.ElementCursor = Cursors.SizeNESW; System.Console.WriteLine("lt==lb:" + object.ReferenceEquals(leftTopPoint, leftBottomPoint)); }