Exemplo n.º 1
0
        /// Called by combo control to query the text to display or to apply newly-entered text
        void StartupProjectComboHandler(object Sender, EventArgs Args)
        {
            var OleArgs = (OleMenuCmdEventArgs)Args;

            // If OutValue is non-zero, then Visual Studio is querying the current combo value to display
            if (OleArgs.OutValue != IntPtr.Zero)
            {
                string ValueString = MakeStartupProjectComboText();
                Marshal.GetNativeVariantForObject(ValueString, OleArgs.OutValue);
            }

            // Has a new input value been entered?
            else if (OleArgs.InValue != null)
            {
                var InputString = OleArgs.InValue.ToString();

                // Lookup the ProjectReference in CachedStartupProjects to get the full name
                ProjectReference ProjectRefMatch = _CachedStartupProjects.FirstOrDefault(ProjRef => ProjRef.Name == InputString);

                if (ProjectRefMatch != null && ProjectRefMatch.Project != null)
                {
                    // Switch to this project using the standard SDK method set_StartupProject
                    var ProjectHierarchy = Utils.ProjectToHierarchyObject(ProjectRefMatch.Project);
                    UnrealVSPackage.Instance.SolutionBuildManager.set_StartupProject(ProjectHierarchy);

                    // Select in solution exp and set as startup project
                    // This forces the .suo to save the project change
                    if (Utils.SelectProjectInSolutionExplorer(ProjectRefMatch.Project))
                    {
                        UnrealVSPackage.Instance.DTE.ExecuteCommand("Project.SetasStartUpProject");
                    }
                }
            }
        }