private async Task Initialize() { RegistryKey rk = Registry.CurrentUser.OpenSubKey ("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); if (rk.GetValue("AnnouncementHelper") != null) { Program.StartupEnabled = true; } if (!Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\AnnouncementHelper\\")) { Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\AnnouncementHelper\\"); } string[] files = Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\AnnouncementHelper\\"); foreach (string s in files) { string filename = s.Split('\\').Last(); if (filename.Contains("reminder")) { string date = filename.Split('_')[1].Split('T')[0]; if (DateTime.ParseExact(date, "yyyy-MM-dd", CultureInfo.InvariantCulture) <= DateTime.Now.Date) { StringEdit.Out("Βρέθηκε ανακοίνωση για σήμερα!", ref richTextBox1, StringEdit.OutType.Success); await Task.Delay(1000); Announcement temp = AnnouncementConvert.FromBase64(File.ReadAllText(s)); File.Delete(s); new Thread(() => { AnnouncementForm f1 = new AnnouncementForm(temp); f1.ShowDialog(); }) { IsBackground = true }.Start(); } } } // Το httpClient χρησιμοποιεί proxy σαν default που το κάνει αργό // οπότε το αφαιρούμε HttpClientHandler hch = new HttpClientHandler { Proxy = null, UseProxy = false, }; client = new HttpClient(hch); }
private void ReminderSet_Click(object sender, EventArgs e) { string temp = AnnouncementConvert.ToBase64(currentAnnouncement); string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\AnnouncementHelper\\reminder_" + dateTimePicker1.Text + "T" + temp.Substring(0, 6); File.WriteAllText(path, temp); if (!Program.StartupEnabled) { DialogResult dialogResult = MessageBox.Show("Θέλετε να ανοίγει το AnnouncementHelper αυτόματα στην έναρξη για να μην χάνετε τις υπενθυμίσεις (προτεινόμενο)?", "Προσθήκη στην έναρξη?", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { Program.SetStartup(true); } } MessageBox.Show("Reminder set!", "Message"); }