private async void btnWhen_Click(object sender, RoutedEventArgs e) { OutcomeOverviewViewModel viewModel = (OutcomeOverviewViewModel)((Button)sender).DataContext; OutcomeWhen dialog = new OutcomeWhen(); dialog.Value = viewModel.When; ContentDialogResult result = await dialog.ShowAsync(); if (result == ContentDialogResult.Primary && dialog.Value != viewModel.When) { await domainFacade.ChangeOutcomeWhen(viewModel.Key, dialog.Value); viewModel.When = dialog.Value; if (month != null && (dialog.Value.Year != month.Year || dialog.Value.Month != month.Month)) { ViewModel.Items.Remove(viewModel); } if (year != null && (dialog.Value.Year != year.Year)) { ViewModel.Items.Remove(viewModel); } } }
private void lvwItems_SelectionChanged(object sender, SelectionChangedEventArgs e) { OutcomeOverviewViewModel selected = (OutcomeOverviewViewModel)e.AddedItems.FirstOrDefault(); foreach (OutcomeOverviewViewModel viewModel in ViewModel.Items) { viewModel.IsSelected = selected == viewModel; } }
private void btnDelete_Click(object sender, RoutedEventArgs e) { OutcomeOverviewViewModel viewModel = (OutcomeOverviewViewModel)((Button)sender).DataContext; navigator .Message(String.Format("Do you realy want to delete an outcome for '{0}' from '{1}'?", viewModel.Amount, viewModel.When)) .Button("Yes", new DeleteOutcomeCommand(commandDispatcher, viewModel.Key).AddExecuted(() => ViewModel.Items.Remove(viewModel))) .ButtonClose("No") .Show(); }
private async void btnWhen_Click(object sender, RoutedEventArgs e) { OutcomeOverviewViewModel viewModel = (OutcomeOverviewViewModel)((Button)sender).DataContext; OutcomeWhen dialog = new OutcomeWhen(); dialog.Value = viewModel.When; ContentDialogResult result = await dialog.ShowAsync(); if (result == ContentDialogResult.Primary && dialog.Value != viewModel.When) { await commandDispatcher.HandleAsync(new ChangeOutcomeWhen(viewModel.Key, dialog.Value)); } }
private async void btnDescription_Click(object sender, RoutedEventArgs e) { OutcomeOverviewViewModel viewModel = (OutcomeOverviewViewModel)((Button)sender).DataContext; OutcomeDescription dialog = new OutcomeDescription(); dialog.Value = viewModel.Description; ContentDialogResult result = await dialog.ShowAsync(); if (result == ContentDialogResult.Primary && dialog.Value != viewModel.Description) { await domainFacade.ChangeOutcomeDescription(viewModel.Key, dialog.Value); viewModel.Description = dialog.Value; } }
private async void btnAmount_Click(object sender, RoutedEventArgs e) { OutcomeOverviewViewModel viewModel = (OutcomeOverviewViewModel)((Button)sender).DataContext; OutcomeAmount dialog = new OutcomeAmount(queryDispatcher); dialog.Value = viewModel.Amount.Value; dialog.Currency = viewModel.Amount.Currency; ContentDialogResult result = await dialog.ShowAsync(true); decimal newValue = dialog.Value; if (result == ContentDialogResult.Primary && newValue != viewModel.Amount.Value) { Price newAmount = new Price(newValue, dialog.Currency); await commandDispatcher.HandleAsync(new ChangeOutcomeAmount(viewModel.Key, newAmount)); } }
private async void btnAmount_Click(object sender, RoutedEventArgs e) { OutcomeOverviewViewModel viewModel = (OutcomeOverviewViewModel)((Button)sender).DataContext; OutcomeAmount dialog = new OutcomeAmount(); dialog.Value = (double)viewModel.Amount.Value; ContentDialogResult result = await dialog.ShowAsync(); decimal newValue = (decimal)dialog.Value; if (result == ContentDialogResult.Primary && newValue != viewModel.Amount.Value) { Price newAmount = new Price(newValue, viewModel.Amount.Currency); await domainFacade.ChangeOutcomeAmount(viewModel.Key, newAmount); viewModel.Amount = newAmount; } }