Esempio n. 1
0
        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);
        }
Esempio n. 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);
        }
Esempio n. 3
0
        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;
            }
        }
Esempio n. 4
0
 /// <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();
 }
Esempio n. 5
0
        // 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);
        }
Esempio n. 6
0
        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));
        }
Esempio n. 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);
        }
Esempio n. 8
0
 public VSCodeEditor(IOleServiceProvider psp)
     : this()
 {
     services = new ServiceBroker(psp);
     CreateCodeWindow();
 }
Esempio n. 9
0
 public VSCodeEditor(IntPtr parent, ServiceBroker services) : this()
 {
     parentHandle  = parent;
     this.services = services;
     CreateCodeWindow();
 }
Esempio n. 10
0
        public void Init(ServiceProvider serviceProvider)
        {
            ServiceBroker sb = new ServiceBroker(serviceProvider);

            nativeWindow = new VSCodeEditorWindow(sb, this);
        }