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 |
|
|
if (e.KeyCode == Keys.Enter) |
49 |
|
|
{ |
50 |
|
|
// load this platform |
51 |
|
|
platform_flow.Visible = false; |
52 |
|
|
CurrentSelectedRom = c.Tag as IEmuConfig; |
53 |
|
|
rom_flow.Visible = true; |
54 |
|
|
rom_flow.BringToFront(); |
55 |
william |
25 |
} |
56 |
|
|
if (e.KeyCode == Keys.Back) |
57 |
|
|
{ |
58 |
|
|
this.Close(); |
59 |
|
|
} |
60 |
william |
30 |
if ((e.KeyCode >= Keys.A && e.KeyCode <= Keys.Z) || |
61 |
|
|
(e.KeyCode >= Keys.D0 && e.KeyCode <= Keys.D9)) |
62 |
|
|
{ |
63 |
|
|
char t = (char)e.KeyCode; |
64 |
|
|
foreach (Control cc in platform_flow.Controls) |
65 |
|
|
{ |
66 |
|
|
PlatformControl gc = cc as PlatformControl; |
67 |
|
|
if (gc.PlatformName.ToLower().StartsWith(t.ToString().ToLower())) |
68 |
|
|
{ |
69 |
|
|
platform_flow.ScrollControlIntoView(gc); |
70 |
|
|
gc.Select(); |
71 |
|
|
break; |
72 |
|
|
} |
73 |
|
|
} |
74 |
|
|
} |
75 |
william |
17 |
} |
76 |
|
|
|
77 |
|
|
private void platform_flow_VisibleChanged(object sender, EventArgs e) |
78 |
|
|
{ |
79 |
|
|
if (!platform_flow.Visible) return; |
80 |
|
|
platform_flow.Controls.Clear(); |
81 |
|
|
platform_flow.BringToFront(); |
82 |
|
|
PlatformParser parser = new PlatformParser(Config.RomPath); |
83 |
|
|
foreach (IEmuConfig config in parser.Platforms) |
84 |
|
|
{ |
85 |
|
|
PlatformControl platform_ctrl = new PlatformControl(); |
86 |
william |
19 |
platform_ctrl.Dock = DockStyle.Top; |
87 |
|
|
platform_ctrl.Width = this.Width - 10; |
88 |
william |
17 |
platform_ctrl.Tag = config; |
89 |
|
|
platform_ctrl.PlatformImage = config.PlatformImage; |
90 |
|
|
platform_ctrl.PlatformName = config.PlatformNameLong; |
91 |
|
|
platform_ctrl.PreviewKeyDown += new PreviewKeyDownEventHandler(platform_ctrl_PreviewKeyDown); |
92 |
|
|
platform_flow.Controls.Add(platform_ctrl); |
93 |
william |
19 |
//platform_flow.SetFlowBreak(platform_ctrl, true); |
94 |
william |
17 |
platform_ctrl.GotFocus += new EventHandler(platform_ctrl_GotFocus); |
95 |
|
|
platform_ctrl.LostFocus += new EventHandler(platform_ctrl_LostFocus); |
96 |
|
|
//CurrentPlatformControl = platform_flow.Controls[0] as PlatformControl; |
97 |
|
|
} |
98 |
|
|
platform_flow.Controls[0].Select(); |
99 |
william |
19 |
(platform_flow.Controls[0] as PlatformControl).BorderStyle = BorderStyle.FixedSingle; |
100 |
|
|
|
101 |
william |
17 |
} |
102 |
|
|
|
103 |
|
|
private void rom_flow_VisibleChanged(object sender, EventArgs e) |
104 |
|
|
{ |
105 |
|
|
if (!rom_flow.Visible) return; |
106 |
|
|
rom_flow.Controls.Clear(); |
107 |
|
|
rom_flow.BringToFront(); |
108 |
william |
29 |
RomParser parser = new RomParser(CurrentSelectedRom); |
109 |
william |
17 |
foreach (IRomConfig config in parser.Roms) |
110 |
|
|
{ |
111 |
|
|
GameControl game_ctrl = new GameControl(); |
112 |
william |
19 |
game_ctrl.Dock = DockStyle.Top; |
113 |
|
|
game_ctrl.Width = this.Width - 10; |
114 |
william |
17 |
game_ctrl.Tag = config; |
115 |
|
|
game_ctrl.GameImage = config.RomImage; |
116 |
|
|
game_ctrl.GameName = config.RomTitle; |
117 |
|
|
game_ctrl.PreviewKeyDown += new PreviewKeyDownEventHandler(game_ctrl_PreviewKeyDown); |
118 |
|
|
rom_flow.Controls.Add(game_ctrl); |
119 |
william |
19 |
//rom_flow.SetFlowBreak(game_ctrl, true); |
120 |
william |
17 |
game_ctrl.GotFocus += new EventHandler(game_ctrl_GotFocus); |
121 |
|
|
game_ctrl.LostFocus += new EventHandler(game_ctrl_LostFocus); |
122 |
|
|
} |
123 |
|
|
rom_flow.Controls[0].Select(); |
124 |
|
|
(rom_flow.Controls[0] as GameControl).BorderStyle = BorderStyle.FixedSingle; |
125 |
|
|
} |
126 |
|
|
|
127 |
|
|
void game_ctrl_LostFocus(object sender, EventArgs e) |
128 |
|
|
{ |
129 |
|
|
GameControl c = sender as GameControl; |
130 |
|
|
c.BorderStyle = BorderStyle.None; |
131 |
|
|
} |
132 |
|
|
|
133 |
|
|
void game_ctrl_GotFocus(object sender, EventArgs e) |
134 |
|
|
{ |
135 |
|
|
GameControl c = sender as GameControl; |
136 |
|
|
c.BorderStyle = BorderStyle.FixedSingle; |
137 |
|
|
} |
138 |
|
|
|
139 |
|
|
void game_ctrl_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) |
140 |
|
|
{ |
141 |
|
|
GameControl c = sender as GameControl; |
142 |
|
|
if (e.KeyCode == Keys.Enter) |
143 |
|
|
{ |
144 |
william |
23 |
IRomConfig config = c.Tag as IRomConfig; |
145 |
|
|
|
146 |
|
|
Process p = new Process(); |
147 |
|
|
p.StartInfo.FileName = config.Config.EmuPath; |
148 |
|
|
p.StartInfo.Arguments = EmuConfigLoader.GetEMUOptions(config); |
149 |
|
|
p.Start(); |
150 |
william |
17 |
} |
151 |
|
|
if (e.KeyCode == Keys.Back) |
152 |
|
|
{ |
153 |
|
|
rom_flow.Visible = false; |
154 |
|
|
platform_flow.Visible = true; |
155 |
|
|
} |
156 |
william |
30 |
|
157 |
|
|
if ( (e.KeyCode >= Keys.A && e.KeyCode <= Keys.Z) || |
158 |
|
|
(e.KeyCode >= Keys.D0 && e.KeyCode <= Keys.D9)) |
159 |
|
|
{ |
160 |
|
|
char t = (char)e.KeyCode; |
161 |
|
|
foreach (Control cc in rom_flow.Controls) |
162 |
|
|
{ |
163 |
|
|
GameControl gc = cc as GameControl; |
164 |
|
|
if (gc.GameName.ToLower().StartsWith(t.ToString().ToLower())) |
165 |
|
|
{ |
166 |
|
|
rom_flow.ScrollControlIntoView(gc); |
167 |
|
|
gc.Select(); |
168 |
|
|
break; |
169 |
|
|
} |
170 |
|
|
} |
171 |
|
|
} |
172 |
william |
25 |
} |
173 |
william |
4 |
} |
174 |
|
|
} |