Пример #1
0
        public MainWindowViewModel()
        {
            SaveCommand = new[] { Answer.ObserveHasErrors }
            .CombineLatestValuesAreAllFalse()
            .ToReactiveCommand();
            SaveCommand.Subscribe(SaveAction);

            ShowPreferencesCommand = new ReactiveCommand();
            ShowPreferencesCommand.Subscribe(ShowPreferencesAction);

            ShowAboutCommand = new ReactiveCommand();
            ShowAboutCommand.Subscribe(ShowAboutAction);

            OpenFolderCommand = new ReactiveCommand();
            OpenFolderCommand.Subscribe(OpenFolderAction);

            OpenFileCommand = new ReactiveCommand();
            OpenFileCommand.Subscribe(OpenFileAction);

            SwitchThemeCommand = new ReactiveCommand();
            SwitchThemeCommand.Subscribe(SwitchThemeAction);

            LoadedCommand = new ReactiveCommand();
            LoadedCommand.Subscribe(LoadedAction);

            Histories = new ReactiveCollection <string>();

            Answer.SetValidateNotifyError(x =>
            {
                string errorMessage = null;
                try
                {
                    WorkTask.Validate(x);
                }
                catch (Exception ex)
                {
                    errorMessage = ex.Message;
                }
                return(errorMessage);
            });
        }