/// <summary> /// 現在の位置種類を設定します /// </summary> private void SetLocation() { foreach (IFramePoint wFramPoint in this.FramePoints) { wFramPoint.CurrentLocationKind = null; } // float型で計算すると小数点以下の誤差でずれてしまうことがあるのでint型で比較する // 頂点は自身の座標を元に判定 // ただし、複数存在する時があるので別方向の座標で確認する IFramePoint wTop = this.FramePoints.OrderBy(x => (int)x.MainPoint.Y).ThenBy(x => (int)x.MainPoint.X).First(); IFramePoint wRight = this.FramePoints.OrderByDescending(x => (int)x.MainPoint.X).ThenBy(x => (int)x.MainPoint.Y).First(); IFramePoint wBottom = this.FramePoints.OrderByDescending(x => (int)x.MainPoint.Y).ThenByDescending(x => (int)x.MainPoint.X).First(); IFramePoint wLeft = this.FramePoints.OrderBy(x => (int)x.MainPoint.X).ThenByDescending(x => (int)x.MainPoint.Y).First(); wTop.CurrentLocationKind = FramePointLocationKindEnum.Top; wRight.CurrentLocationKind = FramePointLocationKindEnum.Right; wBottom.CurrentLocationKind = FramePointLocationKindEnum.Bottom; wLeft.CurrentLocationKind = FramePointLocationKindEnum.Left; // 中点は中心点との位置を比較してどの象限にいるかを判定 int wCenterX = (int)this.CenterPoint.X; int wCenterY = (int)this.CenterPoint.Y; IFramePoint wTopRight = this.FramePoints.Where(x => !x.CurrentLocationKind.HasValue && (int)x.MainPoint.X > wCenterX && (int)x.MainPoint.Y <= wCenterY).Single(); IFramePoint wRightBottom = this.FramePoints.Where(x => !x.CurrentLocationKind.HasValue && (int)x.MainPoint.X >= wCenterX && (int)x.MainPoint.Y > wCenterY).Single(); IFramePoint wBottomLeft = this.FramePoints.Where(x => !x.CurrentLocationKind.HasValue && (int)x.MainPoint.X < wCenterX && (int)x.MainPoint.Y >= wCenterY).Single(); IFramePoint wLeftTop = this.FramePoints.Where(x => !x.CurrentLocationKind.HasValue && (int)x.MainPoint.X <= wCenterX && (int)x.MainPoint.Y < wCenterY).Single(); wTopRight.CurrentLocationKind = FramePointLocationKindEnum.TopRight; wRightBottom.CurrentLocationKind = FramePointLocationKindEnum.RightBottom; wBottomLeft.CurrentLocationKind = FramePointLocationKindEnum.BottomLeft; wLeftTop.CurrentLocationKind = FramePointLocationKindEnum.LeftTop; }
/// <summary> /// 拡大・縮小します /// </summary> public void Zoom(IFramePoint vFramePoint, PointF vStartPoint, PointF vEndPoint, bool vIsPreview = false) { vFramePoint.Zoom(this.Matrix, vStartPoint, vEndPoint, this.CenterPoint, this.CurrentAngle); if (vIsPreview) { return; } this.SetLocation(); }