Esempio n. 1
0
        public virtual int SetSite(Microsoft.VisualStudio.OLE.Interop.IServiceProvider psp)
        {
            this.site = new ServiceProvider(psp);

            extensions = new Hashtable();
            ILocalRegistry3 localRegistry = (ILocalRegistry3)site.GetService(typeof(SLocalRegistry));
            string          root          = null;

            if (localRegistry != null)
            {
                localRegistry.GetLocalRegistryRoot(out root);
            }
            using (RegistryKey rootKey = Registry.LocalMachine.OpenSubKey(root)){
                if (rootKey != null)
                {
                    string relpath = "Editors\\{" + this.GetType().GUID.ToString() + "}\\Extensions";
                    using (RegistryKey key = rootKey.OpenSubKey(relpath, false)){
                        if (key != null)
                        {
                            foreach (string ext in key.GetValueNames())
                            {
                                extensions.Add(ext.ToLower(), ext);
                            }
                        }
                    }
                }
            }
            return(0);
        }
Esempio n. 2
0
        public virtual int SetSite(Microsoft.VisualStudio.OLE.Interop.IServiceProvider site)
        {
            this.site = new ServiceProvider(site);

            // register our independent view with the IVsTextManager so that it knows
            // the user is working with a view over the text buffer. this will trigger
            // the text buffer to prompt the user whether to reload the file if it is
            // edited outside of the development Environment.
            IVsTextManager textManager = (IVsTextManager)this.site.QueryService(VsConstants.SID_SVsTextManager, typeof(IVsTextManager));

            if (textManager != null)
            {
                IVsWindowPane windowPane = (IVsWindowPane)this;
                textManager.RegisterIndependentView(this, (VsTextBuffer)this.buffer);
            }

            //register with ComponentManager for Idle processing
            this.componentManager = (IOleComponentManager)this.site.QueryService(VsConstants.SID_SOleComponentManager, typeof(IOleComponentManager));
            if (componentID == 0)
            {
                OLECRINFO[] crinfo = new OLECRINFO[1];
                crinfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO));
                crinfo[0].grfcrf = (uint)OLECRF.olecrfNeedIdleTime |
                                   (uint)OLECRF.olecrfNeedPeriodicIdleTime;
                crinfo[0].grfcadvf = (uint)OLECADVF.olecadvfModal |
                                     (uint)OLECADVF.olecadvfRedrawOff |
                                     (uint)OLECADVF.olecadvfWarningsOff;
                crinfo[0].uIdleTimeInterval = 1000;
                this.componentManager.FRegisterComponent(this, crinfo, out this.componentID);
            }
            return(0);
        }
Esempio n. 3
0
        /// <include file='doc\EditorView.uex' path='docs/doc[@for="SimpleEditorView.SetSite"]/*' />
        public virtual int SetSite(Microsoft.VisualStudio.OLE.Interop.IServiceProvider site)
        {
            this.site = new ServiceProvider(site);

            if (this.buffer != null)
            {
                // register our independent view with the IVsTextManager so that it knows
                // the user is working with a view over the text buffer. this will trigger
                // the text buffer to prompt the user whether to reload the file if it is
                // edited outside of the development Environment.
                IVsTextManager textManager = (IVsTextManager)this.site.GetService(typeof(SVsTextManager));
                // NOTE: NativeMethods.ThrowOnFailure is removed from this method because you are not allowed
                // to fail a SetSite call, see debug assert at f:\dd\env\msenv\core\docwp.cpp line 87.
                int hr = 0;
                if (textManager != null)
                {
                    IVsWindowPane windowPane = (IVsWindowPane)this;
                    hr = textManager.RegisterIndependentView(this, (VsTextBuffer)this.buffer);
                    if (!NativeMethods.Succeeded(hr))
                    {
                        Debug.Assert(false, "RegisterIndependentView failed");
                    }
                    Marshal.ReleaseComObject(textManager);
                }
            }

            //register with ComponentManager for Idle processing
            this.componentManager = (IOleComponentManager)this.site.GetService(typeof(SOleComponentManager));
            if (componentID == 0)
            {
                OLECRINFO[] crinfo = new OLECRINFO[1];

                crinfo[0].cbSize            = (uint)Marshal.SizeOf(typeof(OLECRINFO));
                crinfo[0].grfcrf            = (uint)_OLECRF.olecrfNeedIdleTime | (uint)_OLECRF.olecrfNeedPeriodicIdleTime | (uint)_OLECRF.olecrfNeedAllActiveNotifs | (uint)_OLECRF.olecrfNeedSpecActiveNotifs;
                crinfo[0].grfcadvf          = (uint)_OLECADVF.olecadvfModal | (uint)_OLECADVF.olecadvfRedrawOff | (uint)_OLECADVF.olecadvfWarningsOff;
                crinfo[0].uIdleTimeInterval = 1000;
                int hr = this.componentManager.FRegisterComponent(this, crinfo, out this.componentID);
                if (!NativeMethods.Succeeded(hr))
                {
                    Debug.Assert(false, "FRegisterComponent failed");
                }
            }
            return(NativeMethods.S_OK);
        }
Esempio n. 4
0
        // --------------------------------------------------------------------------------------------
        /// <summary>
        ///   Sets the site.
        /// </summary>
        /// <param name = "serviceProvider">The p.</param>
        /// <remarks>
        ///   The siting mechanism works as follows:  If the parent provider provides
        ///   ServiceProviderHierarchy as a service we will insert our service provider in the
        ///   WindowPaneSite slot of the hierarchy. If, however, it does not provide this service, we
        ///   will create a new ServiceProvider that will be used to resolve services through this site.
        /// </remarks>
        /// <returns>
        ///   If the method succeeds, it returns S_OK. If it fails, it returns an error code.
        /// </returns>
        // --------------------------------------------------------------------------------------------
        int IVsWindowPane.SetSite(Microsoft.VisualStudio.OLE.Interop.IServiceProvider serviceProvider)
        {
            if (_ServiceProvider != null)
            {
                _ServiceProvider.Dispose();
                _ServiceProvider = null;
            }

            var ows = GetService <IObjectWithSite>();
            var serviceHierarchy = GetService <ServiceProviderHierarchy>();

            if (serviceHierarchy != null)
            {
                ServiceProvider sp = (serviceProvider == null ? null : new ServiceProvider(serviceProvider));
                serviceHierarchy[ServiceProviderHierarchyOrder.WindowPaneSite] = sp;
            }
            else if (ows != null)
            {
                ows.SetSite(serviceProvider);
            }
            else
            {
                if (serviceProvider != null)
                {
                    _ServiceProvider = new ServiceProvider(serviceProvider);
                }
            }
            if (serviceProvider != null)
            {
                var sp   = new ServiceProvider(serviceProvider);
                var menu = sp.GetService(typeof(IMenuCommandService));
            }
            OleCommandTarget = serviceProvider as IOleCommandTarget
                               ?? new ServiceProvider(serviceProvider).GetService(typeof(IOleCommandTarget)) as IOleCommandTarget;


            // --- We can initialize the window pane as soon as it gets sited.
            if (serviceProvider != null)
            {
                InternalInit();
                Initialize();
            }
            return(NativeMethods.S_OK);
        }
Esempio n. 5
0
 public int SetSite(Microsoft.VisualStudio.OLE.Interop.IServiceProvider psp)
 {
     vsServiceProvider = new ServiceProvider(psp);
     return(VSConstants.S_OK);
 }
Esempio n. 6
0
 /// <include file='doc\EditorFactory.uex' path='docs/doc[@for="EditorFactory.SetSite"]/*' />
 public virtual int SetSite(Microsoft.VisualStudio.OLE.Interop.IServiceProvider psp)
 {
     this.site = new Microsoft.VisualStudio.Shell.ServiceProvider(psp);
     return(VSErr.S_OK);
 }
Esempio n. 7
0
 int IVsWindowPane.SetSite(Microsoft.VisualStudio.OLE.Interop.IServiceProvider psp)
 {
     return(((IVsWindowPane)TextView).SetSite(psp));
 }
Esempio n. 8
0
 /// <include file='doc\EditorFactory.uex' path='docs/doc[@for="EditorFactory.SetSite"]/*' />
 public virtual int SetSite(Microsoft.VisualStudio.OLE.Interop.IServiceProvider psp)
 {
     this.site = new ServiceProvider(psp);
     return(NativeMethods.S_OK);
 }
Esempio n. 9
0
 public int GetItemContext(uint itemid, out Microsoft.VisualStudio.OLE.Interop.IServiceProvider ppSP)
 {
     _logger.LogHierarchy("GetItemContext({0})", (int)itemid);
     ppSP = null;
     return(0);
 }
Esempio n. 10
0
 public int SetSite(Microsoft.VisualStudio.OLE.Interop.IServiceProvider site)
 {
     _site = site;
     return(0);
 }
Esempio n. 11
0
 public int GetSite(out Microsoft.VisualStudio.OLE.Interop.IServiceProvider site)
 {
     _logger.LogHierarchy("GetSite()");
     site = _site;
     return(0);
 }