/[EmuXPortal]/branches/mono/EmuXPortal/Form1.cs
ViewVC logotype

Diff of /branches/mono/EmuXPortal/Form1.cs

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

--- branches/mono/EmuXPortal/Form1.cs	2017/12/19 02:44:37	333
+++ branches/mono/EmuXPortal/Form1.cs	2017/12/19 03:35:02	334
@@ -138,6 +138,28 @@
             Cursor.Show();
 #endif
         }
+
+        void ReleasePlatformControlStreams ()
+		{
+			foreach (var c in platform_flow.Controls) {
+				if (c.GetType () == typeof(PlatformControl)) {
+					PlatformControl pc = (c as PlatformControl);
+					if (pc != null) {
+						pc.ReleasePlatformStream();
+					}
+				}
+			}
+        }
+		void ReleaseGameControlStreams() {
+			foreach (var c in rom_flow.Controls) {
+				if (c.GetType () == typeof(GameControl)) {
+					GameControl gc = (c as GameControl);
+					if (gc != null) {
+						gc.ReleaseGameStream();
+					}
+				}
+			}
+        }
         void platform_ctrl_LostFocus(object sender, EventArgs e)
         {
             PlatformControl c = sender as PlatformControl;
@@ -322,6 +344,7 @@
 
             if (e.KeyCode == Keys.Enter)
             {
+				ReleaseGameControlStreams();
                 IRomConfig config = c.Tag as IRomConfig;
 
                 Process p = new Process();
@@ -342,6 +365,7 @@
             }
 			if (e.KeyCode == Keys.Back || e.KeyCode == Keys.Escape)
             {				
+				ReleaseGameControlStreams();
 				SavedPlatformIndex = platform_flow.Controls.IndexOf (CurrentPlatformControl);
                 rom_flow.Visible = false;
                 platform_flow.Visible = true;
@@ -470,14 +494,16 @@
             }
             if (e.KeyCode == Keys.Enter)
             {
-                // load this platform
+				ReleasePlatformControlStreams();
+                // load this platform				
                 platform_flow.Visible = false;
-                CurrentSelectedRom = c.Tag as IEmuConfig;
+                CurrentSelectedRom = c.Tag as IEmuConfig;				
                 rom_flow.Visible = true;
                 rom_flow.BringToFront();
             }
 			if (e.KeyCode == Keys.Back || e.KeyCode == Keys.Escape)
             {
+				ReleasePlatformControlStreams();
                 this.Close();
             }
             if ((e.KeyCode >= Keys.A && e.KeyCode <= Keys.Z) ||
@@ -800,11 +826,12 @@
                     {
 						//gLog.Debug.WriteLine ("handling rom: {0}", config.ToString ());
 						if(String.IsNullOrEmpty(config.RomImage)) {
-							game_ctrl.GameImage = (Image)DefaultGameImage.Clone ();
+							game_ctrl.UpdateGameImage((Image)DefaultGameImage.Clone ());
 						}
 						else {
 							string path = config.GetFullRomImage();
-							game_ctrl.GameImage = Image.FromFile(path);
+							gLog.Debug.WriteLine("game_ctrl.ControlID = {0}", game_ctrl.ControlID);
+							game_ctrl.UpdateGameImage(path);
 						}
                     }
                 }
@@ -923,11 +950,12 @@
 					lock (platformimage_lock) {
 						//gLog.Debug.WriteLine ("handling platform: {0}", config.ToString ());
 						if(String.IsNullOrEmpty(config.PlatformImage)) {
-							platform_ctrl.PlatformImage = (Image)DefaultPlatformImage.Clone ();
+							platform_ctrl.UpdatePlatformImage((Image)DefaultPlatformImage.Clone ());
 						}
 						else {
 							string path = config.GetFullPlatformImage();
-							platform_ctrl.PlatformImage = Image.FromFile(path);
+							gLog.Debug.WriteLine("platform_ctrl.ControlID = {0}", platform_ctrl.ControlID);
+							platform_ctrl.UpdatePlatformImage(path);
 						}
 					}
 				} catch (Exception ex) {

 

  ViewVC Help
Powered by ViewVC 1.1.22