private void AddAppointmentToListView(Event newapp) { string[] arr = new string[3]; arr[0] = newapp.Date.ToShortDateString(); arr[1] = newapp.Title; arr[2] = newapp.Description; var items = new ListViewItem(arr); listView1.Items.Add(items); }
bool IsTrueCriteria(Event ev, string criteria) { switch (criteria) { case "||": return ContainsAnyTag(ev, valueToCompare); case "&&": return ContainsAllTags(ev, valueToCompare); default: return false; } }
public bool IsTrueCriteria(Event ev, Event compare, string criteria) { switch (criteria) { case "=": return (ev.CompareTo(compare) == 0); case "!=": return !(ev.CompareTo(compare) == 0); case "<=": return (ev.CompareTo(compare) <= 0); case "<": return (ev.CompareTo(compare) < 0); case ">=": return (ev.CompareTo(compare) >= 0); case ">": return (ev.CompareTo(compare) > 0); } return false; }
public Events ApplyFilter(Events sourceList) { Events filteredList = new Events(); Event compare = new Event(dateToCompare, "", ""); foreach (Event ev in sourceList) { if (IsTrueCriteria(ev, compare, criteria)) { filteredList.Add(ev); } } return filteredList; }
bool ContainsAnyTag(Event ev, string[] tagValues) { return tagValues.Any(elem => ev.Tags.Contains('#' + elem) || ev.Tags.Contains('@' + elem)); }
bool ContainsAnyString(Event ev, string[] stringValues) { return stringValues.Any(elem => ev.Title.Contains(elem) || ev.Description.Contains(elem)); }
private void SaveNewAppointment(Event newAppointment) { eventsList.Add(newAppointment); TXTFile file = new TXTFile(); file.SaveEventsToFile(eventsList); }