protected override void SetForm() { base.SetForm(); DataGridViewRow row = dataGridView.SelectedRows[0]; Platform platform = (Platform)row.Tag; if (platform == null) { dataGridView.ClearSelection(); return; } string iconPath = RomFunctions.GetPlatformPicture(((Platform)dataGridView.SelectedRows[0].Tag).Name); if (!string.IsNullOrEmpty(iconPath)) { pictureBoxIcon.Load(iconPath); } checkBoxUseRetroarch.Checked = platform.UseRetroarch; buttonSelectCore.Enabled = platform.UseRetroarch; comboBoxPlatformsDB.SelectedValue = platform.Id == "" ? "0" : platform.Id; textBoxPlatformName.Text = platform.Name; buttonColor.BackColor = platform.Color; checkBoxShowInFilters.Checked = platform.ShowInFilter; checkBoxShowInLinksList.Checked = platform.ShowInList; textBoxDefaultRomPath.Text = platform.DefaultRomPath; textBoxDefaultRomExtensions.Text = platform.DefaultRomExtensions; defaultEmulator = platform.DefaultEmulator; checkBoxArcade.Checked = platform.Arcade; checkBoxConsole.Checked = platform.Console; checkBoxHandheld.Checked = platform.Handheld; checkBoxCD.Checked = platform.CD; emulators = platform.Emulators; dataGridViewEmulators.Rows.Clear(); textBoxPlatformName.Enabled = false; FillGridEmulators(); }
public static void Fill() { platforms = new Dictionary <string, Platform>(); if (!Directory.Exists(Values.PlatformsPath)) { Directory.CreateDirectory(Values.PlatformsPath); } var platformnames = Directory.GetDirectories(Values.PlatformsPath); foreach (var platformname in platformnames) { var name = platformname.Replace(Values.PlatformsPath + "\\", ""); var platformNode = XML.GetPlatformNode(name); if (platformNode == null) { continue; } Platform platform = new Platform(); platform.Id = Functions.GetXmlAttribute(platformNode, "Id"); platform.Name = Functions.GetXmlAttribute(platformNode, "Name"); platform.ShowInList = Convert.ToBoolean(Functions.GetXmlAttribute(platformNode, "ShowInList")); platform.ShowInFilter = Convert.ToBoolean(Functions.GetXmlAttribute(platformNode, "ShowInFilter")); platform.DefaultRomPath = Functions.GetXmlAttribute(platformNode, "DefaultRomPath"); platform.DefaultRomExtensions = Functions.GetXmlAttribute(platformNode, "DefaultRomExtensions"); platform.DefaultEmulator = Functions.GetXmlAttribute(platformNode, "DefaultEmulator"); platform.Color = Color.FromArgb(Convert.ToInt32(Functions.GetXmlAttribute(platformNode, "Color"))); string icon = RomFunctions.GetPlatformPicture(platform.Name); platform.Icon = Functions.CreateBitmap(icon); string useRetroarch = Functions.GetXmlAttribute(platformNode, "UseRetroarch"); platform.UseRetroarch = string.IsNullOrEmpty(useRetroarch) ? false : Convert.ToBoolean(useRetroarch); string arcade = Functions.GetXmlAttribute(platformNode, "Arcade"); platform.Arcade = string.IsNullOrEmpty(arcade) ? false : Convert.ToBoolean(arcade); string console = Functions.GetXmlAttribute(platformNode, "Console"); platform.Console = string.IsNullOrEmpty(console) ? false : Convert.ToBoolean(console); string handheld = Functions.GetXmlAttribute(platformNode, "Handheld"); platform.Handheld = string.IsNullOrEmpty(handheld) ? false : Convert.ToBoolean(handheld); string cd = Functions.GetXmlAttribute(platformNode, "CD"); platform.CD = string.IsNullOrEmpty(cd) ? false : Convert.ToBoolean(cd); platforms.Add(platform.Name.ToLower(), platform); if (platformNode.ChildNodes[0] != null) { foreach (XmlNode emuNode in platformNode.ChildNodes[0].ChildNodes) { var emu = new Emulator() { Name = emuNode.InnerText, Path = emuNode.Attributes["Path"].Value, Command = emuNode.Attributes["Command"].Value }; platform.Emulators.Add(emu); } } } }