Esempio n. 1
0
        /// <summary>
        /// Attempts to run the template wizard.
        /// </summary>
        /// <param name="shell">The <see cref="IVsUIShell">shell</see> associated with the wizard.</param>
        /// <returns>True if the wizard completed successfully; otherwise, false if the wizard was canceled.</returns>
        protected override bool TryRunWizard( IVsUIShell shell )
        {
            Arg.NotNull( shell, nameof( shell ) );

            createNewViewModel = false;

            var mapper = new ViewReplacementsMapper( Project );
            var model = new ViewItemTemplateWizardViewModel();

            // map replacements to model
            mapper.Map( Context.Replacements, model );

            // only show the dialog if the context is interactive
            if ( Context.IsInteractive )
            {
                var projectInfo = new ProjectInformation( Project );
                var view = new ViewItemTemplateWizard( model, projectInfo );

                // show the wizard
                if ( !( view.ShowDialog( shell ) ?? false ) )
                    return false;
            }

            // map model back to replacements
            mapper.Map( model, Context.Replacements );

            // store information for view model template, which typically follows
            createNewViewModel = model.ViewModelOption == 1;
            viewModelTemplateKey = model.IsTopLevelSupported && model.IsTopLevel ? "_topLevelViewModelTemplateName" : "_viewModelTemplateName";

            return true;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ViewItemTemplateWizard"/> class.
 /// </summary>
 /// <param name="model">The <see cref="ViewItemTemplateWizardViewModel">model</see> for the view.</param>
 /// <param name="projectInformation">The source <see cref="ProjectInformation">project information</see> used for browsing existing types.</param>
 public ViewItemTemplateWizard( ViewItemTemplateWizardViewModel model, ProjectInformation projectInformation )
     : this()
 {
     Model = model;
     projectInfo = projectInformation;
 }