本文整理汇总了C#中IVsTextView.Initialize方法的典型用法代码示例。如果您正苦于以下问题:C# IVsTextView.Initialize方法的具体用法?C# IVsTextView.Initialize怎么用?C# IVsTextView.Initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IVsTextView
的用法示例。
在下文中一共展示了IVsTextView.Initialize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VsInteractiveWindowCommandFilter
public VsInteractiveWindowCommandFilter(IVsEditorAdaptersFactoryService adapterFactory, IInteractiveWindow window, IVsTextView textViewAdapter, IVsTextBuffer bufferAdapter, IEnumerable<Lazy<IVsInteractiveWindowOleCommandTargetProvider, ContentTypeMetadata>> oleCommandTargetProviders, IContentTypeRegistryService contentTypeRegistry)
{
_window = window;
_oleCommandTargetProviders = oleCommandTargetProviders;
_contentTypeRegistry = contentTypeRegistry;
this.textViewAdapter = textViewAdapter;
// make us a code window so we'll have the same colors as a normal code window.
IVsTextEditorPropertyContainer propContainer;
ErrorHandler.ThrowOnFailure(((IVsTextEditorPropertyCategoryContainer)textViewAdapter).GetPropertyCategory(Microsoft.VisualStudio.Editor.DefGuidList.guidEditPropCategoryViewMasterSettings, out propContainer));
propContainer.SetProperty(VSEDITPROPID.VSEDITPROPID_ViewComposite_AllCodeWindowDefaults, true);
propContainer.SetProperty(VSEDITPROPID.VSEDITPROPID_ViewGlobalOpt_AutoScrollCaretOnTextEntry, true);
// editor services are initialized in textViewAdapter.Initialize - hook underneath them:
_preEditorCommandFilter = new CommandFilter(this, CommandFilterLayer.PreEditor);
ErrorHandler.ThrowOnFailure(textViewAdapter.AddCommandFilter(_preEditorCommandFilter, out _editorCommandFilter));
textViewAdapter.Initialize(
(IVsTextLines)bufferAdapter,
IntPtr.Zero,
(uint)TextViewInitFlags.VIF_HSCROLL | (uint)TextViewInitFlags.VIF_VSCROLL | (uint)TextViewInitFlags3.VIF_NO_HWND_SUPPORT,
new[] { new INITVIEW { fSelectionMargin = 0, fWidgetMargin = 0, fVirtualSpace = 0, fDragDropMove = 1 } });
// disable change tracking because everything will be changed
var textViewHost = adapterFactory.GetWpfTextViewHost(textViewAdapter);
_preLanguageCommandFilter = new CommandFilter(this, CommandFilterLayer.PreLanguage);
ErrorHandler.ThrowOnFailure(textViewAdapter.AddCommandFilter(_preLanguageCommandFilter, out _editorServicesCommandFilter));
_textViewHost = textViewHost;
}
示例2: 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;
}
示例3: InitializeEditor
public void InitializeEditor()
{
IOleServiceProvider oleServiceProvider = codeWindowHost.ServiceProvider;
bufferAdapter = editorAdapterFactoryService.CreateVsTextBufferAdapter(oleServiceProvider, codeSnippetContentType);
int result = bufferAdapter.InitializeContent("", 0);
viewAdapter = editorAdapterFactoryService.CreateVsTextViewAdapter(oleServiceProvider);
((IVsWindowPane) viewAdapter).SetSite(oleServiceProvider);
var initView = new[] {new INITVIEW()};
initView[0].fSelectionMargin = 1;
initView[0].fWidgetMargin = 0;
initView[0].fVirtualSpace = 0;
initView[0].fDragDropMove = 1;
initView[0].fVirtualSpace = 0;
uint readOnlyValue = 0;
if (codeWindowHost.ReadOnlyCodeWindow)
{
readOnlyValue = (uint) TextViewInitFlags2.VIF_READONLY;
}
uint flags =
(uint) TextViewInitFlags.VIF_SET_SELECTION_MARGIN |
(uint) TextViewInitFlags.VIF_SET_DRAGDROPMOVE |
(uint) TextViewInitFlags2.VIF_SUPPRESS_STATUS_BAR_UPDATE |
(uint) TextViewInitFlags2.VIF_SUPPRESSBORDER |
(uint) TextViewInitFlags2.VIF_SUPPRESSTRACKCHANGES |
(uint) TextViewInitFlags2.VIF_SUPPRESSTRACKGOBACK |
(uint) TextViewInitFlags.VIF_HSCROLL |
(uint) TextViewInitFlags.VIF_VSCROLL |
(uint) TextViewInitFlags3.VIF_NO_HWND_SUPPORT |
readOnlyValue;
viewAdapter.Initialize(bufferAdapter as IVsTextLines, Handle, flags, initView);
}
示例4: InitializeEditor
// ----------------------------------------------------------------------------------
/// <summary>
/// Initialize the editor
/// </summary>
// ----------------------------------------------------------------------------------
private void InitializeEditor()
{
const string message = "";
var componentModel = (IComponentModel)Microsoft.VisualStudio.Shell.Package.GetGlobalService(
typeof(SComponentModel));
_OleServiceProvider = (IServiceProvider)GetService(typeof(IServiceProvider));
_BufferFactory = componentModel.GetService<ITextBufferFactoryService>();
_EditorAdapterFactory = componentModel.GetService<IVsEditorAdaptersFactoryService>();
_BufferAdapter = _EditorAdapterFactory.CreateVsTextBufferAdapter(_OleServiceProvider,
_BufferFactory.TextContentType);
_BufferAdapter.InitializeContent(message, message.Length);
_ViewAdapter = _EditorAdapterFactory.CreateVsTextViewAdapter(_OleServiceProvider);
((IVsWindowPane)_ViewAdapter).SetSite(_OleServiceProvider);
var initView = new[] { new INITVIEW() };
initView[0].fSelectionMargin = 0; // original: 0
initView[0].fWidgetMargin = 0; // original: 0
initView[0].fVirtualSpace = 0;
initView[0].fDragDropMove = 1;
initView[0].fVirtualSpace = 0;
_ViewAdapter.Initialize(_BufferAdapter as IVsTextLines, IntPtr.Zero,
(uint)TextViewInitFlags.VIF_HSCROLL |
(uint)TextViewInitFlags3.VIF_NO_HWND_SUPPORT, initView);
}