public static void IncreaseFrequency(ExcelManager excelApp, int indexOfWordInDictionary, int freq) { string oldFrequnecy = excelApp.GetValue(Columns.freq, indexOfWordInDictionary); int newFrequency = Convert.ToInt32(excelApp.GetValue(Columns.freq, indexOfWordInDictionary)) + freq; excelApp.SetValue(Columns.freq, indexOfWordInDictionary, newFrequency.ToString()); }
public static void AddExamples(ExcelManager excelApp, List <string> examples, int indexOfWordInDictionary) { foreach (var example in examples) { for (int col = 0; col < WordsFormer.maxExamples; col++) { string celVal = excelApp.GetValue(col + WordsFormer.whereExamplesStart, indexOfWordInDictionary); if (celVal == example) { break; } if (celVal == null || celVal == "") { excelApp.SetValue(col + WordsFormer.whereExamplesStart, indexOfWordInDictionary, example); break; } } } }
private void loadButton_Click(object sender, EventArgs e) { if (excelApp == null) { string pathToExcel = FileSaver.OpenExcelFile(); if (DM.PathToExcel == "") { MessageBox.Show("Файл " + DM.PathToExcel + " не найден"); return; } excelApp = new ExcelManager(); excelApp.Open(DM.PathToExcel); } memo = new MemoManager(grid); List <string> lWords = excelApp.GetColumn(DM.Columns.word); List <string> lfreq = excelApp.GetColumn(DM.Columns.freq); List <string> lLvl = excelApp.GetColumn(DM.Columns.level); List <string> ltrans1 = excelApp.GetColumn(DM.Columns.trans1); List <string> ltrans2 = excelApp.GetColumn(DM.Columns.trans2); List <string> ltrans3 = excelApp.GetColumn(DM.Columns.trans3); richTextBox1.Text = ""; foreach (var item in countUnknownWords(lfreq, lLvl)) { richTextBox1.Text += item.Key + " " + item.Value + "\r"; } string lvlCondition = "0"; if (unknownRadioButton.Checked) { lvlCondition = unknownRadioButton.Text; } if (fogottenRadioButton.Checked) { lvlCondition = fogottenRadioButton.Text; } if (studiedRadioButton.Checked) { lvlCondition = studiedRadioButton.Text; } int minFreq = Convert.ToInt16(minFreqTextBox.Text); int maxWords = Convert.ToInt16(maxRndTextBox.Text); for (int i = 0; i < lWords.Count && memo.study.Count < maxWords; i++) { if (lLvl[i] == lvlCondition && Convert.ToInt16(lfreq[i]) >= minFreq) { memo.AddStudy(lWords[i], i, ltrans1[i] + "," + ltrans2[i] + "," + ltrans3[i]); for (int j = 0; j < WordsFormer.maxExamples; j++) { if (excelApp.GetValue(j + WordsFormer.whereExamplesStart, i + 2) != "") { memo.study[memo.study.Count - 1].AddEx(excelApp.GetValue(j + WordsFormer.whereExamplesStart, i + 2)); } } Text = i.ToString() + " Слов " + memo.study.Count.ToString(); } } memo.FillGrid(); memo.ApplyParams(Convert.ToInt16(rangeTextBox.Text)); richTextBox1.Focus(); //nextButton_Click(null, null); }