/// <summary> /// /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="width"></param> /// <param name="height"></param> public EllipseElement(float x, float y, float width, float height) : base() { 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; 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 = CIRCLE_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; ParentElement = null; }
public void OnTraction(TractionPoint elemant, float x, float y) { if (KeyPointChangeEventHandler != null) { KeyPointChangeEventHandler(this, X, Y); } }
public KeyPoint(float x, float y, Element parent) { this.Parent = parent; this.tractionPoint = new TractionPoint(x, y, parent); tractionPoint.ParentCoordinate = parent.ParentCoordinate; tractionPoint.ParentElement = parent; tractionPoint.ElementCursor = Cursors.SizeAll; tractionPoint.Z = tractionPoint.ParentElement.Z - 0.01f; tractionPoint.Visible = true; this.tractionPoint.OnTractionEventHandler += OnTraction; }
public void OnRightBottomPointTraction(TractionPoint element, float x, float y) { leftBottomPoint.Y = y; rightTopPoint.X = x; if (this.Width < 0) { FlipHorizontal(); } if (this.Height < 0) { FlipVertical(); } OnElementChange(this); }
public void OnLinePointTraction(TractionPoint tp, float x, float y) { switch (tp.Name) { case "tractionPoint0": this.X = x; this.Y = y; break; case "tractionPoint1": this.X2 = x; this.Y2 = y; break; default: break; } }
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)); }