示例#1
0
        public void OnKeyDown(System.Windows.Input.KeyEventArgs e)
        {
            if (ImageSurface == null || !ImageSurface.Focused)
            {
                return;
            }
            switch (e.Key)
            {
            case Key.Escape:
                if (ImageSurface.IsDrawingZoomRect)
                {
                    ImageSurface.IsDrawingZoomRect = false;
                    ImageSurface.ZoomRect(false);
                    ImageSurface.Invalidate();
                    e.Handled = true;
                }
                else if (IsFullScreen)
                {
                    ToggleFullscreen();
                    ImageSurface.Invalidate();
                    e.Handled = true;
                }
                break;

            case Key.Left:
                if (ImageSurface.Focused)
                {
                    ImageSurface.OnLeft();
                    e.Handled = true;
                }
                break;

            case Key.Right:
                if (ImageSurface.Focused)
                {
                    ImageSurface.OnRight();
                    e.Handled = true;
                }
                break;

            case Key.Up:
                if (ImageSurface.Focused)
                {
                    ImageSurface.OnUp();
                    e.Handled = true;
                }
                break;

            case Key.Down:
                if (ImageSurface.Focused)
                {
                    ImageSurface.OnDown();
                    e.Handled = true;
                }
                break;

            case Key.Add:
                if (ImageSurface.Focused)
                {
                    ImageSurface.Zoom(15f, true, true);
                }
                break;

            case Key.Subtract:
                if (ImageSurface.Focused)
                {
                    ImageSurface.Zoom(-15f, true, true);
                }
                break;

            default:
                break;
            }
        }