Exemplo n.º 1
0
            /// <summary>
            /// Pres the process wm key down.
            /// </summary>
            /// <param name="m">The m.</param>
            /// <returns></returns>
            public virtual bool PreProcessWmKeyDown(ref Message m)
            {
                System.Diagnostics.Debug.WriteLine("PreProcessWmKeyDown(ref Message m)", "KeyInterpreter");

                Keys vc = (Keys)m.WParam.ToInt32();

                Keys keyData = vc | Control.ModifierKeys;

                switch (keyData)
                {
                case Keys.Left:
                case Keys.Up:
                case Keys.Right:
                case Keys.Down:
                case Keys.PageUp:
                case Keys.PageDown:
                case Keys.Left | Keys.Shift:
                case Keys.Up | Keys.Shift:
                case Keys.Right | Keys.Shift:
                case Keys.Down | Keys.Shift:
                case Keys.Tab:
                case Keys.Back:
                case Keys.Delete:
                case Keys.Home:
                case Keys.End:
                case Keys.ShiftKey | Keys.Shift:
                case Keys.C | Keys.Control:
                case Keys.X | Keys.Control:
                case Keys.V | Keys.Control:
                    if (RaiseKeyDown(keyData))
                    {
                        return(true);
                    }
                    break;
                }

                switch (keyData)
                {
                case Keys.Left:                                                 // move left
                    return(PreProcessWmKeyDown_Left(ref m));

                case Keys.Up:                                                   // move up
                    return(PreProcessWmKeyDown_Up(ref m));

                case Keys.Right:                                        // move right
                    return(PreProcessWmKeyDown_Right(ref m));

                case Keys.Down:                                                 // move down
                    return(PreProcessWmKeyDown_Down(ref m));

                case Keys.PageUp:                                       // move pageup
                    return(PreProcessWmKeyDown_PageUp(ref m));

                case Keys.PageDown:                                     // move pagedown
                    return(PreProcessWmKeyDown_PageDown(ref m));

                case Keys.Left | Keys.Shift:                    // move left with selection
                    return(PreProcessWmKeyDown_ShiftLeft(ref m));

                case Keys.Up | Keys.Shift:                      // move up with selection
                    return(PreProcessWmKeyDown_ShiftUp(ref m));

                case Keys.Right | Keys.Shift:                   // move right with selection
                    return(PreProcessWmKeyDown_ShiftRight(ref m));

                case Keys.Down | Keys.Shift:                    // move down with selection
                    return(PreProcessWmKeyDown_ShiftDown(ref m));

                case Keys.Tab:                                                  // switch focus to string view
                    return(PreProcessWmKeyDown_Tab(ref m));

                case Keys.Back:                                                 // back
                    return(PreProcessWmKeyDown_Back(ref m));

                case Keys.Delete:                                       // delete
                    return(PreProcessWmKeyDown_Delete(ref m));

                case Keys.Home:                                                 // move to home
                    return(PreProcessWmKeyDown_Home(ref m));

                case Keys.End:                                                  // move to end
                    return(PreProcessWmKeyDown_End(ref m));

                case Keys.ShiftKey | Keys.Shift:        // begin selection process
                    return(PreProcessWmKeyDown_ShiftShiftKey(ref m));

                case Keys.C | Keys.Control:                     // copy
                    return(PreProcessWmKeyDown_ControlC(ref m));

                case Keys.X | Keys.Control:                     // cut
                    return(PreProcessWmKeyDown_ControlX(ref m));

                case Keys.V | Keys.Control:                     // paste
                    return(PreProcessWmKeyDown_ControlV(ref m));

                default:
                    HexViewer.ScrollByteIntoView();
                    return(HexViewer.BasePreProcessMessage(ref m));
                }
            }
Exemplo n.º 2
0
 /// <summary>
 /// Preprocesses WM_KEYUP window message.
 /// </summary>
 /// <param name="m">the Message object to process.</param>
 /// <returns>True, if the message was processed.</returns>
 public bool PreProcessWmKeyUp(ref Message m)
 {
     return(hexViewer.BasePreProcessMessage(ref m));
 }
Exemplo n.º 3
0
            /// <summary>
            /// Pres the process wm char.
            /// </summary>
            /// <param name="m">The m.</param>
            /// <returns></returns>
            public override bool PreProcessWmChar(ref Message m)
            {
                if (Control.ModifierKeys == Keys.Control)
                {
                    return(HexViewer.BasePreProcessMessage(ref m));
                }

                bool sw = HexViewer._byteProvider.SupportsWriteByte;
                bool si = HexViewer._byteProvider.SupportsInsertBytes;
                bool sd = HexViewer._byteProvider.SupportsDeleteBytes;

                long pos = HexViewer.bytePosition;
                long sel = HexViewer._selectionLength;
                int  cp  = HexViewer.byteCharacterPosition;

                if ((!sw && pos != HexViewer._byteProvider.Length) ||
                    (!si && pos == HexViewer._byteProvider.Length))
                {
                    return(HexViewer.BasePreProcessMessage(ref m));
                }

                char c = (char)m.WParam.ToInt32();

                if (RaiseKeyPress(c))
                {
                    return(true);
                }
                if (HexViewer.ReadOnly)
                {
                    return(true);
                }

                bool isInsertMode = (pos == HexViewer._byteProvider.Length);

                // do insert when insertActive = true
                if (!isInsertMode && si && HexViewer._insertActive)
                {
                    isInsertMode = true;
                }

                if (sd && si && sel > 0)
                {
                    HexViewer._byteProvider.DeleteBytes(pos, sel);
                    isInsertMode = true;
                    cp           = 0;
                    HexViewer.SetPosition(pos, cp);
                }

                HexViewer.ReleaseSelection();

                if (isInsertMode)
                {
                    HexViewer._byteProvider.InsertBytes(pos, new byte[] { (byte)c });
                }
                else
                {
                    HexViewer._byteProvider.WriteByte(pos, (byte)c);
                }

                PerformPosMoveRightByte();
                HexViewer.Invalidate();

                return(true);
            }