using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using EmuXPortal.Api; using EmuXPortal.Logging; using System.Diagnostics; 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; } void platform_ctrl_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { PlatformControl c = sender as PlatformControl; 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(); } } 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.Dock = DockStyle.Top; platform_ctrl.Width = this.Width - 10; 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_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; } 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.Dock = DockStyle.Top; game_ctrl.Width = this.Width - 10; 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); //rom_flow.SetFlowBreak(game_ctrl, true); 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; if (e.KeyCode == Keys.Enter) { IRomConfig config = c.Tag as IRomConfig; Process p = new Process(); p.StartInfo.FileName = config.Config.EmuPath; p.StartInfo.Arguments = EmuConfigLoader.GetEMUOptions(config); p.Start(); } if (e.KeyCode == Keys.Back) { rom_flow.Visible = false; platform_flow.Visible = true; } } } }