public SelectEventArgs(EventViewModel viewModel) { this.viewModel = viewModel; }
private static int EventsCompare(EventViewModel x, EventViewModel y) { if (x.StartHour > y.StartHour) { return 1; } else if (x.StartHour < y.StartHour) { return -1; } else { if (x.Duration > y.Duration) { return -1; } else if (x.Duration < y.Duration) { return 1; } else { return 0; } } }
private bool EventsOverlap(EventViewModel firstEvent, EventViewModel secondEvent) { // Events are sorted, so this function presumes that starting hour of firstEvent <= secondEvent return (firstEvent.StartHour + firstEvent.Duration > secondEvent.StartHour); }
/// <summary> /// Handler for Done button /// </summary> private void DoneButton_click(object sender, EventArgs e) { EventViewModel model = null; if (eventIndex != -1) { model = App.ViewModel.Items[eventIndex]; } else { model = new EventViewModel(); model.DayOfWeek = dayOfWeek; } DateTime startHour = StartsPicker.Value ?? DateTime.Now; DateTime endHour = EndsPicker.Value ?? DateTime.Now; model.StartHour = startHour.Hour; model.Duration = endHour.Hour - startHour.Hour; model.Text = DescriptionInput.Text; if (eventIndex == -1) { App.ViewModel.Items.Add(model); } NavigationService.GoBack(); }