public static void PokazWydarzenia(string path) { Console.Clear(); StreamReader sr = null; try { sr = new StreamReader(path); string str; ushort n = 1; while ((str = sr.ReadLine()) != null) { if (str.Split('#').GetLength(0) != 3) { continue; } string imp = str.Split('#')[0]; string desc = str.Split('#')[1]; DateTime dt; if (DateTime.TryParse(str.Split('#')[2], out dt)) { Przypomnienie prz = new Przypomnienie(imp, desc, dt); Console.Write(n + ".) "); prz.Display(); } else { string title = str.Split('#')[2]; Notatka nt = new Notatka(imp, desc, title); Console.Write(n + ".) "); nt.Display(); } n++; } sr.Close(); }catch (Exception ex) { Console.WriteLine("Wystapił błąd: " + ex.Message + " Spróbuj jeszcze raz."); } finally { if (sr != null) { sr.Close(); } // Console.ReadLine(); } }
public static void Przypomnienia(string path) { List <Przypomnienie> plist = new List <Przypomnienie>(); string str; while (true) { if (_add) { using (StreamReader sr = new StreamReader(path)) { while ((str = sr.ReadLine()) != null) { Przypomnienie prz = null; DateTime dt; if (DateTime.TryParse(str.Split('#')[2], out dt)) { string imp = str.Split('#')[0]; string desc = str.Split('#')[1]; prz = new Przypomnienie(imp, desc, dt); if (!plist.Contains(prz)) { plist.Add(prz); } } } } _add = false; } Thread.Sleep(2000); foreach (Przypomnienie p in plist) { if (DateTime.Now.Date == p.Time.Date && DateTime.Now.Hour == p.Time.Hour && DateTime.Now.Minute == p.Time.Minute && DateTime.Now.Second <= 4) { SystemSounds.Beep.Play(); MessageBox.Show(p.Description, "Przypomnienie", MessageBoxButtons.OK); } } if (_stop) { break; } } }