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


C# IVsCodeWindow.SetBuffer方法代码示例

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


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

示例1: 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

示例2: CreateCodeWindow

        /// <summary>
        /// Used to create Code Window
        /// </summary>
        /// <param name="parentHandle">Parent window handle</param>
        /// <param name="place">The place.</param>
        /// <param name="allowModal">if set to <c>true</c> [allow modal].</param>
        /// <param name="forceLanguageService"></param>
        /// <param name="codeWindow">Represents a multiple-document interface (MDI) child that contains one or more code views.</param>
        private void CreateCodeWindow(IntPtr parentHandle, Rectangle place, bool allowModal, Guid? forceLanguageService, out IVsCodeWindow codeWindow)
        {
            codeWindow = CreateLocalInstance<IVsCodeWindow>(typeof(VsCodeWindowClass), _serviceProvider);

            // initialize code window
            INITVIEW[] initView = new INITVIEW[1];
            initView[0].fSelectionMargin = 0;
            initView[0].IndentStyle = vsIndentStyle.vsIndentStyleSmart;
            initView[0].fWidgetMargin = 0;
            initView[0].fVirtualSpace = 0;
            initView[0].fDragDropMove = 1;
            initView[0].fVisibleWhitespace = 0;

            uint initViewFlags =
                (uint)TextViewInitFlags.VIF_SET_WIDGET_MARGIN |
                (uint)TextViewInitFlags.VIF_SET_SELECTION_MARGIN |
                (uint)TextViewInitFlags2.VIF_SUPPRESSBORDER |
                //(uint)TextViewInitFlags2.VIF_SUPPRESS_STATUS_BAR_UPDATE |
                (uint)TextViewInitFlags2.VIF_SUPPRESSTRACKCHANGES;

            if (allowModal)
                initViewFlags |= (uint)TextViewInitFlags2.VIF_ACTIVEINMODALSTATE;

            _codewindowbehaviorflags cwFlags = _codewindowbehaviorflags.CWB_DEFAULT;

            if (!EnableSplitter)
                cwFlags |= _codewindowbehaviorflags.CWB_DISABLESPLITTER;

            if (!EnableNavigationBar)
                cwFlags |= _codewindowbehaviorflags.CWB_DISABLEDROPDOWNBAR;

            IVsCodeWindowEx codeWindowEx = codeWindow as IVsCodeWindowEx;
            ErrorHandler.ThrowOnFailure(codeWindowEx.Initialize((uint)cwFlags, 0, null, null, initViewFlags, initView));

            // set buffer
            _textBuffer = CreateLocalInstance<IVsTextBuffer>(typeof(VsTextBufferClass), _serviceProvider);
            _textBuffer.InitializeContent("", 0);

            if (forceLanguageService.HasValue)
            {
                Guid languageService = forceLanguageService.Value;

                SetLanguageServiceInternal(languageService);
            }

            ErrorHandler.ThrowOnFailure(codeWindow.SetBuffer((IVsTextLines)_textBuffer));

            // create pane window
            _windowPane = (IVsWindowPane)codeWindow;
            ErrorHandler.ThrowOnFailure(_windowPane.SetSite(_serviceProvider));

            ErrorHandler.ThrowOnFailure(_windowPane.CreatePaneWindow(parentHandle, place.X, place.Y, place.Width, place.Height, out editorHwnd));

            //set the inheritKeyBinding guid so that navigation keys work. The VS 2008 SDK does this from the language service.
            // The VS2005 sdk doesn't
            IOleServiceProvider sp = codeWindow as IOleServiceProvider;
            if (sp != null)
            {
                ServiceProvider site = new ServiceProvider(sp);
                IVsWindowFrame frame = site.GetService(typeof(IVsWindowFrame).GUID) as IVsWindowFrame;
                if (frame != null)
                {
                    Guid CMDUIGUID_TextEditor = new Guid(0x8B382828, 0x6202, 0x11d1, 0x88, 0x70, 0x00, 0x00, 0xF8, 0x75, 0x79, 0xD2);
                    ErrorHandler.ThrowOnFailure(frame.SetGuidProperty((int)__VSFPROPID.VSFPROPID_InheritKeyBindings, ref CMDUIGUID_TextEditor));
                }
            }
        }
开发者ID:necora,项目名称:ank_git,代码行数:75,代码来源:TheVSTextEditor.cs

示例3: CreateCodeWindow

    private void CreateCodeWindow()
    {
      // create code window
      Guid guidVsCodeWindow = typeof(VsCodeWindowClass).GUID;
      codeWindow = services.CreateObject(services.LocalRegistry, guidVsCodeWindow, typeof(IVsCodeWindow).GUID) as IVsCodeWindow;

      CustomizeCodeWindow();

      // set buffer
      Guid guidVsTextBuffer = typeof(VsTextBufferClass).GUID;
      textBuffer = services.CreateObject(services.LocalRegistry, guidVsTextBuffer,
          typeof(IVsTextBuffer).GUID) as IVsTextBuffer;
      textBuffer.InitializeContent("ed", 2);

      Guid langSvc = new Guid(MySqlLanguageService.IID);

      int hr = textBuffer.SetLanguageServiceID(ref langSvc);
      if (hr != VSConstants.S_OK)
        Marshal.ThrowExceptionForHR(hr);

      hr = codeWindow.SetBuffer(textBuffer as IVsTextLines);
      if (hr != VSConstants.S_OK)
        Marshal.ThrowExceptionForHR(hr);

      // this is necessary for the adapters to work in VS2010
      Initialize(String.Empty);

      // create pane window
      IVsWindowPane windowPane = codeWindow as IVsWindowPane;
      hr = windowPane.SetSite(services.IOleServiceProvider);
      if (hr != VSConstants.S_OK)
        Marshal.ThrowExceptionForHR(hr);
      if (parentHandle != IntPtr.Zero)
      {
        hr = windowPane.CreatePaneWindow(parentHandle, 0, 0, 100, 100, out hwnd);
        if (hr != VSConstants.S_OK)
          Marshal.ThrowExceptionForHR(hr);
      }
    }
开发者ID:jimmy00784,项目名称:mysql-connector-net,代码行数:39,代码来源:VSCodeEditor.cs

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