protected string UnionSettingsKeyboardsWithLocalStore()
{
if (string.IsNullOrWhiteSpace(Settings.Default.LocalKeyboards))
{
return m_localStore.LocalKeyboardSettings ?? "";
}
// Parse user.config keyboard list
var root = XElement.Parse(Settings.Default.LocalKeyboards);
var keyboardSettings = new Dictionary<string, XElement>();
foreach (var kbd in root.Elements("keyboard"))
{
keyboardSettings[kbd.Attribute("ws").Value] = kbd;
}
// Update user.config keyboards with any from the local store.
// Although user.config should take precedence, this is safe, because we already should have copied
// any relevant keyboards from user.config to the local store, so the only keyboards that are actually
// changed will be keyboards the user has intentionally changed.
// This step will also save default keyboards for any WS w/o one assigned.
foreach (var ws in m_localStore.AllWritingSystems)
{
var kbd = ((WritingSystemDefinition)ws).LocalKeyboard;
if (kbd == null)
continue;
keyboardSettings[ws.Id] = new XElement("keyboard",
new XAttribute("ws", ws.Id),
new XAttribute("layout", kbd.Layout),
new XAttribute("locale", kbd.Locale));
}
// Convert back to an XML String and return
root.RemoveAll();
foreach (var kbd in keyboardSettings.Values)
{
root.Add(kbd);
}
return root.ToString();
}