Reputation: 5678
I want to use the new Key Enumeration in my ObjectModel to avoid having a reference to Windows.Forms in this Dll. The GUI uses a class library that wants the Keys enumeration.
Is it possible in any way to convert a Key value to a Keys value?
EDIT: I just found out that my question was already asked and answered here: How can I convert 'System.Windows.Input.Key' to 'System.Windows.Forms.Keys'?
Upvotes: 2
Views: 3264
Reputation: 139187
You can use KeyInterop.VirtualKeyFromKey Method to convert to a Win32 key, and then directly cast to winforms Keys.
Upvotes: 5
Reputation: 44605
I would say if you want to use a type declared in another assembly, in your case the enum, you should copy the whole definition in your own assembly, basically declaring it again.
what is worse then? having a cloned declaration or referencing windows.forms.dll ?
Upvotes: 0