Exemplo n.º 1
0
        // Check that actual clipboard text and HTML match the expected clipboard text and HTML.
        private static void CheckCopiedNodes(int shallowestLevel, int expectedLineBreaks)
        {
            StringBuilder htmlSb = new StringBuilder();
            StringBuilder textSb = new StringBuilder();

            int lineBreaks = 0;

            var seqTree = SkylineWindow.SequenceTree;

            foreach (TreeNodeMS node in seqTree.SelectedNodes)
            {
                IClipboardDataProvider provider = node as IClipboardDataProvider;
                DataObject             data     = provider == null ? null : provider.ProvideData();
                if (data == null)
                {
                    continue;
                }
                int    levels       = node.Level - shallowestLevel;
                string providerHtml = (string)data.GetData(DataFormats.Html);
                if (providerHtml != null)
                {
                    AppendText(htmlSb, new HtmlFragment(providerHtml).Fragment,
                               HTML_LINE_BREAK, HTML_INDENT, levels, lineBreaks);
                }
                string providerText = (string)data.GetData("Text");
                if (providerText != null)
                {
                    AppendText(textSb, providerText, TEXT_LINE_BREAK, TEXT_INDENT, levels, lineBreaks);
                }

                lineBreaks = expectedLineBreaks;
            }
            htmlSb.AppendLine();
            textSb.AppendLine();

            Assert.AreEqual(textSb.ToString(), GetClipboardText());
            Assert.AreEqual(htmlSb.ToString(), new HtmlFragment(GetClipboardHtml()).Fragment);
        }
 public FormatOnPasteCommand(ITextView textView, ITextBuffer textBuffer) :
     base(textView, new CommandId(VSConstants.GUID_VSStandardCommandSet97, (int)VSConstants.VSStd97CmdID.Paste)) {
     ClipboardDataProvider = new ClipboardDataProvider();
 }
Exemplo n.º 3
0
 public FormatOnPasteCommand(ITextView textView, ITextBuffer textBuffer) :
     base(textView, new CommandId(VSConstants.GUID_VSStandardCommandSet97, (int)VSConstants.VSStd97CmdID.Paste))
 {
     ClipboardDataProvider = new ClipboardDataProvider();
 }
Exemplo n.º 4
0
 public FormatOnPasteCommand(ITextView textView, ITextBuffer textBuffer, IServiceContainer services) :
     base(textView, services, new CommandId(VSConstants.GUID_VSStandardCommandSet97, (int)VSConstants.VSStd97CmdID.Paste))
 {
     ClipboardDataProvider = new ClipboardDataProvider();
     _settings             = services.GetService <IREditorSettings>();
 }