Ejemplo n.º 1
0
        public PatcherVm(
            ILifetimeScope scope,
            IPatcherNameVm nameVm,
            IProfileDisplayControllerVm selPatcher,
            IConfirmationPanelControllerVm confirmation,
            IPatcherIdProvider idProvider,
            PatcherRenameActionVm.Factory renameFactory,
            PatcherSettings?settings)
        {
            Scope = scope;
            Scope.DisposeWith(this);
            NameVm     = nameVm;
            InternalID = idProvider.InternalId;

            _isSelected = selPatcher.WhenAnyValue(x => x.SelectedObject)
                          .Select(x => x == this)
                          // Not GuiProperty, as it interacts with drag/drop oddly
                          .ToProperty(this, nameof(IsSelected));

            if (settings != null)
            {
                CopyInSettings(settings);
            }

            DeleteCommand = ReactiveCommand.Create(() =>
            {
                confirmation.TargetConfirmation = new ConfirmationActionVm(
                    "Confirm",
                    $"Are you sure you want to delete {NameVm.Name}?",
                    Delete);
            });

            RenameCommand = ReactiveCommand.Create(() =>
            {
                confirmation.TargetConfirmation = renameFactory();
            });

            ErrorDisplayVm = new ErrorDisplayVm(this, this.WhenAnyValue(x => x.State));
        }