private async void AddButton_Click(object sender, RoutedEventArgs e) { if (sender is Button button) { var editWindow = new ModalOkCancelControl(); try { //editWindow.Width = 700; //editWindow.Height = 650; editWindow.Title = "Add New Session"; var content = new SessionEditControl(); var Schedule = button.DataContext as ScheduleViewModel; MainGrid.Children.Add(editWindow); if (content.DataContext is SessionViewModel editVM && Schedule != null) { editVM.Schedule = Schedule; editWindow.ModalContent = content; if (editWindow.ShowDialog() == true) { await Schedule.AddSessionAsync(editVM.Model); } } } finally { MainGrid.Children.Remove(editWindow); } } }
private T OpenSelectDialog <T>(SessionViewModel sender, string title, string message, IEnumerable <T> values) where T : class { var dialog = new ModalOkCancelControl(); try { var content = new SelectionControl() { Header = title, Message = message, Items = CollectionViewSource.GetDefaultView(values), SubmitText = "Ok", CancelText = "Cancel" }; dialog.ModalContent = content; MainGrid.Children.Add(dialog); if (dialog.ShowDialog() == true) { return((T)content.Items.CurrentItem); } return(null); } finally { MainGrid.Children.Remove(dialog); } }
private void EditBasePointsButton_Click(object sender, RoutedEventArgs e) { if (sender is Button button && button.Tag != null) { //var editWindow = new ModalOkCancelWindow(); //editWindow.Width = 250; //editWindow.Height = 500; var EditPanel = new ModalOkCancelControl(); MainGrid.Children.Add(EditPanel); var editWindow = EditPanel; var content = new PointsEditControl(); editWindow.Title = "Edit Base points"; try { if (button.Tag is ScoringViewModel scoring && scoring != null) { var editBasePoints = new ObservableCollection <iRLeagueManager.Models.Results.ScoringModel.BasePointsValue>(scoring.BasePoints.ToList()); content.DataContext = editBasePoints; editWindow.ModalContent = content; if (editWindow.ShowDialog() == true) { int i; for (i = 0; i < editBasePoints.Count(); i++) { if (i >= scoring.BasePoints.Count()) { scoring.BasePoints.Add(editBasePoints[i]); } else { scoring.BasePoints[i] = editBasePoints[i]; } } for (i = editBasePoints.Count(); i < scoring.BasePoints.Count(); i++) { scoring.BasePoints.RemoveAt(i); } } } } finally { MainGrid.Children.Remove(EditPanel); } } }
private async Task EditSessionDialog(SessionViewModel sessionVM) { if (sessionVM == null) { return; } var editWindow = new ModalOkCancelControl(); try { //editWindow.Width = 700; //editWindow.Height = 650; var content = new SessionEditControl(); MainGrid.Children.Add(editWindow); editWindow.Title = "Edit Session"; var editVM = content.DataContext as SessionViewModel; if (sessionVM.SessionType == Enums.SessionType.Race) { editVM.UpdateSource(Models.Sessions.RaceSessionModel.GetTemplate()); } editVM.Model.CopyFrom(sessionVM.Model); editVM.Schedule = sessionVM.Schedule; editWindow.ModalContent = content; if (editWindow.ShowDialog() == true) { sessionVM.Model.CopyFrom(editVM.Model); await sessionVM.SaveChanges(); } } finally { MainGrid.Children.Remove(editWindow); } }
private async void EditFiltersButton_Click(object sender, RoutedEventArgs e) { var EditPanel = new ModalOkCancelControl(); MainGrid.Children.Add(EditPanel); try { if (sender is Button button && button.Tag is ScoringViewModel scoringViewModel) { var editWindow = EditPanel; var filterEdit = new FiltersEditControl(); await filterEdit.ViewModel.Load(scoringViewModel.Model); editWindow.ModalContent = filterEdit; editWindow.ShowDialog(); } } finally { MainGrid.Children.Remove(EditPanel); } }