本文整理汇总了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();
}
}
示例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;
}
}
示例3: PasswordTxb_KeyDown
private async void PasswordTxb_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
await LoadContacts();
}
}
示例4: textBoxMessage_KeyDown
private void textBoxMessage_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
ButtonSend_Click(sender, e);
}
}
示例5: CommonTextBox_KeyUp
private void CommonTextBox_KeyUp(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
base.Focus();
}
}
示例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);
}
示例7: itemList_KeyDown
private void itemList_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter && itemList.SelectedItems.Count == 1)
{
editButton_Click(sender, null);
}
}
示例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;
}
}
示例9: method_3
private void method_3(object sender, KeyEventArgs e)
{
if (e.Key == Key.Return)
{
this.method_1();
}
}
示例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();
}
}
示例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;
}
}
示例12: SearchTermTextBox_KeyDown
private void SearchTermTextBox_KeyDown(object sender, KeyEventArgs e)
{
if(e.Key == Key.Enter && EnterCommand!=null)
{
EnterCommand(this, e);
}
}
示例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 = "";
}
}
示例14: TimeLimit_KeyUp
private void TimeLimit_KeyUp(object sender, KeyEventArgs e)
{
if(e.Key == Key.Enter)
{
TimeLimit_LostFocus(null, null);
}
}
示例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;
}
}