private void SearchWord(WordPad wordPad, string wordKey) { if (wordPad == null) { return; } if (wordKey == null || wordKey.Length == 0) { searchResultList.Hide(); WordList.Show(); UpdateWordCount(); return; } ArrayList searchResult = new ArrayList(); for (int i = 0; i < wordPad.Words.Count; i++) { NewWordItem word = (NewWordItem)wordPad.Words[i]; if (word.Name.Contains(wordKey)) { searchResult.Add(wordPad.Words[i]); } } UpdateWordListByWordList(searchResultList, searchResult); searchResultList.Show(); WordList.Hide(); }
public QuizSetting() { InitializeComponent(); // add word pad list MainDlg mainDlg = MainDlg.Instance; Dictionary <string, WordPad> .Enumerator wordPadEnumerator = mainDlg.WordPadEnumerator; while (wordPadEnumerator.MoveNext()) { this.wordPadsCheckedListBox.Items.Add(wordPadEnumerator.Current.Key, false); } for (int i = 0; i < (int)NewWordItem.ProficiencyLevel.ProficiencyLevelCount; i++) { this.familarityCombo.Items.Add(NewWordItem.ToProficiencyString((NewWordItem.ProficiencyLevel)i)); } this.familarityCombo.Items.Add("All"); this.familarityCombo.SelectedIndex = 0; this.quizTypeCombo.SelectedIndex = 1; this.comboBoxRelDays.SelectedIndex = 0; checkBoxRelativeMode.Checked = true; checkBoxAllTime.Checked = false; }
public int Compare(ListViewItem x, ListViewItem y) { NewWordItem word1 = (NewWordItem)x.Tag; NewWordItem word2 = (NewWordItem)y.Tag; if (SortKey == WordSortKeyType.WordSortKeyName) { return(word1.Name.CompareTo(word2.Name)); } else if (SortKey == WordSortKeyType.WordSortKeyAnnonce) { return(word1.Annoucement.CompareTo(word2.Annoucement)); } else if (SortKey == WordSortKeyType.WordSortKeyMeaning) { return(word1.Meaning.CompareTo(word2.Meaning)); } else if (SortKey == WordSortKeyType.WordSortKeyAddTime) { return(word1.AddTime.CompareTo(word2.AddTime)); } else if (SortKey == WordSortKeyType.WordSortKeyProficiency) { return(word1.Proficiency.CompareTo(word2.Proficiency)); } return(0); }
private void WordList_ItemMouseHover(object sender, ListViewItemMouseHoverEventArgs e) { NewWordItem wordItem = (NewWordItem)e.Item.Tag; string tooltip = wordItem.Name + "\r\n" + wordItem.Annoucement + "\r\n\r\n" + wordItem.Meaning; e.Item.ToolTipText = tooltip; }
private void UpdateWordUI() { NewWordItem curTestWord = (NewWordItem)m_testWords[m_curTestWordIndex]; this.wordTestLabel.Text = curTestWord.Name + "[" + curTestWord.Annoucement + "]"; ArrayList options; if (m_wordToOptionMap.TryGetValue(curTestWord.Name, out options)) { int i = 0; foreach (object o in options) { if (i < m_testWordRatioButtons.Count) { ((RadioButton)m_testWordRatioButtons[i]).Checked = false; ((RadioButton)m_testWordRatioButtons[i]).Text = ((NewWordItem)o).Meaning; //((RadioButton)m_testWordRatioButtons[i]).MouseHover = i++; } } } labelProgress.Text = (m_curTestWordIndex + 1).ToString() + "/" + m_testWords.Count.ToString(); }
public bool InitQuiz(ArrayList testWords, Dictionary <string, ArrayList> testWordOptions) { if (testWords.Count == 0) { return(false); } m_curTestWordIndex = 0; m_startTime = DateTime.Now; m_testWords = (ArrayList)testWords.Clone(); for (int i = 0; i < m_testWords.Count; i++) { NewWordItem word = (NewWordItem)m_testWords[i]; ArrayList optionWords; if (testWordOptions.TryGetValue(word.Name, out optionWords)) { for (int j = 0; j < optionWords.Count; j++) { if (((NewWordItem)optionWords[j]).Name == word.Name) { optionWords[j] = word; } } m_wordToOptionMap.Add(word.Name, (ArrayList)optionWords.Clone()); } } UpdateWordUI(); return(true); }
public bool LoadFromKingsoftWordpad(String fileName, bool append) { /* * +vermilion #adj.朱红色的; 鲜红色的 #n.朱红色; 鲜红色 * &vəˈmiljən * $1 */ if (!File.Exists(fileName)) { return(false); } try { StreamReader sr = File.OpenText(fileName); // unicode file header if (!append) { m_words.Clear(); m_lookupTable.Clear(); } while (!sr.EndOfStream) { NewWordItem wordItem = new NewWordItem(); wordItem.Name = sr.ReadLine().Substring(1); char meaningTag = (char)sr.Read(); while (meaningTag == '#' && !sr.EndOfStream) { wordItem.Meaning += sr.ReadLine() + "\r\n"; meaningTag = (char)sr.Read(); } if (meaningTag == '&') { wordItem.Annoucement = sr.ReadLine(); } char proficiencyTag = (char)sr.Read(); if (proficiencyTag == '$') { wordItem.Proficiency = (NewWordItem.ProficiencyLevel)Convert.ToInt32(sr.ReadLine()); } AddWord(wordItem); } } catch (System.Exception) { return(true); } return(true); }
public NewWordItem Clone() { NewWordItem cloned = new NewWordItem(); cloned.Name = Name; cloned.Annoucement = Annoucement; cloned.Meaning = Meaning; cloned.AddTime = AddTime; cloned.Proficiency = Proficiency; return cloned; }
public NewWordItem Clone() { NewWordItem cloned = new NewWordItem(); cloned.Name = Name; cloned.Annoucement = Annoucement; cloned.Meaning = Meaning; cloned.AddTime = AddTime; cloned.Proficiency = Proficiency; return(cloned); }
private void editToolStripMenuItemWord_Click(object sender, EventArgs e) { if (ActiveWordList.FocusedItem == null) { return; } NewWordItem wordItem = (NewWordItem)ActiveWordList.FocusedItem.Tag; ListViewItem anotherListItem = InactiveWordList.FindItemWithText(wordItem.Name); EditWord dlg = new EditWord(wordItem, ActiveWordList.FocusedItem, anotherListItem); dlg.ShowDialog(this); }
private void UpdateAssociateListItem(ListViewItem listItem) { if (listItem == null) { return; } listItem.SubItems.Clear(); listItem.Text = m_editingWord.Name; listItem.SubItems.Add(m_editingWord.Annoucement); listItem.SubItems.Add(m_editingWord.Meaning); listItem.SubItems.Add(m_editingWord.AddTime.ToString()); listItem.SubItems.Add(NewWordItem.ToProficiencyString(m_editingWord.Proficiency)); }
private void Confirm_Click(object sender, EventArgs e) { NewWordItem newWord = new NewWordItem(); if ( WordNameEdit.Text.Length == 0 ) { MessageBox.Show("Must Enter The Word!"); return; } newWord.Name = WordNameEdit.Text; newWord.Annoucement = AnnoucementEdit.Text; newWord.Meaning = MeaningRichEdit.Text; MainDlg.Instance.AddNewWord( MainDlg.Instance.CurWordPad, newWord); Close(); }
public bool AddWord( NewWordItem word ) { int index; if (m_lookupTable.TryGetValue(word.Name, out index)) return false; m_words.Add(word); m_lookupTable[ word.Name ] = m_words.IndexOf(word); if (m_earliestAddTime.CompareTo(word.AddTime) > 0) m_earliestAddTime = word.AddTime; if (m_latestAddTime.CompareTo(word.AddTime) < 0) m_latestAddTime = word.AddTime; return true; }
private void Confirm_Click(object sender, EventArgs e) { NewWordItem newWord = new NewWordItem(); if (WordNameEdit.Text.Length == 0) { MessageBox.Show("Must Enter The Word!"); return; } newWord.Name = WordNameEdit.Text; newWord.Annoucement = AnnoucementEdit.Text; newWord.Meaning = MeaningRichEdit.Text; MainDlg.Instance.AddNewWord(MainDlg.Instance.CurWordPad, newWord); Close(); }
protected void AddWordItemToList(ListView list, NewWordItem wordItem) { ListViewItem item = new ListViewItem(); item.Text = wordItem.Name; item.SubItems.Add(wordItem.Annoucement); item.SubItems.Add(wordItem.Meaning); item.SubItems.Add(wordItem.AddTime.ToString()); item.SubItems.Add(NewWordItem.ToProficiencyString(wordItem.Proficiency)); foreach (ListViewItem.ListViewSubItem subItem in item.SubItems) { subItem.Tag = wordItem; } item.Tag = wordItem; list.Items.Add(item); }
public EditWord(NewWordItem word, ListViewItem associateItemActive, ListViewItem associateItemInactive ) { InitializeComponent(); m_editingWord = word; m_associateItemActive = associateItemActive; m_associateItemInactive = associateItemInactive; WordNameEdit.Text = m_editingWord.Name; AnnoucementEdit.Text = m_editingWord.Annoucement; MeaningRichEdit.Text = m_editingWord.Meaning; for (int i = 0; i < (int)NewWordItem.ProficiencyLevel.ProficiencyLevelCount; i++) { this.proficiencyCombobox.Items.Add(NewWordItem.ToProficiencyString((NewWordItem.ProficiencyLevel)i)); } proficiencyCombobox.SelectedIndex = (int)m_editingWord.Proficiency; }
public EditWord(NewWordItem word, ListViewItem associateItemActive, ListViewItem associateItemInactive) { InitializeComponent(); m_editingWord = word; m_associateItemActive = associateItemActive; m_associateItemInactive = associateItemInactive; WordNameEdit.Text = m_editingWord.Name; AnnoucementEdit.Text = m_editingWord.Annoucement; MeaningRichEdit.Text = m_editingWord.Meaning; for (int i = 0; i < (int)NewWordItem.ProficiencyLevel.ProficiencyLevelCount; i++) { this.proficiencyCombobox.Items.Add(NewWordItem.ToProficiencyString((NewWordItem.ProficiencyLevel)i)); } proficiencyCombobox.SelectedIndex = (int)m_editingWord.Proficiency; }
private void WordList_MouseDoubleClick(object sender, MouseEventArgs e) { if (ActiveWordList.FocusedItem != null) { ListViewHitTestInfo hitInfo = ActiveWordList.HitTest(e.Location); if (hitInfo.SubItem != null) { NewWordItem wordItem = (NewWordItem)hitInfo.SubItem.Tag; if (hitInfo.SubItem.Text == NewWordItem.ToProficiencyString(wordItem.Proficiency)) { // modify proficiency wordItem.IncProficiency(); hitInfo.SubItem.Text = NewWordItem.ToProficiencyString(wordItem.Proficiency); return; } } editToolStripMenuItemWord_Click(sender, e); } }
public bool AddNewWord(WordPad wordPad, NewWordItem newWord) { if (wordPad == null) { return(false); } if (wordPad.FindWord(newWord.Name) != null) { MessageBox.Show("you already add this word!"); return(false); } bool result = wordPad.AddWord(newWord); if (result) { AddWordItemToList(WordList, newWord); } return(result); }
private void contextMenuWord_ItemClicked(object sender, EventArgs e) { ToolStripMenuItem menuItem = null; if (sender.GetType() == typeof(ToolStripMenuItem)) { menuItem = (ToolStripMenuItem)sender; } if (menuItem.Tag.GetType() == typeof(WordPad)) { WordPad destWordPad = (WordPad)menuItem.Tag; if (destWordPad == null) { return; } if (WordList.SelectedItems.Count > 0) { if (CurWordPad == null) { AddNewWordPad("Default", true); } foreach (ListViewItem item in WordList.SelectedItems) { NewWordItem word = (NewWordItem)item.Tag; destWordPad.AddWord(word); CurWordPad.Words.Remove(word); } foreach (ListViewItem item in WordList.SelectedItems) { WordList.Items.Remove(item); } } } }
public bool AddWord(NewWordItem word) { int index; if (m_lookupTable.TryGetValue(word.Name, out index)) { return(false); } m_words.Add(word); m_lookupTable[word.Name] = m_words.IndexOf(word); if (m_earliestAddTime.CompareTo(word.AddTime) > 0) { m_earliestAddTime = word.AddTime; } if (m_latestAddTime.CompareTo(word.AddTime) < 0) { m_latestAddTime = word.AddTime; } return(true); }
/** * @param proficiency 表示只选择这个熟练度以下(包括当前)的,当取ProficiencyCount时表示不限熟练度 * @param bAllTime 选取全部时间范围的词 */ public bool InitQuiz(ArrayList wordPads, QuizType type, int testWordCount, NewWordItem.ProficiencyLevel proficiency, DateTime starDate, DateTime endDate, bool bAllTime = true) { HashSet<int> alreadyChoosedWordIndice = new HashSet<int>(); ArrayList totalWords = new ArrayList(); ArrayList totalWordsForOption = new ArrayList(); //不考虑时间的所有词,作为选项候选 int totalWordCount = 0; System.Collections.IEnumerator iterator = wordPads.GetEnumerator(); DateTime earliestTime = new DateTime(8000, 12, 31); DateTime latestTime = new DateTime(1000, 1, 1); while ( iterator.MoveNext() ) { WordPad wordPad = iterator.Current as WordPad; totalWordsForOption.AddRange(wordPad.Words); if ( bAllTime ) { totalWordCount += wordPad.Words.Count; totalWords.AddRange(wordPad.Words); } else { ArrayList wordsWithinTimeRange = wordPad.GetWordsByTimeRange(starDate, endDate); totalWordCount += wordsWithinTimeRange.Count; totalWords.AddRange(wordsWithinTimeRange); if (earliestTime.CompareTo(wordPad.EarliestAddTime) > 0) earliestTime = wordPad.EarliestAddTime; if (latestTime.CompareTo(wordPad.LatestAddTime) < 0) latestTime = wordPad.LatestAddTime; } } if (!bAllTime && (starDate.CompareTo(latestTime) > 0 // not in time range || endDate.CompareTo(earliestTime) < 0) ) { MessageBox.Show("specified time range exceed all the words' total time range!"); return false; } if ( totalWords.Count <= 3 ) { MessageBox.Show("Not sufficient words for a valid test!"); return false; } if (testWordCount > totalWords.Count) { testWordCount = totalWords.Count; MessageBox.Show("test word count is more than word count in all selected wordpads, so clamp to the actual count: " + totalWords.Count); } Random randGenerator = new Random(Convert.ToInt32(DateTime.Now.Millisecond)); for (int i = 0; i < testWordCount; i++ ) { int globalIndex = randGenerator.Next(0, totalWordCount); NewWordItem candidateWord = (NewWordItem)totalWords[globalIndex]; // exclude words not fit condition while ( alreadyChoosedWordIndice.Contains(globalIndex) || candidateWord.Meaning == "" || candidateWord.Proficiency > proficiency || ( !bAllTime && ( candidateWord.AddTime.CompareTo(starDate) < 0 // not in time range || candidateWord.AddTime.CompareTo(endDate) > 0 ) ) ) { globalIndex = randGenerator.Next(0, totalWordCount); candidateWord = (NewWordItem)totalWords[globalIndex]; } // add test word m_testWords.Add(totalWords[globalIndex]); // add meaning options for words HashSet<int> optionsChoosedForCurWord = new HashSet<int>(); optionsChoosedForCurWord.Add(globalIndex); ArrayList optionWords = new ArrayList(); for (int j = 0; j < 3; j++) { int optionWordIndex = randGenerator.Next(0, totalWordsForOption.Count); while (optionsChoosedForCurWord.Contains(optionWordIndex) || ((NewWordItem)totalWordsForOption[optionWordIndex]).Meaning == "") { optionWordIndex = randGenerator.Next(0, totalWordsForOption.Count); } optionWords.Add(totalWordsForOption[optionWordIndex]); optionsChoosedForCurWord.Add(optionWordIndex); } // insert correct word option int insertPos = randGenerator.Next(0, 3); optionWords.Insert(insertPos, totalWords[globalIndex]); m_wordToOptionMap.Add( ((NewWordItem)totalWords[globalIndex]).Name, optionWords); alreadyChoosedWordIndice.Add(globalIndex); } m_curTestWordIndex = 0; m_startTime = DateTime.Now; UpdateWordUI(); return true; }
public bool LoadFromKingsoftWordpad(String fileName, bool append ) { /* * +vermilion #adj.朱红色的; 鲜红色的 #n.朱红色; 鲜红色 &vəˈmiljən $1 */ if (!File.Exists(fileName)) return false; try { StreamReader sr = File.OpenText(fileName); // unicode file header if (!append) { m_words.Clear(); m_lookupTable.Clear(); } while (!sr.EndOfStream) { NewWordItem wordItem = new NewWordItem(); wordItem.Name = sr.ReadLine().Substring(1); char meaningTag = (char)sr.Read(); while (meaningTag == '#' && !sr.EndOfStream) { wordItem.Meaning += sr.ReadLine() + "\r\n"; meaningTag = (char)sr.Read(); } if (meaningTag == '&') wordItem.Annoucement = sr.ReadLine(); char proficiencyTag = (char)sr.Read(); if (proficiencyTag == '$') wordItem.Proficiency = (NewWordItem.ProficiencyLevel)Convert.ToInt32(sr.ReadLine()); AddWord(wordItem); } } catch (System.Exception) { return true; } return true; }
/** * @param proficiency 表示只选择这个熟练度以下(包括当前)的,当取ProficiencyCount时表示不限熟练度 * @param bAllTime 选取全部时间范围的词 */ public bool InitQuiz(ArrayList wordPads, QuizType type, int testWordCount, NewWordItem.ProficiencyLevel proficiency, DateTime starDate, DateTime endDate, bool bAllTime = true) { HashSet <int> alreadyChoosedWordIndice = new HashSet <int>(); ArrayList totalWords = new ArrayList(); ArrayList totalWordsForOption = new ArrayList(); //不考虑时间的所有词,作为选项候选 int totalWordCount = 0; System.Collections.IEnumerator iterator = wordPads.GetEnumerator(); DateTime earliestTime = new DateTime(8000, 12, 31); DateTime latestTime = new DateTime(1000, 1, 1); while (iterator.MoveNext()) { WordPad wordPad = iterator.Current as WordPad; totalWordsForOption.AddRange(wordPad.Words); if (bAllTime) { totalWordCount += wordPad.Words.Count; totalWords.AddRange(wordPad.Words); } else { ArrayList wordsWithinTimeRange = wordPad.GetWordsByTimeRange(starDate, endDate); totalWordCount += wordsWithinTimeRange.Count; totalWords.AddRange(wordsWithinTimeRange); if (earliestTime.CompareTo(wordPad.EarliestAddTime) > 0) { earliestTime = wordPad.EarliestAddTime; } if (latestTime.CompareTo(wordPad.LatestAddTime) < 0) { latestTime = wordPad.LatestAddTime; } } } if (!bAllTime && (starDate.CompareTo(latestTime) > 0 || // not in time range endDate.CompareTo(earliestTime) < 0) ) { MessageBox.Show("specified time range exceed all the words' total time range!"); return(false); } if (totalWords.Count <= 3) { MessageBox.Show("Not sufficient words for a valid test!"); return(false); } if (testWordCount > totalWords.Count) { testWordCount = totalWords.Count; MessageBox.Show("test word count is more than word count in all selected wordpads, so clamp to the actual count: " + totalWords.Count); } Random randGenerator = new Random(Convert.ToInt32(DateTime.Now.Millisecond)); for (int i = 0; i < testWordCount; i++) { int globalIndex = randGenerator.Next(0, totalWordCount); NewWordItem candidateWord = (NewWordItem)totalWords[globalIndex]; // exclude words not fit condition while (alreadyChoosedWordIndice.Contains(globalIndex) || candidateWord.Meaning == "" || candidateWord.Proficiency > proficiency || (!bAllTime && (candidateWord.AddTime.CompareTo(starDate) < 0 || // not in time range candidateWord.AddTime.CompareTo(endDate) > 0) ) ) { globalIndex = randGenerator.Next(0, totalWordCount); candidateWord = (NewWordItem)totalWords[globalIndex]; } // add test word m_testWords.Add(totalWords[globalIndex]); // add meaning options for words HashSet <int> optionsChoosedForCurWord = new HashSet <int>(); optionsChoosedForCurWord.Add(globalIndex); ArrayList optionWords = new ArrayList(); for (int j = 0; j < 3; j++) { int optionWordIndex = randGenerator.Next(0, totalWordsForOption.Count); while (optionsChoosedForCurWord.Contains(optionWordIndex) || ((NewWordItem)totalWordsForOption[optionWordIndex]).Meaning == "") { optionWordIndex = randGenerator.Next(0, totalWordsForOption.Count); } optionWords.Add(totalWordsForOption[optionWordIndex]); optionsChoosedForCurWord.Add(optionWordIndex); } // insert correct word option int insertPos = randGenerator.Next(0, 3); optionWords.Insert(insertPos, totalWords[globalIndex]); m_wordToOptionMap.Add(((NewWordItem)totalWords[globalIndex]).Name, optionWords); alreadyChoosedWordIndice.Add(globalIndex); } m_curTestWordIndex = 0; m_startTime = DateTime.Now; UpdateWordUI(); return(true); }
private void nextBtn_Click(object sender, EventArgs e) { // check NewWordItem curTestWord = (NewWordItem)m_testWords[m_curTestWordIndex]; int checkedIndex = -1; for (int i = 0; i < m_testWordRatioButtons.Count; i++) { if (((RadioButton)m_testWordRatioButtons[i]).Checked) { checkedIndex = i; break; } } if (checkedIndex >= 0) { if (curTestWord.Meaning == ((RadioButton)m_testWordRatioButtons[checkedIndex]).Text) { m_correctWords.Add(curTestWord); } } else { MessageBox.Show("You must choose one to proceed!"); return; } m_curTestWordIndex++; if (m_curTestWordIndex < m_testWords.Count) { UpdateWordUI(); } else { Result result; result.correctWords = (ArrayList)m_correctWords.Clone(); result.totalWords = m_testWords.Count; result.wrongWords = new ArrayList(); result.costTime = DateTime.Now - m_startTime; result.wrongWordsOptions = new Dictionary <string, ArrayList>(); for (int i = 0; i < m_testWords.Count; i++) { if (result.correctWords.Contains(m_testWords[i])) { continue; } result.wrongWords.Add(((NewWordItem)m_testWords[i]).Clone()); ArrayList wrongWordOption; if (m_wordToOptionMap.TryGetValue(((NewWordItem)m_testWords[i]).Name, out wrongWordOption)) { NewWordItem word = (NewWordItem)result.wrongWords[result.wrongWords.Count - 1]; ArrayList optionWords = new ArrayList(); foreach (NewWordItem optionWord in wrongWordOption) { optionWords.Add(optionWord); } result.wrongWordsOptions.Add(word.Name, optionWords); } } QuizResult resultDlg = new QuizResult(result); this.Close(); this.Hide(); resultDlg.ShowDialog(MainDlg.Instance); } }
public bool Load(String fileName) { if (!File.Exists(fileName)) return false; FileStream f = new FileStream(fileName, FileMode.Open, FileAccess.Read); ; BinaryReader br = new BinaryReader(f); UInt16 len = 0; try { UTF8Encoding utf8 = new UTF8Encoding(); while (!f.Position.Equals(System.IO.SeekOrigin.End)) { len = br.ReadUInt16(); if (len <= 0) break; // 词名必须不为空 byte[] buffer = new byte[len]; br.Read(buffer, 0, len); NewWordItem wordItem = new NewWordItem(); wordItem.Name = utf8.GetString(buffer); len = br.ReadUInt16(); if ( len > 0 ) { buffer = new byte[len]; br.Read(buffer, 0, len); wordItem.Annoucement = utf8.GetString(buffer); } len = br.ReadUInt16(); if ( len > 0 ) { buffer = new byte[len]; br.Read(buffer, 0, len); wordItem.Meaning = utf8.GetString(buffer); } Int64 addTime = br.ReadInt64(); wordItem.AddTime = DateTime.FromBinary(addTime); byte proficiency = br.ReadByte(); wordItem.Proficiency = (NewWordItem.ProficiencyLevel)proficiency; AddWord(wordItem); } } catch( System.IO.EndOfStreamException ) { f.Close(); br.Close(); return true; } return true; }
public bool Load(String fileName) { if (!File.Exists(fileName)) { return(false); } FileStream f = new FileStream(fileName, FileMode.Open, FileAccess.Read);; BinaryReader br = new BinaryReader(f); UInt16 len = 0; try { UTF8Encoding utf8 = new UTF8Encoding(); while (!f.Position.Equals(System.IO.SeekOrigin.End)) { len = br.ReadUInt16(); if (len <= 0) { break; } // 词名必须不为空 byte[] buffer = new byte[len]; br.Read(buffer, 0, len); NewWordItem wordItem = new NewWordItem(); wordItem.Name = utf8.GetString(buffer); len = br.ReadUInt16(); if (len > 0) { buffer = new byte[len]; br.Read(buffer, 0, len); wordItem.Annoucement = utf8.GetString(buffer); } len = br.ReadUInt16(); if (len > 0) { buffer = new byte[len]; br.Read(buffer, 0, len); wordItem.Meaning = utf8.GetString(buffer); } Int64 addTime = br.ReadInt64(); wordItem.AddTime = DateTime.FromBinary(addTime); byte proficiency = br.ReadByte(); wordItem.Proficiency = (NewWordItem.ProficiencyLevel)proficiency; AddWord(wordItem); } } catch (System.IO.EndOfStreamException) { f.Close(); br.Close(); return(true); } return(true); }