예제 #1
0
        private string GetBookTitles()
        {
            StringBuilder builder = new StringBuilder();
            var           we      = WordEntries
                                    .GroupBy(l => l.Book_ID)
                                    .Select(g => new
            {
                Name  = g.First().Book.Name,
                Count = g.Select(l => l.Book_ID).Count()
            });

            foreach (var z in we)
            {
                string q = String.Format(" {0} ({1})", z.Name, z.Count);
                if (builder.Length == 0)
                {
                    builder.Append(String.Format("-> {0}", q));
                }
                else
                {
                    builder.Append(String.Format(", {0}", q));
                }
            }
            return(builder.ToString());
        }
        private void DeleteCurrentWord()
        {
            CurrentEntry.DeleteWord();
            WordEntries.Remove(CurrentEntry);

            //throw new NotImplementedException();
        }
        public void PreloadEntries()
        {
            var wEntries = efContext.WordEntries.Where(we => we.Book_ID == SelectedBook.Book_ID)
                           .OrderByDescending(z => z.Page)
                           .OrderByDescending(z => z.WordEntry_ID)
                           .Take(maxEntries - 1);

            Language sLanguage = null;

            if (SelectedBook != null)
            {
                sLanguage = SelectedBook.Language;
            }
            foreach (var we in wEntries)
            {
                var wr = efContext.Entry(we);
                //var translationService = ViewModelLocator.getNewTranslationService();
                var translationService       = ViewModelLocator.getTranslationService();
                WordEntryCardViewModel wecVM = new WordEntryCardViewModel(dictionaryDataService, logService, translationService)
                {
                    WordEntry = we
                };
                WordEntries.Add(wecVM);
            }
            AppendNewWord();
            //this.CurrentEntry = WordEntries[0];
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets all the values for an interlinear field. The values can be considered all
        /// the column values for the specified field. When the fieldInfo parameter is for
        /// the phonetic field, then useOriginalPhonetic tells the method to get the value
        /// of the phonetic as it was before applying any experimental transcriptions.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public string[] GetParsedFieldValues(PaField field, bool useOriginalPhonetic)
        {
            if (field == null)
            {
                return(null);
            }

            bool getOrigPhonetic = (useOriginalPhonetic && field.Type == FieldType.Phonetic);

            // Go through the parsed word entries and get the values for the specified field.
            var values = WordEntries.Select(we =>
            {
                var val = (getOrigPhonetic ? we.OriginalPhoneticValue : we.GetField(field.Name, false));
                return(val != null ? val.Trim() : string.Empty);
            }).ToArray();

            return(values.Length == 0 ? null : values.ToArray());
        }
        internal void AppendNewWord()
        {
            //var lastEntry = WordEntries.FirstOrDefault
            var LastSessionPage = WordEntries.Count > 0 ? WordEntries.Max(p => p.WordEntry.Page) :1;
            //lastEntry != null ? lastEntry.WordEntry.Page : 1;
            WordEntry we = new WordEntry()
            {
                Book = this.SelectedBook, Page = LastSessionPage, Date = DateTime.Today
            };
            //var translationService = ViewModelLocator.getNewTranslationService();
            var translationService       = ViewModelLocator.getTranslationService();
            WordEntryCardViewModel wecVM = new WordEntryCardViewModel(dictionaryDataService, logService, translationService)
            {
                WordEntry = we
            };

            WordEntries.Insert(0, wecVM);
            this.CurrentEntry = wecVM;
        }