コード例 #1
0
        void BirthdayButton_Click(object sender, RoutedEventArgs e)
        {
            ++person.Age;
            TextBoxAge.Text = person.Age.ToString();
            TextBoxAge.Focus(FocusState.Pointer);

            this.TextBlock.Text = string.Format(
                "Happy Birthday, {0}, age {1}!",
                person.Name, person.Age);
        }
コード例 #2
0
        private void KeyboardShortcuts(object sender, KeyEventArgs e)
        {
            if (Keyboard.IsKeyDown(Key.A) && Keyboard.IsKeyDown(Key.LeftShift))
            {
                ButtonAdd_Click(sender, e);
            }

            if (Keyboard.IsKeyDown(Key.Delete) && ButtonDelete.IsEnabled)
            {
                ButtonDelete_Click(sender, e);
            }
            if (Keyboard.IsKeyDown(Key.Delete) && Keyboard.IsKeyDown(Key.LeftCtrl) && ButtonDeleteAll.IsEnabled)
            {
                ButtonDeleteAll_Click(sender, e);
            }
            //if (Keyboard.IsKeyDown(Key.LeftCtrl) && Keyboard.IsKeyDown(Key.E) && ButtonEdit.IsEnabled) { ButtonEdit_Click(sender, e); }
            //if (Keyboard.IsKeyDown(Key.LeftCtrl) && Keyboard.IsKeyDown(Key.Back))
            //{
            //    ButtonCancel_Click(sender, e);
            //}

            if (Keyboard.IsKeyDown(Key.Enter))
            {
                if (ButtonAdd.Content.Equals("Save"))
                {
                    if (TextBoxName.Text.Length > 0 && TextBoxAge.Text.Length == 0)
                    {
                        TextBoxAge.Focus();
                    }
                    else
                    {
                        saveAdditions();
                        ButtonEdit.IsEnabled   = false;
                        ButtonCancel.IsEnabled = false;
                        ButtonDelete.IsEnabled = false;
                        ListBoxRabbits.Focus();
                    }
                }
                if (ButtonDelete.IsEnabled && ButtonDelete.Content.Equals("Confirm Delete"))
                {
                    deleteConfirmation();
                    ButtonAdd.IsEnabled = true;
                }
                if (ButtonDeleteAll.IsEnabled && ButtonDeleteAll.Content.Equals("Confirm Delete"))
                {
                    DeleteAllConfirmation();
                }
            }
        }