update disp_engine_t and panel key code to web-based string instead of int64.
This commit is contained in:
parent
5ef643617c
commit
6afe61bcb9
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
@ -255,36 +255,72 @@ namespace Hi.WinForm.Disp
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert WinForms Keys to W3C KeyboardEvent.key string.
|
||||
/// </summary>
|
||||
static string WinFormsKeyToW3C(Keys key) => (key & Keys.KeyCode) switch
|
||||
{
|
||||
Keys.Home => "Home",
|
||||
Keys.End => "End",
|
||||
Keys.PageUp => "PageUp",
|
||||
Keys.PageDown => "PageDown",
|
||||
Keys.Left => "ArrowLeft",
|
||||
Keys.Right => "ArrowRight",
|
||||
Keys.Up => "ArrowUp",
|
||||
Keys.Down => "ArrowDown",
|
||||
Keys.LShiftKey or Keys.RShiftKey or Keys.ShiftKey => "Shift",
|
||||
Keys.LControlKey or Keys.RControlKey or Keys.ControlKey => "Control",
|
||||
Keys.LMenu or Keys.RMenu or Keys.Menu => "Alt",
|
||||
Keys.Return => "Enter",
|
||||
Keys.Escape => "Escape",
|
||||
Keys.Back => "Backspace",
|
||||
Keys.Tab => "Tab",
|
||||
Keys.Delete => "Delete",
|
||||
Keys.Insert => "Insert",
|
||||
Keys.Space => " ",
|
||||
Keys.F1 => "F1",
|
||||
Keys.F2 => "F2",
|
||||
Keys.F3 => "F3",
|
||||
Keys.F4 => "F4",
|
||||
Keys.F5 => "F5",
|
||||
Keys.F6 => "F6",
|
||||
Keys.F7 => "F7",
|
||||
Keys.F8 => "F8",
|
||||
Keys.F9 => "F9",
|
||||
Keys.F10 => "F10",
|
||||
Keys.F11 => "F11",
|
||||
Keys.F12 => "F12",
|
||||
>= Keys.A and <= Keys.Z => ((char)('a' + ((key & Keys.KeyCode) - Keys.A))).ToString(),
|
||||
>= Keys.D0 and <= Keys.D9 => ((char)('0' + ((key & Keys.KeyCode) - Keys.D0))).ToString(),
|
||||
_ => "Unidentified"
|
||||
};
|
||||
|
||||
private void RenderingCanvas_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
Focus();
|
||||
DispEngine.KeyDown((long)e.KeyData);
|
||||
|
||||
// Map specific keys for view transformation
|
||||
long key = (long)e.KeyData;
|
||||
if (key == (long)Keys.LShiftKey || key == (long)Keys.RShiftKey || key == (long)Keys.ShiftKey)
|
||||
key = (long)Keys.Shift;
|
||||
string key = WinFormsKeyToW3C(e.KeyData);
|
||||
DispEngine.KeyDown(key);
|
||||
|
||||
DispEngine.KeyDownTransform(key, new key_table__transform_view_by_key_pressing_t()
|
||||
{
|
||||
HOME = (long)Keys.Home,
|
||||
PAGE_UP = (long)Keys.PageUp,
|
||||
PAGE_DOWN = (long)Keys.PageDown,
|
||||
F1 = (long)Keys.F1,
|
||||
F2 = (long)Keys.F2,
|
||||
F3 = (long)Keys.F3,
|
||||
F4 = (long)Keys.F4,
|
||||
SHIFT = (long)Keys.Shift,
|
||||
ARROW_LEFT = (long)Keys.Left,
|
||||
ARROW_RIGHT = (long)Keys.Right,
|
||||
ARROW_DOWN = (long)Keys.Down,
|
||||
ARROW_UP = (long)Keys.Up
|
||||
HOME = "Home",
|
||||
PAGE_UP = "PageUp",
|
||||
PAGE_DOWN = "PageDown",
|
||||
F1 = "F1",
|
||||
F2 = "F2",
|
||||
F3 = "F3",
|
||||
F4 = "F4",
|
||||
SHIFT = "Shift",
|
||||
ARROW_LEFT = "ArrowLeft",
|
||||
ARROW_RIGHT = "ArrowRight",
|
||||
ARROW_DOWN = "ArrowDown",
|
||||
ARROW_UP = "ArrowUp"
|
||||
});
|
||||
}
|
||||
|
||||
private void RenderingCanvas_KeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
DispEngine.KeyUp((long)e.KeyData);
|
||||
DispEngine.KeyUp(WinFormsKeyToW3C(e.KeyData));
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user