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

Annotation of /trunk/EmuXPortal/Form1.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 29 - (hide annotations) (download)
Wed Apr 4 04:13:17 2012 UTC (8 years, 6 months ago) by william
File size: 5585 byte(s)
+ speed up rom parsing by passing in the EMUConfig (rather than re-generating it each time)

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 17 }
61    
62     private void platform_flow_VisibleChanged(object sender, EventArgs e)
63     {
64     if (!platform_flow.Visible) return;
65     platform_flow.Controls.Clear();
66     platform_flow.BringToFront();
67     PlatformParser parser = new PlatformParser(Config.RomPath);
68     foreach (IEmuConfig config in parser.Platforms)
69     {
70     PlatformControl platform_ctrl = new PlatformControl();
71 william 19 platform_ctrl.Dock = DockStyle.Top;
72     platform_ctrl.Width = this.Width - 10;
73 william 17 platform_ctrl.Tag = config;
74     platform_ctrl.PlatformImage = config.PlatformImage;
75     platform_ctrl.PlatformName = config.PlatformNameLong;
76     platform_ctrl.PreviewKeyDown += new PreviewKeyDownEventHandler(platform_ctrl_PreviewKeyDown);
77     platform_flow.Controls.Add(platform_ctrl);
78 william 19 //platform_flow.SetFlowBreak(platform_ctrl, true);
79 william 17 platform_ctrl.GotFocus += new EventHandler(platform_ctrl_GotFocus);
80     platform_ctrl.LostFocus += new EventHandler(platform_ctrl_LostFocus);
81     //CurrentPlatformControl = platform_flow.Controls[0] as PlatformControl;
82     }
83     platform_flow.Controls[0].Select();
84 william 19 (platform_flow.Controls[0] as PlatformControl).BorderStyle = BorderStyle.FixedSingle;
85    
86 william 17 }
87    
88     private void rom_flow_VisibleChanged(object sender, EventArgs e)
89     {
90     if (!rom_flow.Visible) return;
91     rom_flow.Controls.Clear();
92     rom_flow.BringToFront();
93 william 29 RomParser parser = new RomParser(CurrentSelectedRom);
94 william 17 foreach (IRomConfig config in parser.Roms)
95     {
96     GameControl game_ctrl = new GameControl();
97 william 19 game_ctrl.Dock = DockStyle.Top;
98     game_ctrl.Width = this.Width - 10;
99 william 17 game_ctrl.Tag = config;
100     game_ctrl.GameImage = config.RomImage;
101     game_ctrl.GameName = config.RomTitle;
102     game_ctrl.PreviewKeyDown += new PreviewKeyDownEventHandler(game_ctrl_PreviewKeyDown);
103     rom_flow.Controls.Add(game_ctrl);
104 william 19 //rom_flow.SetFlowBreak(game_ctrl, true);
105 william 17 game_ctrl.GotFocus += new EventHandler(game_ctrl_GotFocus);
106     game_ctrl.LostFocus += new EventHandler(game_ctrl_LostFocus);
107     }
108     rom_flow.Controls[0].Select();
109     (rom_flow.Controls[0] as GameControl).BorderStyle = BorderStyle.FixedSingle;
110     }
111    
112     void game_ctrl_LostFocus(object sender, EventArgs e)
113     {
114     GameControl c = sender as GameControl;
115     c.BorderStyle = BorderStyle.None;
116     }
117    
118     void game_ctrl_GotFocus(object sender, EventArgs e)
119     {
120     GameControl c = sender as GameControl;
121     c.BorderStyle = BorderStyle.FixedSingle;
122     }
123    
124     void game_ctrl_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
125     {
126     GameControl c = sender as GameControl;
127     if (e.KeyCode == Keys.Enter)
128     {
129 william 23 IRomConfig config = c.Tag as IRomConfig;
130    
131     Process p = new Process();
132     p.StartInfo.FileName = config.Config.EmuPath;
133     p.StartInfo.Arguments = EmuConfigLoader.GetEMUOptions(config);
134     p.Start();
135 william 17 }
136     if (e.KeyCode == Keys.Back)
137     {
138     rom_flow.Visible = false;
139     platform_flow.Visible = true;
140     }
141 william 25 }
142 william 4 }
143     }

  ViewVC Help
Powered by ViewVC 1.1.22