Convert Keys and ModifierKey to Shortcut

已答复 Convert Keys and ModifierKey to Shortcut

  • 2012年3月13日 18:35
     
      包含代码

    I have a Windows.Forms.Keys variable and a Windows.input.ModifierKey variable, I want to convert it into a Windows.Forms.Shortcut variable.  

    simple example in VB, sorry about that but question still applies to c#:

            Dim m As ModifierKeys = Windows.Input.ModifierKeys.Control
            Dim k As Keys = Keys.A
     
            Dim s As Shortcut = m <some operation> k

    Anyone have an idea?

    Thanks

    Bill

    • 已移动 Leo Liu - MSFT 2012年3月14日 7:13 move (From:Visual C# Language)
    •  

全部回复

  • 2012年3月13日 20:18
     
     

    Hi blanza,

    You could try to parse arround enums but it's difficult, Look this link:

    http://msdn.microsoft.com/en-us/library/essfb559.aspx

    I suggest you to simple switch, make an simple method that takes those two keys as input params and the method returns your shortcut

    Hope it helps

    Regards Muli


    If some code doesn't work, don't worry help is on the way.. don't forget to mark your thread as solved when done...

  • 2012年3月14日 7:45
    版主
     
     已答复

    I don't think so it would be a good idea, would you let us know the higher level requirement, why you need this conversion?

    And I think the common way we used is combining pressed keys together as a Shortcut, then do the things.

    And according the document said, the Enum.Parse method also cannot do this, this method is for converting one to another, instead of combine two together and become another type.


    Mike Zhang[MSFT]
    MSDN Community Support | Feedback to us

  • 2012年3月16日 5:46
    版主
     
     

    I am writing to check the status of the issue on your side.

    What about this problem now?

    Would you mind letting us know the result of the suggestions?


    Mike Zhang[MSFT]
    MSDN Community Support | Feedback to us