Gwendalin Posted May 13, 2019 Share Posted May 13, 2019 Is anyone good at XML and C#? Would anyone be able to help or create a program to read and compare xml documents? Link to comment Share on other sites More sharing options...
Phenomenal Posted May 13, 2019 Share Posted May 13, 2019 XML is pretty well supported in C#, just read the docs for XMLDocument and XMLReader from System.Xml and you should be pretty good to go. Link to comment Share on other sites More sharing options...
Gwendalin Posted May 17, 2019 Author Share Posted May 17, 2019 I figured out how to read the xml and pull the data i need. Now i'm not sure the best way to display it. Â What should i use to feed my data into to display it? This is what i'm looking to do. Should i load everything into a list... dataset...something else? Â parent name | version | file name clone name | version | file name parent name | version | file name etc.... Link to comment Share on other sites More sharing options...
Phenomenal Posted May 17, 2019 Share Posted May 17, 2019 That's a little unclear, is the data formatted so every parent has clone children and if so is it a fixed amount of variable? If it's just collections of three things then just use an array of tuples Tuple<Type1,Type2,Type3>[]. Sorry if this isn't helpful I don't fully understand your intentions with the data. Link to comment Share on other sites More sharing options...
Gwendalin Posted May 17, 2019 Author Share Posted May 17, 2019 What i'm trying to do is make a program that will let me know what i'm missing from my front end when I update Mame. The front end is not reliable when importing new roms so i have to do it manually, and since Mame changes things frequently it is a pain. Â there is not always a parent - clone relationship. sometimes it will be just a parent. Sometimes the parent can have multiple clones or just one clone. I want my program to basically look like this... but i'm going to have it only display what is different in my lists. As you can see there are different amounts of clones (they call them orphans), and not all have clones (above the first parent). Â This is what i have so far, and it is showing correct data, but i have to step through it each time. I'm just not sure how to get all the individual data listed at the same time. XElement root = XElement.Load(@"C:\source\repos\WindowsFormsApp1\WindowsFormsApp1\test.xml"); IEnumerable < XElement > games = root.Elements(); foreach (var game in games) { try { string pName = game.Element("Title").Value + " " + game.Element("Version").Value; string pRom = System.IO.Path.GetFileNameWithoutExtension(game.Element("ApplicationPath").Value); var clone = from nm in root.Elements("AdditionalApplication") where (string)nm.Element("GameID") == game.Element("ID").Value select nm; MessageBox.Show("Parent: " + pName + " Rom: " + pRom); try { foreach (var game2 in clone) { string cName = game2.Element("Name").Value; string cRom = System.IO.Path.GetFileNameWithoutExtension(game2.Element("ApplicationPath").Value); MessageBox.Show("Parent: " + pName + " Rom: " + pRom + "\n" + " " + "Clone: " + cName + " Rom: " + cRom); } } catch { } } Â Link to comment Share on other sites More sharing options...
Gwendalin Posted May 17, 2019 Author Share Posted May 17, 2019 Ok everything is working properly at least from my xml side. Now i'm just not sure how to list everything in one big list. Â XElement root = XElement.Load(@"C:\source\repos\WindowsFormsApp1\WindowsFormsApp1\test.xml"); IEnumerable < XElement > games = root.Elements(); foreach (var game in games) { try { string pName = game.Element("Title").Value + " " + game.Element("Version").Value; string pRom = System.IO.Path.GetFileNameWithoutExtension(game.Element("ApplicationPath").Value); var clones = from nm in root.Elements("AdditionalApplication") where (string)nm.Element("GameID") == game.Element("ID").Value select nm; if (clones.Any() == false) { MessageBox.Show("Parent: " + pName + " Rom: " + pRom); } try { foreach (var clone in clones) { string cName = clone.Element("Name").Value; string cRom = System.IO.Path.GetFileNameWithoutExtension(clone.Element("ApplicationPath").Value); cName = Regex.Replace(cName, @"Play ", ""); cName = Regex.Replace(cName, @" Version...", ""); MessageBox.Show("Parent: " + pName + " Rom: " + pRom + "\n" + "Clone: " + cName + " Rom: " + cRom); } } catch { } } catch { } Â Phenomenal 1 Link to comment Share on other sites More sharing options...
Gwendalin Posted May 17, 2019 Author Share Posted May 17, 2019 Ok here is another upate to hopefully show what i'm trying to do. Mame lists out all of its games files, and a bunch of stuff i dont care about in an XML file. My frontend Launchbox stores all of its info in an xml file as well but does not have the same information tags so i can't do a straight comparison. I want to be able to see what i have in my front end compared to that mame has. Â I am able to go through both xml files and pull the data i need from each, as an individual variable. Now i need to store them in an array or list or something so i can go through and compare the individual files, and then display what is different or missing. Â i need to get my individual data into this data grid after sorting, but i'm not sure the best way to store the individual data first. i just typed this data in for an example... right now the button is the only thing working, and it just reads the xml files, and shows a message box of the individual variable. Link to comment Share on other sites More sharing options...
Mighty Professional Posted May 17, 2019 Share Posted May 17, 2019 You just want to get all the stuff in a list?  Underneath: IEnumerable < XElement > games = root.Elements();  put List<string> NameList = new List<string>();  List<string> RomList = new List<string>();   Then instead of MessageBox.Show("Parent: " + pName + " Rom: " + pRom); Change that line to NameList.Add(pName);  RomList.Add(pRom);  Then at the end your list will have all the values.   Link to comment Share on other sites More sharing options...
varinyc Posted May 17, 2019 Share Posted May 17, 2019 4 minutes ago, Mighty Professional said: Then at the end your list will have all the values.  Can you screenie what it looks like when it works? Link to comment Share on other sites More sharing options...
Gwendalin Posted May 17, 2019 Author Share Posted May 17, 2019 will do! Link to comment Share on other sites More sharing options...
Gwendalin Posted May 17, 2019 Author Share Posted May 17, 2019 WOO HOOO Â I'm getting there... this is all populated on its own from reading my xml file. Now i just have to compare the data to the other xml file, and have it display only the info that is different or missing. I'm excited... i have not programed anything in a really long time! Thanks Phenom, and Marsh for your guidance! Â Phenomenal and Mighty Professional 2 Link to comment Share on other sites More sharing options...
Gwendalin Posted May 21, 2019 Author Share Posted May 21, 2019 I got farther... but now I'm starting to hit the wall. I got my data displaying from both xml files. If i have data showing in one column but not the other that means it is either missing or named wrong. I want to make it more clear by marking the wrong cell, but i cant figure out how to change a single cell's background. I have tried many different options.  Also I'm trying to break up the program into functions, but i have trouble with scope. For instance I got my filter to work. It checks one xml document and gets the genre of the game, and blocks it from populating. I'm trying to make a global xml variable so i only have to load it once, but i can't get it to be read in any other section of the code. i'm going to keep working at it... I'll be more detailed if i need help.  Anyways here is what the program looks like so far. Its ugly, but it is mostly working. The Mame columns are reading from my mame.xml, and the LB columns are reading from my lB.xml. if there is a rom in Mame but not in LB it will have a blank field. If the name is different in LB from Mame it will list both roms names, and i will need to update my LB frontend. If there is a field empty in the mame columns that means that it is an old entry and needs to be deleted from the front end.  Here is my code so far... its messy i know. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Xml.Linq; using System.Text.RegularExpressions; namespace Mame_Check { public partial class Form1 : Form { Dictionary<string, Machines> dictMame = new Dictionary<string, Machines>(); Dictionary<string, Machines> dictLB = new Dictionary<string, Machines>(); public Form1() { InitializeComponent(); btnSearch.Enabled = false; //if (btnSearch.Enabled == true) { LoadXml(); } } private void LoadXml() { XElement mameXML = XElement.Load(tbMamexml.Text); XElement launchboxXML = XElement.Load(tbLBXML.Text); IEnumerable<XElement> mame = mameXML.Elements(); IEnumerable<XElement> lb = launchboxXML.Elements(); //Read LaunchBox XML foreach (var lbSystem in lb) { try { Machines machine = new Machines(); machine.Name = lbSystem.Element("Title").Value + " " + lbSystem.Element("Version").Value; machine.Rom = System.IO.Path.GetFileNameWithoutExtension(lbSystem.Element("ApplicationPath").Value); machine.Genre = lbSystem.Element("Genre").Value; var clones = from nm in launchboxXML.Elements("AdditionalApplication") where (string)nm.Element("GameID") == lbSystem.Element("ID").Value select nm; if (machine.CloneOf == null && this.clbFIlter.CheckedItems.Contains(machine.Genre) == false) { dictLB.Add(machine.Rom, machine); } foreach (var clone in clones) { Machines cmachine = new Machines(); cmachine.Name = lbSystem.Element("Title").Value + " " + clone.Element("Name").Value; cmachine.Rom = System.IO.Path.GetFileNameWithoutExtension(clone.Element("ApplicationPath").Value); cmachine.Name = Regex.Replace(cmachine.Name, @"Play ", ""); cmachine.Name = Regex.Replace(cmachine.Name, @" Version...", ""); cmachine.CloneOf = machine.Name; cmachine.Genre = machine.Genre; if (this.clbFIlter.CheckedItems.Contains(cmachine.Genre) == false) { dictLB.Add(cmachine.Rom, cmachine); } } } catch { } } //Read Mame XML foreach (var mSystem in mame) { try { Machines machine = new Machines(); machine.Name = mSystem.Element("description").Value; machine.Rom = mSystem.Attribute("name").Value; //Clones if (null != mSystem.Attribute("cloneof") && this.clbFIlter.CheckedItems.Contains(machine.Genre) == false) { machine.CloneOf = mSystem.Attribute("cloneof").Value; } if (this.clbFIlter.CheckedItems.Contains(machine.Genre) == false) { dictMame.Add(machine.Rom, machine); } } catch { } } } private void LoadListBox() { XElement launchboxXML = XElement.Load(tbLBXML.Text); IEnumerable<XElement> lb = launchboxXML.Elements(); //Load listcheck box foreach (var lbSystem in lb) { try { string genre; genre = lbSystem.Element("Genre").Value; if (this.clbFIlter.Items.Contains(genre) != true) { this.clbFIlter.Items.Add(genre); } } catch { } } } private void BtnSearch_Click(object sender, EventArgs e) { LoadXml(); //Check Mame systems foreach (KeyValuePair<string, Machines> item in dictMame) { string key = item.Key; try { //If system is a parent if (item.Value.CloneOf == null) { //If parent is in Mame, but not in LaunchBox if (dictLB.ContainsKey(key) != true) { //this.dgMissingSystems.Rows[dgMissingSystems.Rows.Count].Cells[1].Style.BackColor = Color.Red; this.dgMissingSystems.Rows.Add(item.Value.Name, item.Value.Rom, "", "", "", "", "", ""); } else { //Parent is Named differently than in LaunchBox if (item.Value.Name != dictLB[key].Name) { this.dgMissingSystems.Rows.Add(item.Value.Name, item.Value.Rom, "", "", dictLB[key].Name, dictLB[key].Rom, "", ""); } } } else //If system is a clone { //If clone is in Mame, but not in LaunchBox if (dictLB.ContainsKey(item.Key) != true) { this.dgMissingSystems.Rows.Add(item.Value.CloneOf, "", item.Value.Name, item.Value.Rom, "", "", "", ""); } else { //If clone is Named differently than in LaunchBox if (item.Value.Name != dictLB[key].Name) { this.dgMissingSystems.Rows.Add(item.Value.CloneOf, "", item.Value.Name, item.Value.Rom, dictLB[key].CloneOf, "", dictLB[key].Name, dictLB[key].Rom); } } //dgMissingSystems[4, 2].Style.ForeColor = Color.ForestGreen; } } catch { } } //check LaunchBox systems foreach (KeyValuePair<string, Machines> item in dictLB) { try { //If system is a parent if (item.Value.CloneOf == null) { //If parent is in LaunchBox, but not Mame if (dictMame.ContainsKey(item.Key) != true) { this.dgMissingSystems.Rows.Add("", "", "", "", item.Value.Name, item.Value.Rom, "", ""); } } else //If system is a clone { //If clone is in LaunchBox, but not in Mame if (dictMame.ContainsKey(item.Key) != true) { this.dgMissingSystems.Rows.Add("", "", "", "", item.Value.CloneOf, "", item.Value.Name, item.Value.Rom); } } } catch { } } } private void BtnMameBrowse_Click(object sender, EventArgs e) { DialogResult result = openFileDialogMame.ShowDialog(); if (result == DialogResult.OK) { tbMamexml.Text = openFileDialogMame.FileName; if (tbMamexml.Text != "" && tbLBXML.Text != "") { btnSearch.Enabled = true; } } } private void BtnLBBrowse_Click(object sender, EventArgs e) { DialogResult result = openFileDialogLB.ShowDialog(); if (result == DialogResult.OK) { tbLBXML.Text = openFileDialogLB.FileName; LoadListBox(); if (tbMamexml.Text != "" && tbLBXML.Text != "") { btnSearch.Enabled = true; } } } } }  Link to comment Share on other sites More sharing options...
Mighty Professional Posted May 21, 2019 Share Posted May 21, 2019 "//this.dgMissingSystems.Rows[dgMissingSystems.Rows.Count].Cells[1].Style.BackColor = Color.Red;"  That didnt work? It should have. Though you probably dont want count for the first index. What happens if you just put this.dgMissingSystems.Rows[1].Cells[1].Style.BackColor = Color.Red;  Or how about  this.dgMissingSystems[1, 1].Style.BackColor = System.Drawing.Color.Red; Link to comment Share on other sites More sharing options...
Gwendalin Posted May 21, 2019 Author Share Posted May 21, 2019 i tried this, and it was randomly changing the text to green. i would mess with the [4,2] values, and nothing would change so i was getting discouraged. this.dgMissingSystems[4, 2].Style.ForeColor = Color.ForestGreen;  so far this worked, and i was able to change cell numbers and it worked. Now to get it to pull the cell numbers dynamically. I think i can get it. i do have to start with 0 to get the first cell. this.dgMissingSystems[1, 1].Style.BackColor = System.Drawing.Color.Red;   Ok... i think i was just getting tunnel vision, and because my forecolor worked once i kind of stopped paying attention during my testing. The reason it wasn't showing was because there was no text to change.  oh i also had this... so i was dancing around the answer... this.dgMissingSystems.Rows[dgMissingSystems.Rows.Count].Cells[1].Style.BackColor = Color.Red;   Ok i got it semi working now.... Now my problem is it is only keeping one cell highlighted. I know another cell should be red, but only one is.   not sure whats going on... the yellow box, and one above it should be red as well.   Nevermind... i'm a ditz, and had my numbers backwards! i think its working now!  Thanks Marsh! Mighty Professional 1 Link to comment Share on other sites More sharing options...
Mighty Professional Posted May 22, 2019 Share Posted May 22, 2019 Sometimes you just need to look at it with fresh eyes. So many problems I struggle with all night then solve it in 5 minutes the next morning. Link to comment Share on other sites More sharing options...
Gwendalin Posted May 22, 2019 Author Share Posted May 22, 2019 I finally got it working!!! Well at least 98% working I need to work on how it renames my clones. Right now i add the parent name to the clone followed by the version, but that is not correct for some clones that truly do have a different name, so now it shows as a misname. BUT the actual function of the program is working. I also got my filter working so it will not display any of the checked items. I'm so excited... i haven't programmed anything in a really long time, and even then i never completed my programs. This is my first actual working program!!!  Here is a screen shot of it. The red box means that I'm missing that rom... If it is a clone i display the parent so i know where to find the game to add it. If i dont have any info in the Mame fields that means that Mame removed the rom, or changed the name of the rom, and i need to remove it from my front end. All i have to do is fix my names, and maybe get creative and clean up some of the interface, have the cells be the correct size for what is displayed, or add some options like change the color of the highlighted cells.   Im really excited because I actually figured out how to read two different XML files and compare the data when they are so different. This is what a game and clone looks like in my front end xml. A clone is considered an additional application. Spoiler <Game> <ApplicationPath>N:\Mame\MAME Roms\sc4nmare.zip</ApplicationPath> <CommandLine /> <Completed>false</Completed> <ConfigurationCommandLine /> <ConfigurationPath /> <DateAdded>2018-12-22T21:03:53.0828147-08:00</DateAdded> <DateModified>2018-12-22T21:03:53.0828147-08:00</DateModified> <Developer /> <DosBoxConfigurationPath /> <Emulator>cb87f73e-c468-44e4-8bd0-b9f18180737c</Emulator> <Favorite>false</Favorite> <ID>224abfdb-e376-4b39-a34b-b77543d3e368</ID> <ManualPath /> <MusicPath /> <Notes /> <Platform>Arcade</Platform> <Publisher>BFM</Publisher> <Rating>Not Rated</Rating> <ReleaseDate>0200-01-01T00:00:00-08:00</ReleaseDate> <RootFolder /> <ScummVMAspectCorrection>false</ScummVMAspectCorrection> <ScummVMFullscreen>false</ScummVMFullscreen> <ScummVMGameDataFolderPath /> <ScummVMGameType /> <SortTitle /> <Source>bfm_sc4.cpp</Source> <StarRatingFloat>0</StarRatingFloat> <StarRating>0</StarRating> <CommunityStarRating>2.5</CommunityStarRating> <CommunityStarRatingTotalVotes>1</CommunityStarRatingTotalVotes> <Status>preliminary</Status> <DatabaseID>35354</DatabaseID> <WikipediaURL /> <Title>A Nightmare On Elm Street</Title> <UseDosBox>false</UseDosBox> <UseScummVM>false</UseScummVM> <Version>(Bellfruit) (Scorpion 4) (set 1)</Version> <Series>A Nightmare On Elm Street * Slot</Series> <PlayMode /> <Region>North America</Region> <PlayCount>0</PlayCount> <Portable>false</Portable> <VideoPath /> <Hide>false</Hide> <Broken>false</Broken> <Genre>Electromechanical / Reels</Genre> <MissingVideo>true</MissingVideo> <MissingBoxFrontImage>true</MissingBoxFrontImage> <MissingScreenshotImage>true</MissingScreenshotImage> <MissingClearLogoImage>true</MissingClearLogoImage> <MissingBackgroundImage>true</MissingBackgroundImage> <UseStartupScreen>false</UseStartupScreen> <HideAllNonExclusiveFullscreenWindows>false</HideAllNonExclusiveFullscreenWindows> <StartupLoadDelay>0</StartupLoadDelay> <HideMouseCursorInGame>false</HideMouseCursorInGame> <DisableShutdownScreen>false</DisableShutdownScreen> <AggressiveWindowHiding>false</AggressiveWindowHiding> <OverrideDefaultStartupScreenSettings>false</OverrideDefaultStartupScreenSettings> </Game> <AdditionalApplication> <Id>0106a68b-db09-49c3-bcc1-6fb4b7e83987</Id> <PlayCount>0</PlayCount> <GameID>002ab343-5151-4db0-a340-df220027cf0d</GameID> <ApplicationPath>N:\Mame\MAME Roms\prof180x.zip</ApplicationPath> <AutoRunAfter>false</AutoRunAfter> <AutoRunBefore>false</AutoRunBefore> <Name>Play prof180x Version...</Name> <UseDosBox>false</UseDosBox> <UseEmulator>true</UseEmulator> <WaitForExit>false</WaitForExit> <ReleaseDate>1986-01-01T00:00:00-08:00</ReleaseDate> <Developer /> <Publisher>Conitec Datensysteme</Publisher> <Region /> <Version /> <Status>preliminary</Status> <EmulatorId>cb87f73e-c468-44e4-8bd0-b9f18180737c</EmulatorId> <SideA>false</SideA> <SideB>false</SideB> <Priority>1</Priority> </AdditionalApplication>  This is what a game and clone looks like in mame. The clone looks like the parent, but it has an extra attirbute. Spoiler <machine name="10yard" sourcefile="m58.cpp"> <description>10-Yard Fight (World, set 1)</description> <year>1983</year> <manufacturer>Irem</manufacturer> <rom name="yf-a-3p-b" size="8192" crc="2e205ec2" sha1="fcfa08f45423b35f2c99d4e6b5474ab1b3a84fec" region="maincpu" offset="0"/> <rom name="yf-a-3n-b" size="8192" crc="82fcd980" sha1="7846705b29961cb95ee1571ee7e16baceea522d4" region="maincpu" offset="2000"/> <rom name="yf-a-3m-b" size="8192" crc="a8d5c311" sha1="28edb5cfd943a2262d7e37ef9a7245f7017cbc51" region="maincpu" offset="4000"/> <rom name="yf-s.3b" size="8192" crc="0392a60c" sha1="68030504eafc58db250099edd3c3323bdb9eff6b" region="irem_audio:iremsound" offset="8000"/> <rom name="yf-s.1b" size="8192" crc="6588f41a" sha1="209305efc68171886427216b9a0b37333f40daa8" region="irem_audio:iremsound" offset="a000"/> <rom name="yf-s.3a" size="8192" crc="bd054e44" sha1="f10c32c70d60680229fc0891d0e1308015fa69d6" region="irem_audio:iremsound" offset="c000"/> <rom name="yf-s.1a" size="8192" crc="2490d4c3" sha1="e4da7b01e8ad075b7e3c8beb6668faff72db9aa2" region="irem_audio:iremsound" offset="e000"/> <rom name="yf-a.3e" size="8192" crc="77e9e9cc" sha1="90b0226fc125713dbee2804aeceeb5aa2c8e275e" region="gfx1" offset="0"/> <rom name="yf-a.3d" size="8192" crc="854d5ff4" sha1="9ba09bfabf159facb57faecfe73a6258fa48d152" region="gfx1" offset="2000"/> <rom name="yf-a.3c" size="8192" crc="0cd8ffad" sha1="bd1262de3823c34f7394b718477fb5bc58a6e293" region="gfx1" offset="4000"/> <rom name="yf-b.5b" size="8192" crc="1299ae30" sha1="07d47f827d8bc78a41011ec02ab64036fb8a7a18" region="gfx2" offset="0"/> <rom name="yf-b.5c" size="8192" crc="8708b888" sha1="8c4f305a339f23ec8ed40dfd72fac0f62ee65378" region="gfx2" offset="2000"/> <rom name="yf-b.5f" size="8192" crc="d9bb8ab8" sha1="1325308b4c85355298fec4aa3e5fec1b4b13ad86" region="gfx2" offset="4000"/> <rom name="yf-b.5e" size="8192" crc="47077e8d" sha1="5f78b15fb360e9926ef11841d5d86f2bd9af04d1" region="gfx2" offset="6000"/> <rom name="yf-b.5j" size="8192" crc="713ef31f" sha1="b48df9ed4f26fded3c7eaac3a52b580b2dd60477" region="gfx2" offset="8000"/> <rom name="yf-b.5k" size="8192" crc="f49651cc" sha1="5b87d7360bcd5883ec265b2a01a3e02e10a85345" region="gfx2" offset="a000"/> <rom name="yard.1c" size="256" crc="08fa5103" sha1="98af48dafbbaa42f58232bf74ccbf5da41723e71" region="proms" offset="0"/> <rom name="yard.1d" size="256" crc="7c04994c" sha1="790bf1616335b9df4943cffcafa48d8e8aee009e" region="proms" offset="100"/> <rom name="yard.1f" size="32" crc="b8554da5" sha1="963ca815b5f791b8a7b0937a5d392d5203049eb3" region="proms" offset="200"/> <rom name="yard.2h" size="256" crc="e1cdfb06" sha1="a8cc3456cfc272e3faac80370b2298d8e1f8c2fe" region="proms" offset="220"/> <rom name="yard.2n" size="256" crc="cd85b646" sha1="5268db705006058eec308afe474f4df3c15465bb" region="proms" offset="320"/> <rom name="yard.2m" size="256" crc="45384397" sha1="e4c662ee81aef63efd8b4a45f85c4a78dc2d419e" region="proms" offset="420"/> <device_ref name="z80"/> <device_ref name="gfxdecode"/> <device_ref name="palette"/> <device_ref name="screen"/> <device_ref name="m52_large_audio"/> <device_ref name="m6803"/> <device_ref name="speaker"/> <device_ref name="ay8910"/> <device_ref name="ay8910"/> <device_ref name="msm5205"/> <device_ref name="msm5205"/> <chip type="cpu" tag="maincpu" name="Zilog Z80" clock="3072000"/> <chip type="cpu" tag="irem_audio:iremsound" name="Motorola M6803" clock="3579545"/> <chip type="audio" tag="irem_audio:mono" name="Speaker"/> <chip type="audio" tag="irem_audio:ay_45m" name="AY-3-8910A PSG" clock="894886"/> <chip type="audio" tag="irem_audio:ay_45l" name="AY-3-8910A PSG" clock="894886"/> <chip type="audio" tag="irem_audio:msm1" name="MSM5205" clock="384000"/> <chip type="audio" tag="irem_audio:msm2" name="MSM5205" clock="384000"/> <display tag="screen" type="raster" rotate="0" width="256" height="224" refresh="56.737589" pixclock="6144000" htotal="384" hbend="0" hbstart="256" vtotal="282" vbend="42" vbstart="266" /> <sound channels="1"/> <input players="2" coins="2"> <control type="joy" player="1" buttons="2" ways="8"/> <control type="joy" player="2" buttons="2" ways="8"/> </input> <dipswitch name="Unused" tag="DSW1" mask="1"> <diplocation name="SW1" number="1"/> <dipvalue name="Off" value="1" default="yes"/> <dipvalue name="On" value="0"/> </dipswitch> <dipswitch name="Unused" tag="DSW1" mask="2"> <diplocation name="SW1" number="2"/> <dipvalue name="Off" value="2" default="yes"/> <dipvalue name="On" value="0"/> </dipswitch> <dipswitch name="Time Reduced by Ball Dead" tag="DSW1" mask="12"> <diplocation name="SW1" number="3"/> <diplocation name="SW1" number="4"/> <dipvalue name="Normal" value="12" default="yes"/> <dipvalue name="x1.3" value="8"/> <dipvalue name="x1.5" value="4"/> <dipvalue name="x1.8" value="0"/> </dipswitch> <dipswitch name="Coin A" tag="DSW1" mask="48"> <condition tag="DSW2" mask="4" relation="eq" value="0"/> <diplocation name="SW1" number="5"/> <diplocation name="SW1" number="6"/> <dipvalue name="3 Coins/1 Credit" value="16"/> <dipvalue name="2 Coins/1 Credit" value="32"/> <dipvalue name="1 Coin/1 Credit" value="48" default="yes"/> <dipvalue name="Free Play" value="0"/> </dipswitch> <dipswitch name="Coin B" tag="DSW1" mask="192"> <condition tag="DSW2" mask="4" relation="eq" value="0"/> <diplocation name="SW1" number="7"/> <diplocation name="SW1" number="8"/> <dipvalue name="1 Coin/2 Credits" value="192" default="yes"/> <dipvalue name="1 Coin/3 Credits" value="128"/> <dipvalue name="1 Coin/5 Credits" value="64"/> <dipvalue name="1 Coin/6 Credits" value="0"/> </dipswitch> <dipswitch name="Coinage" tag="DSW1" mask="240"> <condition tag="DSW2" mask="4" relation="ne" value="0"/> <diplocation name="SW1" number="5"/> <diplocation name="SW1" number="6"/> <diplocation name="SW1" number="7"/> <diplocation name="SW1" number="8"/> <dipvalue name="7 Coins/1 Credit" value="144"/> <dipvalue name="6 Coins/1 Credit" value="160"/> <dipvalue name="5 Coins/1 Credit" value="176"/> <dipvalue name="4 Coins/1 Credit" value="192"/> <dipvalue name="3 Coins/1 Credit" value="208"/> <dipvalue name="2 Coins/1 Credit" value="224"/> <dipvalue name="1 Coin/1 Credit" value="240" default="yes"/> <dipvalue name="1 Coin/2 Credits" value="112"/> <dipvalue name="1 Coin/3 Credits" value="96"/> <dipvalue name="1 Coin/4 Credits" value="80"/> <dipvalue name="1 Coin/5 Credits" value="64"/> <dipvalue name="1 Coin/6 Credits" value="48"/> <dipvalue name="1 Coin/7 Credits" value="32"/> <dipvalue name="1 Coin/8 Credits" value="16"/> <dipvalue name="Free Play" value="0"/> </dipswitch> <dipswitch name="Flip Screen" tag="DSW2" mask="1"> <diplocation name="SW2" number="1"/> <dipvalue name="Off" value="1" default="yes"/> <dipvalue name="On" value="0"/> </dipswitch> <dipswitch name="Cabinet" tag="DSW2" mask="2"> <diplocation name="SW2" number="2"/> <dipvalue name="Upright" value="0" default="yes"/> <dipvalue name="Cocktail" value="2"/> </dipswitch> <dipswitch name="Coin Mode" tag="DSW2" mask="4"> <diplocation name="SW2" number="3"/> <dipvalue name="Mode 1" value="4" default="yes"/> <dipvalue name="Mode 2" value="0"/> </dipswitch> <dipswitch name="Slow Motion (Cheat)" tag="DSW2" mask="8"> <diplocation name="SW2" number="4"/> <dipvalue name="Off" value="8" default="yes"/> <dipvalue name="On" value="0"/> </dipswitch> <dipswitch name="Stop Mode (Cheat)" tag="DSW2" mask="16"> <diplocation name="SW2" number="5"/> <dipvalue name="Off" value="16" default="yes"/> <dipvalue name="On" value="0"/> </dipswitch> <dipswitch name="Level Select (Cheat)" tag="DSW2" mask="32"> <diplocation name="SW2" number="6"/> <dipvalue name="Off" value="32" default="yes"/> <dipvalue name="On" value="0"/> </dipswitch> <dipswitch name="Invulnerability (Cheat)" tag="DSW2" mask="64"> <diplocation name="SW2" number="7"/> <dipvalue name="Off" value="64" default="yes"/> <dipvalue name="On" value="0"/> </dipswitch> <dipswitch name="Service Mode" tag="DSW2" mask="128"> <diplocation name="SW2" number="8"/> <dipvalue name="Off" value="128" default="yes"/> <dipvalue name="On" value="0"/> </dipswitch> <port tag=":DSW1"> </port> <port tag=":DSW2"> </port> <port tag=":IN0"> </port> <port tag=":IN1"> </port> <port tag=":IN2"> </port> <driver status="good" emulation="good" savestate="supported"/> </machine> <machine name="10yard85" sourcefile="m58.cpp" cloneof="10yard" romof="10yard"> <description>10-Yard Fight '85 (US, Taito license)</description> <year>1985</year> <manufacturer>Irem (Taito license)</manufacturer> <rom name="yf-a-3p-h.3p" size="8192" crc="c83da5e3" sha1="7f2dd11483158e389f5c39ee8de64be406501451" region="maincpu" offset="0"/> <rom name="yf-a-3n-h.3n" size="8192" crc="8dc5f32f" sha1="f550ed326711d1103711b99777f302f0d48e8eaf" region="maincpu" offset="2000"/> <rom name="yf-a-3m-h.3m" size="8192" crc="7d5d0c20" sha1="38ada7a53881f7f812b02514d13fbf0fa013c0f1" region="maincpu" offset="4000"/> <rom name="yf-s-3b.3b" merge="yf-s.3b" size="8192" crc="0392a60c" sha1="68030504eafc58db250099edd3c3323bdb9eff6b" region="irem_audio:iremsound" offset="8000"/> <rom name="yf-s-1b.1b" merge="yf-s.1b" size="8192" crc="6588f41a" sha1="209305efc68171886427216b9a0b37333f40daa8" region="irem_audio:iremsound" offset="a000"/> <rom name="yf-s-3a.3a" merge="yf-s.3a" size="8192" crc="bd054e44" sha1="f10c32c70d60680229fc0891d0e1308015fa69d6" region="irem_audio:iremsound" offset="c000"/> <rom name="yf-s-1a.1a" merge="yf-s.1a" size="8192" crc="2490d4c3" sha1="e4da7b01e8ad075b7e3c8beb6668faff72db9aa2" region="irem_audio:iremsound" offset="e000"/> <rom name="yf-a-3e-h.3e" size="8192" crc="5fba9074" sha1="aa9881315850e86b49712a4afb551778ee57ae75" region="gfx1" offset="0"/> <rom name="yf-a-3c-h.3c" size="8192" crc="f48eedca" sha1="6aef3208de8b1dd4078de20c0b5ce96219c79d40" region="gfx1" offset="2000"/> <rom name="yf-a-3d-h.3d" size="8192" crc="7d1b4d93" sha1="9389de1230b93f529c492af6fb911c00280cae8a" region="gfx1" offset="4000"/> <rom name="yf-b-5b.5b" merge="yf-b.5b" size="8192" crc="1299ae30" sha1="07d47f827d8bc78a41011ec02ab64036fb8a7a18" region="gfx2" offset="0"/> <rom name="yf-b-5c.5c" merge="yf-b.5c" size="8192" crc="8708b888" sha1="8c4f305a339f23ec8ed40dfd72fac0f62ee65378" region="gfx2" offset="2000"/> <rom name="yf-b-5f.5f" merge="yf-b.5f" size="8192" crc="d9bb8ab8" sha1="1325308b4c85355298fec4aa3e5fec1b4b13ad86" region="gfx2" offset="4000"/> <rom name="yf-b-5e.5e" merge="yf-b.5e" size="8192" crc="47077e8d" sha1="5f78b15fb360e9926ef11841d5d86f2bd9af04d1" region="gfx2" offset="6000"/> <rom name="yf-b-5j.5j" merge="yf-b.5j" size="8192" crc="713ef31f" sha1="b48df9ed4f26fded3c7eaac3a52b580b2dd60477" region="gfx2" offset="8000"/> <rom name="yf-b-5k.5k" merge="yf-b.5k" size="8192" crc="f49651cc" sha1="5b87d7360bcd5883ec265b2a01a3e02e10a85345" region="gfx2" offset="a000"/> <rom name="yf-a-5c.5c" merge="yard.1c" size="256" crc="08fa5103" sha1="98af48dafbbaa42f58232bf74ccbf5da41723e71" region="proms" offset="0"/> <rom name="yf-a-5d.5d" merge="yard.1d" size="256" crc="7c04994c" sha1="790bf1616335b9df4943cffcafa48d8e8aee009e" region="proms" offset="100"/> <rom name="yf-b-2b.2b" size="32" crc="fcd283ea" sha1="6ebc3e966bb920685250f38edab5fe1f8a27c316" region="proms" offset="200"/> <rom name="yf-b-3l.3l" merge="yard.2h" size="256" crc="e1cdfb06" sha1="a8cc3456cfc272e3faac80370b2298d8e1f8c2fe" region="proms" offset="220"/> <rom name="yf-b-2r.2r" merge="yard.2n" size="256" crc="cd85b646" sha1="5268db705006058eec308afe474f4df3c15465bb" region="proms" offset="320"/> <rom name="yf-b-2p.2p" merge="yard.2m" size="256" crc="45384397" sha1="e4c662ee81aef63efd8b4a45f85c4a78dc2d419e" region="proms" offset="420"/> <device_ref name="z80"/> <device_ref name="gfxdecode"/> <device_ref name="palette"/> <device_ref name="screen"/> <device_ref name="m52_large_audio"/> <device_ref name="m6803"/> <device_ref name="speaker"/> <device_ref name="ay8910"/> <device_ref name="ay8910"/> <device_ref name="msm5205"/> <device_ref name="msm5205"/> <chip type="cpu" tag="maincpu" name="Zilog Z80" clock="3072000"/> <chip type="cpu" tag="irem_audio:iremsound" name="Motorola M6803" clock="3579545"/> <chip type="audio" tag="irem_audio:mono" name="Speaker"/> <chip type="audio" tag="irem_audio:ay_45m" name="AY-3-8910A PSG" clock="894886"/> <chip type="audio" tag="irem_audio:ay_45l" name="AY-3-8910A PSG" clock="894886"/> <chip type="audio" tag="irem_audio:msm1" name="MSM5205" clock="384000"/> <chip type="audio" tag="irem_audio:msm2" name="MSM5205" clock="384000"/> <display tag="screen" type="raster" rotate="0" width="256" height="224" refresh="56.737589" pixclock="6144000" htotal="384" hbend="0" hbstart="256" vtotal="282" vbend="42" vbstart="266" /> <sound channels="1"/> <input players="2" coins="2"> <control type="joy" player="1" buttons="2" ways="8"/> <control type="joy" player="2" buttons="2" ways="8"/> </input> <dipswitch name="Unused" tag="DSW1" mask="1"> <diplocation name="SW1" number="1"/> <dipvalue name="Off" value="1" default="yes"/> <dipvalue name="On" value="0"/> </dipswitch> <dipswitch name="Unused" tag="DSW1" mask="2"> <diplocation name="SW1" number="2"/> <dipvalue name="Off" value="2" default="yes"/> <dipvalue name="On" value="0"/> </dipswitch> <dipswitch name="Time Reduced by Ball Dead" tag="DSW1" mask="12"> <diplocation name="SW1" number="3"/> <diplocation name="SW1" number="4"/> <dipvalue name="Normal" value="12" default="yes"/> <dipvalue name="x1.3" value="8"/> <dipvalue name="x1.5" value="4"/> <dipvalue name="x1.8" value="0"/> </dipswitch> <dipswitch name="Coin A" tag="DSW1" mask="48"> <condition tag="DSW2" mask="4" relation="eq" value="0"/> <diplocation name="SW1" number="5"/> <diplocation name="SW1" number="6"/> <dipvalue name="3 Coins/1 Credit" value="16"/> <dipvalue name="2 Coins/1 Credit" value="32"/> <dipvalue name="1 Coin/1 Credit" value="48" default="yes"/> <dipvalue name="Free Play" value="0"/> </dipswitch> <dipswitch name="Coin B" tag="DSW1" mask="192"> <condition tag="DSW2" mask="4" relation="eq" value="0"/> <diplocation name="SW1" number="7"/> <diplocation name="SW1" number="8"/> <dipvalue name="1 Coin/2 Credits" value="192" default="yes"/> <dipvalue name="1 Coin/3 Credits" value="128"/> <dipvalue name="1 Coin/5 Credits" value="64"/> <dipvalue name="1 Coin/6 Credits" value="0"/> </dipswitch> <dipswitch name="Coinage" tag="DSW1" mask="240"> <condition tag="DSW2" mask="4" relation="ne" value="0"/> <diplocation name="SW1" number="5"/> <diplocation name="SW1" number="6"/> <diplocation name="SW1" number="7"/> <diplocation name="SW1" number="8"/> <dipvalue name="7 Coins/1 Credit" value="144"/> <dipvalue name="6 Coins/1 Credit" value="160"/> <dipvalue name="5 Coins/1 Credit" value="176"/> <dipvalue name="4 Coins/1 Credit" value="192"/> <dipvalue name="3 Coins/1 Credit" value="208"/> <dipvalue name="2 Coins/1 Credit" value="224"/> <dipvalue name="1 Coin/1 Credit" value="240" default="yes"/> <dipvalue name="1 Coin/2 Credits" value="112"/> <dipvalue name="1 Coin/3 Credits" value="96"/> <dipvalue name="1 Coin/4 Credits" value="80"/> <dipvalue name="1 Coin/5 Credits" value="64"/> <dipvalue name="1 Coin/6 Credits" value="48"/> <dipvalue name="1 Coin/7 Credits" value="32"/> <dipvalue name="1 Coin/8 Credits" value="16"/> <dipvalue name="Free Play" value="0"/> </dipswitch> <dipswitch name="Flip Screen" tag="DSW2" mask="1"> <diplocation name="SW2" number="1"/> <dipvalue name="Off" value="1" default="yes"/> <dipvalue name="On" value="0"/> </dipswitch> <dipswitch name="Cabinet" tag="DSW2" mask="2"> <diplocation name="SW2" number="2"/> <dipvalue name="Upright" value="0" default="yes"/> <dipvalue name="Cocktail" value="2"/> </dipswitch> <dipswitch name="Coin Mode" tag="DSW2" mask="4"> <diplocation name="SW2" number="3"/> <dipvalue name="Mode 1" value="4" default="yes"/> <dipvalue name="Mode 2" value="0"/> </dipswitch> <dipswitch name="Slow Motion (Cheat)" tag="DSW2" mask="8"> <diplocation name="SW2" number="4"/> <dipvalue name="Off" value="8" default="yes"/> <dipvalue name="On" value="0"/> </dipswitch> <dipswitch name="Stop Mode (Cheat)" tag="DSW2" mask="16"> <diplocation name="SW2" number="5"/> <dipvalue name="Off" value="16" default="yes"/> <dipvalue name="On" value="0"/> </dipswitch> <dipswitch name="Level Select (Cheat)" tag="DSW2" mask="32"> <diplocation name="SW2" number="6"/> <dipvalue name="Off" value="32" default="yes"/> <dipvalue name="On" value="0"/> </dipswitch> <dipswitch name="Invulnerability (Cheat)" tag="DSW2" mask="64"> <diplocation name="SW2" number="7"/> <dipvalue name="Off" value="64" default="yes"/> <dipvalue name="On" value="0"/> </dipswitch> <dipswitch name="Service Mode" tag="DSW2" mask="128"> <diplocation name="SW2" number="8"/> <dipvalue name="Off" value="128" default="yes"/> <dipvalue name="On" value="0"/> </dipswitch> <port tag=":DSW1"> </port> <port tag=":DSW2"> </port> <port tag=":IN0"> </port> <port tag=":IN1"> </port> <port tag=":IN2"> </port> <driver status="good" emulation="good" savestate="supported"/> </machine>   if anyone is interested here is my code. YES it is very ugly, and not optimized, but maybe i can get cleaned up later. Spoiler using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Xml.Linq; using System.Text.RegularExpressions; namespace Mame_Check { public partial class Form1 : Form { Dictionary<string, Machines> dictMame = new Dictionary<string, Machines>(); Dictionary<string, Machines> dictLB = new Dictionary<string, Machines>(); public Form1() { InitializeComponent(); btnSearch.Enabled = false; } private void LoadXml() { XElement mameXML = XElement.Load(tbMamexml.Text); XElement launchboxXML = XElement.Load(tbLBXML.Text); IEnumerable<XElement> mame = mameXML.Elements(); IEnumerable<XElement> lb = launchboxXML.Elements(); dictLB.Clear(); dictMame.Clear(); //Read LaunchBox XML foreach (var lbSystem in lb) { try { Machines lbMachine = new Machines(); lbMachine.Name = lbSystem.Element("Title").Value + " " + lbSystem.Element("Version").Value; lbMachine.Name = lbMachine.Name.Trim(); lbMachine.Rom = System.IO.Path.GetFileNameWithoutExtension(lbSystem.Element("ApplicationPath").Value); lbMachine.Genre = lbSystem.Element("Genre").Value; var clones = from nm in launchboxXML.Elements("AdditionalApplication") where (string)nm.Element("GameID") == lbSystem.Element("ID").Value select nm; if (lbMachine.CloneOf == null) { dictLB.Add(lbMachine.Rom, lbMachine); } foreach (var clone in clones) { Machines lbCMachine = new Machines(); lbCMachine.Name = lbSystem.Element("Title").Value + " " + clone.Element("Name").Value; lbCMachine.Rom = System.IO.Path.GetFileNameWithoutExtension(clone.Element("ApplicationPath").Value); lbCMachine.Name = Regex.Replace(lbCMachine.Name, @"Play ", ""); lbCMachine.Name = Regex.Replace(lbCMachine.Name, @" Version...", ""); lbCMachine.CloneOf = lbMachine.Name; lbCMachine.Genre = lbMachine.Genre; dictLB.Add(lbCMachine.Rom, lbCMachine); } } catch { } } //Read Mame XML foreach (var mSystem in mame) { try { Machines machine = new Machines(); machine.Name = mSystem.Element("description").Value; machine.Rom = mSystem.Attribute("name").Value; //Clones if (null != mSystem.Attribute("cloneof")) { machine.CloneOf = mSystem.Attribute("cloneof").Value; } if (dictLB.ContainsKey(machine.Rom)) { machine.Genre = dictLB[machine.Rom].Genre; dictMame.Add(machine.Rom, machine); if (this.clbFIlter.CheckedItems.Contains(machine.Genre) == true) { dictMame.Remove(machine.Rom); dictLB.Remove(machine.Rom); } } else { dictMame.Add(machine.Rom, machine); } } catch { } } } private void LoadListBox() { XElement launchboxXML = XElement.Load(tbLBXML.Text); IEnumerable<XElement> lb = launchboxXML.Elements(); //Load listcheck box foreach (var lbSystem in lb) { try { string genre; genre = lbSystem.Element("Genre").Value; if (this.clbFIlter.Items.Contains(genre) != true) { this.clbFIlter.Items.Add(genre); } this.clbFIlter.Sorted = true; } catch { } } } private void BtnSearch_Click(object sender, EventArgs e) { LoadXml(); CleanList(); this.dgMissingSystems.Rows.Clear(); this.dgMissingSystems.Refresh(); //Check Mame systems foreach (KeyValuePair<string, Machines> item in dictMame) { string key = item.Key; try { //If system is a parent if (item.Value.CloneOf == null) { //If parent is in Mame, but not in LaunchBox if (dictLB.ContainsKey(key) != true) { this.dgMissingSystems.Rows.Add(item.Value.Name, item.Value.Rom, "", "", "", "", "", ""); this.dgMissingSystems[4, dgMissingSystems.Rows.Count - 1].Style.BackColor = System.Drawing.Color.Red; } else { //Parent is Named differently than in LaunchBox if (item.Value.Name != dictLB[key].Name) { this.dgMissingSystems.Rows.Add(item.Value.Name, item.Value.Rom, "", "", dictLB[key].Name, dictLB[key].Rom, "", ""); this.dgMissingSystems[4, dgMissingSystems.Rows.Count - 1].Style.BackColor = System.Drawing.Color.Yellow; } } } else //If system is a clone { //If clone is in Mame, but not in LaunchBox if (dictLB.ContainsKey(item.Key) != true) { this.dgMissingSystems.Rows.Add(item.Value.CloneOf, "", item.Value.Name, item.Value.Rom, "", "", "", ""); this.dgMissingSystems[6, dgMissingSystems.Rows.Count -1].Style.BackColor = System.Drawing.Color.Red; } else { //If clone is Named differently than in LaunchBox if (item.Value.Name != dictLB[key].Name) { this.dgMissingSystems.Rows.Add(item.Value.CloneOf, "", item.Value.Name, item.Value.Rom, dictLB[key].CloneOf, "", dictLB[key].Name, dictLB[key].Rom); this.dgMissingSystems[6, dgMissingSystems.Rows.Count - 1].Style.BackColor = System.Drawing.Color.Yellow; } } } } catch { } } //check LaunchBox systems foreach (KeyValuePair<string, Machines> item in dictLB) { try { //If system is a parent if (item.Value.CloneOf == null) { //If parent is in LaunchBox, but not Mame if (dictMame.ContainsKey(item.Key) != true) { this.dgMissingSystems.Rows.Add("", "", "", "", item.Value.Name, item.Value.Rom, "", ""); this.dgMissingSystems[4, dgMissingSystems.Rows.Count - 1].Style.BackColor = System.Drawing.Color.Red; } } else //If system is a clone { //If clone is in LaunchBox, but not in Mame if (dictMame.ContainsKey(item.Key) != true) { this.dgMissingSystems.Rows.Add("", "", "", "", item.Value.CloneOf, "", item.Value.Name, item.Value.Rom); this.dgMissingSystems[6, dgMissingSystems.Rows.Count - 1].Style.BackColor = System.Drawing.Color.Salmon; } } } catch { } } } private void BtnMameBrowse_Click(object sender, EventArgs e) { DialogResult result = openFileDialogMame.ShowDialog(); if (result == DialogResult.OK) { tbMamexml.Text = openFileDialogMame.FileName; if (tbMamexml.Text != "" && tbLBXML.Text != "") { btnSearch.Enabled = true; } } } private void BtnLBBrowse_Click(object sender, EventArgs e) { DialogResult result = openFileDialogLB.ShowDialog(); if (result == DialogResult.OK) { tbLBXML.Text = openFileDialogLB.FileName; LoadListBox(); if (tbMamexml.Text != "" && tbLBXML.Text != "") { btnSearch.Enabled = true; } } } private void CleanList() { List<string> keys = new List<string>(dictLB.Keys); foreach (string key in keys) { if (this.clbFIlter.CheckedItems.Contains(dictLB[key].Genre) == true) { dictLB.Remove(key); } } } } }  Mighty Professional and varinyc 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now