示例#1
0
        private void LoadInitial()
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            IVsSolution solution = GetService <IVsSolution>(typeof(SVsSolution));

            if (solution == null)
            {
                return;
            }

            string dir, file, user;

            if (!VSErr.Succeeded(solution.GetSolutionInfo(out dir, out file, out user)) ||
                string.IsNullOrEmpty(file))
            {
                return; // No solution loaded, nothing to load
            }

            Guid             none = Guid.Empty;
            IEnumHierarchies hierEnum;

            if (!VSErr.Succeeded(solution.GetProjectEnum((uint)__VSENUMPROJFLAGS.EPF_LOADEDINSOLUTION, ref none, out hierEnum)))
            {
                return;
            }

            IVsHierarchy[] hiers = new IVsHierarchy[32];
            uint           nFetched;

            while (VSErr.Succeeded(hierEnum.Next((uint)hiers.Length, hiers, out nFetched)))
            {
                if (nFetched == 0)
                {
                    break;
                }
                for (int i = 0; i < nFetched; i++)
                {
                    IVsSccProject2 p2 = hiers[i] as IVsSccProject2;

                    if (p2 != null)
                    {
                        SccEvents.OnProjectOpened(p2, false);
                    }
                }
            }

            _solutionLoaded = true;
            SccEvents.OnSolutionOpened(false);
        }
        public int OnAfterAsynchOpenProject(IVsHierarchy pHierarchy, int fAdded)
        {
            if (!SccProvider.IsActive)
            {
                return(VSErr.S_OK);
            }

            IVsSccProject2 project = pHierarchy as IVsSccProject2;

            if (project != null)
            {
                SccEvents.OnProjectOpened(project, fAdded != 0);
            }

            return(VSErr.S_OK);
        }
        public int OnAfterOpenProject(IVsHierarchy pHierarchy, int fAdded)
        {
            if (!SccProvider.IsActive)
            {
                return(VSErr.S_OK);
            }

            IVsSccProject2 project = pHierarchy as IVsSccProject2;

            if (project != null)
            {
                SccEvents.OnProjectOpened(project, fAdded != 0);
            }
            //else
            //{
            //  IVsSccVirtualFolders vf = pHierarchy as IVsSccVirtualFolders; // Available for webprojects on a server
            //}

            return(VSErr.S_OK);
        }