BililiveRecorder/BililiveRecorder.WPF/Controls/AddRoomCard.xaml.cs

42 lines
972 B
C#
Raw Permalink Normal View History

2020-11-27 18:51:02 +08:00
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
2021-05-01 17:57:43 +08:00
#nullable enable
2020-11-27 18:51:02 +08:00
namespace BililiveRecorder.WPF.Controls
{
/// <summary>
/// Interaction logic for AddRoomCard.xaml
/// </summary>
public partial class AddRoomCard : UserControl
{
2021-05-01 17:57:43 +08:00
public event EventHandler<string>? AddRoomRequested;
2020-11-27 18:51:02 +08:00
public AddRoomCard()
{
2021-01-01 14:46:27 +08:00
this.InitializeComponent();
2020-11-27 18:51:02 +08:00
}
private void AddRoom()
{
2021-01-01 14:46:27 +08:00
AddRoomRequested?.Invoke(this, this.InputTextBox.Text);
this.InputTextBox.Text = string.Empty;
this.InputTextBox.Focus();
2020-11-27 18:51:02 +08:00
}
private void Button_Click(object sender, RoutedEventArgs e)
{
2021-01-01 14:46:27 +08:00
this.AddRoom();
2020-11-27 18:51:02 +08:00
}
private void InputTextBox_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
2021-01-01 14:46:27 +08:00
this.AddRoom();
2020-11-27 18:51:02 +08:00
}
}
}
}