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


C# IVsCodeWindow.GetPrimaryView方法代码示例

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


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

示例1: NavigationBarClient

        public NavigationBarClient(
            IVsDropdownBarManager manager,
            IVsCodeWindow codeWindow,
            IServiceProvider serviceProvider,
            VisualStudioWorkspaceImpl workspace)
        {
            _manager = manager;
            _codeWindow = codeWindow;
            _workspace = workspace;
            _imageService = (IVsImageService2)serviceProvider.GetService(typeof(SVsImageService));
            _projectItems = SpecializedCollections.EmptyList<NavigationBarProjectItem>();
            _currentTypeItems = SpecializedCollections.EmptyList<NavigationBarItem>();

            var vsShell = serviceProvider.GetService(typeof(SVsShell)) as IVsShell;
            if (vsShell != null)
            {
                object varImageList;
                int hresult = vsShell.GetProperty((int)__VSSPROPID.VSSPROPID_ObjectMgrTypesImgList, out varImageList);
                if (ErrorHandler.Succeeded(hresult) && varImageList != null)
                {
                    _imageList = (IntPtr)(int)varImageList;
                }
            }

            _codeWindowEventsSink = ComEventSink.Advise<IVsCodeWindowEvents>(codeWindow, this);
            _editorAdaptersFactoryService = serviceProvider.GetMefService<IVsEditorAdaptersFactoryService>();

            IVsTextView pTextView;
            codeWindow.GetPrimaryView(out pTextView);
            StartTrackingView(pTextView);

            pTextView = null;
            codeWindow.GetSecondaryView(out pTextView);
            StartTrackingView(pTextView);
        }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:35,代码来源:NavigationBarClient.cs

示例2: DartCodeWindowManager

        public DartCodeWindowManager(ITextDocumentFactoryService textDocumentFactory, IVsEditorAdaptersFactoryService editorAdapterFactory, IVsCodeWindow codeWindow, DartAnalysisServiceFactory analysisServiceFactory)
        {
            this.barManager = ((IVsDropdownBarManager)codeWindow);
            this.analysisServiceFactory = analysisServiceFactory;

            // Figure out the filename (seriously; this is the best way?!).
            IVsTextView textView;
            codeWindow.GetPrimaryView(out textView);
            wpfTextView = editorAdapterFactory.GetWpfTextView(textView);
            textDocumentFactory.TryGetTextDocument(wpfTextView.TextBuffer, out this.textDocument);
        }
开发者ID:modulexcite,项目名称:DartVS,代码行数:11,代码来源:DartCodeWindowManager.cs

示例3: GetCodeWindowManager

        public int GetCodeWindowManager(IVsCodeWindow pCodeWin, out IVsCodeWindowManager ppCodeWinMgr)
        {
            var model = _serviceProvider.GetService(typeof(SComponentModel)) as IComponentModel;
            var service = model.GetService<IVsEditorAdaptersFactoryService>();

            IVsTextView textView;
            if (ErrorHandler.Succeeded(pCodeWin.GetPrimaryView(out textView))) {
                ppCodeWinMgr = new CodeWindowManager(pCodeWin, service.GetWpfTextView(textView), _componentModel);

                return VSConstants.S_OK;
            }

            ppCodeWinMgr = null;
            return VSConstants.E_FAIL;
        }
开发者ID:TerabyteX,项目名称:main,代码行数:15,代码来源:PythonLanguageInfo.cs

示例4: GetCodeWindowManager

        public int GetCodeWindowManager(IVsCodeWindow pCodeWin, out IVsCodeWindowManager ppCodeWinMgr) {
#if !DEV12_OR_LATER
            var model = _serviceProvider.GetService(typeof(SComponentModel)) as IComponentModel;
            var service = model.GetService<IVsEditorAdaptersFactoryService>();

            IVsTextView textView;
            if (ErrorHandler.Succeeded(pCodeWin.GetPrimaryView(out textView))) {
                var wpfView = service.GetWpfTextView(textView);

                var controller = DjangoIntellisenseControllerProvider.GetOrCreateController(model, wpfView);
                controller.AttachKeyboardFilter();

#if DEV11
                new TextViewFilter(textView);
#endif
            }
#endif
            ppCodeWinMgr = null;
            return VSConstants.E_FAIL;
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:20,代码来源:DjangoLanguageInfo.cs

示例5: DropdownBarClient

        public DropdownBarClient(
            ITextBuffer textBuffer,
            IVsDropdownBarManager manager,
            IVsCodeWindow codeWindow,            
            IServiceProvider serviceProvider): base(textBuffer) {

            Logger.Trace($"{nameof(DropdownBarClient)}:Ctor");

            _manager          = manager;
            _codeWindow       = codeWindow;
            _serviceProvider  = serviceProvider;
            _projectItems     = ImmutableList<NavigationItem>.Empty;
            _taskItems        = ImmutableList<NavigationItem>.Empty;
            _dispatcher       = Dispatcher.CurrentDispatcher;
            _activeSelections = new Dictionary<int, int>();
            _focusedCombo     = -1;
            _trackedViews     = new Dictionary<IVsTextView, IWpfTextView>();

            _workspaceRegistration = Workspace.GetWorkspaceRegistration(TextBuffer.AsTextContainer());
            _workspaceRegistration.WorkspaceChanged += OnWorkspaceRegistrationChanged;
            VSColorTheme.ThemeChanged += OnThemeChanged;

            var componentModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel));
            _editorAdaptersFactoryService=componentModel.GetService<IVsEditorAdaptersFactoryService>();

            _comEventSink = ComEventSink.Advise<IVsCodeWindowEvents>(codeWindow, this);

            IVsTextView pTextView;
            codeWindow.GetPrimaryView(out pTextView);            
            ConnectView(pTextView);

            codeWindow.GetSecondaryView(out pTextView);
            ConnectView(pTextView);

            ConnectToWorkspace(_workspaceRegistration.Workspace);

            UpdateImageList();
        }
开发者ID:IInspectable,项目名称:Nav.Language.Extensions,代码行数:38,代码来源:DropdownBarClient.cs

示例6: EditorNavigationDropdownBarClient

        public EditorNavigationDropdownBarClient(IVsCodeWindow codeWindow, IVsEditorAdaptersFactoryService editorAdaptersFactory, EditorNavigationSource source, IBufferGraphFactoryService bufferGraphFactoryService)
        {
            _codeWindow = codeWindow;
            _editorAdaptersFactory = editorAdaptersFactory;
            _source = source;
            _bufferGraphFactoryService = bufferGraphFactoryService;
            _currentTextView = editorAdaptersFactory.GetWpfTextView(codeWindow.GetLastActiveView());
            _dispatcher = _currentTextView.VisualElement.Dispatcher;
            _imageList = new ImageList
            {
                ColorDepth = ColorDepth.Depth32Bit
            };

            var connectionPointContainer = codeWindow as IConnectionPointContainer;
            if (connectionPointContainer != null)
            {
                var textViewEventsGuid = typeof(IVsCodeWindowEvents).GUID;
                IConnectionPoint connectionPoint;
                connectionPointContainer.FindConnectionPoint(ref textViewEventsGuid, out connectionPoint);
                connectionPoint?.Advise(this, out _codeWindowEventsCookie);
            }

            var primaryView = codeWindow.GetPrimaryView();
            if (primaryView != null)
                ((IVsCodeWindowEvents)this).OnNewView(primaryView);

            var secondaryView = codeWindow.GetSecondaryView();
            if (secondaryView != null)
                ((IVsCodeWindowEvents)this).OnNewView(secondaryView);

            _navigationItems = new List<EditorTypeNavigationTarget>();

            source.NavigationTargetsChanged += OnNavigationTargetsChanged;
            UpdateNavigationTargets();

            _currentTextView.Caret.PositionChanged += OnCaretPositionChanged;
        }
开发者ID:pminiszewski,项目名称:HlslTools,代码行数:37,代码来源:EditorNavigationDropdownBarClient.cs

示例7: CreateEditorNavigationDropdownBar

        public IEditorNavigationDropdownBarClient CreateEditorNavigationDropdownBar(IVsCodeWindow codeWindow, IVsEditorAdaptersFactoryService editorAdaptersFactory)
        {
            // a code window can only be associated with a single buffer, so the primary view will get us the correct information
            IVsTextView primaryViewAdapter = codeWindow.GetPrimaryView();
            IWpfTextView textView = editorAdaptersFactory.GetWpfTextView(primaryViewAdapter);

            IBufferGraph bufferGraph = BufferGraphFactoryService.CreateBufferGraph(textView.TextBuffer);
            Collection<ITextBuffer> buffers = bufferGraph.GetTextBuffers(i => true);

            List<IEditorNavigationSource> sources = new List<IEditorNavigationSource>();
            foreach (ITextBuffer buffer in buffers)
            {
                var bufferProviders = NavigationSourceProviders.Where(provider => provider.Metadata.ContentTypes.Any(contentType => buffer.ContentType.IsOfType(contentType)));

                var bufferSources =
                    bufferProviders
                    .Select(provider => provider.Value.TryCreateEditorNavigationSource(buffer))
                    .Where(source => source != null);

                sources.AddRange(bufferSources);
            }

            return new EditorNavigationDropdownBar(codeWindow, editorAdaptersFactory, sources, BufferGraphFactoryService, EditorNavigationTypeRegistryService);
        }
开发者ID:sebandraos,项目名称:LangSvcV2,代码行数:24,代码来源:EditorNavigationDropdownBarFactoryService.cs

示例8: CreateVsCodeWindow

        private void CreateVsCodeWindow()
        {
            int hr = VSConstants.S_OK;
            Guid clsidVsCodeWindow = typeof(VsCodeWindowClass).GUID;
            Guid iidVsCodeWindow = typeof(IVsCodeWindow).GUID;
            Guid clsidVsTextBuffer = typeof(VsTextBufferClass).GUID;
            Guid iidVsTextLines = typeof(IVsTextLines).GUID;

            // create/site a VsTextBuffer object
            _vsTextBuffer = (IVsTextBuffer)NuoDbVSPackagePackage.Instance.CreateInstance(ref clsidVsTextBuffer, ref iidVsTextLines, typeof(IVsTextBuffer));
            IObjectWithSite ows = (IObjectWithSite)_vsTextBuffer;
            ows.SetSite(_editor);
            //string strSQL = "select * from sometable";
            //hr = _vsTextBuffer.InitializeContent(strSQL, strSQL.Length);
            switch (NuoDbVSPackagePackage.Instance.GetMajorVStudioVersion())
            {
                case 10:
                    hr = _vsTextBuffer.SetLanguageServiceID(ref GuidList.guidSQLLangSvc_VS2010);
                    break;
                case 11:
                    hr = _vsTextBuffer.SetLanguageServiceID(ref GuidList.guidSQLLangSvc_VS2012);
                    break;
            }

            // create/initialize/site a VsCodeWindow object
            _vsCodeWindow = (IVsCodeWindow)NuoDbVSPackagePackage.Instance.CreateInstance(ref clsidVsCodeWindow, ref iidVsCodeWindow, typeof(IVsCodeWindow));

            INITVIEW[] initView = new INITVIEW[1];
            initView[0].fSelectionMargin = 0;
            initView[0].fWidgetMargin = 0;
            initView[0].fVirtualSpace = 0;
            initView[0].fDragDropMove = 1;
            initView[0].fVirtualSpace = 0;
            IVsCodeWindowEx vsCodeWindowEx = (IVsCodeWindowEx)_vsCodeWindow;
            hr = vsCodeWindowEx.Initialize((uint)_codewindowbehaviorflags.CWB_DISABLEDROPDOWNBAR | (uint)_codewindowbehaviorflags.CWB_DISABLESPLITTER,
                0, null, null,
                (uint)TextViewInitFlags.VIF_SET_WIDGET_MARGIN |
                (uint)TextViewInitFlags.VIF_SET_SELECTION_MARGIN |
                (uint)TextViewInitFlags.VIF_SET_VIRTUAL_SPACE |
                (uint)TextViewInitFlags.VIF_SET_DRAGDROPMOVE |
                (uint)TextViewInitFlags2.VIF_SUPPRESS_STATUS_BAR_UPDATE |
                (uint)TextViewInitFlags2.VIF_SUPPRESSBORDER |
                (uint)TextViewInitFlags2.VIF_SUPPRESSTRACKCHANGES |
                (uint)TextViewInitFlags2.VIF_SUPPRESSTRACKGOBACK,
                initView);

            hr = _vsCodeWindow.SetBuffer((IVsTextLines)_vsTextBuffer);
            IVsWindowPane vsWindowPane = (IVsWindowPane)_vsCodeWindow;
            hr = vsWindowPane.SetSite(_editor);
            hr = vsWindowPane.CreatePaneWindow(this.Handle, 0, 0, this.Parent.Size.Width, this.Parent.Size.Height, out _hWndCodeWindow);

            IVsTextView vsTextView;
            hr = _vsCodeWindow.GetPrimaryView(out vsTextView);

            // sink IVsTextViewEvents, so we can determine when a VsCodeWindow object actually has the focus.
            IConnectionPointContainer connptCntr = (IConnectionPointContainer)vsTextView;
            Guid riid = typeof(IVsTextViewEvents).GUID;
            IConnectionPoint cp;
            connptCntr.FindConnectionPoint(ref riid, out cp);
            cp.Advise(_editor, out cookie);

            // sink IVsTextLinesEvents, so we can determine when a VsCodeWindow text has been changed.
            connptCntr = (IConnectionPointContainer)_vsTextBuffer;
            riid = typeof(IVsTextLinesEvents).GUID;
            connptCntr.FindConnectionPoint(ref riid, out cp);
            cp.Advise(_editor, out cookie);
        }
开发者ID:helluvamatt,项目名称:nuodb-dotnet,代码行数:67,代码来源:CodeWindow.cs

示例9: GetCodeWindowManager

 // GetCodeWindowManager -- this gives us the VsCodeWindow which is what we need to
 // add adornments and so forth.
 public virtual int GetCodeWindowManager(IVsCodeWindow w, out IVsCodeWindowManager mgr) {
   IVsCodeWindow codeWindow = (IVsCodeWindow)w;
   IVsTextView textView;
   w.GetPrimaryView(out textView);
   IVsTextLines buffer;
   textView.GetBuffer(out buffer);
   mgr = this.GetCodeWindowManager(this, codeWindow, GetSource(buffer));
   return 0;
 }
开发者ID:hesam,项目名称:SketchSharp,代码行数:11,代码来源:LanguageService.cs

示例10: EditorNavigationDropdownBar

        public EditorNavigationDropdownBar(IVsCodeWindow codeWindow, IVsEditorAdaptersFactoryService editorAdaptersFactory, IEnumerable<IEditorNavigationSource> sources, IBufferGraphFactoryService bufferGraphFactoryService, IJavaEditorNavigationTypeRegistryService editorNavigationTypeRegistryService)
        {
            Contract.Requires<ArgumentNullException>(codeWindow != null, "codeWindow");
            Contract.Requires<ArgumentNullException>(editorAdaptersFactory != null, "editorAdaptersFactory");
            Contract.Requires<ArgumentNullException>(sources != null, "sources");
            Contract.Requires<ArgumentNullException>(bufferGraphFactoryService != null, "bufferGraphFactoryService");
            Contract.Requires<ArgumentNullException>(editorNavigationTypeRegistryService != null, "editorNavigationTypeRegistryService");

            this._codeWindow = codeWindow;
            this._editorAdaptersFactory = editorAdaptersFactory;
            this._sources = sources;
            this._bufferGraphFactoryService = bufferGraphFactoryService;
            this._editorNavigationTypeRegistryService = editorNavigationTypeRegistryService;
            this._currentTextView = editorAdaptersFactory.GetWpfTextView(codeWindow.GetLastActiveView());
            this._dispatcher = this._currentTextView.VisualElement.Dispatcher;
            this._imageList = new ImageList()
                {
                    ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit
                };

            _navigationControls =
                this._sources
                .SelectMany(source => source.GetNavigationTypes())
                .Distinct()
                //.OrderBy(...)
                .Select(type => Tuple.Create(type, new List<IEditorNavigationTarget>()))
                .ToArray();

            _selectedItem = new IEditorNavigationTarget[_navigationControls.Length];

            if (this._navigationControls.Length == 0)
            {
                return;
            }

            IConnectionPointContainer connectionPointContainer = codeWindow as IConnectionPointContainer;
            if (connectionPointContainer != null)
            {
                Guid textViewEventsGuid = typeof(IVsCodeWindowEvents).GUID;
                IConnectionPoint connectionPoint;
                connectionPointContainer.FindConnectionPoint(ref textViewEventsGuid, out connectionPoint);
                if (connectionPoint != null)
                    connectionPoint.Advise(this, out _codeWindowEventsCookie);
            }

            IVsTextView primaryView = codeWindow.GetPrimaryView();
            if (primaryView != null)
                ((IVsCodeWindowEvents)this).OnNewView(primaryView);

            IVsTextView secondaryView = codeWindow.GetSecondaryView();
            if (secondaryView != null)
                ((IVsCodeWindowEvents)this).OnNewView(secondaryView);

            foreach (var source in this._sources)
            {
                source.NavigationTargetsChanged += WeakEvents.AsWeak(OnNavigationTargetsChanged, eh => source.NavigationTargetsChanged -= eh);
                UpdateNavigationTargets(source);
            }

            _currentTextView.Caret.PositionChanged += OnCaretPositionChanged;
        }
开发者ID:Kav2018,项目名称:JavaForVS,代码行数:61,代码来源:EditorNavigationDropdownBar.cs

示例11: CreateVsCodeWindow

        private void CreateVsCodeWindow()
        {
            int hr = VSConstants.S_OK;
            //ILocalRegistry localRegistry = (ILocalRegistry)Package.GetGlobalService(typeof(SLocalRegistry));
            IComponentModel componentModel = (IComponentModel)Package.GetGlobalService(typeof(SComponentModel));

            Guid clsidVsCodeWindow = typeof(VsCodeWindowClass).GUID;
            Guid iidVsCodeWindow = typeof(IVsCodeWindow).GUID;
            Guid iidVsTextLines = typeof(IVsTextLines).GUID;
            Guid clsidTextBuffer = typeof(VsTextBufferClass).GUID;
            Guid iidTextBuffer = VSConstants.IID_IUnknown;

            // create/site a VsTextBuffer object
            var editorAdaptersFactoryService = componentModel.GetService<IVsEditorAdaptersFactoryService>();
            vsTextBuffer = editorAdaptersFactoryService.CreateVsTextBufferAdapter(OleServiceProvider);

            string strSQL = Global.textStub;
            hr = vsTextBuffer.InitializeContent(strSQL, strSQL.Length);
            hr = vsTextBuffer.SetLanguageServiceID(ref GuidList.guidCppLangSvc);

            // create/initialize/site a VsCodeWindow object
            _vsCodeWindow = editorAdaptersFactoryService.CreateVsCodeWindowAdapter(OleServiceProvider);

            INITVIEW[] initView = new INITVIEW[1];
            initView[0].fSelectionMargin = 0;
            initView[0].fWidgetMargin = 0;
            initView[0].fVirtualSpace = 0;
            initView[0].fDragDropMove = 1;
            initView[0].fVirtualSpace = 0;
            IVsCodeWindowEx vsCodeWindowEx = (IVsCodeWindowEx)_vsCodeWindow;
            hr = vsCodeWindowEx.Initialize((uint)_codewindowbehaviorflags.CWB_DISABLEDROPDOWNBAR | (uint)_codewindowbehaviorflags.CWB_DISABLESPLITTER,
                0, null, null,
                (uint)TextViewInitFlags.VIF_SET_WIDGET_MARGIN |
                (uint)TextViewInitFlags.VIF_SET_SELECTION_MARGIN |
                (uint)TextViewInitFlags.VIF_SET_VIRTUAL_SPACE |
                (uint)TextViewInitFlags.VIF_SET_DRAGDROPMOVE |
                (uint)TextViewInitFlags2.VIF_SUPPRESS_STATUS_BAR_UPDATE |
                (uint)TextViewInitFlags2.VIF_READONLY |
                (uint)TextViewInitFlags2.VIF_SUPPRESSBORDER |
                (uint)TextViewInitFlags2.VIF_SUPPRESSTRACKCHANGES |
                (uint)TextViewInitFlags2.VIF_SUPPRESSTRACKGOBACK,
                initView);

            hr = _vsCodeWindow.SetBuffer((IVsTextLines)vsTextBuffer);

            IVsTextView vsTextView;
            hr = _vsCodeWindow.GetPrimaryView(out vsTextView);

            textViewHost = editorAdaptersFactoryService.GetWpfTextViewHost(vsTextView);

            textViewHost.TextView.Options.SetOptionValue(DefaultTextViewHostOptions.ChangeTrackingId, false);
            textViewHost.TextView.Options.SetOptionValue(DefaultTextViewHostOptions.GlyphMarginId, false);
            textViewHost.TextView.Options.SetOptionValue(DefaultTextViewHostOptions.HorizontalScrollBarId, false);
            textViewHost.TextView.Options.SetOptionValue(DefaultTextViewHostOptions.OutliningMarginId, false);

            textViewHost.TextView.Options.SetOptionValue(DefaultTextViewOptions.ViewProhibitUserInputId, true);
            Content = textViewHost.HostControl;
        }
开发者ID:Predelnik,项目名称:CppFormatter,代码行数:58,代码来源:CodeWindow.xaml.cs


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