Exemplo n.º 1
0
        /// <summary>
        /// Runs this instance.
        /// </summary>
        public void Run()
        {
            TraceService.WriteHeader("ViewModelAndViewsController::Run");

            FrameworkType frameworkType = this.VisualStudioService.GetFrameworkType();

            if (frameworkType == FrameworkType.MvvmCross ||
                frameworkType == FrameworkType.XamarinForms ||
                frameworkType == FrameworkType.MvvmCrossAndXamarinForms)
            {
                this.viewModelAndViewsFactory.RegisterWizardData();

                WizardFrameViewModel viewModel = this.ShowDialog <WizardFrameViewModel>(new WizardView());

                if (viewModel.Continue)
                {
                    ViewsViewModel viewsViewModel = (ViewsViewModel)viewModel.GetWizardStepViewModel("ViewsViewModel").ViewModel;

                    this.Process(viewsViewModel.Views);
                }
            }
            else
            {
                this.ShowNotMvvmCrossOrXamarinFormsSolutionMessage();
            }
        }
        /// <summary>
        /// Runs this instance.
        /// </summary>
        public void Run()
        {
            TraceService.WriteHeader("PluginsController::Run");

            //// we open the nuget package manager console so we don't have
            //// a wait condition later!
            this.nugetService.OpenNugetWindow();

            FrameworkType frameworkType = this.VisualStudioService.GetFrameworkType();

            if (frameworkType.IsMvvmCrossSolutionType())
            {
                PluginsViewModel viewModel = this.ShowDialog <PluginsViewModel>(new PluginsView());

                if (viewModel.Continue)
                {
                    IEnumerable <Plugin> plugins = viewModel.GetRequiredPlugins();

                    if (plugins.Any())
                    {
                        this.Process(plugins);
                    }
                }
            }
            else
            {
                this.ShowNotMvvmCrossOrXamarinFormsSolutionMessage();
            }
        }
        /// <summary>
        /// Runs this instance.
        /// </summary>
        public void Run()
        {
            TraceService.WriteHeader("NugetPackagesController::Run");

            //// we open the nuget package manager console so we don't have
            //// a wait condition later!
            this.nugetService.OpenNugetWindow();

            this.nugetPackagesFactory.RegisterWizardData();

            WizardFrameViewModel viewModel = this.ShowDialog <WizardFrameViewModel>(new WizardView());

            if (viewModel.Continue)
            {
                ApplicationOptionsViewModel        applicationOptionsViewModel        = (ApplicationOptionsViewModel)viewModel.GetWizardStepViewModel("ApplicationOptionsViewModel").ViewModel;
                NinjaCoderOptionsViewModel         ninjaCoderOptionsViewModel         = (NinjaCoderOptionsViewModel)viewModel.GetWizardStepViewModel("NinjaCoderOptionsViewModel").ViewModel;
                ApplicationSamplesOptionsViewModel applicationSamplesOptionsViewModel = (ApplicationSamplesOptionsViewModel)viewModel.GetWizardStepViewModel("ApplicationSamplesOptionsViewModel").ViewModel;
                NugetPackagesViewModel             nugetPackagesViewModel             = (NugetPackagesViewModel)viewModel.GetWizardStepViewModel("NugetPackagesViewModel").ViewModel;
                XamarinFormsLabsViewModel          xamarinFormsLabsViewModel          = (XamarinFormsLabsViewModel)viewModel.GetWizardStepViewModel("XamarinFormsLabsViewModel").ViewModel;

                this.Process(
                    applicationOptionsViewModel,
                    ninjaCoderOptionsViewModel,
                    applicationSamplesOptionsViewModel,
                    nugetPackagesViewModel,
                    xamarinFormsLabsViewModel);
            }
        }
        /// <summary>
        /// Runs this instance.
        /// </summary>
        public void Run()
        {
            TraceService.WriteHeader("ProjectsController::Run");

            //// we open the nuget package manager console so we don't have a wait condition later!

            this.nugetService.OpenNugetWindow();

            this.projectFactory.RegisterWizardData();

            WizardFrameViewModel viewModel = this.ShowDialog <WizardFrameViewModel>(new WizardView());

            try
            {
                if (viewModel.Continue)
                {
                    ProjectsViewModel                  projectsViewModel                  = (ProjectsViewModel)viewModel.GetWizardStepViewModel("ProjectsViewModel").ViewModel;
                    ApplicationOptionsViewModel        applicationOptionsViewModel        = (ApplicationOptionsViewModel)viewModel.GetWizardStepViewModel("ApplicationOptionsViewModel").ViewModel;
                    NinjaCoderOptionsViewModel         ninjaCoderOptionsViewModel         = (NinjaCoderOptionsViewModel)viewModel.GetWizardStepViewModel("NinjaCoderOptionsViewModel").ViewModel;
                    ApplicationSamplesOptionsViewModel applicationSamplesOptionsViewModel = (ApplicationSamplesOptionsViewModel)viewModel.GetWizardStepViewModel("ApplicationSamplesOptionsViewModel").ViewModel;
                    ViewsViewModel            viewsViewModel            = (ViewsViewModel)viewModel.GetWizardStepViewModel("ViewsViewModel").ViewModel;
                    PluginsViewModel          pluginsViewModel          = (PluginsViewModel)viewModel.GetWizardStepViewModel("PluginsViewModel").ViewModel;
                    NugetPackagesViewModel    nugetPackagesViewModel    = (NugetPackagesViewModel)viewModel.GetWizardStepViewModel("NugetPackagesViewModel").ViewModel;
                    XamarinFormsLabsViewModel xamarinFormsLabsViewModel = (XamarinFormsLabsViewModel)viewModel.GetWizardStepViewModel("XamarinFormsLabsViewModel").ViewModel;

                    this.Process(
                        projectsViewModel,
                        applicationOptionsViewModel,
                        ninjaCoderOptionsViewModel,
                        applicationSamplesOptionsViewModel,
                        viewsViewModel,
                        pluginsViewModel,
                        nugetPackagesViewModel,
                        xamarinFormsLabsViewModel);
                }
            }
            catch (Exception exception)
            {
                //// TODO : this needs refactoring.

                this.VisualStudioService.WriteStatusBarMessage(string.Empty);
                TraceService.WriteError(exception);

                //// put the error messages in the readme!
                this.messages.InsertRange(0, TraceService.ErrorMessages);

                TraceService.ErrorMessages = new List <string>();

                this.CreateReadMe(true, true);
            }
        }
        /// <summary>
        /// Processes the specified form.
        /// </summary>
        /// <param name="applicationOptionsViewModel">The application options view model.</param>
        /// <param name="ninjaCoderOptionsViewModel">The ninja coder options view model.</param>
        /// <param name="applicationSamplesOptionsViewModel">The application samples options view model.</param>
        /// <param name="nugetPackagesViewModel">The nuget packages view model.</param>
        /// <param name="xamarinFormsLabsViewModel">The xamarin forms labs view model.</param>
        internal void Process(
            ApplicationOptionsViewModel applicationOptionsViewModel,
            NinjaCoderOptionsViewModel ninjaCoderOptionsViewModel,
            ApplicationSamplesOptionsViewModel applicationSamplesOptionsViewModel,
            NugetPackagesViewModel nugetPackagesViewModel,
            XamarinFormsLabsViewModel xamarinFormsLabsViewModel)
        {
            TraceService.WriteLine("NugetPackagesController::Process");

            this.VisualStudioService.WriteStatusBarMessage(NinjaMessages.NinjaIsRunning);

            this.messages = new List <string>();

            this.PopulateNugetActions(applicationOptionsViewModel);
            this.PopulateNugetActions(ninjaCoderOptionsViewModel);
            this.PopulateNugetActions(applicationSamplesOptionsViewModel);
            this.PopulateNugetActions(nugetPackagesViewModel);
            this.PopulateNugetActions(xamarinFormsLabsViewModel);

            if (this.SettingsService.OutputNugetCommandsToReadMe)
            {
                this.messages.Add(this.commands);
            }

            this.ReadMeService.AddLines(
                this.GetReadMePath(),
                "Add Nuget Packages",
                this.messages,
                TraceService.ErrorMessages,
                this.GetTraceMessages(false));

            TraceService.WriteHeader("RequestedNugetCommands=" + this.commands);

            if (this.SettingsService.ProcessNugetCommands)
            {
                this.nugetService.Execute(
                    this.GetReadMePath(),
                    this.commands,
                    this.SettingsService.SuspendReSharperDuringBuild);
            }

            string message = NinjaMessages.NugetDownload;

            if (this.SettingsService.UseLocalNuget)
            {
                message += " (using local " + this.SettingsService.LocalNugetName + ")";
            }

            this.VisualStudioService.WriteStatusBarMessage(message);
        }
        /// <summary>
        /// Runs this instance.
        /// </summary>
        public void Run()
        {
            TraceService.WriteHeader("EffectsController::Run");

            FrameworkType frameworkType = this.VisualStudioService.GetFrameworkType();

            if (frameworkType.IsXamarinFormsSolutionType())
            {
                this.effectFactory.RegisterWizardData();

                WizardFrameViewModel viewModel = this.ShowDialog <WizardFrameViewModel>(new WizardView());

                if (viewModel.Continue)
                {
                    EffectViewModel effectViewModel = (EffectViewModel)viewModel.GetWizardStepViewModel("EffectViewModel").ViewModel;

                    this.Process(effectViewModel);
                }
            }
            else
            {
                this.ShowNotXamarinFormsSolutionMessage();
            }
        }
        /// <summary>
        /// Processes the specified solution path.
        /// </summary>
        /// <param name="projectsViewModel">The projects view model.</param>
        /// <param name="applicationOptionsViewModel">The application options view model.</param>
        /// <param name="ninjaCoderOptionsViewModel">The ninja coder options view model.</param>
        /// <param name="applicationSamplesOptionsViewModel">The application samples options view model.</param>
        /// <param name="viewsViewModel">The views view model.</param>
        /// <param name="pluginsViewModel">The plugins view model.</param>
        /// <param name="nugetPackagesViewModel">The nuget packages view model.</param>
        /// <param name="xamarinFormsLabsViewModel">The xamarin forms labs view model.</param>
        internal void Process(
            ProjectsViewModel projectsViewModel,
            ApplicationOptionsViewModel applicationOptionsViewModel,
            NinjaCoderOptionsViewModel ninjaCoderOptionsViewModel,
            ApplicationSamplesOptionsViewModel applicationSamplesOptionsViewModel,
            ViewsViewModel viewsViewModel,
            PluginsViewModel pluginsViewModel,
            NugetPackagesViewModel nugetPackagesViewModel,
            XamarinFormsLabsViewModel xamarinFormsLabsViewModel)
        {
            TraceService.WriteLine("ProjectsController::Process");

            foreach (SelectableItemViewModel <ProjectTemplateInfo> projectTemplateInfo in projectsViewModel.Projects)
            {
                TraceService.WriteLine(projectTemplateInfo.Item.Name + " project selected=" + projectTemplateInfo.IsSelected);
            }

            this.VisualStudioService.WriteStatusBarMessage(NinjaMessages.NinjaIsRunning);

            this.applicationService.SuspendResharperIfRequested();

            this.projectsService.IsNewSolution = this.VisualStudioService.SolutionAlreadyCreated;

            //// create the solution if we don't have one!
            if (this.projectsService.IsNewSolution == false)
            {
                this.VisualStudioService.SolutionService.CreateEmptySolution(projectsViewModel.GetSolutionPath(), projectsViewModel.Project);
            }

            if (this.SettingsService.CreateTestProjectsSolutionFolder)
            {
                this.VisualStudioService.SolutionService.AddSolutionFolder(this.SettingsService.TestProjectsSolutionFolderName);
                this.VisualStudioService.DTEService.SaveAll();
            }

            this.messages = this.projectsService.AddProjects(
                this.VisualStudioService,
                projectsViewModel.GetSolutionPath(),
                projectsViewModel.GetFormattedRequiredTemplates())
                            .ToList();

            this.projectsService.SetStartUpProject();

            //// there is a bug in the xamarin iOS code that means it doesnt apply a couple of xml elements
            //// in the info.plist - here we fix that issue.

            if (this.SettingsService.FixInfoPlist)
            {
                this.applicationService.FixInfoPList(projectsViewModel.GetFormattedRequiredTemplates()
                                                     .FirstOrDefault(x => x.ProjectSuffix == this.SettingsService.iOSProjectSuffix));
            }

            IEnumerable <string> viewNugetCommands = new List <string>();

            if (this.SettingsService.FrameworkType != FrameworkType.NoFramework &&
                viewsViewModel != null)
            {
                //// if we dont have a viewmodel and view in memory - add one
                //// user will have dont show views and viewmodel options selected.
                if (!viewsViewModel.Views.Any())
                {
                    viewsViewModel.Add();
                }

                IEnumerable <string> viewModelMessages = this.viewModelViewsService.AddViewModelsAndViews(viewsViewModel.Views);

                this.messages.AddRange(viewModelMessages);

                viewNugetCommands = this.viewModelViewsService.GetNugetCommands();
            }

            TraceService.WriteLine("ProjectsController::Process GetApplication Commands");

            //// we need to get the post nuget commands that are now hosted in xml file that used to be in code
            CommandsList commandsList = this.applicationService.GetCommandsList();

            if (commandsList != null)
            {
                this.postNugetCommands.AddRange(commandsList.Commands);
                this.postNugetFileOperations.AddRange(commandsList.FileOperations);
            }

            IEnumerable <ProjectTemplateInfo> projectTemplateInfos = projectsViewModel.GetFormattedRequiredTemplates();

            this.commands += this.nugetService.GetNugetCommands(projectTemplateInfos);

            if (viewNugetCommands.Any())
            {
                foreach (string viewNugetCommand in viewNugetCommands)
                {
                    this.commands += viewNugetCommand + Environment.NewLine;
                }
            }

            this.PopulateNugetActions(applicationOptionsViewModel);
            this.PopulateNugetActions(ninjaCoderOptionsViewModel);
            this.PopulateNugetActions(applicationSamplesOptionsViewModel);
            this.PopulateNugetActions(pluginsViewModel);
            this.PopulateNugetActions(nugetPackagesViewModel);
            this.PopulateNugetActions(xamarinFormsLabsViewModel);

            this.cachingService.PostNugetCommands       = this.postNugetCommands;
            this.cachingService.PostNugetFileOperations = this.postNugetFileOperations;

            //// a bit of (unnecessary) tidying up - replace double new lines!
            this.commands = this.commands.Replace(Environment.NewLine + Environment.NewLine, Environment.NewLine);

            this.CreateReadMe(false, false);

            TraceService.WriteHeader("RequestedNugetCommands=" + this.commands);

            if (this.SettingsService.ProcessNugetCommands)
            {
                this.ProcessNugetCommands();
            }

            TraceService.WriteLine("ProjectsController::Process END");
        }