public bool CanPaste()
{
if (ReadOnly || !this.Enabled) return false;
if (_byteProvider == null || !_byteProvider.SupportsInsertBytes())
return false;
if (!_byteProvider.SupportsDeleteBytes() && _selectionLength > 0)
return false;
IDataObject da = Clipboard.GetDataObject();
if (da.GetDataPresent("BinaryData"))
return true;
else if (da.GetDataPresent(typeof(string)))
return true;
else
return false;
}
/// <summary>
/// <summary> /// Before opening the ContextMenuStrip, we manage the availability of the items. /// </summary> /// <param name="sender">the sender object</param> /// <param name="e">the event data</param> void BuildInContextMenuStrip_Opening(object sender, CancelEventArgs e) { _cutToolStripMenuItem.Enabled = _hexBox.CanCut(); _copyToolStripMenuItem.Enabled = _hexBox.CanCopy(); _pasteToolStripMenuItem.Enabled = _hexBox.CanPaste(); _selectAllToolStripMenuItem.Enabled = _hexBox.CanSelectAll(); }