private void DataGridViewOnKeyDown(object sender, KeyEventArgs e) { if (e.Handled) { return; } if (DataGridView.IsCurrentCellInEditMode && !(DataGridView.CurrentCell is DataGridViewCheckBoxCell)) { return; } if (SkylineWindow.IsPasteKeys(e.KeyData)) { var clipboardText = ClipboardEx.GetText(); if (null == clipboardText) { return; } using (var reader = new StringReader(clipboardText)) { e.Handled = PerformUndoableOperation(Resources.DataGridViewPasteHandler_DataGridViewOnKeyDown_Paste, () => Paste(reader)); } } else if (e.KeyCode == Keys.Delete && 0 == e.Modifiers) { e.Handled = PerformUndoableOperation(Resources.DataGridViewPasteHandler_DataGridViewOnKeyDown_Clear_cells, ClearCells); } }
/// <summary> /// Get a HTML fragment from the clipboard. /// </summary> /// <example> /// string html = "<b>Hello!</b>"; /// HtmlFragment.CopyToClipboard(html); /// HtmlFragment html2 = HtmlFragment.FromClipboard(); /// Debug.Assert(html2.Fragment == html); /// </example> /// <exception cref="ExternalException" /> public static HtmlFragment FromClipboard() { string rawClipboardText = ClipboardEx.GetText(TextDataFormat.Html); HtmlFragment h = new HtmlFragment(rawClipboardText); return(h); }
public static string GetClipboardText(Control owner) { try { return(ClipboardEx.GetText()); } catch (ExternalException) { MessageDlg.Show(FormUtil.FindTopLevelOwner(owner), GetPasteErrorMessage()); return(null); } }
public static void SetClipboardText(Control owner, string text) { try { ClipboardEx.Clear(); ClipboardEx.SetText(text); } catch (ExternalException) { MessageDlg.Show(FormUtil.FindTopLevelOwner(owner), GetCopyErrorMessage()); } }
/// <summary> /// Clears clipboard and copy a HTML fragment to the clipboard, providing additional meta-information. /// </summary> /// <param name="htmlFragment">a html fragment</param> /// <param name="title">optional title of the HTML document (can be null)</param> /// <param name="sourceUrl">optional Source URL of the HTML document, for resolving relative links (can be null)</param> /// <exception cref="ExternalException" /> public static void CopyToClipboard(string htmlFragment, string title, Uri sourceUrl) { ClipboardEx.SetText(ClipBoardText(htmlFragment, title, sourceUrl), TextDataFormat.Html); }