/[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	2014/08/05 09:20:39	248
+++ trunk/EmuXPortal/Form1.cs	2014/08/05 09:53:04	249
@@ -29,6 +29,13 @@
         PlatformControl CurrentPlatformControl = null;
         GameControl CurrentGameControl = null;
 
+        
+        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
+        {
+            if (!msg.HWnd.Equals(this.Handle) && (keyData == Keys.Left || keyData == Keys.Right || keyData == Keys.Up || keyData == Keys.Down || keyData == Keys.Tab))
+                return true;
+            return base.ProcessCmdKey(ref msg, keyData);
+        }
         #region unhandled exception support
         static void Application_Unhandled_ThreadException(object sender, ThreadExceptionEventArgs e)
         {
@@ -134,338 +141,338 @@
             Cursor.Show();
 #endif
         }
-        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;
-            CurrentPlatformControl = c;
-        }
-        void game_ctrl_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
-        {
-            GameControl c = sender as GameControl;
-
-            int changeAmount = 0;
-            int currentPosition = 0;
-            if (e.KeyCode == Keys.F && (e.Modifiers & Keys.Control) == Keys.Control)
-            {
-                IRomConfig config = c.Tag as IRomConfig;
-                if (config == null)
-                {
-                    gLog.Error.WriteLine("Unable to add/remove from/to favorites (config is null): {0} [{1}]", config.RomTitle, config.RomFile);
-                }
-                else
-                {
-                    var isFavorite = RomFavorite.IsFavorite(config);
-                    if (isFavorite)
-                    {
-                        // add to favorites
-                        gLog.Debug.WriteLine("Removing from favorites: {0} [{1}]", config.RomTitle, config.RomFile);
-                        if (!RomFavorite.RemoveFavorite(config))
-                        {
-                            gLog.Error.WriteLine("Failed to remove from favorites: {0} [{1}]", config.RomTitle, config.RomFile);
-                        }
-                        else
-                        {
-                            gLog.Info.WriteLine("Removed from favorites: {0} [{1}]", config.RomTitle, config.RomFile);
-                            if (config.Config.PlatformNameShort == "Favorites")
-                            {
-                                var parent = c.Parent;
-                                if (parent != null)
-                                {
-                                    parent.Controls.Remove(c);
-                                    if (parent.Controls.Count > 0)
-                                    {
-                                        var next_ctrl = parent.Controls[0];
-                                        if (next_ctrl != null)
-                                        {
-                                            next_ctrl.Select();
-                                        }
-                                    }
-                                }
-                            }                       
-                        }
-                    }
-                    else
-                    {
-                        // add to favorites
-                        gLog.Debug.WriteLine("Adding to favorites: {0} [{1}]", config.RomTitle, config.RomFile);
-                        if (!RomFavorite.AddFavorite(config))
-                        {
-                            gLog.Error.WriteLine("Failed to add to favorites: {0} [{1}]", config.RomTitle, config.RomFile);
-                        }
-                        else
-                        {
-                            gLog.Info.WriteLine("Added to favorites: {0} [{1}]", config.RomTitle, config.RomFile);
-                        }
-                    }
-                    gLog.Debug.WriteLine("Updateing favorites");
-                    if (!RomFavorite.UpdateFavorites())
-                    {
-                        gLog.Error.WriteLine("Failed to update favorites");
-                    }
-                    else
-                    {
-                        gLog.Info.WriteLine("Updated favorites");
-                    }
-                }
-                return; // stop processing other keys
-
-            }
-            if (e.KeyCode == Keys.Home)
-            {
-                rom_flow.SuspendLayout();
-                rom_flow.Controls[0].Select();
-                rom_flow.ScrollControlIntoView(rom_flow.Controls[0]);
-                rom_flow.ResumeLayout(false);
-            }
-            if (e.KeyCode == Keys.End)
-            {
-                rom_flow.SuspendLayout();
-                rom_flow.Controls[rom_flow.Controls.Count - 1].Select();
-                rom_flow.ScrollControlIntoView(rom_flow.Controls[rom_flow.Controls.Count - 1]);
-                rom_flow.ResumeLayout(false);
-            }
-            if (e.KeyCode == Keys.PageUp)
-            {
-                rom_flow.SuspendLayout();
-                changeAmount = rom_flow.VerticalScroll.LargeChange;
-                currentPosition = rom_flow.VerticalScroll.Value;
-                if ((currentPosition - changeAmount) > rom_flow.VerticalScroll.Minimum)
-                {
-                    try
-                    {
-                        rom_flow.VerticalScroll.Value -= changeAmount;
-                    }
-                    catch
-                    {
-                        rom_flow.Controls[0].Select();
-                        rom_flow.ScrollControlIntoView(rom_flow.Controls[0]);
-                        rom_flow.PerformLayout();
-                        return;
-                    }
-                }
-                else
-                {
-                    rom_flow.Controls[0].Select();
-                    rom_flow.ScrollControlIntoView(rom_flow.Controls[0]);
-                }
-                GameControl s = game_ctrl_get_last_visible();
-                s.Select();
-                rom_flow.ScrollControlIntoView(s);
-                rom_flow.ResumeLayout(false);
-            }
-            if (e.KeyCode == Keys.PageDown)
-            {
-                rom_flow.SuspendLayout();
-                changeAmount = rom_flow.VerticalScroll.LargeChange;
-                currentPosition = rom_flow.VerticalScroll.Value;
-                if ((currentPosition - changeAmount) < rom_flow.VerticalScroll.Maximum)
-                {
-                    try
-                    {
-                        rom_flow.VerticalScroll.Value += changeAmount;
-                    }
-                    catch
-                    {
-                        rom_flow.Controls[0].Select();
-                        rom_flow.ScrollControlIntoView(rom_flow.Controls[0]);
-                        rom_flow.PerformLayout();
-                        return;
-                    }
-                }
-                else
-                {
-                    rom_flow.VerticalScroll.Value = rom_flow.VerticalScroll.Maximum;
-                }
-                GameControl s = game_ctrl_get_last_visible();
-                s.Select();
-                rom_flow.ScrollControlIntoView(s);
-                rom_flow.ResumeLayout(false);
-            }
-
-            if (e.KeyCode == Keys.Enter)
-            {
-                IRomConfig config = c.Tag as IRomConfig;
-
-                Process p = new Process();
-
-                p.StartInfo.FileName = config.Config.GameExe == "" ? config.Config.EmuPath : config.Config.GameExe;
-                p.StartInfo.Arguments = config.Config.GameExeArgs == "" ? EmuConfigLoader.GetEMUOptions(config) : config.Config.GameExeArgs;
-                p.Start();
+        //void platform_ctrl_LostFocus(object sender, EventArgs e)
+        //{
+        //    PlatformControl c = sender as PlatformControl;
+        //    c.BorderStyle = BorderStyle.None;
+        //}
 
-                // minimize EmuXPortal
-                this.WindowState = FormWindowState.Minimized;
-                // wait for exit of game
-                p.WaitForExit();
-                // maximize EmuXPortal
-                this.WindowState = FormWindowState.Maximized;
-            }
-            if (e.KeyCode == Keys.Back)
-            {
-                rom_flow.Visible = false;
-                platform_flow.Visible = true;
-            }
+        //void platform_ctrl_GotFocus(object sender, EventArgs e)
+        //{
+        //    PlatformControl c = sender as PlatformControl;
+        //    c.BorderStyle = BorderStyle.FixedSingle;
+        //    CurrentPlatformControl = c;
+        //}
+        //void game_ctrl_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
+        //{
+            //GameControl c = sender as GameControl;
 
-            if ((e.KeyCode >= Keys.A && e.KeyCode <= Keys.Z) ||
-                (e.KeyCode >= Keys.D0 && e.KeyCode <= Keys.D9))
-            {
-                rom_flow.SuspendLayout();
-                char t = (char)e.KeyCode;
-                GameControl ctrl = (rom_flow.GetNextControl(CurrentGameControl, 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)
-                {
-                    if (wrapped)
-                    {
-                        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;
-                }
-                rom_flow.ResumeLayout(false);
-            }
-        }
-        void platform_ctrl_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
-        {
-            PlatformControl c = sender as PlatformControl;
-            int changeAmount = 0;
-            int currentPosition = 0;
-            if (e.KeyCode == Keys.Home)
-            {
-                platform_flow.SuspendLayout();
-                platform_flow.Controls[0].Select();
-                platform_flow.ScrollControlIntoView(platform_flow.Controls[0]);
-                platform_flow.ResumeLayout(false);
-            }
-            if (e.KeyCode == Keys.End)
-            {
-                platform_flow.SuspendLayout();
-                platform_flow.Controls[platform_flow.Controls.Count -1].Select();
-                platform_flow.ScrollControlIntoView(platform_flow.Controls[platform_flow.Controls.Count - 1]);
-                platform_flow.ResumeLayout(false);
-            }
-            if (e.KeyCode == Keys.PageUp)
-            {
-                platform_flow.SuspendLayout();
-                changeAmount = platform_flow.VerticalScroll.LargeChange;
-                currentPosition = platform_flow.VerticalScroll.Value;
-                if ((currentPosition - changeAmount) > platform_flow.VerticalScroll.Minimum)
-                {
-                    platform_flow.VerticalScroll.Value -= changeAmount;
-                }
-                else
-                {
-                    platform_flow.VerticalScroll.Value = platform_flow.VerticalScroll.Minimum;
-                }
-                PlatformControl s = platform_ctrl_get_last_visible();
-                s.Select();
-                platform_flow.ScrollControlIntoView(s);
-                platform_flow.ResumeLayout(false);
-            }
-            if (e.KeyCode == Keys.PageDown)
-            {
-                platform_flow.SuspendLayout();
-                changeAmount = platform_flow.VerticalScroll.LargeChange;
-                currentPosition = platform_flow.VerticalScroll.Value;
-                if ((currentPosition - changeAmount) < platform_flow.VerticalScroll.Maximum)
-                {
-                    try
-                    {
-                        platform_flow.VerticalScroll.Value += changeAmount;
-                    }
-                    catch
-                    {
-                        platform_flow.Controls[0].Select();
-                        platform_flow.ScrollControlIntoView(platform_flow.Controls[0]);
-                        rom_flow.PerformLayout();
-                        return;
-                    }
-                }
-                else
-                {
-                    platform_flow.Controls[0].Select();
-                    platform_flow.ScrollControlIntoView(platform_flow.Controls[0]);
-                }
-                PlatformControl s = platform_ctrl_get_last_visible();
-                s.Select();
-                platform_flow.ScrollControlIntoView(s);
-                platform_flow.ResumeLayout(false);
-            }
-            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)
-            {
-                this.Close();
-            }
-            if ((e.KeyCode >= Keys.A && e.KeyCode <= Keys.Z) ||
-                (e.KeyCode >= Keys.D0 && e.KeyCode <= Keys.D9))
-            {
-                platform_flow.SuspendLayout();
-                char t = (char)e.KeyCode;
-                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)
-                {
-                    if (wrapped)
-                    {
-                        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;
-                }
-                platform_flow.ResumeLayout(false);
-            }
-        }
+            //int changeAmount = 0;
+            //int currentPosition = 0;
+            //if (e.KeyCode == Keys.F && (e.Modifiers & Keys.Control) == Keys.Control)
+            //{
+            //    IRomConfig config = c.Tag as IRomConfig;
+            //    if (config == null)
+            //    {
+            //        gLog.Error.WriteLine("Unable to add/remove from/to favorites (config is null): {0} [{1}]", config.RomTitle, config.RomFile);
+            //    }
+            //    else
+            //    {
+            //        var isFavorite = RomFavorite.IsFavorite(config);
+            //        if (isFavorite)
+            //        {
+            //            // add to favorites
+            //            gLog.Debug.WriteLine("Removing from favorites: {0} [{1}]", config.RomTitle, config.RomFile);
+            //            if (!RomFavorite.RemoveFavorite(config))
+            //            {
+            //                gLog.Error.WriteLine("Failed to remove from favorites: {0} [{1}]", config.RomTitle, config.RomFile);
+            //            }
+            //            else
+            //            {
+            //                gLog.Info.WriteLine("Removed from favorites: {0} [{1}]", config.RomTitle, config.RomFile);
+            //                if (config.Config.PlatformNameShort == "Favorites")
+            //                {
+            //                    var parent = c.Parent;
+            //                    if (parent != null)
+            //                    {
+            //                        parent.Controls.Remove(c);
+            //                        if (parent.Controls.Count > 0)
+            //                        {
+            //                            var next_ctrl = parent.Controls[0];
+            //                            if (next_ctrl != null)
+            //                            {
+            //                                next_ctrl.Select();
+            //                            }
+            //                        }
+            //                    }
+            //                }                       
+            //            }
+            //        }
+            //        else
+            //        {
+            //            // add to favorites
+            //            gLog.Debug.WriteLine("Adding to favorites: {0} [{1}]", config.RomTitle, config.RomFile);
+            //            if (!RomFavorite.AddFavorite(config))
+            //            {
+            //                gLog.Error.WriteLine("Failed to add to favorites: {0} [{1}]", config.RomTitle, config.RomFile);
+            //            }
+            //            else
+            //            {
+            //                gLog.Info.WriteLine("Added to favorites: {0} [{1}]", config.RomTitle, config.RomFile);
+            //            }
+            //        }
+            //        gLog.Debug.WriteLine("Updateing favorites");
+            //        if (!RomFavorite.UpdateFavorites())
+            //        {
+            //            gLog.Error.WriteLine("Failed to update favorites");
+            //        }
+            //        else
+            //        {
+            //            gLog.Info.WriteLine("Updated favorites");
+            //        }
+            //    }
+            //    return; // stop processing other keys
+
+            //}
+            //if (e.KeyCode == Keys.Home)
+            //{
+            //    rom_flow.SuspendLayout();
+            //    rom_flow.Controls[0].Select();
+            //    rom_flow.ScrollControlIntoView(rom_flow.Controls[0]);
+            //    rom_flow.ResumeLayout(false);
+            //}
+            //if (e.KeyCode == Keys.End)
+            //{
+            //    rom_flow.SuspendLayout();
+            //    rom_flow.Controls[rom_flow.Controls.Count - 1].Select();
+            //    rom_flow.ScrollControlIntoView(rom_flow.Controls[rom_flow.Controls.Count - 1]);
+            //    rom_flow.ResumeLayout(false);
+            //}
+            //if (e.KeyCode == Keys.PageUp)
+            //{
+            //    rom_flow.SuspendLayout();
+            //    changeAmount = rom_flow.VerticalScroll.LargeChange;
+            //    currentPosition = rom_flow.VerticalScroll.Value;
+            //    if ((currentPosition - changeAmount) > rom_flow.VerticalScroll.Minimum)
+            //    {
+            //        try
+            //        {
+            //            rom_flow.VerticalScroll.Value -= changeAmount;
+            //        }
+            //        catch
+            //        {
+            //            rom_flow.Controls[0].Select();
+            //            rom_flow.ScrollControlIntoView(rom_flow.Controls[0]);
+            //            rom_flow.PerformLayout();
+            //            return;
+            //        }
+            //    }
+            //    else
+            //    {
+            //        rom_flow.Controls[0].Select();
+            //        rom_flow.ScrollControlIntoView(rom_flow.Controls[0]);
+            //    }
+            //    GameControl s = game_ctrl_get_last_visible();
+            //    s.Select();
+            //    rom_flow.ScrollControlIntoView(s);
+            //    rom_flow.ResumeLayout(false);
+            //}
+            //if (e.KeyCode == Keys.PageDown)
+            //{
+            //    rom_flow.SuspendLayout();
+            //    changeAmount = rom_flow.VerticalScroll.LargeChange;
+            //    currentPosition = rom_flow.VerticalScroll.Value;
+            //    if ((currentPosition - changeAmount) < rom_flow.VerticalScroll.Maximum)
+            //    {
+            //        try
+            //        {
+            //            rom_flow.VerticalScroll.Value += changeAmount;
+            //        }
+            //        catch
+            //        {
+            //            rom_flow.Controls[0].Select();
+            //            rom_flow.ScrollControlIntoView(rom_flow.Controls[0]);
+            //            rom_flow.PerformLayout();
+            //            return;
+            //        }
+            //    }
+            //    else
+            //    {
+            //        rom_flow.VerticalScroll.Value = rom_flow.VerticalScroll.Maximum;
+            //    }
+            //    GameControl s = game_ctrl_get_last_visible();
+            //    s.Select();
+            //    rom_flow.ScrollControlIntoView(s);
+            //    rom_flow.ResumeLayout(false);
+            //}
+
+            //if (e.KeyCode == Keys.Enter)
+            //{
+            //    IRomConfig config = c.Tag as IRomConfig;
+
+            //    Process p = new Process();
+
+            //    p.StartInfo.FileName = config.Config.GameExe == "" ? config.Config.EmuPath : config.Config.GameExe;
+            //    p.StartInfo.Arguments = config.Config.GameExeArgs == "" ? EmuConfigLoader.GetEMUOptions(config) : config.Config.GameExeArgs;
+            //    p.Start();
+
+            //    // minimize EmuXPortal
+            //    this.WindowState = FormWindowState.Minimized;
+            //    // wait for exit of game
+            //    p.WaitForExit();
+            //    // maximize EmuXPortal
+            //    this.WindowState = FormWindowState.Maximized;
+            //}
+            //if (e.KeyCode == Keys.Back)
+            //{
+            //    rom_flow.Visible = false;
+            //    platform_flow.Visible = true;
+            //}
+
+            //if ((e.KeyCode >= Keys.A && e.KeyCode <= Keys.Z) ||
+            //    (e.KeyCode >= Keys.D0 && e.KeyCode <= Keys.D9))
+            //{
+            //    rom_flow.SuspendLayout();
+            //    char t = (char)e.KeyCode;
+            //    GameControl ctrl = (rom_flow.GetNextControl(CurrentGameControl, 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)
+            //    {
+            //        if (wrapped)
+            //        {
+            //            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;
+            //    }
+            //    rom_flow.ResumeLayout(false);
+            //}
+        //}
+        //void platform_ctrl_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
+        //{
+            //PlatformControl c = sender as PlatformControl;
+            //int changeAmount = 0;
+            //int currentPosition = 0;
+            //if (e.KeyCode == Keys.Home)
+            //{
+            //    platform_flow.SuspendLayout();
+            //    platform_flow.Controls[0].Select();
+            //    platform_flow.ScrollControlIntoView(platform_flow.Controls[0]);
+            //    platform_flow.ResumeLayout(false);
+            //}
+            //if (e.KeyCode == Keys.End)
+            //{
+            //    platform_flow.SuspendLayout();
+            //    platform_flow.Controls[platform_flow.Controls.Count -1].Select();
+            //    platform_flow.ScrollControlIntoView(platform_flow.Controls[platform_flow.Controls.Count - 1]);
+            //    platform_flow.ResumeLayout(false);
+            //}
+            //if (e.KeyCode == Keys.PageUp)
+            //{
+            //    platform_flow.SuspendLayout();
+            //    changeAmount = platform_flow.VerticalScroll.LargeChange;
+            //    currentPosition = platform_flow.VerticalScroll.Value;
+            //    if ((currentPosition - changeAmount) > platform_flow.VerticalScroll.Minimum)
+            //    {
+            //        platform_flow.VerticalScroll.Value -= changeAmount;
+            //    }
+            //    else
+            //    {
+            //        platform_flow.VerticalScroll.Value = platform_flow.VerticalScroll.Minimum;
+            //    }
+            //    PlatformControl s = platform_ctrl_get_last_visible();
+            //    s.Select();
+            //    platform_flow.ScrollControlIntoView(s);
+            //    platform_flow.ResumeLayout(false);
+            //}
+            //if (e.KeyCode == Keys.PageDown)
+            //{
+            //    platform_flow.SuspendLayout();
+            //    changeAmount = platform_flow.VerticalScroll.LargeChange;
+            //    currentPosition = platform_flow.VerticalScroll.Value;
+            //    if ((currentPosition - changeAmount) < platform_flow.VerticalScroll.Maximum)
+            //    {
+            //        try
+            //        {
+            //            platform_flow.VerticalScroll.Value += changeAmount;
+            //        }
+            //        catch
+            //        {
+            //            platform_flow.Controls[0].Select();
+            //            platform_flow.ScrollControlIntoView(platform_flow.Controls[0]);
+            //            rom_flow.PerformLayout();
+            //            return;
+            //        }
+            //    }
+            //    else
+            //    {
+            //        platform_flow.Controls[0].Select();
+            //        platform_flow.ScrollControlIntoView(platform_flow.Controls[0]);
+            //    }
+            //    PlatformControl s = platform_ctrl_get_last_visible();
+            //    s.Select();
+            //    platform_flow.ScrollControlIntoView(s);
+            //    platform_flow.ResumeLayout(false);
+            //}
+            //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)
+            //{
+            //    this.Close();
+            //}
+            //if ((e.KeyCode >= Keys.A && e.KeyCode <= Keys.Z) ||
+            //    (e.KeyCode >= Keys.D0 && e.KeyCode <= Keys.D9))
+            //{
+            //    platform_flow.SuspendLayout();
+            //    char t = (char)e.KeyCode;
+            //    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)
+            //    {
+            //        if (wrapped)
+            //        {
+            //            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;
+            //    }
+            //    platform_flow.ResumeLayout(false);
+            //}
+        //}
 
         private void platform_flow_VisibleChanged(object sender, EventArgs e)
         {
@@ -487,39 +494,39 @@
             gameWorker.RunWorkerAsync(t);
         }
 
-        void game_ctrl_LostFocus(object sender, EventArgs e)
-        {
-            GameControl c = sender as GameControl;
-            c.BorderStyle = BorderStyle.None;
-        }
+        //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;
-            CurrentGameControl = c;
-        }
+        //void game_ctrl_GotFocus(object sender, EventArgs e)
+        //{
+        //    GameControl c = sender as GameControl;
+        //    c.BorderStyle = BorderStyle.FixedSingle;
+        //    CurrentGameControl = c;
+        //}
 
-        private GameControl game_ctrl_get_last_visible()
-        {
-            GameControl s = new GameControl();
-            foreach (GameControl c in rom_flow.Controls)
-            {
-                if (c.Bounds.IntersectsWith(rom_flow.Bounds))
-                    s = c;
-            }
-            return s;
-        }
-        private PlatformControl platform_ctrl_get_last_visible()
-        {
-            PlatformControl s = new PlatformControl();
-            foreach (PlatformControl c in platform_flow.Controls)
-            {
-                if (c.Bounds.IntersectsWith(platform_flow.Bounds))
-                    s = c;
-            }
-            return s;
-        }
+        //private GameControl game_ctrl_get_last_visible()
+        //{
+        //    GameControl s = new GameControl();
+        //    foreach (GameControl c in rom_flow.Controls)
+        //    {
+        //        if (c.Bounds.IntersectsWith(rom_flow.Bounds))
+        //            s = c;
+        //    }
+        //    return s;
+        //}
+        //private PlatformControl platform_ctrl_get_last_visible()
+        //{
+        //    PlatformControl s = new PlatformControl();
+        //    foreach (PlatformControl c in platform_flow.Controls)
+        //    {
+        //        if (c.Bounds.IntersectsWith(platform_flow.Bounds))
+        //            s = c;
+        //    }
+        //    return s;
+        //}
       
 
         #region Background Workers
@@ -638,9 +645,9 @@
                 {
                     game_ctrl.GameName = config.RomTitle;
                 }      
-                game_ctrl.PreviewKeyDown += new PreviewKeyDownEventHandler(game_ctrl_PreviewKeyDown);
-                game_ctrl.GotFocus += new EventHandler(game_ctrl_GotFocus);
-                game_ctrl.LostFocus += new EventHandler(game_ctrl_LostFocus);
+                //game_ctrl.PreviewKeyDown += new PreviewKeyDownEventHandler(game_ctrl_PreviewKeyDown);
+                //game_ctrl.GotFocus += new EventHandler(game_ctrl_GotFocus);
+                //game_ctrl.LostFocus += new EventHandler(game_ctrl_LostFocus);
                 if (rom_flow.InvokeRequired) { rom_flow.Invoke((MethodInvoker)delegate() { rom_flow.Controls.Add(game_ctrl); }); }
                 else { rom_flow.Controls.Add(game_ctrl); }
                 count++;
@@ -658,16 +665,16 @@
             if (rom_flow.Controls.Count == 0)
             {
                 GameControl game_ctrl = new GameControl();
-                game_ctrl.PreviewKeyDown += new PreviewKeyDownEventHandler(game_ctrl_PreviewKeyDown);
-                game_ctrl.GotFocus += new EventHandler(game_ctrl_GotFocus);
-                game_ctrl.LostFocus += new EventHandler(game_ctrl_LostFocus);
+                //game_ctrl.PreviewKeyDown += new PreviewKeyDownEventHandler(game_ctrl_PreviewKeyDown);
+                //game_ctrl.GotFocus += new EventHandler(game_ctrl_GotFocus);
+                //game_ctrl.LostFocus += new EventHandler(game_ctrl_LostFocus);
                 game_ctrl.Font = GetFormFont();
                 game_ctrl.Dock = DockStyle.Top;
                 game_ctrl.Width = this.Width - 10;
                 game_ctrl.GameName = "You haven't favorited any games, select a game and then press CTRL+F to favorite it";
                 rom_flow.Controls.Add(game_ctrl);
             }
-            rom_flow.Controls[0].Select();
+            //rom_flow.Controls[0].Select();
             t.Stop();
             gLog.Profiler.WriteLine("RomParser took: {0}s to parse roms", (int)t.Elapsed.TotalSeconds);
         }
@@ -716,9 +723,9 @@
                     throw ex;
                 } 
                 platform_ctrl.PlatformName = config.ToString();
-                platform_ctrl.PreviewKeyDown += new PreviewKeyDownEventHandler(platform_ctrl_PreviewKeyDown);
-                platform_ctrl.GotFocus += new EventHandler(platform_ctrl_GotFocus);
-                platform_ctrl.LostFocus += new EventHandler(platform_ctrl_LostFocus);
+                //platform_ctrl.PreviewKeyDown += new PreviewKeyDownEventHandler(platform_ctrl_PreviewKeyDown);
+                //platform_ctrl.GotFocus += new EventHandler(platform_ctrl_GotFocus);
+                //platform_ctrl.LostFocus += new EventHandler(platform_ctrl_LostFocus);
                 if (platform_flow.InvokeRequired) { platform_flow.Invoke((MethodInvoker)delegate() { platform_flow.Controls.Add(platform_ctrl); }); }
                 else { platform_flow.Controls.Add(platform_ctrl); }                  
                 count++;
@@ -736,16 +743,16 @@
             if (platform_flow.Controls.Count == 0)
             {
                 PlatformControl platform_ctrl = new PlatformControl();
-                platform_ctrl.PreviewKeyDown += new PreviewKeyDownEventHandler(platform_ctrl_PreviewKeyDown);
-                platform_ctrl.GotFocus += new EventHandler(platform_ctrl_GotFocus);
-                platform_ctrl.LostFocus += new EventHandler(platform_ctrl_LostFocus);
+                //platform_ctrl.PreviewKeyDown += new PreviewKeyDownEventHandler(platform_ctrl_PreviewKeyDown);
+                //platform_ctrl.GotFocus += new EventHandler(platform_ctrl_GotFocus);
+                //platform_ctrl.LostFocus += new EventHandler(platform_ctrl_LostFocus);
                 platform_ctrl.Font = GetFormFont();
                 platform_ctrl.Dock = DockStyle.Top;
                 platform_ctrl.Width = this.Width - 10;
                 platform_ctrl.PlatformName = string.Format("You don't have any roms in your rompath: '{0}'",Config.RomPath);
                 platform_flow.Controls.Add(platform_ctrl);
             }
-            platform_flow.Controls[0].Select();
+            //platform_flow.Controls[0].Select();
             gLog.Profiler.WriteLine("PlatformParser took: {0}s to parse platforms", (int)t.Elapsed.TotalSeconds);
 
 

 

  ViewVC Help
Powered by ViewVC 1.1.22