Exemplo n.º 1
0
        private bool TryOpenRom(string f)
        {
            using (FileStream fileStream = File.OpenRead(f))
            {
                MemoryStream memStream = new MemoryStream();
                memStream.SetLength(fileStream.Length);
                fileStream.Read(memStream.GetBuffer(), 0, (int)fileStream.Length);
                this.imageStream = memStream;
            }

            foreach (KeyValuePair <string, Definition> device in SharpTuner.AvailableDevices.DefDictionary)
            {
                this.imageStream.Seek(device.Value.internalIdAddress, SeekOrigin.Begin);

                byte[] b = new byte[device.Value.internalId.Length];
                this.imageStream.Read(b, 0, device.Value.internalId.Length);

                if (device.Value.internalId.ToString() == System.Text.Encoding.UTF8.GetString(b))
                {
                    CalIdOffset = device.Value.internalIdAddress;
                    CalId       = device.Key.ToString();
                    Definition  = device.Value;
                    Definition.Populate();
                    //this.tableList = new List<Table>();

                    //foreach (XElement table in this.Definition.xRomTableList.Values)
                    //{
                    //    this.tableList.Add(TableFactory.CreateTable(table, this));
                    //}
                    //this.imageTree = new TableTree(this);
                    this.imageTree = new TreeNode("(" + this.CalId + ") " + this.FileName);
                    ModList        = this.GetValidMods();
                    return(true);
                }
            }
            Trace.TraceWarning(String.Format("Error opening Rom at {0}, Definition not found!", f));
            MessageBox.Show("Error opening Rom!, Definition not found!");
            return(false);
        }