public void Paste()
{
if(!CanPaste()) return;
if(_selectionLength > 0)
_byteProvider.DeleteBytes(_bytePos, _selectionLength);
byte[] buffer = null;
IDataObject da = Clipboard.GetDataObject();
if(da.GetDataPresent("BinaryData"))
{
System.IO.MemoryStream ms = (System.IO.MemoryStream)da.GetData("BinaryData");
buffer = new byte[ms.Length];
ms.Read(buffer, 0, buffer.Length);
}
else if(da.GetDataPresent(typeof(string)))
{
string sBuffer = (string)da.GetData(typeof(string));
buffer = System.Text.Encoding.ASCII.GetBytes(sBuffer);
}
else
{
return;
}
_byteProvider.InsertBytes(_bytePos, buffer);
SetPosition(_bytePos + buffer.Length, 0);
ReleaseSelection();
ScrollByteIntoView();
UpdateCaret();
Invalidate();
}