System.Windows.Forms.Clipboard.GetText(System.Windows.Forms.TextDataFormat)

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

33 Examples 7

1. Example

Project: storybrew
Source File: ClipboardHelper.cs
View license
public static string GetText(TextDataFormat format = TextDataFormat.Text)
            => Misc.WithRetries(() => Clipboard.GetText(format), 500, false);

2. Example

Project: gitextensions
Source File: HtmlFragment.cs
View license
static public HtmlFragment FromClipboard()
        {
            string rawClipboardText = Clipboard.GetText(TextDataFormat.Html);
            var h = new HtmlFragment(rawClipboardText);
            return h;
        }

3. Example

Project: FileHelpers
Source File: frmDataPreview.cs
View license
private void txtPasteData_Click(object sender, EventArgs e)
        {
            txtInput.Text = Clipboard.GetText(TextDataFormat.Text);
        }

4. Example

Project: nodejstools
Source File: NodejsReplEvaluator.cs
View license
public string FormatClipboard()
        {
            return Clipboard.GetText();
        }

5. Example

Project: XmlNotepad
Source File: UnitTest1.cs
View license
void WaitForText(string value) {            
            int retries = 20;
            string clip = null;
            while (retries-- > 0) {
                this.window.SendKeystrokes("^c");
                clip = Clipboard.GetText();
                Trace.WriteLine("clip=" + clip);
                if (clip == value)
                    return;
                Sleep(2000);
            }
            throw new Exception("Not finding expected text '" + value + "', instead we got '" + clip + "'");
        }

6. Example

Project: XmlNotepad
Source File: UnitTest1.cs
View license
string CopyHtml() {
            AutomationWrapper xsltViewer = this.window.FindDescendant("xsltViewer");
            Rectangle bounds = xsltViewer.Bounds;
            // click in HTML view
            Mouse.MouseClick(bounds.Center(), MouseButtons.Left);

            // select all the text
            Sleep(1000);
            this.window.SendKeystrokes("^a");
            
            Sleep(1000);
            this.window.SendKeystrokes("^c");
            return Clipboard.GetText();
        }

7. Example

Project: PoshSecFramework
Source File: frmMain.cs
View license
private void cmnuPSFConsole_Opening(object sender, CancelEventArgs e)
        {
            cmbtnCopy.Enabled = false;
            cmbtnPaste.Enabled = false;

            if (txtPShellOutput.SelectedText.Length > 0)
            {
                cmbtnCopy.Enabled = true;
            }

            String cliptxt = Clipboard.GetText(TextDataFormat.Text);
            if (cliptxt != null && cliptxt != "")
            {
                cmbtnPaste.Enabled = true;
            }
        }

8. Example

Project: osu-framework
Source File: LinuxClipboard.cs
View license
public override string GetText()
        {
            return System.Windows.Forms.Clipboard.GetText(TextDataFormat.UnicodeText);
        }

9. Example

View license
private void ImportURLItem_Click(object sender, EventArgs e)
        {
            var success = controller.AddServerBySSURL(Clipboard.GetText(TextDataFormat.Text));
            if (success)
            {
                ShowConfigForm();
            }
        }

10. Example

Project: FileHelpers
Source File: frmDataPreview.cs
View license
private void toolStripButton2_Click(object sender, EventArgs e)
        {
            ShowCode(Clipboard.GetText(TextDataFormat.Text), NetLanguage.CSharp);
        }

11. Example

Project: XmlNotepad
Source File: TestBase.cs
View license
public virtual void CheckClipboard(string expected) {
            if (!Clipboard.ContainsText()) {
                throw new ApplicationException("clipboard does not contain any text!");
            }
            string text = Clipboard.GetText();
            if (text != expected) {
                throw new ApplicationException("clipboard does not match expected cut node");
            }
        }

12. Example

Project: XmlNotepad
Source File: FormSchemas.cs
View license
private void pasteToolStripMenuItem_Click(object sender, EventArgs e) {
            string text = Clipboard.GetText();
            if (!string.IsNullOrEmpty(text)) {
                Push(new SchemaDialogAddFiles(this.dataGridView1, this.items,
                    text.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)));
            }
        }

13. Example

Project: PoshSecFramework
Source File: frmMain.cs
View license
private void cmbtnPaste_Click(object sender, EventArgs e)
        {
            //This gets rid of any formating and nontext data.
            Clipboard.SetText(Clipboard.GetText(TextDataFormat.Text));
            txtPShellOutput.Paste();
        }

14. Example

Project: vrs
Source File: PageWebSiteInitialSettings.cs
View license
private void linkLabelCopyFromClipboard_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            try {
                var text = Clipboard.ContainsText(TextDataFormat.UnicodeText) ? Clipboard.GetText(TextDataFormat.UnicodeText) : "";
                SettingsView.Configuration.GoogleMapSettings.InitialSettings = text;
            } catch {
            }
        }

15. Example

Project: RTVS
Source File: CommandsTest.cs
View license
[Test]
        [Category.Project]
        public async Task CopyItemPath() {
            IImmutableSet<IProjectTree> nodes1;
            IImmutableSet<IProjectTree> nodes2;
            var filePath = @"C:\Temp";
            CreateTestNodeSetPair(filePath, out nodes1, out nodes2);

            var cmd = new CopyItemPathCommand(_interactiveWorkflowProvider);
            await InUI(() => CheckSingleNodeCommandStatusAsync(cmd, RPackageCommandId.icmdCopyItemPath, nodes1, nodes2));

            var contents = await InUI(() => Clipboard.GetText());
            contents.Should().Be("\"" + filePath + "\"");
        }

16. Example

Project: XmlNotepad
Source File: UnitTest1.cs
View license
[TestMethod]
        public void TestSchemaDialog() {
            Trace.WriteLine("TestSchemaDialog=/n ..... /n //View Source file for more details /n }

17. Example

Project: XmlNotepad
Source File: UnitTest1.cs
View license
public void CheckClipboard(Regex expected)
        {
            int retries = 5;
            while (retries-- > 0)
            {
                if (Clipboard.ContainsText())
                {
                    string text = Clipboard.GetText();
                    if (expected.IsMatch(text))
                    {
                        return;
                    }
                }
                Sleep(250);
            }

            if (!Clipboard.ContainsText())
            {
                throw new ApplicationException("clipboard does not contain any text!");
            }
            throw new ApplicationException(@"clipboard [" + Clipboard.GetText() + "] does not match expected value: [" + expected + "]");
        }

18. Example

Project: subtitleedit
Source File: StartNumberingFrom.cs
View license
private void TextBox1KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == K/n ..... /n //View Source file for more details /n }

19. Example

Project: XmlNotepad
Source File: UnitTest1.cs
View license
public override void CheckClipboard(string expected) {
            int retries = 5;
            string text = null;
            while (retries-- > 0)
            {
                if (Clipboard.ContainsText())
                {
                    text = Clipboard.GetText();
                    if (IsNormalizedEqual(Clipboard.GetText(), expected))
                    {
                        return;
                    }
                }
                Sleep(250);    
            }

            if (!Clipboard.ContainsText())
            {
                throw new ApplicationException("clipboard does not contain any text!");
            } 
            AssertNormalizedEqual(""+ text, expected);
        }

20. Example

Project: XmlNotepad
Source File: UnitTest1.cs
View license
public void CheckClipboard(string expected, StringComparison comparison)
        {
            int retries = 5;
            string text = null;
            while (retries-- > 0)
            {
                if (Clipboard.ContainsText())
                {
                    text = Clipboard.GetText();
                    if (IsNormalizedEqual(text, expected, comparison))
                    {
                        return;
                    }
                }
                Sleep(250);
            }

            if (!Clipboard.ContainsText())
            {
                throw new ApplicationException("clipboard does not contain any text!");
            }
            AssertNormalizedEqual("" + text, expected, comparison);
        }

21. 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);
        }

22. Example

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

23. Example

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

24. Example

Project: subtitleedit
Source File: GoToLine.cs
View license
private void TextBox1KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == K/n ..... /n //View Source file for more details /n }

25. Example

Project: IceChat
Source File: IceInputBox.cs
View license
protected override bool ProcessCmdKey(ref System.Windows.Forms.Message msg, System.Windows.Forms.Key/n ..... /n //View Source file for more details /n }

26. Example

View license
private void pasteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string txt = Clipboard.GetText(TextDataFormat.UnicodeText);
            string[] lines = txt.Split('\n').Select(s => s.Trim('\r')).ToArray();
            foreach (string line in lines)
            {
                string[] fields = line.Split('\t');
                string sysname = fields[0].Trim();
                string dist = fields.Length >= 2 ? fields[1].Trim() : null;

                if (sysname != "")
                {
                    var row = dataGridViewDistances.Rows.Add(sysname, dist);
                    dataGridViewDistances_CellEndEdit(this, new DataGridViewCellEventArgs(0, row));
                    if (dist != "")
                    {
                        dataGridViewDistances_CellEndEdit(this, new DataGridViewCellEventArgs(1, row));
                    }
                }
            }
        }

27. Example

Project: XmlNotepad
Source File: UnitTest1.cs
View license
[TestMethod]
        public void TestChangeTo() {
            Trace.WriteLine("TestChangeTo=========/n ..... /n //View Source file for more details /n }

28. Example

Project: gitextensions
Source File: FormClone.cs
View license
protected override void OnRuntimeLoad(EventArgs e)
        {
            base.OnRuntimeLoad(e);
    /n ..... /n //View Source file for more details /n }

29. Example

View license
protected override void OnKeyDown(KeyEventArgs e)
		{
			if ((e.KeyCode == Keys.V && 0 != (e.Modifiers & Keys.Control)) ||
				(e.KeyCode == Keys.Insert && 0 != (e.Modifiers & Keys.Shift)))
			{
				e.Handled = true;
				PausePainting();
				try
				{
					// We do this in the middle of a paused painting because this way the text isn't
					// drawn twice: once without syntax highlighting and then with highlight
					if (Clipboard.ContainsText())
					{
						string text = Clipboard.GetText(TextDataFormat.UnicodeText);
						if (TextLength - SelectionLength + text.Length <= MaxLength)
							SelectedText = text;
					}
					DetectAndSaveChange();
				}
				finally
				{
					ResumePainting();
				}
			}
			else if (e.KeyCode == Keys.Z && 0 != (e.Modifiers & Keys.Control))
			{
				Undo();
				e.Handled = true;
			}
			else if (e.KeyCode == Keys.Y && 0 != (e.Modifiers & Keys.Control))
			{
				Redo();
				e.Handled = true;
			}

			if (!e.Handled)
				base.OnKeyDown(e);
		}

30. Example

Project: TweetDuck
Source File: WindowsUtils.cs
View license
public static void ClipboardStripHtmlStyles(){
            if (!Clipboard.ContainsText(TextDataFormat.Html) || !Clipboard.ContainsText(TextDataFormat.UnicodeText)){
                return;
            }

            string originalText = Clipboard.GetText(TextDataFormat.UnicodeText);
            string originalHtml = Clipboard.GetText(TextDataFormat.Html);

            string updatedHtml = RegexStripHtmlStyles.Value.Replace(originalHtml, string.Empty);

            int removed = originalHtml.Length-updatedHtml.Length;
            updatedHtml = RegexOffsetClipboardHtml.Value.Replace(updatedHtml, match => (int.Parse(match.Value)-removed).ToString().PadLeft(match.Value.Length, '0'));
            
            DataObject obj = new DataObject();
            obj.SetText(originalText, TextDataFormat.UnicodeText);
            obj.SetText(updatedHtml, TextDataFormat.Html);
            SetClipboardData(obj);
        }

31. Example

Project: SharpSCADA
Source File: Form1.cs
View license
private void LoadFromCsv()
        {
            if (Clipboard.ContainsText(TextDataFormat.Text))
  /n ..... /n //View Source file for more details /n }

32. Example

Project: Pscx
Source File: GetClipboardCommand.cs
View license
void GetClipboardContents()
        {
            if (_image)
            {
                if (WinF/n ..... /n //View Source file for more details /n }

33. Example

Project: ground-control
Source File: FormMain.cs
View license
private void PasteFromClipboard()
        {
            try
            {
                // Get dat/n ..... /n //View Source file for more details /n }