示例#1
0
        /// <summary>
        /// Unloads the current tool and switches to the new tool, e.g. "SwitchToTool(new MainTool());"
        /// </summary>
        /// <param name="newTool">The tool to switch to. Usually "new SomeToolDerivedFromToolBase()"</param>
        internal static void SwitchToTool(ToolBase newTool)
        {
            if (Current != null)
            {
                Current.UnloadTool();
                ClickData.Clear(true);
                Current = null;
            }

            Current = newTool;
        }
示例#2
0
        private static void ProcessKeys(KeyEventArgs e, bool isDown)
        {
            switch (e.KeyCode)
            {
            // Escape from any unsupported keys
            case Keys.None:
            default:
                break;

            case Keys.R:
                if (!isDown && !ClickData.IsShapesEmpty() && Canvas.Instance.Focused)
                {
                    foreach (var s in ClickData.Shapes)
                    {
                        s.Height = s.Width;
                    }
                }
                break;

            case Keys.PageUp:
                if (!isDown && !ClickData.IsShapesEmpty() && Canvas.Instance.Focused)
                {
                    foreach (var s in ClickData.Shapes)
                    {
                        Canvas.Instance.layer.MoveShapeUp(s);
                    }
                }
                break;

            case Keys.PageDown:
                if (!isDown && !ClickData.IsShapesEmpty() && Canvas.Instance.Focused)
                {
                    foreach (var s in ClickData.Shapes)
                    {
                        Canvas.Instance.layer.MoveShapeDown(s);
                    }
                }
                break;

            case Keys.M:
                IsMoveDown = isDown && Canvas.Instance.Focused;
                break;

            case Keys.P:
                if (isDown)
                {
                    ToolBase.SwitchToTool(new MainTool());
                }
                break;

            case Keys.E:
                if (isDown)
                {
                    ToolBase.SwitchToTool(new EraserTool());
                }
                break;

            case Keys.S:
                if (isDown)
                {
                    ToolBase.SwitchToTool(new SelectorTool());
                }
                break;

            case Keys.ControlKey:
                IsControlDown = isDown;
                break;

            case Keys.A:
                ShowAllBordersDown = isDown;
                break;

            case Keys.ShiftKey:
                IsShiftDown = isDown;
                break;

            case Keys.OemQuestion:
                Debug.Show();
                break;
            }

            ToolBase.Current.ProcessKeys(e, isDown);

            // Invalidate Canvas if it was a new key input
            if (!(m_prevKey == e.KeyCode && m_prevIsDown == isDown))
            {
                Canvas.Instance.Invalidate();
            }

            m_prevKey    = e.KeyCode;
            m_prevIsDown = isDown;
        }