private async void CalcBMIButton_Click(object sender, RoutedEventArgs e) { ((Button)sender).IsEnabled = false; (ApplicationBar.Buttons[0] as ApplicationBarIconButton).IsEnabled = false; BMIValidationOutput validationOutput = BMICalculator.ValidateInputText(TxtBoxBMIHeight.Text, TxtBoxBMIWeight.Text); if (validationOutput.Error == null) { CalcBMIClickAnimationStart.Begin(); BMICalculator bmiCalc = new BMICalculator(validationOutput, App.BMIValuesViewModel.Items); BMILimit bmiLimit = bmiCalc.ShowLimitList.FirstOrDefault(x => x.Equals(bmiCalc.ShowLimit)); if (App.BMIValuesViewModel.Prop != null) { App.BMIValuesViewModel.Prop.CurrentColor = null; } App.BMIValuesViewModel.Prop = bmiLimit; bmiLimit.IsSelected = true; bmiLimit.CurrentColor = bmiLimit.Color; txtBMIResult.Text = bmiCalc.Value.ToString(); CalcBMIClickAnimationEnd.Begin(); Deployment.Current.Dispatcher.BeginInvoke(() => { BMIList.ScrollTo(App.BMIValuesViewModel.Prop); }); await IsolatedStorageOps.Append( new BMIHistoryModel { Date = DateTime.Now, Value = bmiCalc.Value }, _xmlBMIFileName); } else { MessageBox.Show(validationOutput.Error, AppResources.Error, MessageBoxButton.OK); } ((Button)sender).IsEnabled = true; (ApplicationBar.Buttons[0] as ApplicationBarIconButton).IsEnabled = true; }
private async void BMIHistory_Click(object sender, EventArgs e) { var list = await IsolatedStorageOps.Load <List <BMIHistoryModel> >(_xmlBMIFileName); var output = new StringBuilder(); if (list.Count == 0) { output.Append(AppResources.BMIHistoryIsEmptyPlaceholder); } else { int i = 0; list.Sort((x, y) => y.Date.CompareTo(x.Date)); list.ForEach(x => output.Append(String.Format( "{0,2}. {1}\t{2:0.00}\n", ++i, x.Date.ToShortDateString(), x.Value))); } MessageBox.Show(output.ToString(), AppResources.BMIHistoryWindowTitle, MessageBoxButton.OK); }