private void bindGameComboBox() { gameConfigs.Clear(); gameComboBox.DataSource = null; //add None as a default gameConfigs.Add(new GameConfiguration { Path = String.Empty, Title = "None" }); //add games from the Portable Games folder String[] filePaths = Directory.GetFiles(Global.PortableGamesFolderPath, "*.*") .Where(file => file.EndsWith(".exe") || file.EndsWith(".swf")) .ToArray(); foreach (String filePath in filePaths) { gameConfigs.Add(new GameConfiguration { Path = filePath, Title = Path.GetFileNameWithoutExtension(filePath) }); } //add games from the config file AMS.Profile.Xml profile = new AMS.Profile.Xml(Global.ConfigurationFilePath); using (profile.Buffer()) { String[] entries = profile.GetEntryNames("GamePaths"); foreach (String entry in entries) { String gamePath = (String)profile.GetValue("GamePaths", entry); //if game does not exist delete the entry from the config file if (!File.Exists(gamePath)) { profile.RemoveEntry("GamePaths", entry); continue; } gameConfigs.Add(new GameConfiguration { Path = gamePath, Title = Path.GetFileNameWithoutExtension(gamePath) }); } } //bind game combo box gameComboBox.ValueMember = "Path"; gameComboBox.DisplayMember = "Title"; gameComboBox.DataSource = gameConfigs; }
private void bindGameComboBox() { gameConfigs.Clear(); gameComboBox.DataSource = null; //add None as a default gameConfigs.Add(new GameConfiguration { Path = String.Empty, Title = "None" }); //add games from the Portable Games folder String[] filePaths = Directory.GetFiles(Global.PortableGamesFolderPath, "*.*") .Where(file => file.EndsWith(".exe") || file.EndsWith(".swf")) .ToArray(); foreach (String filePath in filePaths) gameConfigs.Add(new GameConfiguration { Path = filePath, Title = Path.GetFileNameWithoutExtension(filePath) }); //add games from the config file AMS.Profile.Xml profile = new AMS.Profile.Xml(Global.ConfigurationFilePath); using (profile.Buffer()) { String[] entries = profile.GetEntryNames("GamePaths"); foreach (String entry in entries) { String gamePath = (String)profile.GetValue("GamePaths", entry); //if game does not exist delete the entry from the config file if (!File.Exists(gamePath)) { profile.RemoveEntry("GamePaths", entry); continue; } gameConfigs.Add(new GameConfiguration { Path = gamePath, Title = Path.GetFileNameWithoutExtension(gamePath) }); } } //bind game combo box gameComboBox.ValueMember = "Path"; gameComboBox.DisplayMember = "Title"; gameComboBox.DataSource = gameConfigs; }