/[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

--- trunk/EmuXPortal/Form1.cs	2012/04/03 21:54:58	16
+++ trunk/EmuXPortal/Form1.cs	2012/04/04 01:32:37	17
@@ -7,21 +7,142 @@
 using System.Text;
 using System.Windows.Forms;
 using EmuXPortal.Api;
+using EmuXPortal.Logging;
 
 namespace EmuXPortal
 {
     public partial class Form1 : Form
     {
+        IEmuConfig CurrentSelectedRom = null;
+        //PlatformControl CurrentPlatformControl = null;
         public Form1()
         {
             InitializeComponent();
+            platform_flow.Dock = DockStyle.Fill;
+            rom_flow.Dock = DockStyle.Fill;
+
             Config.LoadConfig();            
         }
+     
+        private void Form1_Load(object sender, EventArgs e)
+        {
+            Config.InitializePresentationForm(this);           
+        }
+        private void Form1_Shown(object sender, EventArgs e) { platform_flow.Visible = true; }
+        void platform_ctrl_LostFocus(object sender, EventArgs e)
+        {
+            PlatformControl c = sender as PlatformControl;
+            c.BorderStyle = BorderStyle.None;
+        }
+
+        void platform_ctrl_GotFocus(object sender, EventArgs e)
+        {
+            PlatformControl c = sender as PlatformControl;
+            c.BorderStyle = BorderStyle.FixedSingle;
+        }
 
-        private void Form1_Shown(object sender, EventArgs e)
+        void platform_ctrl_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
         {
-            Config.InitializePresentationForm(this);
-            RomParser parser = new RomParser(Config.RomPath);
+            PlatformControl c = sender as PlatformControl;
+            //PlatformControl d = null;
+            //if (e.KeyCode == Keys.Right)
+            //    d = platform_flow.GetNextControl(c, true) as PlatformControl;
+            //if (e.KeyCode == Keys.Left)
+            //    d = platform_flow.GetNextControl(c, false) as PlatformControl;
+            //logger.WriteLine("Deteted key down: {0} for Platform: {1}", e.KeyCode, d.PlatformName);
+
+            if (e.KeyCode == Keys.Enter)
+            {
+                // load this platform
+                platform_flow.Visible = false;
+                CurrentSelectedRom = c.Tag as IEmuConfig;
+                rom_flow.Visible = true;
+                rom_flow.BringToFront();
+            }            
         }
+
+        private void platform_flow_VisibleChanged(object sender, EventArgs e)
+        {
+            if (!platform_flow.Visible) return;
+            platform_flow.Controls.Clear();
+            platform_flow.BringToFront();
+            PlatformParser parser = new PlatformParser(Config.RomPath);           
+            foreach (IEmuConfig config in parser.Platforms)
+            {
+                PlatformControl platform_ctrl = new PlatformControl();
+                platform_ctrl.Tag = config;
+                platform_ctrl.PlatformImage = config.PlatformImage;
+                platform_ctrl.PlatformName = config.PlatformNameLong;
+                platform_ctrl.PreviewKeyDown += new PreviewKeyDownEventHandler(platform_ctrl_PreviewKeyDown);
+                platform_flow.Controls.Add(platform_ctrl);
+                platform_ctrl.GotFocus += new EventHandler(platform_ctrl_GotFocus);
+                platform_ctrl.LostFocus += new EventHandler(platform_ctrl_LostFocus);
+                //CurrentPlatformControl = platform_flow.Controls[0] as PlatformControl;
+            }
+            platform_flow.Controls[0].Select();
+            (platform_flow.Controls[0] as PlatformControl).BorderStyle = BorderStyle.FixedSingle;
+        }
+
+        private void rom_flow_VisibleChanged(object sender, EventArgs e)
+        {
+            if (!rom_flow.Visible) return;
+            rom_flow.Controls.Clear();
+            rom_flow.BringToFront();
+            RomParser parser = new RomParser(string.Format(@"{0}\{1}", CurrentSelectedRom.EmuRomPath, "Roms"), CurrentSelectedRom.Extenstions);
+            foreach (IRomConfig config in parser.Roms)
+            {
+                GameControl game_ctrl = new GameControl();
+                game_ctrl.Tag = config;
+                game_ctrl.GameImage = config.RomImage;
+                game_ctrl.GameName = config.RomTitle;
+                game_ctrl.PreviewKeyDown += new PreviewKeyDownEventHandler(game_ctrl_PreviewKeyDown);
+                rom_flow.Controls.Add(game_ctrl);
+                game_ctrl.GotFocus += new EventHandler(game_ctrl_GotFocus);
+                game_ctrl.LostFocus += new EventHandler(game_ctrl_LostFocus);
+            }
+            rom_flow.Controls[0].Select();
+            (rom_flow.Controls[0] as GameControl).BorderStyle = BorderStyle.FixedSingle;
+        }
+
+        void game_ctrl_LostFocus(object sender, EventArgs e)
+        {
+            GameControl c = sender as GameControl;
+            c.BorderStyle = BorderStyle.None;
+        }
+
+        void game_ctrl_GotFocus(object sender, EventArgs e)
+        {
+            GameControl c = sender as GameControl;
+            c.BorderStyle = BorderStyle.FixedSingle;
+        }
+
+        void game_ctrl_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
+        {
+            GameControl c = sender as GameControl;
+            //PlatformControl d = null;
+            //if (e.KeyCode == Keys.Right)
+            //    d = platform_flow.GetNextControl(c, true) as PlatformControl;
+            //if (e.KeyCode == Keys.Left)
+            //    d = platform_flow.GetNextControl(c, false) as PlatformControl;
+            //logger.WriteLine("Deteted key down: {0} for Platform: {1}", e.KeyCode, d.PlatformName);
+
+            if (e.KeyCode == Keys.Enter)
+            {
+                //// load this platform
+                //platform_flow.Visible = false;
+                //CurrentSelectedRom = c.Tag as IEmuConfig;
+                //rom_flow.Visible = true;
+                //rom_flow.BringToFront();
+            }
+            if (e.KeyCode == Keys.Back)
+            {
+                rom_flow.Visible = false;
+                platform_flow.Visible = true;
+            }
+        }
+
+   
+
+    
     }
 }

 

  ViewVC Help
Powered by ViewVC 1.1.22