コード例 #1
0
ファイル: VSCodeEditorWindow.cs プロジェクト: Meetkp001/mysql
        public VSCodeEditorWindow(ServiceBroker sb, UserControl parent)
        {
            services   = sb;
            coreEditor = new VSCodeEditor(parent.Handle, services);

            //Create window
            IVsCodeWindow win = coreEditor.CodeWindow;

            cmdTarget = win as IOleCommandTarget;

            IVsTextView textView;
            int         hr = win.GetPrimaryView(out textView);

            if (hr != VSConstants.S_OK)
            {
                Marshal.ThrowExceptionForHR(hr);
            }

            // assign the window handle
            IntPtr commandHwnd = textView.GetWindowHandle();

            AssignHandle(commandHwnd);

            //Register priority command target
            hr = services.VsRegisterPriorityCommandTarget.RegisterPriorityCommandTarget(
                0, (IOleCommandTarget)this, out cmdTargetCookie);

            if (hr != VSConstants.S_OK)
            {
                Marshal.ThrowExceptionForHR(hr);
            }

            //Add message filter
            Application.AddMessageFilter((System.Windows.Forms.IMessageFilter) this);
        }
コード例 #2
0
        /// <summary>
        /// Initializes the specified service provider.
        /// </summary>
        /// <param name="serviceProvider">The service provider.</param>
        /// <param name="editor">The generic editor.</param>
        public void Init(ServiceProvider serviceProvider, BaseEditorControl editor)
        {
            Editor = editor;
            ServiceBroker sb = new ServiceBroker(serviceProvider);

            _nativeWindow = new VSCodeEditorWindow(sb, this);
        }
コード例 #3
0
ファイル: VSCodeEditorWindow.cs プロジェクト: Meetkp001/mysql
        public void Dispose()
        {
            //Remove message filter
            Application.RemoveMessageFilter((System.Windows.Forms.IMessageFilter) this);

            if (services != null)
            {
                // Remove this object from the list of the priority command targets.
                if (cmdTargetCookie != 0)
                {
                    IVsRegisterPriorityCommandTarget register =
                        services.VsRegisterPriorityCommandTarget;
                    if (null != register)
                    {
                        int hr = register.UnregisterPriorityCommandTarget(cmdTargetCookie);
                        if (hr != VSConstants.S_OK)
                        {
                            Marshal.ThrowExceptionForHR(hr);
                        }
                    }
                    cmdTargetCookie = 0;
                }
                services = null;
            }
            if (coreEditor != null)
            {
                IVsCodeWindow win = coreEditor.CodeWindow;
                win.Close();
                coreEditor = null;
            }
        }
コード例 #4
0
ファイル: VSCodeEditor.cs プロジェクト: lauxjpn/mysql-for-vs
 /// <summary>
 /// Initializes a new instance of the <see cref="VSCodeEditor"/> class.
 /// </summary>
 /// <param name="windowParent">The parent window.</param>
 /// <param name="services">The services broker.</param>
 public VSCodeEditor(VSCodeEditorUserControl windowParent, ServiceBroker services)
     : this()
 {
     parent        = windowParent;
     parentHandle  = parent.Handle;
     this.services = services;
     CreateCodeWindow();
 }
コード例 #5
0
ファイル: EditorBroker.cs プロジェクト: lauxjpn/mysql-for-vs
        // this method must be externally synchronized
        internal static void CreateSingleton(ServiceBroker sb)
        {
            if (Broker != null)
            {
                throw new InvalidOperationException("The singleton broker has alreaby been created.");
            }

            Broker = new EditorBroker(sb);
        }
コード例 #6
0
ファイル: EditorBroker.cs プロジェクト: lauxjpn/mysql-for-vs
        private EditorBroker(ServiceBroker sb)
        {
            // Register priority command target, this dispatches mappable keys like Enter, Backspace, Arrows, etc.
            int hr = sb.VsRegisterPriorityCommandTarget.RegisterPriorityCommandTarget(0, (IOleCommandTarget)this, out this.CmdTargetCookie);

            if (hr != VSConstants.S_OK)
            {
                Marshal.ThrowExceptionForHR(hr);
            }

            Dte = (DTE)sb.Site.GetService(typeof(DTE));
        }
コード例 #7
0
        public VSCodeEditorWindow(ServiceBroker sb, VSCodeEditorUserControl parent)
        {
            Parent     = parent;
            services   = sb;
            coreEditor = new VSCodeEditor(Parent, services);

            //Create window
            IVsCodeWindow win = coreEditor.CodeWindow;

            cmdTarget = win as IOleCommandTarget;

            IVsTextView textView;
            int         hr = win.GetPrimaryView(out textView);

            if (hr != VSConstants.S_OK)
            {
                Marshal.ThrowExceptionForHR(hr);
            }

            // assign the window handle
            IntPtr commandHwnd = textView.GetWindowHandle();

            AssignHandle(commandHwnd);

            //// Register priority command target, this dispatches mappable keys like Enter, Backspace, Arrows, etc.
            //hr = services.VsRegisterPriorityCommandTarget.RegisterPriorityCommandTarget(
            //    0, (IOleCommandTarget)CommandBroker.Broker, out cmdTargetCookie);

            //if (hr != VSConstants.S_OK)
            //  Marshal.ThrowExceptionForHR(hr);

            lock (typeof(EditorBroker))
            {
                if (EditorBroker.Broker == null)
                {
                    EditorBroker.CreateSingleton(services);
                }
                EditorBroker.RegisterEditor(this);
            }
            //Add message filter
            //Application.AddMessageFilter((System.Windows.Forms.IMessageFilter)this);
        }
コード例 #8
0
ファイル: VSCodeEditor.cs プロジェクト: lauxjpn/mysql-for-vs
 public VSCodeEditor(IOleServiceProvider psp)
     : this()
 {
     services = new ServiceBroker(psp);
     CreateCodeWindow();
 }
コード例 #9
0
 public VSCodeEditor(IntPtr parent, ServiceBroker services) : this()
 {
     parentHandle  = parent;
     this.services = services;
     CreateCodeWindow();
 }
コード例 #10
0
        public void Init(ServiceProvider serviceProvider)
        {
            ServiceBroker sb = new ServiceBroker(serviceProvider);

            nativeWindow = new VSCodeEditorWindow(sb, this);
        }