Пример #1
0
        private void textBoxCommand_TextPasted(object sender, ClipboardEventArgs e)
        {
            if (e.ClipboardText.Contains("\n"))
            {
                e.Handled = true;

                // Get current text, insert at caret and process, leave any trailing line unpasted
                StringBuilder currText = new StringBuilder(textBoxCommand.Text);

                currText.Insert(textBoxCommand.SelectionStart, e.ClipboardText);

                string[] parts = Regex.Split(currText.ToString(), @"(?<=[\n])");
                foreach (string line in parts)
                {
                    if (line.EndsWith("\n"))
                    {
                        WriteOutputString(lblPrompt.Text + " " + line.TrimEnd('\r', '\n') + Environment.NewLine);
                        _input.Enqueue(line.TrimEnd('\r', '\n'));
                    }
                    else
                    {
                        if (String.IsNullOrWhiteSpace(line))
                        {
                            _input.Enqueue(String.Empty);
                            textBoxCommand.Text = String.Empty;
                        }
                        else
                        {
                            textBoxCommand.Text           = line;
                            textBoxCommand.SelectionStart = line.Length;
                        }
                    }
                }
            }
        }
Пример #2
0
        protected override void WndProc(ref Message m)
        {
            bool handled = false;

            if (m.Msg == WM_PASTE)
            {
                EventHandler<ClipboardEventArgs> evt = TextPasted;
                if ((evt != null) && Clipboard.ContainsText())
                {                    
                    ClipboardEventArgs args = new ClipboardEventArgs(Clipboard.GetText());

                    evt(this, args);
                    handled = args.Handled;
                }
            }

            if (!handled)
            {
                base.WndProc(ref m);
            }
        }
Пример #3
0
        protected override void WndProc(ref Message m)
        {
            bool handled = false;

            if (m.Msg == WM_PASTE)
            {
                EventHandler <ClipboardEventArgs> evt = TextPasted;
                if ((evt != null) && Clipboard.ContainsText())
                {
                    ClipboardEventArgs args = new ClipboardEventArgs(Clipboard.GetText());

                    evt(this, args);
                    handled = args.Handled;
                }
            }

            if (!handled)
            {
                base.WndProc(ref m);
            }
        }
Пример #4
0
        private void textBoxCommand_TextPasted(object sender, ClipboardEventArgs e)
        {
            if (e.ClipboardText.Contains("\n"))
            {
                e.Handled = true;

                // Get current text, insert at caret and process, leave any trailing line unpasted
                StringBuilder currText = new StringBuilder(textBoxCommand.Text);

                currText.Insert(textBoxCommand.SelectionStart, e.ClipboardText);

                string[] parts = Regex.Split(currText.ToString(), @"(?<=[\n])");
                foreach (string line in parts)
                {
                    if (line.EndsWith("\n"))
                    {
                        WriteOutputString(lblPrompt.Text + " " + line.TrimEnd('\r', '\n') + Environment.NewLine);                        
                        _input.Enqueue(line.TrimEnd('\r', '\n'));
                    }
                    else
                    {
                        if (String.IsNullOrWhiteSpace(line))
                        {
                            _input.Enqueue(String.Empty);
                            textBoxCommand.Text = String.Empty;
                        }
                        else
                        {
                            textBoxCommand.Text = line;
                            textBoxCommand.SelectionStart = line.Length;
                        }
                    }
                }
            }
        }