private void calander1_MouseDoubleClick(object sender, MouseButtonEventArgs e) { List <ListOfTasks> ls = new List <ListOfTasks>(); List <Task> chosenT = new List <Task>(); ViewModel vm = new ViewModel(popAlert); vm.getAll(ls); foreach (Task t in ls[0].Tasks.ToList()) { if (t.DateTask.Equals(calander1.SelectedDate)) { chosenT.Add(t); } } foreach (Task t in ls[1].Tasks.ToList()) { if (t.DateTask.Equals(calander1.SelectedDate)) { chosenT.Add(t); } } foreach (Task t in ls[2].Tasks.ToList()) { if (t.DateTask.Equals(calander1.SelectedDate)) { chosenT.Add(t); } } TaskDetails td = new TaskDetails(chosenT); td.ShowDialog(); }
public List <TaskDetails> convertStringIntoTaskDetails(List <String> ListOfCompletedEvents) { try { List <TaskDetails> listOfTasksInFile = new List <TaskDetails>(); for (int j = 0; j < ListOfCompletedEvents.Count(); j++) { String line = ListOfCompletedEvents[j]; int i = j + 1; string[] eventParameters = line.Split(';'); TaskDetails task = new TaskDetails(); task.setEventname(eventParameters[0]); task.setlocation(eventParameters[1]); task.setStartDate(eventParameters[2]); task.setEndDate(eventParameters[3]); task.setStartTime(eventParameters[4]); task.setEndTime(eventParameters[5]); task.setDuration(eventParameters[6]); task.setPriority(eventParameters[7]); task.setReminder(eventParameters[8]); task.setID(i.ToString()); listOfTasksInFile.Add(task); } return(listOfTasksInFile); } catch (Exception e) { StreamWriter loggingWriter = new StreamWriter("Logging.txt"); loggingWriter.WriteLine(System.DateTime.Now + e.Message + "\n"); loggingWriter.Close(); return(null); } }
//if postponed is clicked then the start time or the end time is changed private void button2_Click(object sender, RoutedEventArgs e) { Conversions objectConversions = new Conversions(); Parser parserObject = new Parser("display"); List <Event> datagriditemSource = parserObject.taskToBePerformed(); TaskDetails taskObj = objectConversions.convertEventsIntoTaskdetails(datagriditemSource[id - 1]); string DateToBePostponedTo = taskObj.getStartDate(); string TimeToBePostponedTo = hours.ToString() + ":" + minutes.ToString() + ":" + seconds.ToString(); if (days != 0) { DateTime sDate = objectConversions.ConvertStringToDate(DateToBePostponedTo); DateToBePostponedTo = sDate.AddDays(days).ToShortDateString(); EditCommand = "edit id" + " \"" + id.ToString() + "\"" + " start" + " \"" + DateToBePostponedTo + "\""; } if (taskObj.getEndTime() != "null") { string endTime = (TimeSpan.Parse(taskObj.getEndTime()) + TimeSpan.Parse(TimeToBePostponedTo)).ToString(); EditCommand = "edit id" + " \"" + id.ToString() + "\"" + " to" + " \"" + endTime + "\"" + " start" + " \"" + DateToBePostponedTo + "\"" + "reminder" + " \"1H" + "\""; } if (taskObj.getStartTime() != "null") { string startTime = (TimeSpan.Parse(taskObj.getStartTime()) + TimeSpan.Parse(TimeToBePostponedTo)).ToString(); EditCommand = "edit id" + " \"" + id.ToString() + "\"" + " from" + " \"" + startTime + "\"" + " start" + " \"" + DateToBePostponedTo + "\"" + "\"" + "reminder" + " \"1H" + "\""; } this.Close(); }
public /*List<TaskDetails> */ TaskDetails convertEventsIntoTaskdetails(/*List<Event> */ Event events) { try { List <TaskDetails> tasks = new List <TaskDetails>(); TaskDetails taskObj = new TaskDetails(); // for (int i = 0; i < events.Count(); i++) { string eventName = events.Event_Name; string sDate = events.Start.Trim(); string eDate = events.End.Trim(); string sTime = "null", eTime = "null"; string location = "null"; if (events.Event_Name.IndexOf("@") != -1) { eventName = events.Event_Name.Split('@')[0]; location = events.Event_Name.Split('@')[1]; } if (events.Start.IndexOf(',') != -1) { string[] start = events.Start.Split(','); sDate = start[0].Trim(); sTime = start[1].Trim(); } if (events.End.IndexOf(',') != -1) { string[] end = events.End.Split(','); eDate = end[0].Trim(); eTime = end[1].Trim(); } taskObj.setEventname(eventName); taskObj.setlocation(location); taskObj.setStartDate(sDate); taskObj.setEndDate(eDate); taskObj.setStartTime(sTime); taskObj.setEndTime(eTime); taskObj.setPriority(events.Priority); taskObj.setReminder(events.Remind_Me_Before); taskObj.setID(events.Event_ID); tasks.Add(taskObj); } return(taskObj); } catch (Exception e) { StreamWriter loggingWriter = new StreamWriter("Logging.txt"); loggingWriter.WriteLine(System.DateTime.Now + e.Message + "\n"); loggingWriter.Close(); return(null); } }
public List <TaskDetails> readFromFile() { // Create an instance of StreamReader to read from a file. // The using statement also closes the StreamReader. List <TaskDetails> listOfTasksInFile = new List <TaskDetails>(); using (StreamReader sr = new StreamReader(filename)) { Debug.Assert(sr != null); String line; int i = 1; int j = 1; // Read and display lines from the file until the end of // the file is reached. while ((line = sr.ReadLine()) != null) { //Console.WriteLine(line); if (!(line.Contains("*******")) && line.CompareTo("") != 0) { j++; string[] eventParameters = line.Split(';'); TaskDetails task = new TaskDetails(); task.setEventname(eventParameters[0]); task.setlocation(eventParameters[1]); task.setStartDate(eventParameters[2]); task.setEndDate(eventParameters[3]); task.setStartTime(eventParameters[4]); task.setEndTime(eventParameters[5]); task.setDuration(eventParameters[6]); task.setPriority(eventParameters[7]); task.setReminder(eventParameters[8]); task.setID(i.ToString()); i++; listOfTasksInFile.Add(task); } else { listOfTasksInFile.RemoveRange(0, listOfTasksInFile.Count()); } } sr.Close(); } return(listOfTasksInFile); }
public string convertTaskDetailToWriteIntoFile(TaskDetails objectDetailsOfTask) { try { return(objectDetailsOfTask.getEventname() + ";" + objectDetailsOfTask.getLocation() + ";" + objectDetailsOfTask.getStartDate() + ";" + objectDetailsOfTask.getEndDate() + ";" + objectDetailsOfTask.getStartTime() + ";" + objectDetailsOfTask.getEndTime() + ";" + objectDetailsOfTask.getDuration() + ";" + objectDetailsOfTask.getPriority() + ";" + objectDetailsOfTask.getRemainderTime() + ";" + objectDetailsOfTask.getRepeat()); } catch (Exception e) { StreamWriter loggingWriter = new StreamWriter("Logging.txt"); loggingWriter.WriteLine(System.DateTime.Now + e.Message + "\n"); loggingWriter.Close(); return(null); } }
public List <TaskDetails> readFromFile() { List <TaskDetails> listOfTasksInFile = new List <TaskDetails>(); using (StreamReader sr = new StreamReader(this.filename)) { string line; int i = 1; int j = 1; while ((line = sr.ReadLine()) != null) { if (!(line.Contains("*******") || (line.CompareTo("") == 0))) { j++; string[] eventParameters = line.Split(new char[] { ';' }); TaskDetails task = new TaskDetails(); task.setEventname(eventParameters[0]); task.setlocation(eventParameters[1]); task.setStartDate(eventParameters[2]); task.setEndDate(eventParameters[3]); task.setStartTime(eventParameters[4]); task.setEndTime(eventParameters[5]); task.setDuration(eventParameters[6]); task.setPriority(eventParameters[7]); task.setReminder(eventParameters[8]); task.setID(i.ToString()); i++; listOfTasksInFile.Add(task); } else { listOfTasksInFile.RemoveRange(0, listOfTasksInFile.Count <TaskDetails>()); } } sr.Close(); } return(listOfTasksInFile); }
public edit_event(int eventid) { InitializeComponent(); id = eventid; Parser obj = new Parser("display"); List <Event> currentevents = new List <Event>(); currentevents = obj.taskToBePerformed(); TaskDetails TaskDetailsObject = new TaskDetails(); Conversions Conversionsobject = new Conversions(); TaskDetailsObject = Conversionsobject.convertEventsIntoTaskdetails(currentevents[id]); textBox2.Text = TaskDetailsObject.getEventname() == "null" ? " " : TaskDetailsObject.getEventname(); textBox3.Text = TaskDetailsObject.getLocation() == "null" ? " " : TaskDetailsObject.getLocation(); textBox4.Text = TaskDetailsObject.getStartDate() == "null" ? " " : TaskDetailsObject.getStartDate(); textBox5.Text = TaskDetailsObject.getEndDate() == "null" ? " " : TaskDetailsObject.getEndDate(); textBox6.Text = TaskDetailsObject.getStartTime() == "null" ? " " : TaskDetailsObject.getStartTime(); textBox7.Text = TaskDetailsObject.getEndTime() == "null" ? " " : TaskDetailsObject.getEndTime(); textBox9.Text = currentevents[id].Remind_Me_Before == "null" ? " " : TaskDetailsObject.getRemainderTime(); textBox10.Text = currentevents[id].Priority == "null" ? " " : TaskDetailsObject.getPriority(); command = ""; }
public List <TaskDetails> convertStringIntoTaskDetails(List <string> ListOfCompletedEvents) { List <TaskDetails> listOfTasksInFile = new List <TaskDetails>(); for (int j = 0; j < ListOfCompletedEvents.Count <string>(); j++) { string line = ListOfCompletedEvents[j]; int i = j + 1; string[] eventParameters = line.Split(new char[] { ';' }); TaskDetails task = new TaskDetails(); task.setEventname(eventParameters[0]); task.setlocation(eventParameters[1]); task.setStartDate(eventParameters[2]); task.setEndDate(eventParameters[3]); task.setStartTime(eventParameters[4]); task.setEndTime(eventParameters[5]); task.setDuration(eventParameters[6]); task.setPriority(eventParameters[7]); task.setReminder(eventParameters[8]); task.setID(i.ToString()); listOfTasksInFile.Add(task); } return(listOfTasksInFile); }