/[EmuXPortal]/branches/mono/EmuXPortal/Form1.cs
ViewVC logotype

Contents of /branches/mono/EmuXPortal/Form1.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 19 - (show annotations) (download)
Wed Apr 4 01:55:32 2012 UTC (7 years, 10 months ago) by william
Original Path: trunk/EmuXPortal/Form1.cs
File size: 6314 byte(s)
set positioning of ui elements

1 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 using EmuXPortal.Api;
10 using EmuXPortal.Logging;
11
12 namespace EmuXPortal
13 {
14 public partial class Form1 : Form
15 {
16 IEmuConfig CurrentSelectedRom = null;
17 //PlatformControl CurrentPlatformControl = null;
18 public Form1()
19 {
20 InitializeComponent();
21 platform_flow.Dock = DockStyle.Fill;
22 rom_flow.Dock = DockStyle.Fill;
23
24 Config.LoadConfig();
25 }
26
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
38 void platform_ctrl_GotFocus(object sender, EventArgs e)
39 {
40 PlatformControl c = sender as PlatformControl;
41 c.BorderStyle = BorderStyle.FixedSingle;
42 }
43
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.Dock = DockStyle.Top;
74 platform_ctrl.Width = this.Width - 10;
75 platform_ctrl.Tag = config;
76 platform_ctrl.PlatformImage = config.PlatformImage;
77 platform_ctrl.PlatformName = config.PlatformNameLong;
78 platform_ctrl.PreviewKeyDown += new PreviewKeyDownEventHandler(platform_ctrl_PreviewKeyDown);
79 platform_flow.Controls.Add(platform_ctrl);
80 //platform_flow.SetFlowBreak(platform_ctrl, true);
81 platform_ctrl.GotFocus += new EventHandler(platform_ctrl_GotFocus);
82 platform_ctrl.LostFocus += new EventHandler(platform_ctrl_LostFocus);
83 //CurrentPlatformControl = platform_flow.Controls[0] as PlatformControl;
84 }
85 platform_flow.Controls[0].Select();
86 (platform_flow.Controls[0] as PlatformControl).BorderStyle = BorderStyle.FixedSingle;
87
88 }
89
90 private void rom_flow_VisibleChanged(object sender, EventArgs e)
91 {
92 if (!rom_flow.Visible) return;
93 rom_flow.Controls.Clear();
94 rom_flow.BringToFront();
95 RomParser parser = new RomParser(string.Format(@"{0}\{1}", CurrentSelectedRom.EmuRomPath, "Roms"), CurrentSelectedRom.Extenstions);
96 foreach (IRomConfig config in parser.Roms)
97 {
98 GameControl game_ctrl = new GameControl();
99 game_ctrl.Dock = DockStyle.Top;
100 game_ctrl.Width = this.Width - 10;
101 game_ctrl.Tag = config;
102 game_ctrl.GameImage = config.RomImage;
103 game_ctrl.GameName = config.RomTitle;
104 game_ctrl.PreviewKeyDown += new PreviewKeyDownEventHandler(game_ctrl_PreviewKeyDown);
105 rom_flow.Controls.Add(game_ctrl);
106 //rom_flow.SetFlowBreak(game_ctrl, true);
107 game_ctrl.GotFocus += new EventHandler(game_ctrl_GotFocus);
108 game_ctrl.LostFocus += new EventHandler(game_ctrl_LostFocus);
109 }
110 rom_flow.Controls[0].Select();
111 (rom_flow.Controls[0] as GameControl).BorderStyle = BorderStyle.FixedSingle;
112 }
113
114 void game_ctrl_LostFocus(object sender, EventArgs e)
115 {
116 GameControl c = sender as GameControl;
117 c.BorderStyle = BorderStyle.None;
118 }
119
120 void game_ctrl_GotFocus(object sender, EventArgs e)
121 {
122 GameControl c = sender as GameControl;
123 c.BorderStyle = BorderStyle.FixedSingle;
124 }
125
126 void game_ctrl_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
127 {
128 GameControl c = sender as GameControl;
129 //PlatformControl d = null;
130 //if (e.KeyCode == Keys.Right)
131 // d = platform_flow.GetNextControl(c, true) as PlatformControl;
132 //if (e.KeyCode == Keys.Left)
133 // d = platform_flow.GetNextControl(c, false) as PlatformControl;
134 //logger.WriteLine("Deteted key down: {0} for Platform: {1}", e.KeyCode, d.PlatformName);
135
136 if (e.KeyCode == Keys.Enter)
137 {
138 //// load this platform
139 //platform_flow.Visible = false;
140 //CurrentSelectedRom = c.Tag as IEmuConfig;
141 //rom_flow.Visible = true;
142 //rom_flow.BringToFront();
143 }
144 if (e.KeyCode == Keys.Back)
145 {
146 rom_flow.Visible = false;
147 platform_flow.Visible = true;
148 }
149 }
150
151
152
153
154 }
155 }

  ViewVC Help
Powered by ViewVC 1.1.22