Be.Windows.Forms.HexBox.Copy C# (CSharp) Method

Copy() public method

Copies the current selection in the hex box to the Clipboard.
public Copy ( ) : void
return void
        public void Copy()
        {
            if (!CanCopy()) return;

            // put bytes into buffer
            byte[] buffer = GetCopyData();

            DataObject da = new DataObject();

            // set string buffer clipbard data
            string sBuffer = "";
            if (_keyInterpreter == _ki && buffer.Length < 2000)
            {
                for (int i = 0; i < buffer.Length; i++)
                {
                    sBuffer += buffer[i].ToString("x2");
                }
            }
            else
            {
                sBuffer = System.Text.Encoding.ASCII.GetString(buffer, 0, buffer.Length);
            }
            da.SetData(typeof(string), sBuffer);

            //set memorystream (BinaryData) clipboard data
            System.IO.MemoryStream ms = new System.IO.MemoryStream(buffer, 0, buffer.Length, false, true);
            da.SetData("BinaryData", ms);

            Clipboard.SetDataObject(da, true);
            UpdateCaret();
            ScrollByteIntoView();
            Invalidate();

            OnCopied(EventArgs.Empty);
        }

Usage Example

Ejemplo n.º 1
0
 private void menuCopy_Click(object sender, EventArgs e)
 {
     hexBox1.Copy();
 }
All Usage Examples Of Be.Windows.Forms.HexBox::Copy
HexBox