Commit c47660e9 by liulongfei

快捷键控件bug修复

parent a8013904
...@@ -22,82 +22,47 @@ namespace VIZ.Framework.Common ...@@ -22,82 +22,47 @@ namespace VIZ.Framework.Common
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
// Ctl Alt Shift // Ctl Alt Shift
if (e.KeyboardDevice.IsKeyDown(Key.LeftCtrl) || e.KeyboardDevice.IsKeyDown(Key.RightCtrl)) if (e.KeyboardDevice.Modifiers.HasFlag(ModifierKeys.Control))
{ {
sb.Append("Ctrl + "); sb.Append("Ctrl + ");
} }
if (e.KeyboardDevice.IsKeyDown(Key.LeftAlt) || e.KeyboardDevice.IsKeyDown(Key.RightAlt)) if (e.KeyboardDevice.Modifiers.HasFlag(ModifierKeys.Alt))
{ {
sb.Append("Alt + "); sb.Append("Alt + ");
} }
if (e.KeyboardDevice.IsKeyDown(Key.LeftShift) || e.KeyboardDevice.IsKeyDown(Key.RightShift)) if (e.KeyboardDevice.Modifiers.HasFlag(ModifierKeys.Shift))
{ {
sb.Append("Shift + "); sb.Append("Shift + ");
} }
// D0 - D9 A - Z // D0 - D9 A - Z
for (int i = (int)Key.D0; i <= (int)Key.Z; i++) if (e.SystemKey >= Key.D0 && e.SystemKey <= Key.Z)
{ {
Key key = (Key)i; sb.Append($"{e.SystemKey}");
if (e.KeyboardDevice.IsKeyDown(key))
{
sb.Append($"{key}");
break;
}
} }
if (e.Key >= Key.D0 && e.Key <= Key.Z)
// F1 - F12
for (int i = (int)Key.F1; i <= (int)Key.F12; i++)
{ {
Key key = (Key)i; sb.Append($"{e.Key}");
if (e.KeyboardDevice.IsKeyDown(key))
{
sb.Append($"{key}");
break;
}
} }
return sb.ToString(); // F1 - F12
} if (e.SystemKey >= Key.F1 && e.SystemKey <= Key.F12)
/// <summary>
/// 获取热键值
/// </summary>
/// <param name="e">键盘事件</param>
/// <returns>热键值</returns>
public static string GetHotkey(System.Windows.Forms.KeyEventArgs e)
{
StringBuilder sb = new StringBuilder();
if (e.Control)
{
sb.Append("Ctrl + ");
}
if (e.Alt)
{
sb.Append("Alt + ");
}
if (e.Shift)
{ {
sb.Append("Shift + "); sb.Append($"{e.SystemKey}");
} }
// D0 - D9 if (e.Key >= Key.F1 && e.Key <= Key.F12)
if (e.KeyCode >= System.Windows.Forms.Keys.D0 && e.KeyCode <= System.Windows.Forms.Keys.D9)
{ {
sb.Append($"{e.KeyCode}"); sb.Append($"{e.Key}");
return sb.ToString();
} }
// A - Z
if (e.KeyCode >= System.Windows.Forms.Keys.A && e.KeyCode <= System.Windows.Forms.Keys.Z) // Delete
if (e.SystemKey == Key.Delete)
{ {
sb.Append($"{e.KeyCode}"); sb.Append($"{e.SystemKey}");
return sb.ToString();
} }
// F1 - F12 if (e.Key == Key.Delete)
if (e.KeyCode >= System.Windows.Forms.Keys.F1 && e.KeyCode <= System.Windows.Forms.Keys.F12)
{ {
sb.Append($"{e.KeyCode}"); sb.Append($"{e.Key}");
return sb.ToString();
} }
return sb.ToString(); return sb.ToString();
......
...@@ -8,6 +8,6 @@ ...@@ -8,6 +8,6 @@
mc:Ignorable="d" WindowStartupLocation="CenterScreen" WindowState="Maximized" mc:Ignorable="d" WindowStartupLocation="CenterScreen" WindowState="Maximized"
Title="MainWindow" Height="800" Width="1200"> Title="MainWindow" Height="800" Width="1200">
<Grid> <Grid>
<local:TallyTest></local:TallyTest> <local:HotkeyBoxTest></local:HotkeyBoxTest>
</Grid> </Grid>
</Window> </Window>
...@@ -55,11 +55,11 @@ namespace VIZ.Framework.WpfTest ...@@ -55,11 +55,11 @@ namespace VIZ.Framework.WpfTest
this.video.AttachPlugin(centerAxisPlugin); this.video.AttachPlugin(centerAxisPlugin);
// 接入OpenCV插件 // 接入OpenCV插件
OpenCVStreamOption option = new OpenCVStreamOption(); //OpenCVStreamOption option = new OpenCVStreamOption();
OpenCVStream stream = new OpenCVStream(option); //OpenCVStream stream = new OpenCVStream(option);
stream.ExecuteVideoFrame += Stream_ExecuteVideoFrame; //stream.ExecuteVideoFrame += Stream_ExecuteVideoFrame;
stream.ChangeUri(@"E:\视频\1.mp4"); //stream.ChangeUri(@"E:\视频\1.mp4");
stream.Play(); //stream.Play();
// 更新矩形框信息 // 更新矩形框信息
//List<TrackingBoxInfo> list = new List<TrackingBoxInfo>(); //List<TrackingBoxInfo> list = new List<TrackingBoxInfo>();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment