Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 29 additions & 4 deletions llcom/View/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1430,17 +1430,42 @@ private void uartDataFlowDocument_PreviewTextInput(object sender, TextCompositio
if (Tools.Global.uart.IsOpen())
try
{
Tools.Global.uart.SendData(Encoding.ASCII.GetBytes(e.TextComposition.Text));
//用设置里的编码,而不是写死ASCII,否则中文等字符会被替换成?
Tools.Global.uart.SendData(Tools.Global.GetEncoding().GetBytes(e.TextComposition.Text));
}
catch { }
}

private void uartDataFlowDocument_PreviewKeyDown(object sender, KeyEventArgs e)
{
if (!(Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)) ||
!Tools.Global.setting.terminal)
if (!Tools.Global.setting.terminal || !Tools.Global.uart.IsOpen())
return;
if (e.Key >= Key.A && e.Key <= Key.Z && Tools.Global.uart.IsOpen())

//空格与退格不会走到PreviewTextInput(输入法会把空格当上屏键吃掉,
//退格根本不产生TextComposition),只能在这里单独发
switch (e.Key)
{
case Key.Space:
try
{
Tools.Global.uart.SendData(new byte[] { 0x20 });
}
catch { }
e.Handled = true;
return;
case Key.Back:
try
{
Tools.Global.uart.SendData(new byte[] { 0x08 });
}
catch { }
e.Handled = true;
return;
}

if (!(Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)))
return;
if (e.Key >= Key.A && e.Key <= Key.Z)
try
{
Tools.Global.uart.SendData(new byte[] { (byte)((int)e.Key - (int)Key.A + 1) });
Expand Down
Loading