System.Windows.Forms.Clipboard.ContainsText()

Here are the examples of the csharp api class System.Windows.Forms.Clipboard.ContainsText() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

88 Examples 7

1. Example

Project: KeeThief
Source File: ClipboardUtil.cs
View license
public static bool ContainsText()
		{
			if(!NativeLib.IsUnix()) return Clipboard.ContainsText();
			return true;
		}

2. Example

Project: Calculator
Source File: CalculatorForm.cs
View license
private void OnApplicationIdle(object sender, EventArgs e)
        {
            numLockToolStripStatusLabel.Text = NativeMethods.IsNumLockOn ? "NUM" : string.Empty;
            answerToolStripStatusLabel.Text = "Answer: " + _eval.Answer;

            undoToolStripMenuItem.Enabled = inputTextBox.ContainsFocus && inputTextBox.CanUndo;
            undoToolStripButton.Enabled = undoToolStripMenuItem.Enabled;
            undoContextStripMenuItem.Enabled = undoToolStripMenuItem.Enabled;

            cutToolStripMenuItem.Enabled = inputTextBox.ContainsFocus && inputTextBox.CanSelect;
            cutToolStripButton.Enabled = cutToolStripMenuItem.Enabled;
            cutContextStripMenuItem.Enabled = cutToolStripMenuItem.Enabled;

            pasteToolStripMenuItem.Enabled = inputTextBox.ContainsFocus && Clipboard.ContainsText();
            pasteToolStripButton.Enabled = pasteToolStripMenuItem.Enabled;
            pasteContextStripMenuItem.Enabled = pasteToolStripMenuItem.Enabled;
        }

3. Example

Project: subtitleedit
Source File: Main.cs
View license
private void AudioWaveform_OnNewSelectionRightClicked(object sender, AudioVisualizer.ParagraphEventArgs e)
        {
            SubtitleListview1.SelectIndexAndEnsureVisible(_subtitle.GetIndex(e.Paragraph));

            addParagraphHereToolStripMenuItem.Visible = true;
            addParagraphAndPasteToolStripMenuItem.Visible = Clipboard.ContainsText();

            deleteParagraphToolStripMenuItem.Visible = false;
            toolStripMenuItemFocusTextbox.Visible = false;
            splitToolStripMenuItem1.Visible = false;
            mergeWithPreviousToolStripMenuItem.Visible = false;
            mergeWithNextToolStripMenuItem.Visible = false;

            contextMenuStripWaveform.Show(MousePosition.X, MousePosition.Y);
        }

4. Example

View license
private void contextMenuCopyPaste_Opening(object sender, CancelEventArgs e)
        {
            bool hastext = false;

            try
            {
                hastext = Clipboard.ContainsText();
            }
            catch
            {
                System.Diagnostics.Trace.WriteLine("Unable to access clipboard");
            }

            if (hastext)
            {
                pasteToolStripMenuItem.Enabled = true;
                insertCopiedToolStripMenuItem.Enabled = true;
            }
            else
            {
                pasteToolStripMenuItem.Enabled = false;
                insertCopiedToolStripMenuItem.Enabled = false;
            }
        }

5. Example

View license
private void contextMenuCopyPaste_Opening(object sender, CancelEventArgs e)
        {
            bool hastext = false;

            try
            {
                hastext = Clipboard.ContainsText();
            }
            catch
            {
                System.Diagnostics.Trace.WriteLine("Unable to access clipboard");
            }

            if (hastext)
            {
                pasteToolStripMenuItem.Enabled = true;
                insertCopiedToolStripMenuItem.Enabled = true;
            }
            else
            {
                pasteToolStripMenuItem.Enabled = false;
                insertCopiedToolStripMenuItem.Enabled = false;
            }
        }

6. Example

View license
private void ContextMenuStripOnOpening(object sender, CancelEventArgs cancelEventArgs)
            {
                var strip = sender as TextBoxContextMenuStrip;
                if (strip != null)
                {
                    strip.Undo.Enabled = CanUndo;
                    strip.Cut.Enabled = !string.IsNullOrEmpty(SelectedText);
                    strip.Copy.Enabled = !string.IsNullOrEmpty(SelectedText);
                    strip.Paste.Enabled = Clipboard.ContainsText();
                    strip.Delete.Enabled = !string.IsNullOrEmpty(SelectedText);
                    strip.SelectAll.Enabled = !string.IsNullOrEmpty(Text);
                }
            }

7. Example

View license
private void ContextMenuStripOnOpening(object sender, CancelEventArgs cancelEventArgs)
                {
                    var strip = sender as TextBoxContextMenuStrip;
                    if (strip != null)
                    {
                        strip.undo.Enabled = CanUndo;
                        strip.cut.Enabled = !string.IsNullOrEmpty(SelectedText);
                        strip.copy.Enabled = !string.IsNullOrEmpty(SelectedText);
                        strip.paste.Enabled = Clipboard.ContainsText();
                        strip.delete.Enabled = !string.IsNullOrEmpty(SelectedText);
                        strip.selectAll.Enabled = !string.IsNullOrEmpty(Text);
                    }
                }

8. Example

View license
private void ContextMenuStripOnOpening(object sender, CancelEventArgs cancelEventArgs)
            {
                var strip = sender as TextBoxContextMenuStrip;
                if (strip != null)
                {
                    strip.undo.Enabled = CanUndo;
                    strip.cut.Enabled = !string.IsNullOrEmpty(SelectedText);
                    strip.copy.Enabled = !string.IsNullOrEmpty(SelectedText);
                    strip.paste.Enabled = Clipboard.ContainsText();
                    strip.delete.Enabled = !string.IsNullOrEmpty(SelectedText);
                    strip.selectAll.Enabled = !string.IsNullOrEmpty(Text);
                }
            }

9. Example

Project: MaterialWinforms
Source File: MaterialTextBox.cs
View license
private void ContextMenuStripOnOpening(object sender, CancelEventArgs cancelEventArgs)
            {
                var strip = sender as TextBoxContextMenuStrip;
                if (strip != null)
                {
                    strip.undo.Enabled = CanUndo;
                    strip.cut.Enabled = !string.IsNullOrEmpty(SelectedText);
                    strip.copy.Enabled = !string.IsNullOrEmpty(SelectedText);
                    strip.paste.Enabled = Clipboard.ContainsText();
                    strip.delete.Enabled = !string.IsNullOrEmpty(SelectedText);
                    strip.selectAll.Enabled = !string.IsNullOrEmpty(Text);
                }
            }

10. Example

View license
public static string GetURLOnClipboard()
        {
            string url = string.Empty;

            if (Clipboard.ContainsText())
            {
                string tempUrl = Clipboard.GetText();

                if (ResourceLocation.IsURL(tempUrl))
                {
                    url = tempUrl;
                }
                else
                {
                    tempUrl = null;
                }
            }

            return url;
        }

11. Example

Project: KeeThief
Source File: ClipboardUtil.Unix.cs
View license
private static string GetStringU()
		{
			// string strGtk = GtkGetString();
			// if(strGtk != null) return strGtk;

			// string str = NativeLib.RunConsoleApp("xclip",
			//	"-out -selection clipboard");
			// if(str != null) return str;

			string str = NativeLib.RunConsoleApp("xsel",
				"--output --clipboard", null, XSelFlags);
			if(str != null) return str;

			if(Clipboard.ContainsText())
				return (Clipboard.GetText() ?? string.Empty);

			return string.Empty;
		}

12. Example

View license
private void ContextMenuStripOnOpening(object sender, CancelEventArgs cancelEventArgs)
            {
                var strip = sender as TextBoxContextMenuStrip;
                if (strip != null)
                {
                    strip.Undo.Enabled = CanUndo;
                    strip.Cut.Enabled = !string.IsNullOrEmpty(SelectedText);
                    strip.Copy.Enabled = !string.IsNullOrEmpty(SelectedText);
                    strip.Paste.Enabled = Clipboard.ContainsText();
                    strip.Delete.Enabled = !string.IsNullOrEmpty(SelectedText);
                    strip.SelectAll.Enabled = !string.IsNullOrEmpty(Text);
                }
            }

13. Example

View license
private void btnPaste_Click(object sender, EventArgs e)
        {
            if (Clipboard.ContainsText())
            {
                txtAccessToken.Text = Clipboard.GetText();
            }
            DialogResult = DialogResult.OK;
        }

14. Example

Project: ShareX
Source File: WebpageCaptureForm.cs
View license
private void CheckClipboardURL()
        {
            if (Clipboard.ContainsText())
            {
                string text = Clipboard.GetText();

                if (URLHelpers.IsValidURL(text))
                {
                    txtURL.Text = text;
                }
            }
        }

15. Example

View license
private void ContextMenuStripOnOpening(object sender, CancelEventArgs cancelEventArgs)
            {
                var strip = sender as TextBoxContextMenuStrip;
                if (strip != null)
                {
                    strip.undo.Enabled = CanUndo;
                    strip.cut.Enabled = !string.IsNullOrEmpty(SelectedText);
                    strip.copy.Enabled = !string.IsNullOrEmpty(SelectedText);
                    strip.paste.Enabled = Clipboard.ContainsText();
                    strip.delete.Enabled = !string.IsNullOrEmpty(SelectedText);
                    strip.selectAll.Enabled = !string.IsNullOrEmpty(Text);
                }
            }

16. Example

View license
private void CheckClipboard()
        {
            if (cbClipboard.Visible &&
                Properties.Settings.Default.CheckClipboard)
            {
                if (Clipboard.ContainsText())
                {
                    txtLinks.Text = Clipboard.GetText();                    
                }
            }
        }

17. Example

Project: xenadmin
Source File: Clip.cs
View license
private static void GetClipboard()
        {
            Program.AssertOffEventThread();

            try
            {
                if (Clipboard.ContainsText())
                {
                    string s = Clipboard.GetText();
                    if (s != ClipboardText)
                    {
                        ClipboardText = s;
                        Program.Invoke(Program.MainWindow, OnClipboardChanged);
                    }
                }
            }
            catch
            {
            }
            GettingClipboard = false;
        }

18. Example

Project: gitextensions
Source File: EditNetSpell.cs
View license
private void PasteMenuItemClick(object sender, EventArgs e)
        {
            if (!Clipboard.ContainsText()) return;
            PasteTextFromClipboard();
            CheckSpelling();
        }

19. Example

Project: GKeyBank
Source File: Import.cs
View license
private void tsbpaste_Click(object sender, EventArgs e)
        {
            if (Clipboard.ContainsText()) txtsource.Text = Clipboard.GetText();
            else MessageBox.Show(Functions.Translation("No text found in the clipboard") + ".", App.Name, MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

20. Example

Project: PKHeX
Source File: Main.cs
View license
private void ClickShowdownImportPKM(object sender, EventArgs e)
        {
            if (!Clipboard.ContainsText())
            { WinFormsUtil.Alert("Clipboard does not contain text."); return; }

            // Get Simulator Data
            ShowdownSet Set = new ShowdownSet(Clipboard.GetText());

            if (Set.Species < 0)
            { WinFormsUtil.Alert("Set data not found in clipboard."); return; }

            if (Set.Nickname?.Length > C_SAV.SAV.NickLength)
                Set.Nickname = Set.Nickname.Substring(0, C_SAV.SAV.NickLength);

            if (DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Import this set?", Set.Text))
                return;

            if (Set.InvalidLines.Any())
                WinFormsUtil.Alert("Invalid lines detected:", string.Join(Environment.NewLine, Set.InvalidLines));

            // Set Species & Nickname
            PKME_Tabs.LoadShowdownSet(Set);
        }

21. Example

Project: IronAHK
Source File: Environment.cs
View license
public static void ClipWait(double timeout, bool type)
        {
            int frequency = 100, time = (int)(timeout * 1000);

            for (int i = 0; i < time; i += frequency)
            {
                if ((!type && Clipboard.ContainsText()) || Clipboard.ContainsData(DataFormats.WaveAudio))
                {
                    ErrorLevel = 0;
                    return;
                }
                System.Threading.Thread.Sleep(frequency);
            }

            ErrorLevel = 1;
        }

22. Example

Project: Youtube-downloader
Source File: MainForm.cs
View license
private void getClipboardData()
        {

            if (Clipboard.ContainsText())
            {
                Regex isUrl = new Regex("^https?://|^www"); //if it begins with http:// or https:// or www
                Match URLtest = isUrl.Match(Clipboard.GetText());
                if (URLtest.Success) //copy content from clipboard only if it begins with http:// or https:// or www
                {
                    txtURL.Text = Clipboard.GetText();
                }

            }
        }

23. Example

Project: ShareX
Source File: ExportImportControl.cs
View license
private void tsmiImportClipboard_Click(object sender, EventArgs e)
        {
            if (ImportRequested != null)
            {
                if (Clipboard.ContainsText())
                {
                    string json = Clipboard.GetText();
                    Import(json);
                }
            }
        }

24. Example

Project: ShareX
Source File: WebpageCaptureForm.cs
View license
private void CheckClipboardURL()
        {
            if (Clipboard.ContainsText())
            {
                string text = Clipboard.GetText();

                if (!string.IsNullOrEmpty(text) && URLHelpers.IsValidURLRegex(text))
                {
                    txtURL.Text = text;
                }
            }
        }

25. Example

Project: ShareX
Source File: ExportImportControl.cs
View license
private void tsmiImportClipboard_Click(object sender, EventArgs e)
        {
            if (ImportRequested != null)
            {
                if (Clipboard.ContainsText())
                {
                    string json = Clipboard.GetText();
                    Import(json);
                }
            }
        }

26. Example

Project: jirastopwatch
Source File: ComboTextBoxEvents.cs
View license
protected override void WndProc(ref Message m)
        {
            if (m.Msg == WM_PASTE)
            {
                if (Clipboard.ContainsText())
                    Paste?.Invoke(this, new EventArgs());
                return;
            }

            if (m.Msg == WM_LBUTTONDOWN)
                MouseDown?.Invoke(this, new EventArgs());

            base.WndProc(ref m);
        }

27. Example

Project: jirastopwatch
Source File: IssueControl.cs
View license
public void PasteKeyFromClipboard()
        {
            if (Clipboard.ContainsText())
            {
                cbJira.Text = JiraKeyHelpers.ParseUrlToKey(Clipboard.GetText());
                UpdateOutput(true);
            }
        }

28. Example

Project: animalcrossingqr
Source File: URLDialog.cs
View license
private void URLDialog_Load(object sender, EventArgs e)
        {
            if (Clipboard.ContainsText())
            {
                Uri uri;
                if (Uri.TryCreate(Clipboard.GetText(), UriKind.Absolute, out uri))
                {
                    if (uri.Scheme.Equals("http", StringComparison.OrdinalIgnoreCase) ||
                        uri.Scheme.Equals("https", StringComparison.OrdinalIgnoreCase))
                        urlTextBox.Text = Clipboard.GetText();
                }
            }
        }

29. Example

Project: ipaddresscontrollib
Source File: FieldControl.cs
View license
private bool OnPaste()
      {
         if ( Clipboard.ContainsText() )
         {
            string text = Clipboard.GetText();
            if ( IsInteger( text ) )
            {
               return false;  // handle locally
            }
            else
            {
               if ( null != PasteEvent )
               {
                  PasteEventArgs args = new PasteEventArgs();
                  args.FieldIndex = FieldIndex;
                  args.Text = text;
                  PasteEvent( this, args );
                  return true;  // let parent handle it
               }
            }
         }

         return false;
      }

30. Example

Project: ipaddresscontrollib
Source File: FieldControl.cs
View license
private bool OnPaste()
      {
         if ( Clipboard.ContainsText() )
         {
            string text = Clipboard.GetText();
            if ( IsInteger( text ) )
            {
               return false;  // handle locally
            }
            else
            {
               if ( null != PasteEvent )
               {
                  PasteEventArgs args = new PasteEventArgs();
                  args.FieldIndex = FieldIndex;
                  args.Text = text;
                  PasteEvent( this, args );
                  return true;  // let parent handle it
               }
            }
         }

         return false;
      }

31. Example

Project: ipaddresscontrollib
Source File: FieldControl.cs
View license
private bool OnPaste()
    {
      if (Clipboard.ContainsText())
      {
        string text = Clipboard.GetText();
        if (IsInteger(text))
        {
          return false;  // handle locally
        }
        else
        {
          if (null != PasteEvent)
          {
            PasteEventArgs args = new PasteEventArgs();
            args.FieldIndex = FieldIndex;
            args.Text = text;
            PasteEvent(this, args);
            return true;  // let parent handle it
          }
        }
      }

      return false;
    }

32. Example

Project: ipaddresscontrollib
Source File: FieldControl.cs
View license
private bool OnPaste()
    {
      if (Clipboard.ContainsText())
      {
        string text = Clipboard.GetText();
        if (IsInteger(text))
        {
          return false;  // handle locally
        }
        else
        {
          if (null != PasteEvent)
          {
            PasteEventArgs args = new PasteEventArgs();
            args.FieldIndex = FieldIndex;
            args.Text = text;
            PasteEvent(this, args);
            return true;  // let parent handle it
          }
        }
      }

      return false;
    }

33. Example

Project: UPnP-Pentest-Toolkit
Source File: Form1.cs
View license
void requestPasteAction(object sender, EventArgs e)
        {
            if (Clipboard.ContainsText())
            {
                textBox4.Text
                    += Clipboard.GetText(TextDataFormat.Text).ToString();
            }
            HighlightRTF(textBox4);
        }

34. Example

View license
void requestPasteAction(object sender, EventArgs e)
        {
            if (Clipboard.ContainsText())
            {
                requestEdit.Text
                    += Clipboard.GetText(TextDataFormat.Text).ToString();
            }
            HighlightRTF(requestEdit);
        }

35. Example

View license
void responsePasteAction(object sender, EventArgs e)
        {
            if (Clipboard.ContainsText())
            {
                response.Text
                    += Clipboard.GetText(TextDataFormat.Text).ToString();
            }
            HighlightRTF(response);
        }

36. Example

View license
private void addModFromURLToolStripMenuItem_Click(object sender, EventArgs e)
		{
			string strDefault = "nxm://";
			if (Clipboard.ContainsText())
			{
				string strClipboard = Clipboard.GetText();
				if (!String.IsNullOrEmpty(strClipboard) && strClipboard.StartsWith("nxm://", StringComparison.OrdinalIgnoreCase))
					strDefault = strClipboard;
			}
			PromptDialog ptDialog = PromptDialog.ShowDialog(null, this, "NMM URL: (eg. nxm://Skyrim/mods/193/files/8998)", "Choose URL", strDefault, @"nxm://\w+/mods/\d+/files/\d+", "Must be a Nexus Mod URL.");
			if (ptDialog != null)
			{
				if (!String.IsNullOrEmpty(ptDialog.EnteredText))
					ViewModel.AddModCommand.Execute(ptDialog.EnteredText);
			}
		}

37. Example

Project: ShareX
Source File: UploadManager.cs
View license
public static void UploadURL(TaskSettings taskSettings = null)
        {
            if (taskSettings == null) taskSettings = TaskSettings.GetDefaultTaskSettings();

            string inputText = null;

            if (Clipboard.ContainsText())
            {
                string text = Clipboard.GetText();

                if (URLHelpers.IsValidURL(text))
                {
                    inputText = text;
                }
            }

            string url = InputBox.GetInputText("ShareX - " + Resources.UploadManager_UploadURL_URL_to_download_from_and_upload, inputText);

            if (!string.IsNullOrEmpty(url))
            {
                DownloadAndUploadFile(url, taskSettings);
            }
        }

38. Example

Project: ShareX
Source File: UploadManager.cs
View license
public static void ShowShortenURLDialog(TaskSettings taskSettings = null)
        {
            if (taskSettings == null) taskSettings = TaskSettings.GetDefaultTaskSettings();

            string inputText = null;

            if (Clipboard.ContainsText())
            {
                string text = Clipboard.GetText();

                if (URLHelpers.IsValidURL(text))
                {
                    inputText = text;
                }
            }

            string url = InputBox.GetInputText("ShareX - " + "Shorten URL", inputText, "Shorten");

            if (!string.IsNullOrEmpty(url))
            {
                ShortenURL(url, taskSettings);
            }
        }

39. Example

Project: oleviewdotnet
Source File: InputTextBox.cs
View license
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);
            }
        }

40. Example

Project: ShareX
Source File: UploadManager.cs
View license
public static void UploadURL(TaskSettings taskSettings = null)
        {
            if (taskSettings == null) taskSettings = TaskSettings.GetDefaultTaskSettings();

            string inputText = null;

            if (Clipboard.ContainsText())
            {
                string text = Clipboard.GetText();

                if (!string.IsNullOrEmpty(text) && URLHelpers.IsValidURLRegex(text))
                {
                    inputText = text;
                }
            }

            string url = InputBox.GetInputText("ShareX - " + Resources.UploadManager_UploadURL_URL_to_download_from_and_upload, inputText);

            if (!string.IsNullOrEmpty(url))
            {
                DownloadAndUploadFile(url, taskSettings);
            }
        }

41. Example

Project: xenadmin
Source File: VNCGraphicsClient.cs
View license
public void ClientCutText(String text)
        {
            Program.AssertOffEventThread();

            if (talkingToVNCTerm)
            {
                // Lets translate from unix line endings to windows ones...
                clipboardStash = toWindowsLineEndings(text);
            }
            else
            {
                if (!RedirectingClipboard())
                    return;
                Program.Invoke(this, delegate()
                {
                    if (Clipboard.ContainsText() && Clipboard.GetText() == text)
                        return;
                    Clip.SetClipboardText(text);
                });
            }
        }

42. Example

View license
[Test]
        [STAThread]
        public void CopyToClipBoard()
        {
            Clipboard.Clear();

            _traceDisplay.OnStackTraceChanged("hi, there!");
            _traceDisplay.CopyToClipBoard();

            Assert.That(Clipboard.ContainsText(), Is.True);
            Assert.That(Clipboard.GetText(), Is.EqualTo("hi, there!"));

            // calling twice doesn't add twice same content

            _traceDisplay.CopyToClipBoard();
            _traceDisplay.CopyToClipBoard();
            Assert.That(Clipboard.GetText(), Is.EqualTo("hi, there!"));

            // test to fail: calling copy to clipboard
            // with an empty stack trace is valid

            _traceDisplay.OnStackTraceChanged("");
            _traceDisplay.CopyToClipBoard();
            Assert.That(Clipboard.GetText(), Is.EqualTo(""));

            return;
        }

43. Example

View license
[Test]
        [STAThread]
        public void CopyToClipBoard()
        {
            Clipboard.Clear();

            _traceDisplay.OnStackTraceChanged("hi, there!");
            _traceDisplay.CopyToClipBoard();

            Assert.That(Clipboard.ContainsText(), Is.True);
            Assert.That(Clipboard.GetText(), Is.EqualTo("hi, there!"));

            // calling twice doesn't add twice same content

            _traceDisplay.CopyToClipBoard();
            _traceDisplay.CopyToClipBoard();
            Assert.That(Clipboard.GetText(), Is.EqualTo("hi, there!"));

            // test to fail: calling copy to clipboard
            // with an empty stack trace is valid

            _traceDisplay.OnStackTraceChanged("");
            _traceDisplay.CopyToClipBoard();
            Assert.That(Clipboard.GetText(), Is.EqualTo(""));

            return;
        }

44. Example

View license
[Test]
        [STAThread]
        public void CopyToClipBoard()
        {
            Clipboard.Clear();

            _traceDisplay.OnStackTraceChanged("hi, there!");
            _traceDisplay.CopyToClipBoard();

            Assert.That(Clipboard.ContainsText(), Is.True);
            Assert.That(Clipboard.GetText(), Is.EqualTo("hi, there!"));

            // calling twice doesn't add twice same content

            _traceDisplay.CopyToClipBoard();
            _traceDisplay.CopyToClipBoard();
            Assert.That(Clipboard.GetText(), Is.EqualTo("hi, there!"));

            // test to fail: calling copy to clipboard
            // with an empty stack trace is valid

            _traceDisplay.OnStackTraceChanged("");
            _traceDisplay.CopyToClipBoard();
            Assert.That(Clipboard.GetText(), Is.EqualTo(""));

            return;
        }

45. Example

View license
private void selectGUID()
    {
    	string guidString = string.Empty;
		if(Clipboard.ContainsText())
		{
			string clipboardText = Clipboard.GetText().Trim();
			if (this.isGUIDString(clipboardText))
			{
				guidString = clipboardText;
			}
		}
		if (guidString == string.Empty)
		{
			//TODO
			FQNInputForm fqnForm = new FQNInputForm("","Fill in the GUID","GUID:");
			if (fqnForm.ShowDialog() == DialogResult.OK)
			{
				guidString = fqnForm.fqn;
			}
		}
		if (guidString != string.Empty)
		{
			this.selectGUID(guidString);
		}
    }

46. Example

View license
private void selectFQN()
	{
		string fqn = string.Empty;
		if(Clipboard.ContainsText())
		{
			string clipboardText = Clipboard.GetText().Trim();
			if (this.looksLikeFQN(clipboardText))
			{
				fqn = clipboardText;
			}
		}
		if (fqn == string.Empty)
		{
			FQNInputForm fqnForm = new FQNInputForm();
			if (fqnForm.ShowDialog() == DialogResult.OK)
			{
				fqn = fqnForm.fqn;
			}
		}
		if (fqn != string.Empty)
		{
			this.selectFQN(fqn);
		}
		
	}

47. Example

View license
private void lnkExtractDataFromBuildUrlCopiedInTheClipboard_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (Clipboard.ContainsText() && Clipboard.GetText().Contains("buildTypeId="))
            {
                var buildUri = new Uri(Clipboard.GetText());
                var teamCityServerUrl = buildUri.Scheme + "://" + buildUri.Authority;
                TeamCityServerUrl.Text = teamCityServerUrl;
                _teamCityAdapter.InitializeHttpClient(teamCityServerUrl);

                var paramResults = _teamcityBuildUrlParameters.Matches(buildUri.Query);
                foreach (Match paramResult in paramResults)
                {
                    if (paramResult.Success)
                    {
                        if (paramResult.Groups[2].Value == "buildTypeId")
                        {
                            var buildType = _teamCityAdapter.GetBuildType(paramResult.Groups[3].Value);
                            TeamCityProjectName.Text = buildType.ParentProject;
                            TeamCityBuildIdFilter.Text = buildType.Id;
                            return;
                        }
                    }
                }
            }

            MessageBox.Show(this, _failToExtractDataFromClipboardMessage.Text, _failToExtractDataFromClipboardCaption.Text,
                MessageBoxButtons.OK, MessageBoxIcon.Warning);

        }

48. Example

View license
public static string GetClipboardText()
        {
            // code from http://forums.getpaint.net/index.php?/topic/13712-trouble-accessing-the-clipboard/page__view__findpost__p__226140
            string ret = String.Empty;
            Thread staThread = new Thread(
                () =>
                {
                    try
                    {
                        if (!Clipboard.ContainsText())
                            return;
                        ret = Clipboard.GetText();
                    }
                    catch (Exception)
                    {
                        return;
                    }
                });
            staThread.SetApartmentState(ApartmentState.STA);
            staThread.Start();
            staThread.Join();
            // at this point either you have clipboard data or an exception
            return ret;
        }

49. Example

Project: ecsharp
Source File: DiagramControl.cs
View license
[Command(null, "Paste")]
		public bool Paste(bool run = true)
		{
			if (Clipboard.ContainsData("DiagramDocument"))
			{
				if (run)
				{
					var buf = Clipboard.GetData("DiagramDocument") as byte[];
					if (buf != null)
						PasteAndSelect(new MemoryStream(buf), VectorT.Zero);
				}
				return true;
			}
			else if (Clipboard.ContainsText())
			{
				if (run)
				{
					var text = Clipboard.GetText();

					DoOrUndo act = null;
					if (_focusShape != null && (act = _focusShape.AppendTextAction(text)) != null)
						_doc.UndoStack.Do(act, true);
					else
					{
						var textBox = new TextBox(new BoundingBox<Coord>(0, 0, 300, 200))
						{
							Text = text,
							TextJustify = LLTextShape.JustifyMiddleCenter,
							BoxType = BoxType.Borderless,
							Style = BoxStyle
						};
						_doc.AddShape(textBox);
					}
				}
				return true;
			}
			return false;
		}

50. Example

Project: SLED
Source File: SledProjectNewForm.cs
View license
private void BtnProjPaste_Click(object sender, EventArgs e)
        {
            try
            {
/n ..... /n //View Source file for more details /n }