示例#1
0
        /// <summary>
        /// Initializes a new instance of the LearnCardViewModel class.
        /// </summary>
        public LearnCardViewModel(IDictionaryDataService dictionaryDataService)
        {
            this.dictionaryDataService = dictionaryDataService;
            efContext = dictionaryDataService.GetEFLearnDictionaryContext();
            efContext.Words.Load();
            efContext.WordMeanings.Load();
            efContext.Languages.Load();
            Words        = efContext.Words.Local;
            WordMeanings = efContext.WordMeanings.Local;
            Languages    = efContext.Languages.Local;
            Messenger.Default.Register <NotificationMessage <List <Word> > >(this, (m) =>
            {
                LearningWords = m.Content;
                FillTranslationAlternatives();
            });

            VariantAmount = new List <int>()
            {
                1, 2, 3, 4, 5, 6
            };
            VariantAmountSelected = 4;
            //FillTranslationAlternatives();
            EditWordCommand              = new RelayCommand(EditWord, () => LearningWords != null && LearningWords.Count > 0);
            ShowAnswerCommand            = new RelayCommand(ShowAnswer, () => ShowAnswerEnabled);
            NextCommand                  = new RelayCommand(NextWord, () => NextEnabled);
            SpeakCommand                 = new RelayCommand(Speak);
            RefreshCommand               = new RelayCommand(Refresh);
            WordMeaningsSelectionCommand = new RelayCommand(WordMeaningsSelection);
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the WordEntryCardViewModel class.
        /// </summary>
        public WordEntryCardViewModel(IDictionaryDataService dictionaryDataService, ILogService dlogService, ITranslationService translationService)
        {
            this.logService = dlogService;
            TranslationVM   = new TranslationLookUpViewModel(dlogService, translationService);
            // AddMeaningCommand = new RelayCommand(AddMeaning);
            AddNewMeaningCommand     = new RelayCommand(AddNewMeaning);
            RemoveMeaningCommand     = new RelayCommand(RemoveMeaning);
            SaveWordCommand          = new RelayCommand(SaveChanges);
            SpeakCommand             = new RelayCommand(Speak);
            ShowMariamWebsterCommand = new RelayCommand(ShowMariamWebster,
                                                        () => { return(WordEntry != null && WordEntry.Word != null); });
            CancelWordCommand      = new RelayCommand(DeleteWord, () => { return(WordEntry != null); });
            MeaningGotFocusCommand = new RelayCommand <bool>((p) =>
            {
                Messenger.Default.Send(
                    new SetInputNotificationMessage(this, "")
                {
                    Language = this.WordMeaningLanguage.ShortName, Token = this.Token, WhatControl = "Meaning", GotFocus = p
                });
            });

            WordGotFocusCommand = new RelayCommand <bool>((p) =>
            {
                Messenger.Default.Send(
                    new SetInputNotificationMessage(this, "")
                {
                    Language = this.SelectedLanguage.ShortName, Token = this.Token, WhatControl = "Word", GotFocus = p
                });
                Messenger.Default.Send(
                    new SetInputNotificationMessage(this, "")
                {
                    Language = this.SelectedLanguage.ShortName, Token = this.Token, WhatControl = "Word", GotFocus = p
                });
            });

            AutoCompleteLostFocusCommand = new RelayCommand(TryEnterNewWord);
            LookUpWordCommand            = new RelayCommand(LookUpWord);
            this.dictionaryDataService   = dictionaryDataService;
            efContext = dictionaryDataService.GetEFLearnDictionaryContext();
            Messenger.Default.Register <DictionaryLookupNotificationMessage>(
                this,
                message =>
            {
                if (message.Token == this.TranslationVM.Token)
                {
                    string tr = message.TtanslationItm.Translation;
                    AppendNewMeaning(tr);
                }
            });


            efContext.Books.Load();
            efContext.Languages.Load();
            Books                     = efContext.Books.Local;
            Languages                 = efContext.Languages.Local;
            SelectedLanguage          = Languages[0];
            WordMeaningLanguage       = Languages[1];
            WordSugesstions           = new WordValuesSuggestionProvider();
            WordSugesstions.EFContext = efContext;
        }
 public WordCardViewModel(IDictionaryDataService dictionaryDataService, ILogService logService)
 {
     this.dictionaryDataService = dictionaryDataService;
     this.logService            = logService;
     efContext = dictionaryDataService.GetEFLearnDictionaryContext();
     ShowMariamWebsterCommand = new RelayCommand(ShowMariamWebster);
     SpeakCommand             = new RelayCommand(Speak);
     SaveWordCommand          = new RelayCommand(SaveChanges);
 }
示例#4
0
 public AuthorsWindowViewModel(IDictionaryDataService dictionaryDataService, ILogService logService)
 {
     this.dictionaryDataService = dictionaryDataService;
     this.logService            = logService;
     AddAuthorCommand           = new RelayCommand(AddAuthorMethod);
     DeleteAuthorCommand        = new RelayCommand(DeleteAuthorMethod);
     SaveAuthorsCommand         = new RelayCommand(SaveAuthorsMethod);
     efContext = dictionaryDataService.GetEFLearnDictionaryContext();
     efContext.Authors.Load();
     Authors = efContext.Authors.Local;
     // SelectedAuthor = Authors.ElementAt(0);
 }
        public BookEntryViewModel(IDictionaryDataService dictionaryDataService, ILogService logService)
        {
            this.dictionaryDataService = dictionaryDataService;
            this.logService            = logService;
            Messenger.Default.Register <NotificationMessage <Book> >(this, LoadBookContext());

            SaveBookCommand     = new RelayCommand(SaveBookMethod);
            CancelEditCommand   = new RelayCommand(CancelEditMethod);
            AddAuthorCommand    = new RelayCommand(AddAuthorMethod, () => { return(SelectedAuthorAdd != null); });
            RemoveAuthorCommand = new RelayCommand(RemoveAuthorMethod, () => { return(SelectedAuthorRemove != null); });
            efContext           = dictionaryDataService.GetEFLearnDictionaryContext();
        }
 public BookListViewModel(IDictionaryDataService dictionaryDataService, ILogService logService, IOpenViewService openViewService)
 {
     this.dictionaryDataService = dictionaryDataService;
     this.logService            = logService;
     this.openViewService       = openViewService;
     AddBookCommand             = new RelayCommand(AddBookMethod);
     EditBookCommand            = new RelayCommand(EditBookMethod);
     DeleteBookCommand          = new RelayCommand(DeleteBookMethod);
     efContext = dictionaryDataService.GetEFLearnDictionaryContext();
     efContext.Books.Load();
     Books = efContext.Books.Local;
 }
        public void RestoreLastContext()
        {
            efContext = dictionaryDataService.GetEFLearnDictionaryContext();
            efContext.Languages.Load();
            efContext.Books.Load();
            efContext.Words.Include("WordEntries").Load();
            var wEntry = efContext.WordEntries
                         .OrderByDescending(z => z.WordEntry_ID)
                         .FirstOrDefault();

            SelectedBook = wEntry.Book;
            PreloadLastEntries();
        }
 public LearnWordsViewModel(IDictionaryDataService dictionaryDataService, IOpenViewService openViewService, ILogService logService)
 {
     this.dictionaryDataService = dictionaryDataService;
     this.openViewService       = openViewService;
     this.logService            = logService;
     efContext = dictionaryDataService.GetEFLearnDictionaryContext();
     efContext.Books.Load();
     efContext.Languages.Load();
     Books                 = efContext.Books.Local;
     Languagies            = efContext.Languages.Local;
     SelectedLanguage      = Languagies[0];
     FillCandidatesCommand = new RelayCommand(FillAllWords);
     //LearnCommand = new RelayCommand(LearnWords, CanLearnWords);
     StartLearningCommand     = new RelayCommand(StartLearning, () => WordsToLearn != null && WordsToLearn.Count > 0);
     ShowMariamWebsterCommand = new RelayCommand(ShowMariamWebster);
     OpenWordCardCommand      = new RelayCommand <Word>(
         w =>
     {
         OpenWordCard(w);
     });
     FillStrategies();
 }
 public AllWordsViewModel(IOpenViewService openViewService, IDictionaryDataService dictionaryDataService, ILogService logService)
 {
     this.openViewService       = openViewService;
     this.dictionaryDataService = dictionaryDataService;
     this.logService            = logService;
     efContext = dictionaryDataService.GetEFLearnDictionaryContext();
     efContext.Languages.Load();
     efContext.Books.Load();
     //efContext.WordEntries.Load();
     efContext.Words.Include("WordEntries").Load();
     Languages = efContext.Languages.Local;
     Books     = efContext.Books.Local;
     Words     = efContext.Words.Local;
     //WordEntries = efContext.WordEntries.Local;
     SelectedSortingItem = SortingItems[0];
     FilterWords();
     SelectBookCommand     = new RelayCommand(FilterWords);
     SelectLanguageCommand = new RelayCommand(FilterWords);
     SelectSortingCommand  = new RelayCommand(FilterWords);
     AddNewWordCommand     = new RelayCommand(AddNewWord);
     EditNewWordCommand    = new RelayCommand(EditNewWord);
     DeleteWordCommand     = new RelayCommand(DeleteWord);
 }