本文整理汇总了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;
}
示例2: ChangeContentType
private void ChangeContentType(ITextBuffer buffer)
{
IContentType fakeXLang =
Registry.GetContentType(ContentTypes.XLang);
buffer.ChangeContentType(fakeXLang, FakeTag);
}