// 創建 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); }
// caculate horizontal line length private double CalculateHorizontalLine(DrawingModel.Point startPoint, DrawingModel.Point endPoint) { double length = startPoint.GetLeftDifference(endPoint); double width = startPoint.GetTopDifference(endPoint); double horizontalLine = 0; if (IsLengthBiggerThanWidth(length, width)) { horizontalLine = GetHorizontalLineWithBiggerLength(length, width); } else { horizontalLine = GetHorizontalLineWithBiggerWidth(length, width); } return(horizontalLine); }
// use side to calculate point's position private Windows.Foundation.Point CalculatePointPosition(int side, double horizontalLine, DrawingModel.Point startPoint, DrawingModel.Point endPoint) { double left = 0; double top = 0; double length = startPoint.GetLeftDifference(endPoint); double width = startPoint.GetTopDifference(endPoint); if (side % Constant.THREE == 0) { left = (side == 0) ? length : 0; top = width / Constant.TWO; } else { left = (side % Constant.TWO == 0) ? length - horizontalLine : horizontalLine; top = (side < Constant.THREE) ? 0 : width; } DetermineAbsolutePosition(ref left, ref top, startPoint, endPoint); return(new Windows.Foundation.Point((float)left, (float)top)); }