Example #1
0
        protected virtual void KeyHandleWorkspace_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
        {
            if (!IsControllable)
            {
                WriteLine(Properties.Strings.NoControllable);
                return;
            }

            // アクティビティが実行中であれば中止する.
            Activity activity = new Activity(parameterManager);

            activity.Abort();

            // モータが移動中であれば移動を中止する.
            MotorControler mc = MotorControler.GetInstance(parameterManager);

            if (mc.IsMoving)
            {
                mc.AbortMoving();
                WriteLine(Properties.Strings.AbortMotor);
            }
            try {
#if !_NoHardWare
                if (e.Key == Key.A)
                {
                    mc.ContinuousDrive(VectorId.X, PlusMinus.Minus, mc.Speed.X);
                }
                else if (e.Key == Key.D)
                {
                    mc.ContinuousDrive(VectorId.X, PlusMinus.Plus, mc.Speed.X);
                }
                else if (e.Key == Key.X)
                {
                    mc.ContinuousDrive(VectorId.Y, PlusMinus.Minus, mc.Speed.Y);
                }
                else if (e.Key == Key.W)
                {
                    mc.ContinuousDrive(VectorId.Y, PlusMinus.Plus, mc.Speed.Y);
                }
                else if (e.Key == Key.Q)
                {
                    mc.ContinuousDrive(VectorId.Z, PlusMinus.Minus, mc.Speed.Z);
                }
                else if (e.Key == Key.E)
                {
                    mc.ContinuousDrive(VectorId.Z, PlusMinus.Plus, mc.Speed.Z);
                }
                else if (e.Key == Key.N)
                {
                    mc.MoveInSpiral();
                }
                else if (e.Key == Key.O)
                {
                    mc.SetSpiralCenterPoint();
                }
                else if (e.Key == Key.I)
                {
                    mc.BackToSpiralCenter();
                }
                else if (e.Key == Key.B)
                {
                    mc.SpiralBack();
                }
#endif
            } catch (MotorException ex) {
                WriteLine(ex.Message);
            }
        }