内置触摸键盘,参数设置系统设置添加打开触摸键盘功能
This commit is contained in:
commit
683c7b03f3
8 files changed
+309
-98
No files matched your search
+28
-15
@@ -11,6 +11,7 @@ using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using static DyeingComputer.KEY.TouchKeyboardNumeral;
|
||||
|
||||
namespace DyeingComputer.KEY
|
||||
{
|
||||
@@ -20,8 +21,10 @@ namespace DyeingComputer.KEY
|
||||
public partial class TouchKeyboard : Window
|
||||
{
|
||||
private bool isShiftActive = false;
|
||||
private bool isSymbolActive = false;
|
||||
public string KeyValue;
|
||||
public event EventHandler<KeyPressedEventArgs> KeyPressed;
|
||||
private KeyboardMode currentMode = KeyboardMode.Default;
|
||||
private TextBox targetTextBox;
|
||||
|
||||
public TouchKeyboard()
|
||||
{
|
||||
@@ -55,19 +58,7 @@ namespace DyeingComputer.KEY
|
||||
{
|
||||
isShiftActive = !isShiftActive;
|
||||
UpdateButtonAppearance();
|
||||
}
|
||||
|
||||
private void Symbol_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
isSymbolActive = !isSymbolActive;
|
||||
// 这里可以添加切换符号键盘的逻辑
|
||||
StatusTextBlock.Text = isSymbolActive ? "符号模式" : "字母模式";
|
||||
}
|
||||
|
||||
private void Space_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
PreviewTextBox.Text += " ";
|
||||
}
|
||||
}
|
||||
|
||||
private void Backspace_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
@@ -79,13 +70,16 @@ namespace DyeingComputer.KEY
|
||||
|
||||
private void Enter_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
KeyValue = PreviewTextBox.Text;
|
||||
// 触发回车事件
|
||||
KeyPressed?.Invoke(this, new KeyPressedEventArgs(KeyType.Enter, PreviewTextBox.Text));
|
||||
|
||||
this.Close();
|
||||
// PreviewTextBox.Text += Environment.NewLine;
|
||||
}
|
||||
|
||||
private void Hide_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
KeyPressed?.Invoke(this, new KeyPressedEventArgs(KeyType.Hide, ""));
|
||||
this.Close();
|
||||
}
|
||||
|
||||
@@ -101,5 +95,24 @@ namespace DyeingComputer.KEY
|
||||
ShiftButton.Background = new SolidColorBrush(Color.FromRgb(224, 224, 224));
|
||||
}
|
||||
}
|
||||
|
||||
public class KeyPressedEventArgs : EventArgs
|
||||
{
|
||||
public KeyType KeyType { get; }
|
||||
public string KeyValue { get; }
|
||||
|
||||
public KeyPressedEventArgs(KeyType keyType, string keyValue)
|
||||
{
|
||||
KeyType = keyType;
|
||||
KeyValue = keyValue;
|
||||
}
|
||||
}
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 初始化为默认模式
|
||||
// SetKeyboardMode(KeyboardMode.Default);
|
||||
PreviewTextBox.Text = null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,8 +19,6 @@ namespace DyeingComputer.KEY
|
||||
/// </summary>
|
||||
public partial class TouchKeyboardNumeral : Window
|
||||
{
|
||||
private bool isShiftActive = false;
|
||||
private bool isSymbolActive = false;
|
||||
private bool mode = false;
|
||||
public string KeyValue;
|
||||
public event EventHandler<KeyPressedEventArgs> KeyPressed;
|
||||
|
||||
Reference in new issue
Block a user