当前位置: 首页>>代码示例>>C#>>正文


C# ITextBuffer.ChangeContentType方法代码示例

本文整理汇总了C#中ITextBuffer.ChangeContentType方法的典型用法代码示例。如果您正苦于以下问题:C# ITextBuffer.ChangeContentType方法的具体用法?C# ITextBuffer.ChangeContentType怎么用?C# ITextBuffer.ChangeContentType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ITextBuffer的用法示例。


在下文中一共展示了ITextBuffer.ChangeContentType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Initialize

        protected override void Initialize()
        {
            base.Initialize();

            IComponentModel compMod = GetService(typeof(SComponentModel)) as IComponentModel;
            ITextBufferFactoryService bufferFactory = compMod.GetService<ITextBufferFactoryService>();
            ITextEditorFactoryService editorFactory = compMod.GetService<ITextEditorFactoryService>();
            IVsEditorAdaptersFactoryService adapterFactory = compMod.GetService<IVsEditorAdaptersFactoryService>();
            IContentTypeRegistryService registryService = compMod.GetService<IContentTypeRegistryService>();

            completionBroker = compMod.GetService<ICompletionBroker>();

            textView  = adapterFactory.CreateVsTextViewAdapter(GetService(typeof(IOleServiceProvider)) as IOleServiceProvider);
            IVsTextBuffer textBuffer = adapterFactory.CreateVsTextBufferAdapter(GetService(typeof(IOleServiceProvider)) as IOleServiceProvider);
            uint textViewInitFlags = (uint)TextViewInitFlags.VIF_DEFAULT
                    | (uint)TextViewInitFlags.VIF_HSCROLL
                    | (uint)TextViewInitFlags.VIF_VSCROLL;
            textBuffer.InitializeContent("", 0);
            textView.Initialize(textBuffer as IVsTextLines, IntPtr.Zero, textViewInitFlags, null);

            // Create Dev10 objects
            _textView = adapterFactory.GetWpfTextView(textView);
            mefTextBuffer = adapterFactory.GetDataBuffer(textBuffer);

            IVsUserData userData = textView as IVsUserData;
            if (userData != null)
            {
                Guid g = Microsoft.VisualStudio.Editor.DefGuidList.guidIWpfTextViewHost;
                object obj;
                int hr = userData.GetData(ref g, out obj);
                if (hr == VSConstants.S_OK)
                {
                    _textViewHost = obj as IWpfTextViewHost;
                }
            }

            //Initialize the history
            history = new HistoryBuffer();

            // Create the stream on top of the text buffer.
            textStream = new TextBufferStream(mefTextBuffer);

            // Initialize the engine.
            InitializeEngine();

            IContentType ipContentType = registryService.GetContentType(PyContentTypeDefinition.ConsoleContentType);
            mefTextBuffer.ChangeContentType(ipContentType, null);

            adapterFactory.GetWpfTextView(textView).Caret.MoveTo(new SnapshotPoint(mefTextBuffer.CurrentSnapshot, mefTextBuffer.CurrentSnapshot.Length));

            // Set the title of the window.
            this.Caption = Resources.ToolWindowTitle;

            // Set the icon of the toolwindow.
            this.BitmapResourceID = 301;
            this.BitmapIndex = 0;

            return;
        }
开发者ID:kageyamaginn,项目名称:VSSDK-Extensibility-Samples,代码行数:59,代码来源:ConsoleWindow.cs

示例2: ChangeContentType

 private void ChangeContentType(ITextBuffer buffer)
 {
     IContentType fakeXLang =
     Registry.GetContentType(ContentTypes.XLang);
       buffer.ChangeContentType(fakeXLang, FakeTag);
 }
开发者ID:bayulabster,项目名称:viasfora,代码行数:6,代码来源:XLangTextViewCreationListener.cs


注:本文中的ITextBuffer.ChangeContentType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。