public AuxiliaryLineParameter Execute(int changeWidth, int changeHeight) { AuxiliaryLineParameter nowParameter = AC.CloneParameter(); AuxiliaryLineParameter newParameter = null; // 矩形のRatioに合わせたマウス移動距離を求め、その通りにサイズを変更する int changeSizeWidth = changeWidth; int changeSizeHeight = changeHeight; if (BaseWidthWhenChangeSize(changeSizeWidth, changeSizeHeight)) { newParameter = GetNewAuxiliaryLineParameterBaseWidth(changeSizeWidth, changeSizeHeight); } else { newParameter = GetNewAuxiliaryLineParameterBaseHeight(changeSizeWidth, changeSizeHeight); } // 原点が変わるような操作の場合、サイズ変更しない if (WillChangeAuxilirayOrigin(newParameter.Left, newParameter.Top, newParameter.Right, newParameter.Bottom)) { return(nowParameter); } return(newParameter); }
public override AuxiliaryLineParameter GetNewAuxiliaryLineParameterBaseHeight(int changeSizeWidth, int changeSizeHeight) { AuxiliaryLineParameter newParameter = AC.CloneParameter(); // 右上点の操作なら左側や下側は変わらない int changeWidth = changeSizeWidth; int changeHeight = changeSizeHeight; int newTop = AC.AuxiliaryTop - changeSizeHeight; int newRight = AC.AuxiliaryRight + CalcWidthChangeSize(changeSizeWidth, changeSizeHeight); int maxRight = GetMaxRight(); int minTop = GetMinTop(); if (newTop < minTop) { changeHeight = AC.AuxiliaryTop - minTop; newRight = AC.AuxiliaryRight + CalcWidthChangeSize(changeWidth, changeHeight); newTop = minTop; } if (newRight > maxRight) { newRight = maxRight; newTop = AC.AuxiliaryTop - CalcHeightChangeSize(newRight - AC.AuxiliaryRight, changeHeight); } newParameter.ReplacePoint(new Point(AC.AuxiliaryLeft, newTop), new Point(AC.AuxiliaryLeft, AC.AuxiliaryBottom), new Point(newRight, newTop), new Point(newRight, AC.AuxiliaryBottom)); return(newParameter); }
public override AuxiliaryLineParameter GetNewAuxiliaryLineParameterBaseHeight(int changeSizeWidth, int changeSizeHeight) { AuxiliaryLineParameter newParameter = AC.CloneParameter(); // 左下点の操作なら右側と上側は変わらない int changeWidth = changeSizeWidth; int changeHeight = changeSizeHeight; int newLeft = AC.AuxiliaryLeft - CalcWidthChangeSize(changeSizeWidth, changeSizeHeight); int newBottom = AC.AuxiliaryBottom + changeSizeHeight; int minLeft = GetMinLeft(); int maxBottom = GetMaxBottom(); if (newBottom > maxBottom) { changeHeight = maxBottom - AC.AuxiliaryBottom; newLeft = AC.AuxiliaryLeft - CalcWidthChangeSize(changeWidth, changeHeight); newBottom = maxBottom; } if (newLeft < minLeft) { newLeft = minLeft; newBottom = AC.AuxiliaryBottom + CalcHeightChangeSize(AC.AuxiliaryLeft - newLeft, changeHeight); } newParameter.ReplacePoint(new Point(newLeft, AC.AuxiliaryTop), new Point(newLeft, newBottom), new Point(AC.AuxiliaryRight, AC.AuxiliaryTop), new Point(AC.AuxiliaryRight, newBottom)); return(newParameter); }
public override AuxiliaryLineParameter ExecuteCore(object operation = null) { Point leftTop = AC.AuxiliaryLeftTop; Point leftBottom = AC.AuxiliaryLeftBottom; Point rightTop = AC.AuxiliaryRightTop; Point rightBottom = AC.AuxiliaryRightBottom; int centerX = Common.CalcCenterX(leftTop, rightBottom); int centerY = Common.CalcCenterY(leftBottom, rightTop); Point newLeftTop = CalcRotatePoint(leftTop, centerX, centerY, Degree); Point newLeftBottom = CalcRotatePoint(leftBottom, centerX, centerY, Degree); Point newRightTop = CalcRotatePoint(rightTop, centerX, centerY, Degree); Point newRightBottom = CalcRotatePoint(rightBottom, centerX, centerY, Degree); // degreeの通りに回転したら画像からはみ出る場合に回転しない if (IsOutOfRangeDisplayImage(newLeftTop) || IsOutOfRangeDisplayImage(newLeftBottom) || IsOutOfRangeDisplayImage(newRightTop) || IsOutOfRangeDisplayImage(newRightBottom)) { return(AC.CloneParameter()); } AuxiliaryLineParameter newParameter = AC.CloneParameter(); newParameter.ReplaceParameter(newLeftTop, newLeftBottom, newRightTop, newRightBottom, newParameter.Degree + Degree); return(newParameter); }
private void SetNewParameter(AuxiliaryLineParameter param, int changeSizeRight, int changeSizeBottom) { param.ReplacePoint(AC.AuxiliaryLeftTop, new Point(AC.AuxiliaryLeftBottom.X, AC.AuxiliaryLeftBottom.Y + changeSizeBottom), new Point(AC.AuxiliaryRightTop.X + changeSizeRight, AC.AuxiliaryRightTop.Y), new Point(AC.AuxiliaryRightBottom.X + changeSizeRight, AC.AuxiliaryRightBottom.Y + changeSizeBottom)); return; //if (AC.AuxiliaryDegree == 0) //{ // param.ReplacePoint(AC.AuxiliaryLeftTop, // new Point(AC.AuxiliaryLeftBottom.X, AC.AuxiliaryLeftBottom.Y + changeSizeBottom), // new Point(AC.AuxiliaryRightTop.X + changeSizeRight, AC.AuxiliaryRightTop.Y), // new Point(AC.AuxiliaryRightBottom.X + changeSizeRight, AC.AuxiliaryRightBottom.Y + changeSizeBottom)); // return; //} //// TODO: LeftTopを基準に矩形のWidthとHeight(比率保ったまま)を求めて、そのサイズと回転角から残り3点の座標を計算した方が良い //Point newRightBottom = GetNewRightBottom(changeSizeRight, changeSizeBottom); //Point newRightTop = GetNewRightTop(newRightBottom); //Point newLeftBottom = GetNewLeftBottom(newRightBottom); //param.ReplacePoint(AC.AuxiliaryLeftTop, newLeftBottom, newRightTop, newRightBottom); //return; }
public override AuxiliaryLineParameter GetNewAuxiliaryLineParameterBaseWidth(int changeSizeWidth, int changeSizeHeight) { AuxiliaryLineParameter newParameter = AC.CloneParameter(); // 右下点の操作なら左側や上側は変わらない int changeWidth = changeSizeWidth; int changeHeight = changeSizeHeight; int newRight = AC.AuxiliaryRight + changeWidth; int newBottom = AC.AuxiliaryBottom + CalcHeightChangeSize(changeWidth, changeHeight); int maxRight = GetMaxRight(); int maxBottom = GetMaxBottom(); if (newRight > maxRight) { newBottom = AC.AuxiliaryBottom + CalcHeightChangeSize(newRight - maxRight, changeHeight); newRight = maxRight; } if (newBottom > maxBottom) { changeHeight = maxBottom - AC.AuxiliaryBottom; newRight = AC.AuxiliaryRight + CalcWidthChangeSize(changeWidth, changeHeight); newBottom = maxBottom; } SetNewParameter(newParameter, newRight - AC.AuxiliaryRight, newBottom - AC.AuxiliaryBottom); return(newParameter); }
private AuxiliaryLineParameter MoveByMouse(Point moveFinishPoint) { AuxiliaryLineParameter newParameter = AC.CloneParameter(); int moveDistanceX = (int)(moveFinishPoint.X - MoveStartPoint.X); int moveDistanceY = (int)(moveFinishPoint.Y - MoveStartPoint.Y); newParameter.Move(moveDistanceX, moveDistanceY); return(newParameter); }
public AuxiliaryLineParameter ReExecute(AuxiliaryController ac) { if (CommandListIndex >= CommandList.Count) { return(ac.CloneParameter()); } AuxiliaryLineParameter redo = CommandList[CommandListIndex].AfterParameter; CommandListIndex++; return(redo); }
private AuxiliaryLineParameter(AuxiliaryLineParameter copy) { ImageWidth = copy.ImageWidth; ImageHeight = copy.ImageHeight; Width = copy.Width; Height = copy.Height; LeftTop = copy.LeftTop; LeftBottom = copy.LeftBottom; RightTop = copy.RightTop; RightBottom = copy.RightBottom; Ratio = copy.Ratio; Thickness = copy.Thickness; Degree = copy.Degree; }
public AuxiliaryLineParameter Execute(AuxiliaryLineCommand command, object operation) { if (DoneUnExecuteBefore()) { // かつての操作内容を削除し、今の操作内容を最新の履歴とする if (CommandListIndex >= 0) { CommandList.RemoveRange(CommandListIndex, CommandList.Count - CommandListIndex); } } AuxiliaryLineParameter result = command.Execute(operation); CommandList.Add(command); CommandListIndex++; return(result); }
private AuxiliaryLineParameter MoveByKey(Keys.EnableKeys key) { AuxiliaryLineParameter newParameter = AC.CloneParameter(); // TODO: カーソルキーでの移動距離を可変にする if (key == Keys.EnableKeys.Up) { newParameter.MoveHeight(-1); } else if (key == Keys.EnableKeys.Down) { newParameter.MoveHeight(1); } else if (key == Keys.EnableKeys.Right) { newParameter.MoveWidth(1); } else if (key == Keys.EnableKeys.Left) { newParameter.MoveWidth(-1); } return(newParameter); }