Пример #1
0
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            //if ((keyData == (Keys.Control | Keys.C)))
            //{
            //    //your implementation
            //    return true;
            //}

            if ((keyData == (Keys.Control | Keys.V)))
            {
                //ClipboardAsync Clipboard2 = new ClipboardAsync();

                //string ptxt = Clipboard2.GetText(TextDataFormat.UnicodeText).Replace(Environment.NewLine, "\r\n");
                //cbxInput.Text += ptxt;
                //return true;

                ClipboardAsync Clipboard2 = new ClipboardAsync();

                string insertText     = Clipboard2.GetText(TextDataFormat.UnicodeText).Replace(Environment.NewLine, "\r\n");
                int    selectionIndex = cbxInput.SelectionStart;
                cbxInput.Text           = cbxInput.Text.Insert(selectionIndex, insertText);
                cbxInput.SelectionStart = selectionIndex + insertText.Length;

                return(true);
            }
            else
            {
                return(base.ProcessCmdKey(ref msg, keyData));
            }
        }
Пример #2
0
 public string GetText(TextDataFormat format)
 {
     ClipboardAsync instance = new ClipboardAsync();
     Thread staThread = new Thread(instance._thGetText);
     staThread.SetApartmentState(ApartmentState.STA);
     staThread.Start(format);
     staThread.Join();
     return instance._GetText;
 }
Пример #3
0
 public System.Collections.Specialized.StringCollection GetFileDropList()
 {
     ClipboardAsync instance = new ClipboardAsync();
     Thread staThread = new Thread(instance._thGetFileDropList);
     staThread.SetApartmentState(ApartmentState.STA);
     staThread.Start();
     staThread.Join();
     return instance._GetFileDropList;
 }
Пример #4
0
 public bool ContainsText(object format)
 {
     ClipboardAsync instance = new ClipboardAsync();
     Thread staThread = new Thread(instance._thContainsFileDropList);
     staThread.SetApartmentState(ApartmentState.STA);
     staThread.Start(format);
     staThread.Join();
     return instance._ContainsText;
 }
Пример #5
0
        public bool ContainsText(object format)
        {
            ClipboardAsync instance  = new ClipboardAsync();
            Thread         staThread = new Thread(instance._thContainsFileDropList);

            staThread.SetApartmentState(ApartmentState.STA);
            staThread.Start(format);
            staThread.Join();
            return(instance._ContainsText);
        }
Пример #6
0
        public string GetText(TextDataFormat format)
        {
            ClipboardAsync instance  = new ClipboardAsync();
            Thread         staThread = new Thread(instance._thGetText);

            staThread.SetApartmentState(ApartmentState.STA);
            staThread.Start(format);
            staThread.Join();
            return(instance._GetText);
        }
Пример #7
0
        public System.Collections.Specialized.StringCollection GetFileDropList()
        {
            ClipboardAsync instance  = new ClipboardAsync();
            Thread         staThread = new Thread(instance._thGetFileDropList);

            staThread.SetApartmentState(ApartmentState.STA);
            staThread.Start();
            staThread.Join();
            return(instance._GetFileDropList);
        }
Пример #8
0
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            //if ((keyData == (Keys.Control | Keys.C)))
            //{
            //    //your implementation
            //    return true;
            //}

            if ((keyData == (Keys.Control | Keys.V)))
            {
                //ClipboardAsync Clipboard2 = new ClipboardAsync();

                //string ptxt = Clipboard2.GetText(TextDataFormat.UnicodeText).Replace(Environment.NewLine, "\r\n");
                //cbxInput.Text += ptxt;
                //return true;

                ClipboardAsync Clipboard2 = new ClipboardAsync();

                string insertText = Clipboard2.GetText(TextDataFormat.UnicodeText).Replace(Environment.NewLine, "\r\n");
                int selectionIndex = cbxInput.SelectionStart;
                cbxInput.Text = cbxInput.Text.Insert(selectionIndex, insertText);
                cbxInput.SelectionStart = selectionIndex + insertText.Length;

                return true;
            }
            else
            {
                return base.ProcessCmdKey(ref msg, keyData);
            }
        }
Пример #9
0
        private void cbxInput_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter) e.SuppressKeyPress = true;

            if (e.Control && e.KeyCode == Keys.V)
            {
                //e.Handled = true;

                ClipboardAsync Clipboard2 = new ClipboardAsync();

                //string ptxt = Clipboard2.GetText(TextDataFormat.UnicodeText).Replace(Environment.NewLine, "\r\n");
                //cbxInput.Text += ptxt;
                ////Clipboard.SetText(" ");
                ////Clipboard.Clear();
                ////string fgt = Clipboard.GetText();
                ////Clipboard.SetText(ptxt);

                ////////pasted = true;
                ////string ptxt = Clipboard.GetText().Replace(Environment.NewLine, "\r\n");

                ////Clipboard.SetText(" ");
                ////string fgt = Clipboard.GetText();
                ////Clipboard.Clear();
                ////Clipboard.SetText(ptxt);
                ////cbxInput.Text += ptxt;

                string insertText = Clipboard2.GetText(TextDataFormat.UnicodeText).Replace(Environment.NewLine, "\r\n");
                int selectionIndex = textBox1.SelectionStart;
                cbxInput.Text = cbxInput.Text.Insert(selectionIndex, insertText);
                cbxInput.SelectionStart = selectionIndex + insertText.Length;
            }
        }