Esempio n. 1
0
        public SetupFinishViewModel(SetupResult result, AdvancedWizardPageViewModel previousPage, IScreen screen = null) : base("setup_finish", screen)
        {
            Button1Visible = false;
            Button2Visible = false;
            Button3Text    = "Finish";
            IsFinishPage   = true;

            Button3Command = ReactiveCommand.CreateFromObservable(() =>
            {
                var closeWizard = (HostScreen as SetupWindowViewModel)?.CloseWizard;
                return(closeWizard?.Handle(Unit.Default));
            });

            if (result.OperationCanceled)
            {
                Title = "Setup Aborted";
                Text  = "Setup Aborted";
                return;
            }

            if (result.OperationFailed)
            {
                Title = "Setup Failed";
                Text  = Properties.Resources.Setup_Finish_UnexpectedError_Message;
                return;
            }

            Title = "Setup Completed";

            if (previousPage is SetupCheckFlutterViewModel || previousPage is SetupCheckFlutterErrorViewModel)
            {
                FlutterDiagOutArg operationResult = (FlutterDiagOutArg)result.OperationResult;

                string txt = string.Empty;
                switch (operationResult.Compatibility)
                {
                case FlutterCompatibility.Supported:
                    txt = Properties.Resources.Setup_Finish_Congratulations_v1_Message;
                    break;

                case FlutterCompatibility.SupportNotGuaranteed:
                    txt = !string.IsNullOrEmpty(operationResult.NextSupportedVersion)
                            ? Properties.Resources.Setup_Finish_LimitedSupport_v1_Message
                            : Properties.Resources.Setup_Finish_LimitedSupport_v2_Message;
                    break;

                case FlutterCompatibility.NotSupported:
                    txt = Properties.Resources.Setup_Finish_NoCompatibility_Message;
                    break;
                }

                Text = SetupWindowViewModel.ReplaceText(txt, operationResult.InstalledVersion, operationResult.LatestSupportedVersion);
            }
            else
            {
                Text = Properties.Resources.Setup_Finish_Congratulations_v2_Message;
            }
        }
Esempio n. 2
0
        public SetupCheckFlutterErrorViewModel(FlutterDiagOutArg checkResult, IScreen screen = null) : base("setup_check_flutter_err", screen)
        {
            _checkResult = checkResult;

            Button1Visible = true;
            Button1Text    = "Check again";
            Button1Command = screen?.Router.NavigateBack;

            Button3Visible = true;
            Button3Text    = "Assisted setup";
            Button3Command = ReactiveCommand.CreateFromTask(async() =>
            {
                await HostScreen.Router.Navigate.Execute(new SetupAssistedViewModel(_checkResult, HostScreen));
            });

            if (checkResult.Issues == FlutterIssues.SdkNotFound)
            {
                Title = "Flutter Not Detected";

                Text = SetupWindowViewModel.ReplaceText(Properties.Resources.Setup_Check_FlutterNotFound_Message, checkResult.InstalledVersion, checkResult.LatestSupportedVersion);

                Button2Visible = false;

                FlutterNotFound = true;
            }
            else
            {
                Title = "Flutter Installed with Errors";

                Text = Properties.Resources.Setup_Check_FlutterErrors_Message;

                Button2Visible = true;
                Button2Text    = "Ignore and continue";
                Button2Command = ReactiveCommand.CreateFromTask(async() =>
                {
                    await HostScreen.Router.Navigate.Execute(new SetupFinishViewModel(new Models.SetupResult
                    {
                        OperationResult = _checkResult
                    }, this, HostScreen));
                });

                FlutterNotFound = false;

                StringBuilder sb = new StringBuilder();
                foreach (var kvp in _checkResult.DoctorErrors)
                {
                    sb.AppendLine(kvp.Key);
                    foreach (string line in kvp.Value.Split(Environment.NewLine))
                    {
                        sb.AppendFormat("    {0}", line);
                        sb.AppendLine();
                    }
                    sb.AppendLine();
                }
                Errors = sb.ToString();
            }
        }