コード例 #1
0
        static VocabCategoriesToStringConverter()
        {
            CategoryDictionary = new Dictionary<long, VocabCategoryInfo>();

            VocabDao vocabDao = new VocabDao();
            foreach (VocabCategory category in vocabDao.GetAllCategories())
            {
                VocabCategoryInfo info = GetInfo(category);
                if (info != null)
                {
                    CategoryDictionary.Add(category.ID, info);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Builds a ViewModel aimed at editing an existing SrsEntry,
        /// or adding a pre-composed SrsEntry.
        /// </summary>
        /// <param name="entity">Entity to edit.</param>
        public SrsEntryViewModel(SrsEntry entity)
        {
            // Initialize fields.
            _entry = new ExtendedSrsEntry(entity);
            _originalNextReviewDate = entity.NextAnswerDate;
            _originalLevelValue = entity.CurrentGrade;
            _associatedKanjiString = Entry.AssociatedKanji;
            _associatedVocabString = Entry.AssociatedVocab;
            _srsEntryDao = new SrsEntryDao();
            _kanjiDao = new KanjiDao();
            _vocabDao = new VocabDao();
            if (IsNew)
            {
                Entry.Tags = Properties.Settings.Default.LastSrsTagsValue;
            }

            // Create the relay commands.
            SubmitCommand = new RelayCommand(OnSubmit);
            CancelCommand = new RelayCommand(OnCancel);
            SrsProgressResetCommand = new RelayCommand(OnSrsProgressReset);
            ApplyAssociatedKanjiCommand = new RelayCommand(OnApplyAssociatedKanji);
            ApplyAssociatedVocabCommand = new RelayCommand(OnApplyAssociatedVocab);
            ToggleSuspendCommand = new RelayCommand(OnToggleSuspend);
            DeleteCommand = new RelayCommand(OnDelete);
            ToggleDateEditCommand = new RelayCommand(OnToggleDateEdit);
            DateToNowCommand = new RelayCommand(OnDateToNow);
            DateToNeverCommand = new RelayCommand(OnDateToNever);

            // Get the associated kanji or vocab.
            GetAssociatedKanji();
            GetAssociatedVocab();

            // Initialize the VM.
            _isFirstSrsLevelSelect = true;
            SrsLevelPickerVm = new SrsLevelPickerViewModel();
            SrsLevelPickerVm.SrsLevelSelected += OnSrsLevelSelected;
            SrsLevelPickerVm.Initialize(_entry.CurrentGrade);
        }
コード例 #3
0
ファイル: VocabEtl.cs プロジェクト: roundedsquare/Houhou-SRS
 private void AttachWordFrequencyOnSingleKanaMatch()
 {
     _log.InfoFormat("Attaching word frequency on single kana match...");
     VocabDao dao = new VocabDao();
     dao.OpenMassTransaction();
     foreach (string line in FileReadingHelper.ReadLineByLine(PathHelper.WordUsagePath, Encoding.UTF8))
     {
         if (!string.IsNullOrWhiteSpace(line))
         {
             string[] split = line.Trim().Split('|');
             long? rank = ParsingHelper.ParseLong(split[0]);
             if (split.Count() == 3 && rank.HasValue)
             {
                 string kanjiReading = split[1];
                 string kanaReading = split[2];
                 if (kanjiReading == kanaReading)
                 {
                     if (dao.UpdateFrequencyRankOnSingleKanaMatch(kanaReading, (int)rank.Value))
                     {
                         _log.InfoFormat("{0} has a frequency of {1}", kanaReading, rank.Value);
                     }
                 }
             }
         }
     }
     dao.CloseMassTransaction();
 }