예제 #1
0
 void Start()
 {
     parent       = this.transform.parent;
     rotateButton = this.transform.Find("Button").GetComponent <RotateWindow>();
     tempValue    = 25;
     itemWidth    = 200;
     itemLen      = 100;
 }
예제 #2
0
        // 旋转
        public void Rotate(string angel)
        {
            if (angel == "90")
            {
                ImageMat = ImageProcessor.Rotate.Rot90(ImageMat);
                AddOperationToHistory(new Operation($"顺时针旋转 90°", ImageMat));
            }

            if (angel == "180")
            {
                ImageMat = ImageProcessor.Rotate.Rot180(ImageMat);
                AddOperationToHistory(new Operation($"顺时针旋转 180°", ImageMat));
            }

            if (angel == "270")
            {
                ImageMat = ImageProcessor.Rotate.Rot270(ImageMat);
                AddOperationToHistory(new Operation($"顺时针旋转 270°", ImageMat));
            }

            if (angel == "Any")
            {
                var rotateDialog = new RotateWindow();
                if (rotateDialog.ShowDialog() == true)
                {
                    var clockWise  = rotateDialog.ClockWise;
                    var angelValue = rotateDialog.AngelValue;
                    ImageMat = ImageProcessor.Rotate.ImgRotate(ImageMat, angelValue, !clockWise);
                    if (clockWise)
                    {
                        AddOperationToHistory(new Operation($"顺时针旋转 {angelValue}°", ImageMat));
                    }
                    else
                    {
                        AddOperationToHistory(new Operation($"逆时针旋转 {angelValue}°", ImageMat));
                    }
                }
            }

            if (angel == "Vertical")
            {
                ImageMat = ImageProcessor.Rotate.VertRot(ImageMat);
                AddOperationToHistory(new Operation($"垂直翻转", ImageMat));
            }

            if (angel == "Horizontal")
            {
                ImageMat = ImageProcessor.Rotate.HoriRot(ImageMat);
                AddOperationToHistory(new Operation($"水平翻转", ImageMat));
            }

            CanSave = true;
            ShowMatInTab();
        }
예제 #3
0
        /// <summary>
        /// Show dialog to modify an Instruction.
        /// </summary>
        /// <param name="ins">The Instruction being modified.</param>
        /// <param name="owner">The owner Window.</param>
        /// <returns>The modified Instruction.</returns>
        public static Instruction ShowDialog(Instruction ins, Window owner)
        {
            BaseParamWindow dlg = null;

            switch (ins.opcode)
            {
            case Instruction.MOVE:
                dlg = new MoveWindow();
                break;

            case Instruction.ROTATE:
                dlg = new RotateWindow();
                break;

            case Instruction.LED:
                dlg = new LedWindow();
                break;

            case Instruction.SONG:
                dlg = new SongWindow();
                break;

            case Instruction.DEMO:
                dlg = new DemoWindow();
                break;

            case Instruction.DRIVE:
                dlg = new DriveWindow();
                break;

            case Instruction.DELAY:
                dlg = new DelayWindow();
                break;
            }

            if (dlg != null)
            {
                dlg.Owner = owner;
                dlg.Ins   = ins;
                dlg.ShowDialog();

                // Alway read from the Window. There is no guarantee that the original Instruction is modified.
                Instruction result = dlg.Ins;
                Debug.WriteLine(result);
                return(dlg.Ins);
            }
            else
            {
                MessageBox.Show(ins.opcode + " no implemented.");
            }
            return(null);
        }