Ejemplo n.º 1
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;
        }
Ejemplo n.º 2
0
 public void Init(LearnDictionaryEntities context, WordEntry wordEntry, Book lastBook, int lastPage)
 {
     _context = context;
     if (wordEntry != null)
     {
         _wordEntry            = wordEntry;
         _word                 = _wordEntry.Word;
         btnNextWord.IsEnabled = false;
     }
     else
     {
         LastSessionPage = lastPage;
         //SelectedBook = lastBook;
         _wordEntry = new WordEntry();
         //_wordEntry.Book = SelectedBook ?? _context.Books.First();
         _word = new Word()
         {
             Value = "", Language_ID = _context.Languages.First().Language_ID
         };
         _word.Language  = _wordEntry.Book.Language;
         _wordEntry.Date = DateTime.Now;
         _wordEntry.Page = LastSessionPage;
         _wordEntry.Word = _word;
     }
     //this.DataContext = _wordEntry;
     ContextMenuToNewMeaningWord();
     ContextMenuToMeaningWords();
     RefreshWord();
 }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
 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);
 }
Ejemplo n.º 5
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);
 }
Ejemplo n.º 6
0
 public LearnDictionaryEntities GetEFLearnDictionaryContext(string connName)
 {
     // if (_learnDictionaryEntities == null || _learnDictionaryEntities.Connection.ConnectionString != ConnectionStringEF)
     // _learnDictionaryEntities = new EF_BookEntities(ConnectionStringEF);
     // if (_learnDictionaryEntities == null  )
     // _learnDictionaryEntities = LearnDictionaryEntities.getLearnDictionaryEntities();
     if (_learnDictionaryEntities == null)
     {
         _learnDictionaryEntities = new LearnDictionaryEntities();
     }
     return(_learnDictionaryEntities);
 }
Ejemplo n.º 7
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();
        }
Ejemplo n.º 8
0
 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;
 }
Ejemplo n.º 9
0
        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();
        }
Ejemplo n.º 10
0
 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();
 }
Ejemplo n.º 11
0
 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);
 }