private void LoadKeyboardLayoutList(bool removeOld) { if (removeOld) { lvLayouts.Items.Clear(); ToolStripItem defItem = cmsLeft.Items[0]; cmsLeft.Items.Clear(); cmsLeft.Items.Add(defItem); ActiveKeyboardList.Clear(); ActiveKeyboardList.Add(DefaultLayout); } KeyboardLayoutList keyboardList = new KeyboardLayoutList(); FileStream fs = null; System.Xml.XmlReader reader = null; try { fs = new FileStream(layoutXMLFile, FileMode.Open, FileAccess.Read); reader = System.Xml.XmlReader.Create(fs); reader.MoveToContent(); if (reader.LocalName == "Layouts") { reader.ReadStartElement("Layouts"); keyboardList.ReadXml(reader); reader.ReadEndElement(); } } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { if (reader != null) reader.Close(); if (fs != null) fs.Close(); } //long lPtr = DllPtrHotkeys.ToInt64(); List<Hotkey> hotkeys = new List<Hotkey>(); hotkeys.Add(htkyOnOff.Hotkey); foreach (KeyboardLayout layout in keyboardList) { KeyMagicDotNet.InfoList infoList = KeyMagicDotNet.KeyMagicKeyboard.GetInfosFromKeyboardFile(GetSaveKeyboardPath(layout.file)); ListViewItem lvItem = new ListViewItem(layout.file); hotkeys.Add(new Hotkey(layout.hotkey)); lvItem.SubItems.Add(layout.display); lvItem.SubItems.Add(layout.hotkey); lvItem.SubItems.Add(KeyMagicDotNet.KeyMagicKeyboard.GetVersion(GetSaveKeyboardPath(layout.file)).ToString()); lvItem.SubItems.Add(infoList.GetDescription()); using (Bitmap bmIcon = infoList.GetIcon()) { if (bmIcon != null) { imageList.Images.Add(layout.file, bmIcon); lvItem.ImageKey = layout.file; } if (layout.enable) { ActiveKeyboardList.Add(layout); lvItem.Group = lvLayouts.Groups["Enabled"]; KToolStripMenuItem menuItem = new KToolStripMenuItem(layout.display); if (bmIcon != null) using (Icon icon = Icon.FromHandle(bmIcon.GetHicon())) { iconList[layout.file] = menuItem.Icon = icon; } else iconList[layout.file] = defaultKeyboardIcon; menuItem.ImageKey = lvItem.ImageKey; menuItem.ShortcutKeyDisplayString = layout.hotkey; String fontFamily = infoList.GetFontFamily(); menuItem.Click += new EventHandler(cmsLeftMenuItem_Click); cmsLeft.Items.Add(menuItem); } else { lvItem.Group = lvLayouts.Groups["Disabled"]; } } lvLayouts.Items.Add(lvItem); } keyEventHandler.Hotkeys = hotkeys.ToArray(); }