/// <summary> /// Called when one of the command buttons is clicked. /// </summary> private void AccountTypeButton_Clicked(object sender, RoutedEventArgs e) { FrameworkElement button = sender as FrameworkElement; if (button != null) { AccountType accountType = (AccountType)button.Tag; AccountDetailsPage detailsPage = new AccountDetailsPage(); detailsPage.AccountChangeCoordinator = this.Workbook.CreateAccount(accountType); detailsPage.Return += new WizardPageReturnEventHandler(DetailsPage_Return); this.NavigationService.Navigate(detailsPage); } }
/// <summary> /// Shows this dialog for a given account. /// </summary> /// <param name="editableAccount">An <see cref="T:ChangeCoordinator[T]"/> around a given account to show.</param> private static AccountDetailsDialog Show(Workbook workbook, ChangeCoordinator<Account> editableAccount, WizardPageReturnEventHandler returnEventHandler) { AccountDetailsDialog result = null; Account account = null; if (editableAccount != null) { account = editableAccount.OriginalItem; if (account == null) { account = editableAccount.EditableItem; } } if (editableAccount != null && _openWindows.ContainsKey(account)) { result = _openWindows[account]; result.Activate(); } else { WizardPage page = null; if (editableAccount != null) { AccountDetailsPage detailsPage = new AccountDetailsPage(); detailsPage.AccountChangeCoordinator = editableAccount; page = detailsPage; } else { page = new AccountTypePage(workbook); } result = new AccountDetailsDialog(page); if (returnEventHandler != null) { result.Return += returnEventHandler; } result.Show(); if (account != null) { _openWindows[account] = result; result.Closed += new EventHandler( delegate(object sender, EventArgs e) { _openWindows.Remove(account); }); } } return result; }