protected InstallationModelBase(
            IWixStateProvider wixStateProvider,
            ISession session,
            string[] args
            )
        {
            this.Session = session;

            this.AllSteps = new ReactiveList <IStep> {
                ChangeTrackingEnabled = true
            };
            this.Steps = this.AllSteps.CreateDerivedCollection(x => x, x => x.IsRelevant);
            this.Steps.Changed.Subscribe(e => this.Steps.RaisePropertyChanged());

            this._wixStateProvider = wixStateProvider ?? throw new ArgumentNullException(nameof(wixStateProvider));

            this.NextButtonText = TextResources.SetupView_NextText;

            var canMoveForwards = this.WhenAny(vm => vm.TabSelectedIndex, vm => vm.TabSelectionMax,
                                               (i, max) => i.GetValue() < max.GetValue());

            this.Next = ReactiveCommand.Create(canMoveForwards);
            this.Next.Subscribe(i => { this.TabSelectedIndex = Math.Min(this.Steps.Count - 1, this.TabSelectedIndex + 1); });

            var canMoveBackwards = this.WhenAny(vm => vm.TabSelectedIndex, i => i.GetValue() > 0);

            this.Back = ReactiveCommand.Create(canMoveBackwards);
            this.Back.Subscribe(i => { this.TabSelectedIndex = Math.Max(0, this.TabSelectedIndex - 1); });

            this.Help                  = ReactiveCommand.Create();
            this.ShowLicenseBlurb      = ReactiveCommand.Create();
            this.ShowCurrentStepErrors = ReactiveCommand.Create();
            this.RefreshCurrentStep    = ReactiveCommand.Create();
            this.RefreshCurrentStep.Subscribe(x => { this.Steps[this.TabSelectedIndex].Refresh(); });
            this.Exit  = ReactiveCommand.Create();
            this.Proxy = ReactiveCommand.Create();

            this.Steps.Changed.Subscribe((e => UpdateNextButtonText(this.TabSelectedIndex)));
            this.WhenAny(vm => vm.TabSelectedIndex, v => v.GetValue())
            .Subscribe(i =>
            {
                this.UpdateNextButtonText(i);
                var c = this.Steps.Count;
                ProxyButtonVisible = c > 0 && ActiveStep is PluginsModel;
            });

            this.WhenAnyValue(view => view.ValidationFailures)
            .Subscribe(failures =>
            {
                this.PrerequisiteFailures = (failures ?? Enumerable.Empty <ValidationFailure>())
                                            .Where(v => PrerequisiteProperties.Contains(v.PropertyName))
                                            .ToList();
            });
        }
Exemple #2
0
        protected InstallationModelBase(
            IWixStateProvider wixStateProvider,
            ISession session,
            string[] args
            )
        {
            this.Session = session;

            this._wixStateProvider = wixStateProvider ?? throw new ArgumentNullException(nameof(wixStateProvider));

            this.NextButtonText = TextResources.SetupView_NextText;

            var canMoveForwards = this.WhenAny(vm => vm.TabSelectedIndex, vm => vm.TabSelectionMax,
                                               (i, max) => i.GetValue() < max.GetValue());

            this.Next = ReactiveCommand.Create(canMoveForwards);
            this.Next.Subscribe(i =>
            {
                this.TabSelectedIndex = Math.Min(this.Steps.Count - 1, this.TabSelectedIndex + 1);
            });

            var canMoveBackwards = this.WhenAny(vm => vm.TabSelectedIndex, i => i.GetValue() > 0);

            this.Back = ReactiveCommand.Create(canMoveBackwards);
            this.Back.Subscribe(i =>
            {
                this.TabSelectedIndex = Math.Max(0, this.TabSelectedIndex - 1);
            });

            this.Help                  = ReactiveCommand.Create();
            this.ShowLicenseBlurb      = ReactiveCommand.Create();
            this.ShowCurrentStepErrors = ReactiveCommand.Create();
            this.RefreshCurrentStep    = ReactiveCommand.Create();
            this.RefreshCurrentStep.Subscribe(x => { this.Steps[this.TabSelectedIndex].Refresh(); });
            this.Exit = ReactiveCommand.Create();

            this.WhenAny(vm => vm.TabSelectedIndex, v => v.GetValue())
            .Subscribe(i =>
            {
                var c = this.Steps.Count;
                if (i == (c - 1))
                {
                    this.NextButtonText = TextResources.SetupView_ExitText;
                }
                else if (i == (c - 2))
                {
                    this.NextButtonText = TextResources.SetupView_InstallText;
                }
                else
                {
                    this.NextButtonText = TextResources.SetupView_NextText;
                }
            });

            this.WhenAnyValue(view => view.ValidationFailures)
            .Subscribe(failures =>
            {
                this.PrerequisiteFailures = (failures ?? Enumerable.Empty <ValidationFailure>())
                                            .Where(v => PrerequisiteProperties.Contains(v.PropertyName))
                                            .ToList();
            });
        }