/// <summary> /// Initializes a new instance of the <see cref="EmptyKeyInterpreter"/> class. /// </summary> /// <param name="owner">The owner.</param> public EmptyKeyInterpreter(HexViewer owner) { if (owner == null) { throw new ArgumentNullException("owner"); } hexViewer = owner; }
/// <summary> /// Gives some information about where to place the caret. /// </summary> /// <param name="byteIndex">the index of the byte</param> /// <returns> /// the position where the caret is to place. /// </returns> public override PointF GetCaretPointF(long byteIndex) { System.Diagnostics.Debug.WriteLine("GetCaretPointF()", "StringKeyInterpreter"); Point gp = HexViewer.GetGridBytePoint(byteIndex); return(HexViewer.GetByteStringPointF(gp)); }
/// <summary> /// Gets the byte position info. /// </summary> /// <param name="p">The position.</param> /// <returns></returns> protected override BytePositionInfo GetBytePositionInfo(Point p) { return(HexViewer.GetStringBytePositionInfo(p)); }
/// <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); }
/// <summary> /// Initializes a new instance of the <see cref="StringKeyInterpreter"/> class. /// </summary> /// <param name="owner">The owner.</param> public StringKeyInterpreter(HexViewer owner) : base(owner) { HexViewer.byteCharacterPosition = 0; }