Beispiel #1
0
        public void TestUndoAndRedo()
        {
            AuxiliaryController           ac   = Common.GetAuxiliaryControllerImage001RatioTypeW16H9();
            List <AuxiliaryLineParameter> list = new List <AuxiliaryLineParameter>();

            list.Add(ac.CloneParameter());

            ac.SetEvent();
            ac.PublishEvent(Keys.EnableKeys.Down);
            list.Add(ac.CloneParameter());

            ChangeAuxiliaryLineSizeWhereTopRight(ac, -100, -5, true);
            list.Add(ac.CloneParameter());

            ChangeAuxiliaryLineSizeWhereTopRight(ac, -5, -100, false);
            list.Add(ac.CloneParameter());

            ac.CancelEvent();
            AreParameterEqual(list[2], ac);

            ac.CancelEvent();
            AreParameterEqual(list[1], ac);

            ac.RedoEvent();
            AreParameterEqual(list[2], ac);

            ChangeAuxiliaryLineSizeWhereTopRight(ac, 50, 5, true);
            list.Add(ac.CloneParameter());

            ac.CancelEvent();
            AreParameterEqual(list[2], ac);

            ac.RedoEvent();
            AreParameterEqual(list[4], ac);
        }
Beispiel #2
0
        public void TestRedoSizeChangeOperationWhereTopRight()
        {
            AuxiliaryController           ac   = Common.GetAuxiliaryControllerImage001RatioTypeW16H9();
            List <AuxiliaryLineParameter> list = new List <AuxiliaryLineParameter>();

            list.Add(ac.CloneParameter());

            // Width基準でHeightを変更するよう、Width >> height となる値を設定
            ChangeAuxiliaryLineSizeWhereTopRight(ac, -100, -5, true);
            list.Add(ac.CloneParameter());

            // Height基準でWidthを変更するよう、Height >> Width となる値を設定
            ChangeAuxiliaryLineSizeWhereTopRight(ac, -5, -100, false);
            list.Add(ac.CloneParameter());

            ac.CancelEvent();
            AreParameterEqual(list[1], ac);

            ac.CancelEvent();
            AreParameterEqual(list[0], ac);

            ac.RedoEvent();
            AreParameterEqual(list[1], ac);

            ac.RedoEvent();
            AreParameterEqual(list[2], ac);
        }
Beispiel #3
0
        public AuxiliaryLineTestData Execute(AuxiliaryController ac, int degree)
        {
            Point leftTop     = ac.AuxiliaryLeftTop;
            Point leftBottom  = ac.AuxiliaryLeftBottom;
            Point rightTop    = ac.AuxiliaryRightTop;
            Point rightBottom = ac.AuxiliaryRightBottom;
            int   centerX     = CalcCenterX(leftTop, rightBottom);
            int   centerY     = 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);

            AuxiliaryLineParameter before   = ac.CloneParameter();
            AuxiliaryLineTestData  testData = new AuxiliaryLineTestData(newLeftTop, newLeftBottom, newRightTop, newRightBottom, degree);

            if (IsOutOfRangeImagePoint(newLeftTop, ac) ||
                IsOutOfRangeImagePoint(newLeftBottom, ac) ||
                IsOutOfRangeImagePoint(newRightTop, ac) ||
                IsOutOfRangeImagePoint(newRightBottom, ac))
            {
                testData = new AuxiliaryLineTestData(before);
            }

            // 回転実施
            ac.SetEvent(degree);
            ac.PublishEvent(null);

            return(testData);
        }
Beispiel #4
0
        public void TestRedoInputCursorKeyDown()
        {
            AuxiliaryController           ac   = Common.GetAuxiliaryControllerImage001RatioTypeW16H9();
            List <AuxiliaryLineParameter> list = new List <AuxiliaryLineParameter>();

            list.Add(ac.CloneParameter());

            ac.SetEvent();
            ac.PublishEvent(Keys.EnableKeys.Down);
            list.Add(ac.CloneParameter());

            ac.CancelEvent();
            AreParameterEqual(list[0], ac);

            ac.RedoEvent();
            AreParameterEqual(list[1], ac);
        }
        public AuxiliaryLineParameter UnExecute(AuxiliaryController ac)
        {
            if (CommandListIndex <= 0)
            {
                return(ac.CloneParameter());
            }

            CommandListIndex--;
            return(CommandList[CommandListIndex].BeforeParameter);
        }
        public AuxiliaryLineParameter ReExecute(AuxiliaryController ac)
        {
            if (CommandListIndex >= CommandList.Count)
            {
                return(ac.CloneParameter());
            }

            AuxiliaryLineParameter redo = CommandList[CommandListIndex].AfterParameter;

            CommandListIndex++;
            return(redo);
        }
Beispiel #7
0
        public void TestNoRedoIfNewOperationAfterUndo()
        {
            // 操作 → Undo → 別操作 → Redoしないことを確認する
            AuxiliaryController           ac   = Common.GetAuxiliaryControllerImage001RatioTypeW16H9();
            List <AuxiliaryLineParameter> list = new List <AuxiliaryLineParameter>();

            list.Add(ac.CloneParameter());

            ac.SetEvent();
            ac.PublishEvent(Keys.EnableKeys.Down);
            list.Add(ac.CloneParameter());

            ac.CancelEvent();
            AreParameterEqual(list[0], ac);

            // 適当に別操作
            ChangeAuxiliaryLineSizeWhereTopRight(ac, -100, -5, true);
            list[1] = ac.CloneParameter();

            ac.RedoEvent();
            AreParameterEqual(list[1], ac);
        }
Beispiel #8
0
        public void TestAuxiliaryLineNoRotateIfAuxiliaryLineOutOfRangeAfterRotate()
        {
            // 回転すると画像からはみ出る場合は回転しない
            AuxiliaryController ac = Common.GetAuxiliaryControllerImage001RatioTypeW16H9();

            // 縮小&移動して回転できそうなスペースを作る(実際には回転させたくない)
            ChangeAuxiliaryLineSizeWhereBottomRight(ac, -100, -5, true);
            MoveAuxiliaryLine(ac, 100, 80);

            AuxiliaryLineParameter before = ac.CloneParameter();
            AuxiliaryLineTestData  testData
                = new AuxiliaryLineRotate().Execute(ac, 20);

            AreParameterEqual(before, ac);
        }