Esempio n. 1
0
        private int OpenItemViaMiscellaneousProject(uint flags, string moniker, ref Guid rguidLogicalView, out IVsWindowFrame ppWindowFrame)
        {
            ppWindowFrame = null;

            var miscellaneousProject = VsShellUtilities.GetMiscellaneousProject(this._serviceProvider);
            int hresult = VSConstants.E_FAIL;

            if (miscellaneousProject != null &&
                _serviceProvider.GetService(typeof(SVsUIShellOpenDocument)) is IVsUIShellOpenDocument)
            {
                var externalFilesManager = this._serviceProvider.GetService(typeof(SVsExternalFilesManager)) as IVsExternalFilesManager;
                externalFilesManager.TransferDocument(null, moniker, null);
                IVsProject ppProject;
                hresult = externalFilesManager.GetExternalFilesProject(out ppProject);
                if (ppProject != null)
                {
                    int  pfFound;
                    uint pitemid;
                    var  pdwPriority = new VSDOCUMENTPRIORITY[1];
                    hresult = ppProject.IsDocumentInProject(moniker, out pfFound, pdwPriority, out pitemid);
                    if (pfFound == 1 && (int)pitemid != -1)
                    {
                        hresult = ppProject.OpenItem(pitemid, ref rguidLogicalView, IntPtr.Zero, out ppWindowFrame);
                    }
                }
            }
            return(hresult);
        }