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

Annotation of /trunk/EmuXPortal/Form1.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 17 - (hide annotations) (download)
Wed Apr 4 01:32:37 2012 UTC (8 years, 3 months ago) by william
File size: 5963 byte(s)
+ add entries for platforms
+ add entries for roms
+ add key events

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

  ViewVC Help
Powered by ViewVC 1.1.22