/[EmuXPortal]/trunk/EmuXPortal/Form1.cs
ViewVC logotype

Annotation of /trunk/EmuXPortal/Form1.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 23 - (hide annotations) (download)
Wed Apr 4 03:09:19 2012 UTC (8 years, 4 months ago) by william
File size: 6376 byte(s)
+ add support to replace emu placeholder options with the real options

1 william 4 using System;
2     using System.Collections.Generic;
3     using System.ComponentModel;
4     using System.Data;
5     using System.Drawing;
6     using System.Linq;
7     using System.Text;
8     using System.Windows.Forms;
9 william 12 using EmuXPortal.Api;
10 william 17 using EmuXPortal.Logging;
11 william 23 using System.Diagnostics;
12 william 4
13     namespace EmuXPortal
14     {
15     public partial class Form1 : Form
16     {
17 william 17 IEmuConfig CurrentSelectedRom = null;
18     //PlatformControl CurrentPlatformControl = null;
19 william 4 public Form1()
20     {
21     InitializeComponent();
22 william 17 platform_flow.Dock = DockStyle.Fill;
23     rom_flow.Dock = DockStyle.Fill;
24    
25 william 13 Config.LoadConfig();
26 william 4 }
27 william 17
28     private void Form1_Load(object sender, EventArgs e)
29     {
30     Config.InitializePresentationForm(this);
31     }
32     private void Form1_Shown(object sender, EventArgs e) { platform_flow.Visible = true; }
33     void platform_ctrl_LostFocus(object sender, EventArgs e)
34     {
35     PlatformControl c = sender as PlatformControl;
36     c.BorderStyle = BorderStyle.None;
37     }
38 william 13
39 william 17 void platform_ctrl_GotFocus(object sender, EventArgs e)
40 william 13 {
41 william 17 PlatformControl c = sender as PlatformControl;
42     c.BorderStyle = BorderStyle.FixedSingle;
43 william 13 }
44 william 17
45     void platform_ctrl_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
46     {
47     PlatformControl c = sender as PlatformControl;
48     //PlatformControl d = null;
49     //if (e.KeyCode == Keys.Right)
50     // d = platform_flow.GetNextControl(c, true) as PlatformControl;
51     //if (e.KeyCode == Keys.Left)
52     // d = platform_flow.GetNextControl(c, false) as PlatformControl;
53     //logger.WriteLine("Deteted key down: {0} for Platform: {1}", e.KeyCode, d.PlatformName);
54    
55     if (e.KeyCode == Keys.Enter)
56     {
57     // load this platform
58     platform_flow.Visible = false;
59     CurrentSelectedRom = c.Tag as IEmuConfig;
60     rom_flow.Visible = true;
61     rom_flow.BringToFront();
62     }
63     }
64    
65     private void platform_flow_VisibleChanged(object sender, EventArgs e)
66     {
67     if (!platform_flow.Visible) return;
68     platform_flow.Controls.Clear();
69     platform_flow.BringToFront();
70     PlatformParser parser = new PlatformParser(Config.RomPath);
71     foreach (IEmuConfig config in parser.Platforms)
72     {
73     PlatformControl platform_ctrl = new PlatformControl();
74 william 19 platform_ctrl.Dock = DockStyle.Top;
75     platform_ctrl.Width = this.Width - 10;
76 william 17 platform_ctrl.Tag = config;
77     platform_ctrl.PlatformImage = config.PlatformImage;
78     platform_ctrl.PlatformName = config.PlatformNameLong;
79     platform_ctrl.PreviewKeyDown += new PreviewKeyDownEventHandler(platform_ctrl_PreviewKeyDown);
80     platform_flow.Controls.Add(platform_ctrl);
81 william 19 //platform_flow.SetFlowBreak(platform_ctrl, true);
82 william 17 platform_ctrl.GotFocus += new EventHandler(platform_ctrl_GotFocus);
83     platform_ctrl.LostFocus += new EventHandler(platform_ctrl_LostFocus);
84     //CurrentPlatformControl = platform_flow.Controls[0] as PlatformControl;
85     }
86     platform_flow.Controls[0].Select();
87 william 19 (platform_flow.Controls[0] as PlatformControl).BorderStyle = BorderStyle.FixedSingle;
88    
89 william 17 }
90    
91     private void rom_flow_VisibleChanged(object sender, EventArgs e)
92     {
93     if (!rom_flow.Visible) return;
94     rom_flow.Controls.Clear();
95     rom_flow.BringToFront();
96     RomParser parser = new RomParser(string.Format(@"{0}\{1}", CurrentSelectedRom.EmuRomPath, "Roms"), CurrentSelectedRom.Extenstions);
97     foreach (IRomConfig config in parser.Roms)
98     {
99     GameControl game_ctrl = new GameControl();
100 william 19 game_ctrl.Dock = DockStyle.Top;
101     game_ctrl.Width = this.Width - 10;
102 william 17 game_ctrl.Tag = config;
103     game_ctrl.GameImage = config.RomImage;
104     game_ctrl.GameName = config.RomTitle;
105     game_ctrl.PreviewKeyDown += new PreviewKeyDownEventHandler(game_ctrl_PreviewKeyDown);
106     rom_flow.Controls.Add(game_ctrl);
107 william 19 //rom_flow.SetFlowBreak(game_ctrl, true);
108 william 17 game_ctrl.GotFocus += new EventHandler(game_ctrl_GotFocus);
109     game_ctrl.LostFocus += new EventHandler(game_ctrl_LostFocus);
110     }
111     rom_flow.Controls[0].Select();
112     (rom_flow.Controls[0] as GameControl).BorderStyle = BorderStyle.FixedSingle;
113     }
114    
115     void game_ctrl_LostFocus(object sender, EventArgs e)
116     {
117     GameControl c = sender as GameControl;
118     c.BorderStyle = BorderStyle.None;
119     }
120    
121     void game_ctrl_GotFocus(object sender, EventArgs e)
122     {
123     GameControl c = sender as GameControl;
124     c.BorderStyle = BorderStyle.FixedSingle;
125     }
126    
127     void game_ctrl_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
128     {
129     GameControl c = sender as GameControl;
130     //PlatformControl d = null;
131     //if (e.KeyCode == Keys.Right)
132     // d = platform_flow.GetNextControl(c, true) as PlatformControl;
133     //if (e.KeyCode == Keys.Left)
134     // d = platform_flow.GetNextControl(c, false) as PlatformControl;
135     //logger.WriteLine("Deteted key down: {0} for Platform: {1}", e.KeyCode, d.PlatformName);
136    
137     if (e.KeyCode == Keys.Enter)
138     {
139 william 23 IRomConfig config = c.Tag as IRomConfig;
140    
141     Process p = new Process();
142     p.StartInfo.FileName = config.Config.EmuPath;
143     p.StartInfo.Arguments = EmuConfigLoader.GetEMUOptions(config);
144     p.Start();
145 william 17 }
146     if (e.KeyCode == Keys.Back)
147     {
148     rom_flow.Visible = false;
149     platform_flow.Visible = true;
150     }
151     }
152    
153    
154    
155    
156 william 4 }
157     }

  ViewVC Help
Powered by ViewVC 1.1.22