/[EmuXPortal]/trunk/EmuXPortal/Api/EmuConfig.cs
ViewVC logotype

Diff of /trunk/EmuXPortal/Api/EmuConfig.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/EmuXPortal/Api/EmuConfig.cs	2012/04/04 01:32:37	17
+++ trunk/EmuXPortal/Api/EmuConfig.cs	2012/04/04 02:11:37	20
@@ -5,6 +5,7 @@
 using System.Drawing;
 using System.IO;
 using EmuXPortal.Logging;
+using System.Xml;
 
 namespace EmuXPortal.Api
 {
@@ -35,11 +36,54 @@
             if (fi.Exists)
             {
                 logger.WriteLine("Found EMU Config File: {0}", config_path);
+                logger.WriteLine("\tLoading Config: {0}", config_path);
+                //bool loaded = false;
+                try
+                {
+                    using (FileStream fs = new FileStream(config_path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
+                    {
+                        using (XmlReader reader = XmlReader.Create(fs))
+                        {
+                            reader.ReadToFollowing("PLATFORMNAMESHORT");
+                            config.PlatformNameShort = reader.ReadElementContentAsString();
+                            logger.WriteLine("\tPLATFORMNAMESHORT={0}", config.PlatformNameShort);
+
+                            reader.ReadToFollowing("PLATFORMNAMELONG");
+                            config.PlatformNameLong = reader.ReadElementContentAsString();
+                            logger.WriteLine("\tPLATFORMNAMELONG={0}", config.PlatformNameLong);
+
+                            reader.ReadToFollowing("PLATFORMIMAGE");
+                            string platform_image = reader.ReadElementContentAsString();
+                            
+                            config.PlatformImage = (platform_image == "") ? Properties.Resources.DefaultPlatformImage : Image.FromFile(string.Format(@"{0}\{1}",rom_path,platform_image));
+                            string str_platform_image = (platform_image == "") ? "DefaultPlatformImage" : platform_image;
+                            logger.WriteLine("\tPLATFORMIMAGE={0}", str_platform_image);
+
+                            reader.ReadToFollowing("EXTENSIONS");
+                            config.Extenstions = reader.ReadElementContentAsString();
+                            logger.WriteLine("\tEXTENSIONS={0}", config.Extenstions);
+
+                            reader.ReadToFollowing("EMULATORPATH");
+                            config.EmuPath = reader.ReadElementContentAsString();
+                            logger.WriteLine("\tEMULATORPATH={0}", config.EmuPath);
+
+                            reader.ReadToFollowing("EMULATOROPTIONS");
+                            config.EmuOptions = reader.ReadElementContentAsString();
+                            logger.WriteLine("\tEMULATOROPTIONS={0}", config.EmuOptions);
+                        }
+                    }
+                    logger.WriteLine("\tLoaded Config: {0}", config_path);
+                    //loaded = true;
+                }
+                catch(Exception ex)
+                {
+                    logger.WriteLine("\tFailed to Load Config: {0}", config_path);
+                    Console.WriteLine(ex.ToString());
+                    logger.WriteLine("Error: {0}", ex.ToString());
+                    //loaded = false;
+                }
             }
-            else
-            {
-                logger.WriteLine("Could not find EMU Config File: {0}", config_path);
-            }
+            else { logger.WriteLine("Could not find EMU Config File: {0}", config_path); }
             return config;
         }
         #region private class EmuConfig : IEmuConfig
@@ -78,7 +122,7 @@
                         return Unknown_Platform;
                     }
                 }
-                private set { _PlatformNameShort = value; }
+                set { _PlatformNameShort = value; }
             }
             private string _PlatformNameLong;
             public string PlatformNameLong
@@ -96,12 +140,12 @@
                         return Unknown_Platform;
                     }
                 }
-                private set { _PlatformNameLong = value; }
+                set { _PlatformNameLong = value; }
             }
-            public Image PlatformImage { get; private set; }
-            public string Extenstions { get; private set; }
-            public string EmuPath { get; private set; }
-            public string EmuOptions { get; private set; }
+            public Image PlatformImage { get; set; }
+            public string Extenstions { get; set; }
+            public string EmuPath { get; set; }
+            public string EmuOptions { get; set; }
             public string EmuRomPath { get; set; }
             #endregion      
         }

 

  ViewVC Help
Powered by ViewVC 1.1.22