Example #1
0
        public void PasteFromClipboard()
        {
            string ClipboardText;

            try
            {
                ClipboardText = Clipboard.GetText();
            }
            catch (ExternalException)
            {
                return;
            }

            if (!string.IsNullOrEmpty(ClipboardText))
            {
                if (Idling)
                {
                    int LineBreakIndex = ClipboardText.IndexOfAny(new char[] { '\r', '\n' });
                    if (LineBreakIndex < 0)
                    {
                        InsertToInputBuffer(ClipboardText);
                    }
                    else
                    if (LineBreakIndex > 0)
                    {
                        InsertToInputBuffer(ClipboardText.Substring(0, LineBreakIndex));
                    }
                }
                else
                {
                    WriteToStandardInput(ClipboardText);
                }
            }
        }
Example #2
0
 private void Clipboard_OnClick(object sender, RoutedEventArgs e)
 {
     Popup.IsOpen = true;
     ClipboardText.GetBindingExpression(TextBox.TextProperty)?.UpdateTarget();
 }