c# - ShortcutKey from string -


i want provider user option set toolstripmenuitem.shortcutkeys via configuration file, i've figured out need somehow transform string keys.

i've already found how simple values using enum.parse, won't recognize formats like:

  • ctrl+i (with space @ end)
  • i
  • ctrl+alt+esc

q: there standardized way of parsing stings (ctrl+i) keys?

i'd avoid writing own function split text pieces , handle each case/special string separately.

the string see in properties window shortcutkeys property generated typeconverter. can use type converter in own code well. this:

    var txt = "ctrl+i";     var cvt = new keysconverter();     var key = (keys)cvt.convertfrom(txt);     system.diagnostics.debug.assert(key == (keys.control | keys.i)); 

do beware i or ctrl+alt+escape not valid short-cut keys. keysconverter not complain, you'll exception when assign shortcutkeys property. wrap both try/except catch invalid config data.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -