//launch form to add an event private void addEventToolStripMenuItem_Click(object sender, EventArgs e) { AddEventForm form = new AddEventForm(); form.ShowDialog(); //if the user saved the event, add it to the calendar view Appointment newAppt = form.getnewEvent(); if (newAppt != null) { calendarEvents.Add(newAppt); calendarView.Invalidate(); updateLeftPanel(); } }
//button to add an event private void tsAddTaskBtn_Click(object sender, EventArgs e) { //get the time current selected DateTime selectedDateTime = calendarView.SelectionStart; //before showing the form, set the start date and time // for the event if the date is valid AddEventForm form = new AddEventForm(); if (selectedDateTime.Year > 2000) { form.setStartDate(selectedDateTime); form.setStartTime(selectedDateTime); } //show the form form.ShowDialog(); //if a new event was saved, update the calendar view as well as the left panel Appointment newAppt = form.getnewEvent(); if (newAppt != null) { calendarEvents.Add(newAppt); calendarView.Invalidate(); updateLeftPanel(); } }