private void ReadCommands(XmlReader reader)
{
if (reader.HasAttributes)
{
while (reader.MoveToNextAttribute())
{
string attrName = reader.Name.ToLower();
switch (attrName)
{
case "Inherit":
this._commands_KeyBindingList.Inherit = this.getBool(reader.Value);
break;
case "AllowDuplicateBindings":
this._commands_KeyBindingList.AllowDuplicateBindings = this.getBool(reader.Value);
break;
}
}
reader.MoveToElement();
}
if (!reader.IsEmptyElement)
{
while (!(reader.NodeType == XmlNodeType.EndElement && reader.Name.Equals("commands", StringComparison.OrdinalIgnoreCase)))
{
reader.Read();
if (reader.NodeType == XmlNodeType.Element && reader.Name.Equals("binding", StringComparison.OrdinalIgnoreCase))
{
if (reader.HasAttributes)
{
var kb = new KeyBinding();
var cmd = new BindableCommand();
bool? replaceCurrent = null;
while (reader.MoveToNextAttribute())
{
string attrName = reader.Name.ToLower();
switch (attrName)
{
case "key":
kb.KeyCode = Utilities.GetKeys(reader.Value);
break;
case "modifier":
if (reader.Value != string.Empty)
{
foreach (string modifier in reader.Value.Split(' '))
kb.Modifiers |= (Keys)Enum.Parse(typeof(Keys), modifier.Trim(), true);
}
break;
case "command":
cmd = (BindableCommand)Enum.Parse(typeof(BindableCommand), reader.Value, true);
break;
case "replacecurrent":
replaceCurrent = this.getBool(reader.Value);
break;
}
}
this._commands_KeyBindingList.Add(new CommandBindingConfig(kb, replaceCurrent, cmd));
}
reader.MoveToElement();
}
}
}
reader.Read();
}