Beispiel #1
0
        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("{fa498a2d-116a-4f25-9b55-7938e8e6dda7}");

            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);
                }
            }
        }
Beispiel #2
0
        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();

            if (parent == null || typeof(SqlEditor) == parent.Editor.GetType())
            {
                langSvc = new Guid(MySqlLanguageService.IID);
            }
            else
            {
                //TODO: [MYSQLFORVS-276] - CREATE A CLASSIFIER EXTENSION THAT COLORS THE APPROPRIATE TEXT (MYJS FILES).
                if (parent == null || typeof(MySqlHybridScriptEditor) == parent.Editor.GetType() && ((MySqlHybridScriptEditor)parent.Editor).ScriptLanguageType == ScriptLanguageType.JavaScript)
                {
                    langSvc = new Guid(MyJsLanguageService.IID);
                }
                //else
                //TODO: [MYSQLFORVS-402] - CREATE A CLASSIFIER EXTENSION THAT COLORS THE APPROPRIATE TEXT (MYPY FILES).
                else if (parent == null || typeof(MySqlHybridScriptEditor) == parent.Editor.GetType() && ((MySqlHybridScriptEditor)parent.Editor).ScriptLanguageType == ScriptLanguageType.Python)
                {
                    langSvc = new Guid(MyPyLanguageService.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);
                }
            }
        }