當前位置: 首頁>>代碼示例>>C#>>正文


C# Input.KeyEventArgs類代碼示例

本文整理匯總了C#中System.Windows.Input.KeyEventArgs的典型用法代碼示例。如果您正苦於以下問題:C# KeyEventArgs類的具體用法?C# KeyEventArgs怎麽用?C# KeyEventArgs使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


KeyEventArgs類屬於System.Windows.Input命名空間,在下文中一共展示了KeyEventArgs類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: TrayWindow_KeyDown

 void TrayWindow_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Escape)
     {
         this.Close();
     }
 }
開發者ID:troelsrichter,項目名稱:ShellLight,代碼行數:7,代碼來源:TrayWindow.xaml.cs

示例2: OnTextBoxKeyDown

        /// <summary>
        /// Occurs when the KeyDown event fires and the drop down is not open.
        /// </summary>
        /// <param name="e">The key event data.</param>
        protected void OnTextBoxKeyDown(KeyEventArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }
            else if (e.Handled)
            {
                return;
            }

            switch (e.Key)
            {
                case Key.Down:
                    if (!IsDropDownOpen)
                    {
                        ToggleDropDown(this, e);
                        e.Handled = true;
                    }
                    break;

                case Key.F4:
                    ToggleDropDown(this, e);
                    e.Handled = true;
                    break;

                case Key.Enter:
                    OnAdapterSelectionComplete(this, new RoutedEventArgs());
                    e.Handled = true;
                    break;

                default:
                    break;
            }
        }
開發者ID:Mrding,項目名稱:Ribbon,代碼行數:39,代碼來源:AutoCompleteBox.KeyBoard.cs

示例3: PasswordTxb_KeyDown

 private async void PasswordTxb_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Enter)
     {
         await LoadContacts();
     }
 }
開發者ID:BluePosition,項目名稱:ApiSamples,代碼行數:7,代碼來源:MainWindow.xaml.cs

示例4: textBoxMessage_KeyDown

 private void textBoxMessage_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Enter)
     {
         ButtonSend_Click(sender, e);
     }
 }
開發者ID:pzwwei,項目名稱:MyICQ,代碼行數:7,代碼來源:WindowDialog.xaml.cs

示例5: CommonTextBox_KeyUp

 private void CommonTextBox_KeyUp(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Enter)
     {
         base.Focus();
     }
 }
開發者ID:RukaiYu,項目名稱:TinyMoneyManager.WP8,代碼行數:7,代碼來源:DataSyncingSettingPage.xaml.cs

示例6: TextBox1_KeyDown

 public void TextBox1_KeyDown(object sender, KeyEventArgs e)
 {
     e.Handled = false;
     System.Windows.Controls.TextBox textBox = TextBox1;
     if (e.Key == Key.Enter)
     {
         if (!Keyboard.IsKeyDown(Key.LeftShift))
             textBox.MoveFocus(traversalRequest);
         else
         {
             int i = textBox.CaretIndex;
             textBox.Text = textBox.Text.Substring(0, i) + "\n" + textBox.Text.Substring(i, textBox.Text.Length - i);
             textBox.CaretIndex = i + 1;
         }
     }
     else if (e.Key == Key.Subtract)
     {
         System.Windows.Controls.TextBox box = (System.Windows.Controls.TextBox)sender;
         int caret = box.CaretIndex;
         box.Text = box.Text.Insert(box.CaretIndex, "-");
         box.CaretIndex = caret + 1;
         e.Handled = true;
     }
     textBox.AppendText(String.Empty);
 }
開發者ID:juancampa,項目名稱:Gearset,代碼行數:25,代碼來源:StringItem.xaml.cs

示例7: itemList_KeyDown

 private void itemList_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Enter && itemList.SelectedItems.Count == 1)
     {
         editButton_Click(sender, null);
     }
 }
開發者ID:Mavtak,項目名稱:Arcadia,代碼行數:7,代碼來源:RepositoryListWindow.xaml.cs

示例8: KeyDown

        public void KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.Key)
            {
                case Key.K:
                    foreach (var label in Dane.tablica)
                    {
                        label.BorderThickness =
                            (label.BorderThickness == new Thickness(1))
                                ? label.BorderThickness = new Thickness(0)
                                : label.BorderThickness = new Thickness(1);
                    }
                    break;
                case Key.Left:
                    if (Wunsz.kierunek != Kierunek.right)
                        Wunsz.kierunek = Kierunek.left;
                    break;
                case Key.Up:
                    if (Wunsz.kierunek != Kierunek.down)
                        Wunsz.kierunek = Kierunek.up;
                    break;
                case Key.Right:
                    if (Wunsz.kierunek != Kierunek.left)
                        Wunsz.kierunek = Kierunek.right;
                    break;
                case Key.Down:
                    if (Wunsz.kierunek != Kierunek.up)
                        Wunsz.kierunek = Kierunek.down;
                    break;
                

            }

        }
開發者ID:MaciekAiR,項目名稱:Snake,代碼行數:34,代碼來源:MainViewModel.cs

示例9: method_3

		private void method_3(object sender, KeyEventArgs e)
		{
			if (e.Key == Key.Return)
			{
				this.method_1();
			}
		}
開發者ID:akordowski,項目名稱:Source-Code-Nitriq,代碼行數:7,代碼來源:RenameCategory.cs

示例10: DoKeyDown

 /// <summary>
 /// Close the window when the Esc key is pressed.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void DoKeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Escape)
     {
         Hide();
     }
 }
開發者ID:pengyancai,項目名稱:cs-util,代碼行數:12,代碼來源:AboutBox.xaml.cs

示例11: studentsList_KeyDown

        // When the user presses a key, determine whether to add a new student to a class, remove a student from a class, or modify the details of a student
        private void studentsList_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.Key)
            {
                // If the user pressed Enter, edit the details for the currently selected student
                case Key.Enter: Student student = this.studentsList.SelectedItem as Student;

                    // Use the StudentsForm to display and edit the details of the student
                    StudentForm sf = new StudentForm();

                    // Set the title of the form and populate the fields on the form with the details of the student
                    sf.Title = "Edit Student Details";
                    sf.firstName.Text = student.FirstName;
                    sf.lastName.Text = student.LastName;
                    sf.dateOfBirth.Text = student.DateOfBirth.ToString("d"); // Format the date to omit the time element

                    // Display the form
                    if (sf.ShowDialog().Value)
                    {
                        // When the user closes the form, copy the details back to the student
                        student.FirstName = sf.firstName.Text;
                        student.LastName = sf.lastName.Text;
                        student.DateOfBirth = DateTime.Parse(sf.dateOfBirth.Text);

                        // Enable saving (changes are not made permanent until they are written back to the database)
                        saveChanges.IsEnabled = true;
                    }
                    break;

                // If the user pressed Insert, add a new student
                case Key.Insert:

                    // Use the StudentsForm to get the details of the student from the user
                    sf = new StudentForm();

                    // Set the title of the form to indicate which class the student will be added to (the class for the currently selected teacher)
                    sf.Title = "New Student for Class " + teacher.Class;

                    // Display the form and get the details of the new student
                    if (sf.ShowDialog().Value)
                    {
                        // When the user closes the form, retrieve the details of the student from the form
                        // and use them to create a new Student object
                        Student newStudent = new Student();
                        newStudent.FirstName = sf.firstName.Text;
                        newStudent.LastName = sf.lastName.Text;
                        newStudent.DateOfBirth = DateTime.Parse(sf.dateOfBirth.Text);

                        // Assign the new student to the current teacher
                        this.teacher.Students.Add(newStudent);

                        // Add the student to the list displayed on the form
                        this.studentsInfo.Add(newStudent);

                        // Enable saving (changes are not made permanent until they are written back to the database)
                        saveChanges.IsEnabled = true;
                    }
                    break;
            }
        }
開發者ID:Rahul21Lal,項目名稱:Main-Lab,代碼行數:61,代碼來源:MainWindow.xaml.cs

示例12: SearchTermTextBox_KeyDown

 private void SearchTermTextBox_KeyDown(object sender, KeyEventArgs e)
 {
     if(e.Key == Key.Enter && EnterCommand!=null)
     {
         EnterCommand(this, e);
     }
 }
開發者ID:alexiej,項目名稱:YATE,代碼行數:7,代碼來源:TextBoxWatermark.xaml.cs

示例13: DecimalIpAddressTextBox_KeyUp

        private void DecimalIpAddressTextBox_KeyUp(object sender, KeyEventArgs e)
        {
            string RawInput;
            RawInput = DecimalIpAddressTextBox.Text.Trim();

            // CIDR regex
            string pattern = @"((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)";
            Regex rgx = new Regex(pattern, RegexOptions.IgnoreCase);

            if (rgx.IsMatch(RawInput) == true)
            {
                try
                {
                    IpAddress Address = new IpAddress(RawInput);
                    BinaryIpAddressTextBox.Text = Address.ToBinaryString();
                }
                catch (Exception)
                {

                    BinaryIpAddressTextBox.Text = "Invalid Address";
                }
            }
            else
            {
                BinaryIpAddressTextBox.Text = "";
            }
        }
開發者ID:Wamadahama,項目名稱:Subnetting-Calculator,代碼行數:27,代碼來源:AddressToBinary.xaml.cs

示例14: TimeLimit_KeyUp

 private void TimeLimit_KeyUp(object sender, KeyEventArgs e)
 {
     if(e.Key == Key.Enter)
     {
         TimeLimit_LostFocus(null, null);
     }
 }
開發者ID:Hathor86,項目名稱:MMBizHawkTool,代碼行數:7,代碼來源:ClockPanel.xaml.cs

示例15: OnlyNumbersAndCommas

 public static void OnlyNumbersAndCommas(KeyEventArgs e, TextBox tb)
 {
     if (e.Key != Key.Decimal && e.Key != Key.OemComma && (e.Key < Key.D0 || e.Key > Key.D9) && (e.Key < Key.NumPad0 || e.Key > Key.NumPad9))
     {
         e.Handled = true;
     }
 }
開發者ID:pavlove,項目名稱:DailyClient,代碼行數:7,代碼來源:Validation.cs


注:本文中的System.Windows.Input.KeyEventArgs類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。