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
0
1. Example
View licensepublic static bool ContainsText() { if(!NativeLib.IsUnix()) return Clipboard.ContainsText(); return true; }
0
2. Example
View licenseprivate 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; }
0
3. Example
View licenseprivate 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); }
0
4. Example
View licenseprivate 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; } }
0
5. Example
View licenseprivate 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; } }
0
6. Example
View licenseprivate 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); } }
0
7. Example
View licenseprivate 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); } }
0
8. Example
View licenseprivate 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); } }
0
9. Example
View licenseprivate 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); } }
0
10. Example
View licensepublic 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; }
0
11. Example
View licenseprivate 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; }
0
12. Example
View licenseprivate 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); } }
0
13. Example
View licenseprivate void btnPaste_Click(object sender, EventArgs e) { if (Clipboard.ContainsText()) { txtAccessToken.Text = Clipboard.GetText(); } DialogResult = DialogResult.OK; }
0
14. Example
View licenseprivate void CheckClipboardURL() { if (Clipboard.ContainsText()) { string text = Clipboard.GetText(); if (URLHelpers.IsValidURL(text)) { txtURL.Text = text; } } }
0
15. Example
View licenseprivate 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); } }
0
16. Example
View licenseprivate void CheckClipboard() { if (cbClipboard.Visible && Properties.Settings.Default.CheckClipboard) { if (Clipboard.ContainsText()) { txtLinks.Text = Clipboard.GetText(); } } }
0
17. Example
View licenseprivate 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; }
0
18. Example
View licenseprivate void PasteMenuItemClick(object sender, EventArgs e) { if (!Clipboard.ContainsText()) return; PasteTextFromClipboard(); CheckSpelling(); }
0
19. Example
View licenseprivate 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); }
0
20. Example
View licenseprivate 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); }
0
21. Example
View licensepublic 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; }
0
22. Example
View licenseprivate 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(); } } }
0
23. Example
View licenseprivate void tsmiImportClipboard_Click(object sender, EventArgs e) { if (ImportRequested != null) { if (Clipboard.ContainsText()) { string json = Clipboard.GetText(); Import(json); } } }
0
24. Example
View licenseprivate void CheckClipboardURL() { if (Clipboard.ContainsText()) { string text = Clipboard.GetText(); if (!string.IsNullOrEmpty(text) && URLHelpers.IsValidURLRegex(text)) { txtURL.Text = text; } } }
0
25. Example
View licenseprivate void tsmiImportClipboard_Click(object sender, EventArgs e) { if (ImportRequested != null) { if (Clipboard.ContainsText()) { string json = Clipboard.GetText(); Import(json); } } }
0
26. Example
View licenseprotected 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); }
0
27. Example
View licensepublic void PasteKeyFromClipboard() { if (Clipboard.ContainsText()) { cbJira.Text = JiraKeyHelpers.ParseUrlToKey(Clipboard.GetText()); UpdateOutput(true); } }
0
28. Example
View licenseprivate 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(); } } }
0
29. Example
View licenseprivate 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; }
0
30. Example
View licenseprivate 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; }
0
31. Example
View licenseprivate 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; }
0
32. Example
View licenseprivate 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; }
0
33. Example
View licensevoid requestPasteAction(object sender, EventArgs e) { if (Clipboard.ContainsText()) { textBox4.Text += Clipboard.GetText(TextDataFormat.Text).ToString(); } HighlightRTF(textBox4); }
0
34. Example
View licensevoid requestPasteAction(object sender, EventArgs e) { if (Clipboard.ContainsText()) { requestEdit.Text += Clipboard.GetText(TextDataFormat.Text).ToString(); } HighlightRTF(requestEdit); }
0
35. Example
View licensevoid responsePasteAction(object sender, EventArgs e) { if (Clipboard.ContainsText()) { response.Text += Clipboard.GetText(TextDataFormat.Text).ToString(); } HighlightRTF(response); }
0
36. Example
View licenseprivate 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); } }
0
37. Example
View licensepublic 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); } }
0
38. Example
View licensepublic 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); } }
0
39. Example
View licenseprotected 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); } }
0
40. Example
View licensepublic 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); } }
0
41. Example
View licensepublic 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); }); } }
0
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; }
0
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; }
0
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; }
0
45. Example
View licenseprivate 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); } }
0
46. Example
View licenseprivate 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); } }
0
47. Example
View licenseprivate 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); }
0
48. Example
View licensepublic 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; }
0
49. Example
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; }
0
50. Example
View licenseprivate void BtnProjPaste_Click(object sender, EventArgs e) { try { /n ..... /n //View Source file for more details /n }