コード例 #1
0
        private void HandleUserInput(char key)
        {
            if (!_editor.CaretFocused)
            {
                return;
            }

            HandleUserRemove();

            byte newByte = Convert.ToByte(key);

            if (_editor.HexTableLength <= 0)
            {
                _editor.AppendByte(newByte);
            }
            else
            {
                _editor.InsertByte(_editor.CaretIndex, newByte);
            }

            int   index       = _editor.CaretIndex + 1;
            Point newLocation = GetCaretLocation(index);

            _editor.SetCaretStart(index, newLocation);
        }
コード例 #2
0
ファイル: HexViewHandler.cs プロジェクト: usama7628674/DcRat
        private void HandleUserInput(char key)
        {
            if (!_editor.CaretFocused)
            {
                return;
            }

            //Perform overwrite
            HandleUserRemove();

            if (_isEditing)
            {
                //Editing has already started, should change the second nibble
                _isEditing = false;
                //Load old bytes to allow change
                byte oldByte = _editor.GetByte(_editor.CaretIndex);
                //Append the new nibble
                oldByte += Convert.ToByte(key.ToString(), 16);
                _editor.SetByte(_editor.CaretIndex, oldByte);
                //Relocate the caret
                int   index       = _editor.CaretIndex + 1;
                Point newLocation = GetCaretLocation(index);
                _editor.SetCaretStart(index, newLocation);
            }
            else
            {
                //Begin new edit phase
                _isEditing = true;
                string hexByte = key.ToString() + "0";
                byte   newByte = Convert.ToByte(hexByte, 16);

                if (_editor.HexTable.Length <= 0)
                {
                    _editor.AppendByte(newByte);
                }
                else
                {
                    _editor.InsertByte(_editor.CaretIndex, newByte);
                }

                //Relocate the caret to the middle of the hex value (provide illusion of editing the second value)
                int xPos = (_recHexValue.X + (_recHexValue.Width * ((_editor.CaretIndex) % _editor.BytesPerLine)) + (_recHexValue.Width / 2));
                int yPos = _recHexValue.Y + (_recHexValue.Height * ((_editor.CaretIndex - (_editor.FirstVisibleByte + _editor.CaretIndex % _editor.BytesPerLine)) / _editor.BytesPerLine));

                _editor.SetCaretStart(_editor.CaretIndex, new Point(xPos, yPos));
            }
        }