private void SaveButton_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(textBoxClientID.Text) || string.IsNullOrWhiteSpace(textBoxSecret.Text) || string.IsNullOrWhiteSpace(textBoxProjectID.Text) || string.IsNullOrWhiteSpace(textBoxMail.Text)) { SettingsMessageBox Message = new SettingsMessageBox(); Message.Text = "Fill all informations!"; Message.Show(); } else { using (var id = new StreamWriter(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\myID.setting", false)) { id.WriteLine(textBoxClientID.Text); id.WriteLine(textBoxSecret.Text); id.WriteLine(textBoxProjectID.Text); id.WriteLine(textBoxMail.Text); id.Close(); SettingsMessageBox Message = new SettingsMessageBox(); Message.Text = "Configuration saved!"; Message.Show(); this.Close(); } } }
private void buttonDelNotes_Click(object sender, EventArgs e) { /// DELETE NOTES WHERE DATE IS LOWER THAN TODAY DATE string[] files = Directory.GetFiles(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)); foreach (string file in files) { Match match = Regex.Match(file, @".mnote", RegexOptions.IgnoreCase); if (match.Success) { DateTime todayDate = DateTime.Now; int TDay = todayDate.Day; int TMonth = todayDate.Month; int TYear = todayDate.Year; TextReader Load = new StreamReader(file); Load.ReadLine(); int NYear = Convert.ToInt32(Load.ReadLine()); Dictionary <string, int> Months = new Dictionary <string, int>(); Months.Add("January", 1); Months.Add("February", 2); Months.Add("March", 3); Months.Add("April", 4); Months.Add("May", 5); Months.Add("June", 6); Months.Add("July", 7); Months.Add("August", 8); Months.Add("September", 9); Months.Add("October", 10); Months.Add("November", 11); Months.Add("December", 12); int NMonth = Months[Load.ReadLine()]; int NDay = Convert.ToInt32(Load.ReadLine()); Load.Close(); string Npath = file; if (TYear >= NYear && TMonth >= NMonth && TDay >= NMonth) { File.Delete(Npath); SettingsMessageBox Message = new SettingsMessageBox(); Message.Text = "Outdated Notes deleted!"; Message.Show(); } else { SettingsMessageBox Message = new SettingsMessageBox(); Message.Text = "No outdated Notes to delete!"; Message.Show(); } } } }
private void SendButton_Click(object sender, EventArgs e) { using (var sw = new StreamWriter(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\personal.setting", false)) { sw.WriteLine(textBoxMyMail.Text); sw.WriteLine(textBoxMyPassword.Text); SettingsMessageBox Message = new SettingsMessageBox(); Message.Text = "Default E-mail & password changed!"; Message.Show(); this.Close(); } }
private void SaveButton_Click(object sender, EventArgs e) { using (var sw = new StreamWriter(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\color.setting", false)) { sw.WriteLine(BackgroundBox.Text + " "); sw.WriteLine(DaysBox.Text + " "); sw.WriteLine(BusyBox.Text + " "); sw.WriteLine(TodayBox.Text + " "); SettingsMessageBox Message = new SettingsMessageBox(); Message.Text = "Default colors changed!"; Message.Show(); this.Close(); } }
private void buttonDelVisits_Click(object sender, EventArgs e) { /// DELETE EVENTS WHERE DATE IS LOWER THAN TODAY DATE string[] files = Directory.GetFiles(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)); foreach (string file in files) { Match match = Regex.Match(file, @".mevent", RegexOptions.IgnoreCase); if (match.Success) { DateTime todayDate = DateTime.Now; int TDay = todayDate.Day; int TMonth = todayDate.Month; int TYear = todayDate.Year; TextReader Load = new StreamReader(file); Load.ReadLine(); string Eyear = Load.ReadLine(); int NYear = Convert.ToInt32(Eyear); Dictionary <string, int> Months = new Dictionary <string, int>(); Months.Add("January", 1); Months.Add("February", 2); Months.Add("March", 3); Months.Add("April", 4); Months.Add("May", 5); Months.Add("June", 6); Months.Add("July", 7); Months.Add("August", 8); Months.Add("September", 9); Months.Add("October", 10); Months.Add("November", 11); Months.Add("December", 12); string EMonth = Load.ReadLine(); string EDay = Load.ReadLine(); int NMonth = Months[EMonth]; int NDay = Convert.ToInt32(EDay); Load.ReadLine(); Load.ReadLine(); Load.ReadLine(); string Name = Load.ReadLine(); Load.Close(); string Npath = file; if (TYear >= NYear && TMonth >= NMonth && TDay >= NMonth) { /// DELETE EVENT FILE File.Delete(Npath); /// DELETE EVENT FROM GOOGLE CALENDAR string[] Scopes = { CalendarService.Scope.Calendar }; string ApplicationName = "MyCalendar Google Calendar API"; UserCredential credential; using (var stream = new FileStream("credentials.json", FileMode.Open, FileAccess.Read)) { // The file token.json stores the user's access and refresh tokens, and is created // automatically when the authorization flow completes for the first time. string credPath = "token.json"; credential = GoogleWebAuthorizationBroker.AuthorizeAsync( GoogleClientSecrets.Load(stream).Secrets, Scopes, "user", CancellationToken.None, new FileDataStore(credPath, true)).Result; } // Create Google Calendar API service. var service = new CalendarService(new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = ApplicationName, }); String calendarId = "primary"; String eventId = Eyear + EMonth + EDay; service.Events.Delete(calendarId, eventId); SettingsMessageBox Message = new SettingsMessageBox(); Message.Text = "Outdated visits deleted!"; Message.Show(); } else { SettingsMessageBox Message = new SettingsMessageBox(); Message.Text = "No outdated visits to delete!"; Message.Show(); } } } }