/[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/04 04:27:01	30
+++ trunk/EmuXPortal/Form1.cs	2012/04/04 05:12:58	31
@@ -15,7 +15,8 @@
     public partial class Form1 : Form
     {
         IEmuConfig CurrentSelectedRom = null;
-        //PlatformControl CurrentPlatformControl = null;
+        PlatformControl CurrentPlatformControl = null;
+        GameControl CurrentGameControl = null;
         public Form1()
         {
             InitializeComponent();
@@ -40,6 +41,7 @@
         {
             PlatformControl c = sender as PlatformControl;
             c.BorderStyle = BorderStyle.FixedSingle;
+            CurrentPlatformControl = c;
         }
 
         void platform_ctrl_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
@@ -61,15 +63,35 @@
                 (e.KeyCode >= Keys.D0 && e.KeyCode <= Keys.D9))
             {                
                 char t = (char)e.KeyCode;
-                foreach (Control cc in platform_flow.Controls)
+                PlatformControl ctrl = (platform_flow.GetNextControl(CurrentPlatformControl, true) as PlatformControl);
+                if (ctrl == null) { ctrl = (platform_flow.GetNextControl(platform_flow.Controls[0], true) as PlatformControl); }
+                bool found = false;
+                PlatformControl pc = CurrentPlatformControl;
+                bool wrapped = false;
+                bool not_found = true;
+                while (!found)
                 {
-                    PlatformControl gc = cc as PlatformControl;
-                    if (gc.PlatformName.ToLower().StartsWith(t.ToString().ToLower()))
+                    if (wrapped)
                     {
-                        platform_flow.ScrollControlIntoView(gc);
-                        gc.Select();
-                        break;
+                        foreach (Control ctl in platform_flow.Controls) 
+                        { 
+                            PlatformControl p_ctl = ctl as PlatformControl; if (p_ctl.PlatformName.ToLower().StartsWith(t.ToString().ToLower())) { not_found = false; } 
+                        }
+                        if (not_found) { found = true; }
                     }
+                    ctrl = (platform_flow.GetNextControl(pc, true) as PlatformControl);
+                    if (ctrl == null)
+                    {
+                        ctrl = platform_flow.Controls[0] as PlatformControl;
+                        wrapped = true;
+                    }
+                    if (ctrl.PlatformName.ToLower().StartsWith(t.ToString().ToLower()))
+                    {
+                        platform_flow.ScrollControlIntoView(ctrl);
+                        ctrl.Select();
+                        found = true;
+                    }
+                    pc = ctrl;
                 }
             }
         }
@@ -90,10 +112,8 @@
                 platform_ctrl.PlatformName = config.PlatformNameLong;
                 platform_ctrl.PreviewKeyDown += new PreviewKeyDownEventHandler(platform_ctrl_PreviewKeyDown);
                 platform_flow.Controls.Add(platform_ctrl);
-                //platform_flow.SetFlowBreak(platform_ctrl, true);
                 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;            
@@ -116,7 +136,6 @@
                 game_ctrl.GameName = config.RomTitle;
                 game_ctrl.PreviewKeyDown += new PreviewKeyDownEventHandler(game_ctrl_PreviewKeyDown);
                 rom_flow.Controls.Add(game_ctrl);
-                //rom_flow.SetFlowBreak(game_ctrl, true);
                 game_ctrl.GotFocus += new EventHandler(game_ctrl_GotFocus);
                 game_ctrl.LostFocus += new EventHandler(game_ctrl_LostFocus);
             }
@@ -134,6 +153,7 @@
         {
             GameControl c = sender as GameControl;
             c.BorderStyle = BorderStyle.FixedSingle;
+            CurrentGameControl = c;
         }
 
         void game_ctrl_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
@@ -158,16 +178,36 @@
                 (e.KeyCode >= Keys.D0 && e.KeyCode <= Keys.D9))
             {
                 char t = (char)e.KeyCode;
-                foreach (Control cc in rom_flow.Controls)
+                GameControl ctrl = (rom_flow.GetNextControl(CurrentPlatformControl, true) as GameControl);
+                if (ctrl == null) { ctrl = (rom_flow.GetNextControl(rom_flow.Controls[0], true) as GameControl); }
+                bool found = false;
+                GameControl pc = CurrentGameControl;
+                bool wrapped = false;
+                bool not_found = true;
+                while (!found)
                 {
-                    GameControl gc = cc as GameControl;
-                    if (gc.GameName.ToLower().StartsWith(t.ToString().ToLower()))
+                    if (wrapped)
                     {
-                        rom_flow.ScrollControlIntoView(gc);
-                        gc.Select();                        
-                        break;
+                        foreach (Control ctl in rom_flow.Controls)
+                        {
+                            GameControl p_ctl = ctl as GameControl; if (p_ctl.GameName.ToLower().StartsWith(t.ToString().ToLower())) { not_found = false; }
+                        }
+                        if (not_found) { found = true; }
                     }
-                }
+                    ctrl = (rom_flow.GetNextControl(pc, true) as GameControl);
+                    if (ctrl == null)
+                    {
+                        ctrl = rom_flow.Controls[0] as GameControl;
+                        wrapped = true;
+                    }
+                    if (ctrl.GameName.ToLower().StartsWith(t.ToString().ToLower()))
+                    {
+                        rom_flow.ScrollControlIntoView(ctrl);
+                        ctrl.Select();
+                        found = true;
+                    }
+                    pc = ctrl;
+                }           
             }
         }    
     }

 

  ViewVC Help
Powered by ViewVC 1.1.22