public override DialogResult CreateContent(IWin32Window dialogOwner, ref string newContent) { try { if (Clipboard.ContainsData(DataFormats.Rtf)) { string rtf = (string)Clipboard.GetData(DataFormats.Rtf); string rtfNoNewline = rtfNewlineRegex.Replace(rtf, "}"); string fontName = rtfFontRegex.Match(rtf).Groups[1].Value; string html = HtmlRootProcessor.FromRTF(rtfNoNewline); newContent = "<font face=\"" + fontName + ", 'Courier New', Courier, Monospace\">" + html + "</font>"; if (newContent.Contains("\n")) { newContent = $"<pre style=\"word-wrap: break-word; white-space: pre-wrap\">{newContent}</pre><br/>"; } else { newContent += " "; } return(DialogResult.OK); } } catch (Exception e) { MessageBox.Show("Could not convert RTF content:" + e.Message, "VS Paste Problem", MessageBoxButtons.OK, MessageBoxIcon.Hand); } return(DialogResult.Cancel); }
public override DialogResult CreateContent(IWin32Window dialogOwner, ref string newContent) { try { if (Clipboard.ContainsData(DataFormats.Rtf)) { var html = HtmlRootProcessor.FromRTF((string)Clipboard.GetData(DataFormats.Rtf), options); newContent = $"<div class=\"olwVSPaste\" {GetContainerStyles()}><div {GetCodeStyles()}>{html}</div></div>"; return(DialogResult.OK); } } catch (Exception e) { MessageBox.Show("Could not convert RTF content:" + e.Message, "VS Paste Problem", MessageBoxButtons.OK, MessageBoxIcon.Hand); } return(DialogResult.Cancel); }