mirror of
https://github.com/cyanfish/naps2.git
synced 2024-10-05 20:07:42 +03:00
Replace Ctrl special case for parsing keyboard shortcuts with a map including a few more cases
This commit is contained in:
parent
66c43ebb24
commit
e003606463
@ -10,6 +10,14 @@ namespace NAPS2.Util
|
||||
private readonly Dictionary<Keys, Action> dict = new Dictionary<Keys, Action>();
|
||||
private readonly Dictionary<Keys, ToolStripMenuItem> itemDict = new Dictionary<Keys, ToolStripMenuItem>();
|
||||
|
||||
private readonly Dictionary<string, Keys> customMap = new Dictionary<string, Keys>
|
||||
{
|
||||
{ "ctrl", Keys.Control },
|
||||
{ "del", Keys.Delete },
|
||||
{ "ins", Keys.Insert },
|
||||
{ "break", Keys.Pause },
|
||||
};
|
||||
|
||||
public Keys Parse(string value)
|
||||
{
|
||||
try
|
||||
@ -17,11 +25,11 @@ namespace NAPS2.Util
|
||||
if (!string.IsNullOrWhiteSpace(value))
|
||||
{
|
||||
var keys = Keys.None;
|
||||
foreach (var part in value.Split('+').Select(x => x.Trim()))
|
||||
foreach (var part in value.Split('+').Select(x => x.Trim().ToLowerInvariant()))
|
||||
{
|
||||
if (part.Equals("Ctrl", StringComparison.InvariantCultureIgnoreCase))
|
||||
if (customMap.ContainsKey(part))
|
||||
{
|
||||
keys |= Keys.Control;
|
||||
keys |= customMap[part];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user