将密钥转换为 C# 中的密钥

tes*_*ino 2 .net c# winforms

我想在我的 ObjectModel 中使用新的键枚举以避免在此 Dll 中引用 Windows.Forms。GUI 使用需要Keys枚举的类库。

是否可以通过任何方式将Key值转换为Keys值?

编辑:我刚刚发现我的问题已经在这里提出并回答:How can I conversion 'System.Windows.Input.Key' to 'System.Windows.Forms.Keys'?

Sim*_*ier 5

您可以使用KeyInterop.VirtualKeyFromKey 方法转换为 Win32 键,然后直接转换为 winforms 键。