示例#1
0
            /// <summary>
            /// Pres the process wm key down_ up.
            /// </summary>
            /// <param name="m">The m.</param>
            /// <returns></returns>
            protected virtual bool PreProcessWmKeyDown_Up(ref Message m)
            {
                long pos = HexViewer.bytePosition;
                int  cp  = HexViewer.byteCharacterPosition;

                if (!(pos == 0 && cp == 0))
                {
                    pos = Math.Max(-1, pos - HexViewer.hexMaxHBytes);
                    if (pos == -1)
                    {
                        return(true);
                    }

                    HexViewer.SetPosition(pos);

                    if (pos < HexViewer.startByte)
                    {
                        HexViewer.PerformScrollLineUp();
                    }

                    HexViewer.UpdateCaret();
                    HexViewer.Invalidate();
                }

                HexViewer.ScrollByteIntoView();
                HexViewer.ReleaseSelection();

                return(true);
            }
示例#2
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);
            }