Ejemplo n.º 1
0
        /// <summary>
        /// Initializes the package right after it's been "sited" into the fully-initialized Visual Studio IDE.
        /// </summary>
        protected override void Initialize()
        {
            Logging.WriteLine("Initializing UnrealVS extension...");

            // Grab the MenuCommandService
            MenuCommandService = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            // Get access to Visual Studio's DTE object.  This object has various hooks into the Visual Studio
            // shell that are useful for writing extensions.
            DTE = (DTE)GetGlobalService(typeof(DTE));
            Logging.WriteLine("DTE version " + DTE.Version);

            // Get selection manager and register to receive events
            SelectionManager =
                ServiceProvider.GlobalProvider.GetService(typeof(SVsShellMonitorSelection)) as IVsMonitorSelection;
            SelectionManager.AdviseSelectionEvents(this, out SelectionEventsHandle);

            // Get solution and register to receive events
            SolutionManager = ServiceProvider.GlobalProvider.GetService(typeof(SVsSolution)) as IVsSolution2;
            UpdateUnrealLoadedStatus();
            SolutionManager.AdviseSolutionEvents(this, out SolutionEventsHandle);

            // Grab the solution build manager.  We need this in order to change certain things about the Visual
            // Studio environment, like what the active startup project is
            // Get solution build manager
            SolutionBuildManager =
                ServiceProvider.GlobalProvider.GetService(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager2;
            SolutionBuildManager.AdviseUpdateSolutionEvents(this, out UpdateSolutionEventsHandle);

            // Create our command-line editor
            CommandLineEditor = new CommandLineEditor();

            // Create our startup project selector
            StartupProjectSelector = new StartupProjectSelector();

            // Create 'BuildStartupProject' instance
            BuildStartupProject = new BuildStartupProject();

            // Create 'CompileSingleFile' instance
            CompileSingleFile = new CompileSingleFile();

            // Create 'GenerateProjectFiles' tools
            GenerateProjectFiles = new GenerateProjectFiles();

            // Create Batch Builder tools
            BatchBuilder = new BatchBuilder();

            // Create the project menu quick builder
            QuickBuilder = new QuickBuild();

            // Call parent implementation
            base.Initialize();

            if (DTE.Solution.IsOpen)
            {
                StartTicker();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Releases unmanaged and - optionally - managed resources
        /// </summary>
        /// <param name="disposing">
        ///     <c>true</c> to release both managed and unmanaged resources;
        ///     <c>false</c> to release only unmanaged resources.
        /// </param>
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (SolutionBuildManager != null && updateSolutionEventsCookie != 0)
            {
                SolutionBuildManager.UnadviseUpdateSolutionEvents(updateSolutionEventsCookie);
            }
        }
Ejemplo n.º 3
0
        /// IDispose pattern lets us clean up our stuff!
        protected override void Dispose(bool disposing)
        {
            if (Ticker != null && Ticker.IsAlive)
            {
                Thread.Sleep(TickPeriod + TickPeriod);
                if (Ticker.IsAlive)
                {
                    Logging.WriteLine("WARNING: Force aborting Ticker thread");
                    Ticker.Abort();
                }
            }

            base.Dispose(disposing);

            // Clean up singleton instance
            PrivateInstance = null;

            CommandLineEditor      = null;
            StartupProjectSelector = null;
            BatchBuilder           = null;
            QuickBuilder           = null;

            if (CompileSingleFile != null)
            {
                CompileSingleFile.Dispose();
                CompileSingleFile = null;
            }

            // No longer want solution events
            if (SolutionEventsHandle != 0)
            {
                SolutionManager.UnadviseSolutionEvents(SolutionEventsHandle);
                SolutionEventsHandle = 0;
            }
            SolutionManager = null;

            // No longer want selection events
            if (SelectionEventsHandle != 0)
            {
                SelectionManager.UnadviseSelectionEvents(SelectionEventsHandle);
                SelectionEventsHandle = 0;
            }
            SelectionManager = null;

            // No longer want update solution events
            if (UpdateSolutionEventsHandle != 0)
            {
                SolutionBuildManager.UnadviseUpdateSolutionEvents(UpdateSolutionEventsHandle);
                UpdateSolutionEventsHandle = 0;
            }
            SolutionBuildManager = null;

            Logging.WriteLine("Closing UnrealVS extension");
            Logging.Close();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Called when the VSPackage is loaded by Visual Studio.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            var preferredLocale = settingsRepository.GetSettings().PreferredLocale;

            try
            {
                var cultureInfo = preferredLocale == string.Empty
                                ? CultureInfo.InvariantCulture
                                : CultureInfo.GetCultureInfo(preferredLocale);

                System.Threading.Thread.CurrentThread.CurrentUICulture = cultureInfo;
            }
            catch
            {
                //Ignored. This will throw if the culture in the settings repo isn't a valid culture.
            }

            if (MenuService != null)
            {
                var menuCommandID = new CommandID(
                    GuidList.guidCSharpAchiever_Achiever_VSIXCmdSet,
                    (int)PkgCmdIDList.showAchievementIndex);

                var menuItem = new MenuCommand(MenuItemCallback, menuCommandID);

                MenuService.AddCommand(menuItem);
            }

            if (SolutionBuildManager != null)
            {
                var buildTracker = new BuildTracker(DTE, achievementService);

                SolutionBuildManager.AdviseUpdateSolutionEvents(buildTracker, out updateSolutionEventsCookie);
            }

            AddService <IAchievementLibraryService>(this, true);
            AddService(achievementService, true);

            RegisterAchievementAssembly(typeof(NRefactoryAchievement).Assembly);

            AchievementUIContext.AchievementClicked    += AchievementContext_AchievementClicked;
            achievementService.StaticAnalysisCompleted += DetectionDispatcher_DetectionCompleted;
        }
Ejemplo n.º 5
0
        public int OnActiveProjectCfgChange(IVsHierarchy pIVsHierarchy)
        {
            // This function is called after a Visual Studio project has its active config changed

            // Check whether the project is the current startup project
            IVsHierarchy StartupProjectHierarchy;

            SolutionBuildManager.get_StartupProject(out StartupProjectHierarchy);
            if (StartupProjectHierarchy != null && StartupProjectHierarchy == pIVsHierarchy)
            {
                // Get the actual Project object from the IVsHierarchy object that was supplied
                var Project = Utils.HierarchyObjectToProject(pIVsHierarchy);
                if (Project != null && OnStartupProjectConfigChanged != null)
                {
                    OnStartupProjectConfigChanged(Project);
                }
            }
            return(VSConstants.S_OK);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Called when the VSPackage is loaded by Visual Studio.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            //Set a uiculture
            //System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo("ru-RU");

            ObjectFactory.Configure(a =>
            {
                a.For <IAchievementRepository>().Singleton().Use <AppDataXmlCompletedAchievementsRepository>();
                a.For <ISettingsRepository>().Singleton().Use <AppDataXmlSettingsRepository>();
            });

            if (MenuService != null)
            {
                var menuCommandID = new CommandID(
                    GuidList.guidCSharpAchiever_Achiever_VSIXCmdSet,
                    (int)PkgCmdIDList.showAchievementIndex);

                var menuItem = new MenuCommand(MenuItemCallback, menuCommandID);

                MenuService.AddCommand(menuItem);
            }

            if (SolutionBuildManager != null)
            {
                var buildTracker = new BuildTracker(DTE);

                SolutionBuildManager.AdviseUpdateSolutionEvents(buildTracker, out updateSolutionEventsCookie);
            }

            AddService <IAchevementLibraryService>(this, true);

            RegisterAchievementAssembly(typeof(NRefactoryAchievement).Assembly);

            GuiInitializer.Initialize();

            AchievementContext.AchievementClicked  += AchievementContext_AchievementClicked;
            DetectionDispatcher.DetectionCompleted += DetectionDispatcher_DetectionCompleted;
        }