/[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/08/22 02:12:46	104
+++ trunk/EmuXPortal/Api/EmuConfig.cs	2012/08/23 02:44:26	110
@@ -9,7 +9,7 @@
 
 namespace EmuXPortal.Api
 {
-    public interface IEmuConfig : IComparable<IEmuConfig>
+    public interface IEmuConfig : IComparable<IEmuConfig>, IDisposable
     {
         string ConfigPath { get; }
         string PlatformNameShort { get; }
@@ -32,6 +32,7 @@
 
 
         void RefreshConfig();
+        void ReleasePlatformImageResource();
     }
 
 
@@ -78,7 +79,7 @@
         #endregion
 
         #region private class EmuConfig : IEmuConfig
-        private class EmuConfig : IEmuConfig, IComparable<IEmuConfig>
+        private class EmuConfig : IEmuConfig, IComparable<IEmuConfig>, IDisposable
         {
             public IEmuConfig Create(string rom_path) { return this.Create(string.Empty, rom_path); }
             public IEmuConfig Create(string config_path, string rom_path)
@@ -128,7 +129,7 @@
                                             if (reader.IsStartElement())
                                             {
                                                 string platform_image = reader.ReadElementContentAsString();
-                                                PlatformImage = (platform_image == "") ? Properties.Resources.DefaultPlatformImage : Image.FromFile(string.Format(@"{0}\{1}", rom_path, platform_image));
+                                                PlatformImage = (platform_image == "") ? null : Image.FromFile(string.Format(@"{0}\{1}", rom_path, platform_image));
                                                 string str_platform_image = (platform_image == "") ? "DefaultPlatformImage" : platform_image;
                                                 logger.WriteLine("\t\tPLATFORMIMAGE={0}", str_platform_image);
                                             }
@@ -321,6 +322,12 @@
             public string GameImage { get; set; }
             public string GameExe { get; set; }
             public string GameExeArgs { get; set; }
+
+            public void ReleasePlatformImageResource()
+            {
+                if (this.PlatformImage != null)
+                    this.PlatformImage.Dispose();
+            }
             #endregion
 
             public override string ToString()
@@ -339,6 +346,12 @@
                 this.Create(EmuRomPath);
             }
             #endregion
+
+            public void Dispose()
+            {
+                if (this.PlatformImage != null)
+                    this.PlatformImage.Dispose();
+            }
         }
         #endregion
 

 

  ViewVC Help
Powered by ViewVC 1.1.22