Esempio n. 1
0
        public VocabularyBrowserViewModel(
            IReduxStore <WordTutorApplication> store,
            ILogger logger)
        {
            if (logger is null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            _store  = store ?? throw new ArgumentNullException(nameof(store));
            _logger = logger.Action("Browse Vocabulary List");

            var screen = (VocabularyBrowserScreen)_store.State.CurrentScreen;
            var vocab  = _store.State.VocabularySet.Words;

            _selection = screen.Selection;
            _modified  = screen.Modified;
            Words      = new ObservableCollection <VocabularyWord>(
                vocab.OrderBy(w => w.Spelling));

            _screenSubscription = _store.SubscribeToReference(
                app => app.CurrentScreen as VocabularyBrowserScreen,
                RefreshFromScreen);

            _vocabularySubscription = _store.SubscribeToReference(
                app => app.VocabularySet,
                RefreshFromVocabularySet);

            AddWordCommand =
                new RoutedCommandSink(ItemCommands.New, AddWord);

            ModifyWordCommand = new RoutedCommandSink <VocabularyWord>(
                ItemCommands.Open, ModifyWord, CanModifyWord);
        }
 public SpeechMiddleware(
     ISpeechService speechServices,
     IReduxStore <WordTutorApplication> reduxStore)
 {
     _speechServices = speechServices;
     _reduxStore     = reduxStore;
 }
        public ModifyVocabularyWordViewModel(
            IReduxStore <WordTutorApplication> store,
            ILogger logger)
        {
            if (logger is null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            _store = store ?? throw new ArgumentNullException(nameof(store));

            var screen    = _store.State.CurrentScreen as ModifyVocabularyWordScreen;
            var areAdding = screen?.ExistingWord is null;

            _logger = logger.Action(
                areAdding
                ? "Create Vocabulary Word"
                : "Modify Vocabulary Word");

            _spelling      = screen?.Spelling ?? string.Empty;
            _phrase        = screen?.Phrase ?? string.Empty;
            _pronunciation = screen?.Pronunciation ?? string.Empty;
            _caption       = areAdding ? "Add Word" : "Modify Word";

            _screenSubscription = _store.SubscribeToReference(
                app => app.CurrentScreen as ModifyVocabularyWordScreen,
                RefreshFromScreen);

            SpeakCommand = new RoutedCommandSink <string>(
                VoiceCommands.StartSpeaking, Speak, CanSpeak, this);
            SaveCommand = new RoutedCommandSink(
                ItemCommands.Save, Save, CanSave);
            CloseCommand = new RoutedCommandSink(
                ItemCommands.Close, Close);
        }
        public WordTutorViewModel(
            IReduxStore <WordTutorApplication> store,
            ViewModelFactory factory)
        {
            _store   = store ?? throw new ArgumentNullException(nameof(store));
            _factory = factory ?? throw new ArgumentNullException(nameof(factory));

            _currentScreen = _factory.Create(_store.State.CurrentScreen);

            _screenSubscription = _store.SubscribeToReference(
                app => app.CurrentScreen,
                RefreshFromScreen);
        }
 public static ReduxProviderElement <TState2, TAction2> Create <TState2, TAction2>(IReduxStore <TState2, TAction2> store, IElement <IElementState> child)
     where TState2 : class
 {
     return(new ReduxProviderElement <TState2, TAction2>(store, child));
 }
 public ReduxProviderElement(IReduxStore <TState, TAction> store, IElement <IElementState> child)
 {
     this.Store = store;
     this.Child = child;
 }