示例#1
0
        public CliPatcherVm(
            IPatcherIdProvider idProvider,
            IPatcherNameVm nameVm,
            IPathToExecutableInputVm pathToExecutableInputVm,
            IProfileDisplayControllerVm selPatcher,
            IConfirmationPanelControllerVm confirmation,
            IShowHelpSetting showHelpSetting,
            ILifetimeScope scope,
            PatcherRenameActionVm.Factory renameFactory,
            CliPatcherSettings?settings = null)
            : base(scope, nameVm, selPatcher, confirmation, idProvider, renameFactory, settings)
        {
            ExecutableInput = pathToExecutableInputVm;
            ShowHelpSetting = showHelpSetting;

            _state = pathToExecutableInputVm.WhenAnyValue(x => x.Picker.ErrorState)
                     .Select(e =>
            {
                return(new ConfigurationState()
                {
                    IsHaltingError = !e.Succeeded,
                    RunnableState = e
                });
            })
                     .ToGuiProperty <ConfigurationState>(this, nameof(State), new ConfigurationState(ErrorResponse.Fail("Evaluating"))
            {
                IsHaltingError = false
            }, deferSubscription: true);
        }
示例#2
0
        public static IDisposable HelpWiring(IShowHelpSetting showHelp, Button button, TextBlock helpBlock, IObservable <bool>?show = null)
        {
            CompositeDisposable ret = new();

            show ??= Observable.Return(true);

            show.Select(x => x ? Visibility.Visible : Visibility.Collapsed)
            .Subscribe(x => button.Visibility = x)
            .DisposeWith(ret);

            Observable.CombineLatest(
                show,
                showHelp.WhenAnyValue(x => x.ShowHelp),
                (newPatcher, on) => on && newPatcher)
            .Select(x => x ? Visibility.Visible : Visibility.Collapsed)
            .Subscribe(x => helpBlock.Visibility = x)
            .DisposeWith(ret);

            showHelp.WhenAnyValue(x => x.ShowHelpToggleCommand)
            .Subscribe(x => button.Command = x)
            .DisposeWith(ret);

            showHelp.WhenAnyValue(x => x.ShowHelp)
            .Select(x => x ? 1.0d : 0.4d)
            .Subscribe(x => button.Opacity = x)
            .DisposeWith(ret);

            return(ret);
        }
示例#3
0
 public CliPatcherInitVm(
     IPatcherNameVm nameVm,
     IPatcherInitializationVm init,
     IShowHelpSetting showHelpSetting,
     IPathToExecutableInputVm executableInputVm,
     IPatcherFactory factory)
 {
     _init                     = init;
     Factory                   = factory;
     NameVm                    = nameVm;
     ShowHelpSetting           = showHelpSetting;
     ExecutableInput           = executableInputVm;
     _canCompleteConfiguration = executableInputVm.WhenAnyValue(x => x.Picker.ErrorState)
                                 .Cast <ErrorResponse, ErrorResponse>()
                                 .ToGuiProperty(this, nameof(CanCompleteConfiguration), ErrorResponse.Success);
 }