private void LoadWords() { StreamReader sr = null; try { sr = new StreamReader(dataFileName); while (!sr.EndOfStream) { string[] str = sr.ReadLine().Split(";".ToArray()); WordStruct wordStruct = new WordStruct { Eng = str[0], Ukr = str[1], Time = DateTime.ParseExact(str[2], "dd.MM.yyyy H:mm:ss", CultureInfo.InvariantCulture), LastShow = DateTime.ParseExact(str[3], "dd.MM.yyyy H:mm:ss", CultureInfo.InvariantCulture) }; words.Add(wordStruct); } } catch (Exception ex) { throw new FileLoadException(ex.Message); } finally { if (sr != null) { sr.Close(); } } }
public WordStruct Next() { WordStruct word = null; bool isShow = false; while (!isShow) { if (next >= words.Count) { break; } word = words[next++]; TimeSpan lastShow = DateTime.Now - word.LastShow; TimeSpan added = DateTime.Now - word.Time; if (added.TotalHours < param.Max1 && lastShow.TotalHours > param.Freq1) { isShow = true; } else if (added.TotalDays < param.Max2 && lastShow.TotalHours > param.Freq2) { isShow = true; } else if (added.TotalDays < param.Max3 && lastShow.TotalDays > param.Freq3) { isShow = true; } else { words.Remove(word); archive.Add(word); } } return(word); }
private void Timer_Tick(object sender, EventArgs e) { WordStruct word = wordReminder.Next(); if (word != null) { notifyForm.Show(word); } }
public void AddWord(string en, string ua) { WordStruct wordStruct = new WordStruct() { Eng = en, Ukr = ua, Time = DateTime.Now, LastShow = DateTime.Now }; words.Add(wordStruct); }
public DialogResult Show(WordStruct _word) { word = _word; Size scr = Screen.PrimaryScreen.WorkingArea.Size; Location = new Point(scr.Width - Size.Width, scr.Height - Size.Height); timer.Start(); lWord.Text = word.Eng; lTranslate.Text = ""; Show(); return(DialogResult.OK); }