示例#1
0
            /// <summary>
            /// Begins the mouse selection.
            /// </summary>
            /// <param name="sender">The sender.</param>
            /// <param name="e">The <see cref="System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
            private void BeginMouseSelection(object sender, MouseEventArgs e)
            {
                System.Diagnostics.Debug.WriteLine("BeginMouseSelection()", "KeyInterpreter");

                mouseDown = true;

                if (!ShiftDown)
                {
                    startPositionInfo = new BytePositionInfo(HexViewer.bytePosition, HexViewer.byteCharacterPosition);
                    HexViewer.ReleaseSelection();
                }
                else
                {
                    UpdateMouseSelection(this, e);
                }
            }
示例#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);
            }