using System; using System.Windows; using System.Windows.Input; using DebtMgr.Extensions; using DebtMgr.Model; namespace DebtMgr.View.Dialogs { /// /// Interaktionslogik für NewPersonDialogView.xaml /// public partial class NewPersonDialogView : Window { public NewPersonDialogView(PersonDialogMode mode, Guid personId = default(Guid)) { InitializeComponent(); this.CenterOnParent(); App.Locator.NewPersonDialogView.ClearView(); App.Locator.NewPersonDialogView.DialogMode = mode; App.Locator.NewPersonDialogView.EditPersonId = personId; App.Locator.NewPersonDialogView.SetModeSpecifics(); App.Locator.NewPersonDialogView.RequestClose += (s, e) => Close(); DataContext = App.Locator.NewPersonDialogView; FirstNameTextBox.Focus(); } #region TextBox_OnKeyUp() //////////////////////////////////////////////////////////////////////////////////////////////////// /// Event handler. Called by TextBox for on key up events. /// /// Andre Beging, 09.09.2017. /// /// Source of the event. /// Key event information. //////////////////////////////////////////////////////////////////////////////////////////////////// private void TextBox_OnKeyUp(object sender, KeyEventArgs e) { if (e.Key.Equals(Key.Enter) || e.Key.Equals(Key.Return)) App.Locator.NewPersonDialogView.CreatePersonButtonClickCommand.Execute(null); } #endregion #region Window_KeyUp() //////////////////////////////////////////////////////////////////////////////////////////////////// /// Event handler. Called by Window for key up events. /// /// Andre Beging, 09.09.2017. /// /// Source of the event. /// Key event information. //////////////////////////////////////////////////////////////////////////////////////////////////// private void Window_KeyUp(object sender, KeyEventArgs e) { if (e.Key.Equals(Key.Escape)) Close(); } #endregion } }