private void UpdateSelectedSavedGradeScale() { try { var scales = SavedGradeScales; if (scales == null) { return; } GradeScale[] curr = GradeScales.ToArray(); var matching = scales.Where(i => i.GradeScales != null).FirstOrDefault(i => i.GradeScales.SequenceEqual(curr)); // If no match, we use the Custom (not saved) last item if (matching == null) { matching = scales.Last(); } if (SelectedSavedGradeScale == matching) { return; } SetSelectedGradeScaleWithoutChangingExistingScales(matching); } catch { } }
public void SaveGradeScale() { try { PagedViewModelWithPopups popupHost; if (ShowSaveScalePopupInSeparatePopupPane) { // We'll show on a popup layer a level higher, so that the current content is still visible popupHost = MainScreenViewModel.GetPopupViewModelHost(); } else { popupHost = GetPopupViewModelHost(); } popupHost.ShowPopup(new SaveGradeScaleViewModel(popupHost, MainScreenViewModel, new SaveGradeScaleViewModel.Parameter() { Name = "", OnSaved = delegate { var dontWait = ReloadSavedGradeScalesPicker(); }, Scales = GradeScales.ToArray() })); } catch (Exception ex) { TelemetryExtension.Current?.TrackException(ex); } }
protected override BaseItem serialize() { Class into = new Class() { CourseNumber = CourseNumber, GradeScales = GradeScales?.ToArray(), ShouldAverageGradeTotals = ShouldAverageGradeTotals, Credits = Credits, Position = Position, Color = Color.FromArgb(255, RawColor[0], RawColor[1], RawColor[2]).ToString(), DoesRoundGradesUp = DoesRoundGradesUp }; base.serialize(into); return(into); }
public async void Save() { try { if (!AreScalesValid()) { await new PortableMessageDialog(PowerPlannerResources.GetString("String_InvalidGradeScalesMessageBody"), PowerPlannerResources.GetString("String_InvalidGradeScalesMessageHeader")).ShowAsync(); return; } GradeScale[] newScales = GradeScales.ToArray(); DataChanges changes = new DataChanges(); // Class changes { var c = new DataItemClass() { Identifier = Class.Identifier }; c.SetGradeScales(newScales); changes.Add(c); } TryStartDataOperationAndThenNavigate(delegate { return(PowerPlannerApp.Current.SaveChanges(changes)); }, delegate { this.RemoveViewModel(); }); } catch (Exception ex) { TelemetryExtension.Current?.TrackException(ex); await new PortableMessageDialog("Error encountered while saving. Your error report has been sent to the developer.", "Error").ShowAsync(); } }