// 創建 rectangle private RectangleF GetRectangle(DrawingModel.Point startPoint, DrawingModel.Point endPoint) { float left = (float)startPoint.GetSmallLeft(endPoint); float top = (float)startPoint.GetSmallTop(endPoint); float width = (float)startPoint.GetLeftDifference(endPoint); float height = (float)startPoint.GetTopDifference(endPoint); return(new RectangleF(new PointF(left, top), new SizeF(new PointF(width, height)))); }
// 判斷是否在 2 point 的 range 內 public bool IsInRange(Point startPoint, Point endPoint) { double left = startPoint.GetSmallLeft(endPoint); double top = startPoint.GetSmallTop(endPoint); double width = startPoint.GetLeftDifference(endPoint); double height = startPoint.GetTopDifference(endPoint); return(_left >= left && _left <= left + width && _top >= top && _top <= top + height); }
// 取得 4 個corner 的圓座標 private List <DrawingModel.Point> GetCornerPointsPosition(DrawingModel.Point startPoint, DrawingModel.Point endPoint) { List <DrawingModel.Point> points = new List <DrawingModel.Point>(); for (int count = 0; count < Constant.FOUR; count++) { double left = (count % Constant.TWO == 0) ? startPoint.GetSmallLeft(endPoint) : startPoint.GetBigLeft(endPoint); double top = (count / Constant.TWO == 0) ? startPoint.GetSmallTop(endPoint) : startPoint.GetBigTop(endPoint); left -= Constant.MARK_CIRCLE_RADIUS; top -= Constant.MARK_CIRCLE_RADIUS; points.Add(new DrawingModel.Point(left, top)); } return(points); }
// Determine the position on canvas private void DetermineAbsolutePosition(ref double left, ref double top, DrawingModel.Point startPoint, DrawingModel.Point endPoint) { left += startPoint.GetSmallLeft(endPoint); top += startPoint.GetSmallTop(endPoint); }