예제 #1
0
        public void FrameMove()
        {
            if (keysEnabled[keySave] && keys[keySave])
            {
                keysEnabled[keySave] = false;
                viewer.SaveToBitmap("sample.bmp");
            }
            if (keysEnabled[keyMotion] && keys[keyMotion])
            {
                keysEnabled[keyMotion] = false;
                viewer.SwitchMotionEnabled();
            }
            if (keysEnabled[keyShadow] && keys[keyShadow])
            {
                keysEnabled[keyShadow] = false;
                viewer.SwitchShadowShown();
            }
            if (keysEnabled[keySprite] && keys[keySprite])
            {
                keysEnabled[keySprite] = false;
                viewer.SwitchSpriteShown();
            }
            if (keysEnabled[keyFigure] && keys[keyFigure])
            {
                keysEnabled[keyFigure] = false;
                viewer.NextFigure();
            }
            if (keysEnabled[keyDelete] && keys[keyDelete])
            {
                keysEnabled[keyDelete] = false;

                if (keys[(int)Keys.ControlKey])
                {
                    viewer.ClearFigureList();
                }
                else
                {
                    viewer.RemoveSelectedFigure();
                }
            }
            if (keysEnabled[keyCameraReset] && keys[keyCameraReset])
            {
                keysEnabled[keyCameraReset] = false;
                camera.Reset();
                Figure fig;
                if (viewer.TryGetFigure(out fig))
                {
                    camera.SetCenter(fig.Center);
                }
            }
            if (keysEnabled[keyFigureForm] && keys[keyFigureForm])
            {
                keys[keyFigureForm]        = false;
                keysEnabled[keyFigureForm] = true;
                // stale KeyUp event
                fig_form.Show();
                fig_form.Activate();
            }

            float keyL    = 0.0f;
            float keyR    = 0.0f;
            float keyU    = 0.0f;
            float keyD    = 0.0f;
            float keyPush = 0.0f;
            float keyPull = 0.0f;
            float keyZRol = 0.0f;

            if (keys[(int)Keys.Left])
            {
                keyL = 2.0f;
            }
            if (keys[(int)Keys.Right])
            {
                keyR = 2.0f;
            }
            if (keys[(int)Keys.PageUp])
            {
                keyU = 2.0f;
            }
            if (keys[(int)Keys.PageDown])
            {
                keyD = 2.0f;
            }
            if (keys[(int)Keys.Up])
            {
                keyPush = 1.0f;
            }
            if (keys[(int)Keys.Down])
            {
                keyPull = 1.0f;
            }
            if (keys[(int)Keys.A])
            {
                keyZRol = -2.0f;
            }
            if (keys[(int)Keys.D])
            {
                keyZRol = +2.0f;
            }

            camera.Move(keyR - keyL, keyU - keyD, keyPull - keyPush);
            camera.RotZ(DegreeToRadian(keyZRol));
        }