Ejemplo n.º 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 OnAfterOpenSolution(object pUnkReserved, int fNewSolution)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            _solutionLoaded = true;
            SccEvents.OnSolutionOpened(true);

            GetService <IAnkhServiceEvents>().OnSolutionOpened(EventArgs.Empty);

            if (!SccProvider.IsActive)
            {
                return(VSErr.S_OK);
            }
            try
            {
                VerifySolutionNaming();

                IAnkhSolutionSettings ss = GetService <IAnkhSolutionSettings>();

                if (ss != null && ss.ProjectRoot != null)
                {
                    string rootDir = Path.GetPathRoot(ss.ProjectRoot);
                    if (rootDir.Length == 3 && rootDir.EndsWith(":\\", StringComparison.OrdinalIgnoreCase))
                    {
                        DriveInfo di    = new DriveInfo(rootDir);
                        bool      oldFs = false;

                        switch ((di.DriveFormat ?? "").ToUpperInvariant())
                        {
                        case "FAT32":
                        case "FAT":
                            oldFs = true;
                            break;
                        }

                        if (oldFs)
                        {
                            IAnkhConfigurationService cs = GetService <IAnkhConfigurationService>();

                            if (!cs.GetWarningBool(AnkhWarningBool.FatFsFound))
                            {
                                using (SccFilesystemWarningDialog dlg = new SccFilesystemWarningDialog())
                                {
                                    dlg.Text = Path.GetFileName(ss.SolutionFilename);
                                    if (DialogResult.OK == dlg.ShowDialog(Context))
                                    {
                                        cs.SetWarningBool(AnkhWarningBool.FatFsFound, true);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                IAnkhErrorHandler handler = GetService <IAnkhErrorHandler>();

                if (handler.IsEnabled(ex))
                {
                    handler.OnError(ex);
                }
                else
                {
                    throw;
                }
            }

            return(VSErr.S_OK);
        }