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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 16 by william, Tue Apr 3 21:54:58 2012 UTC revision 17 by william, Wed Apr 4 01:32:37 2012 UTC
# Line 7  using System.Linq; Line 7  using System.Linq;
7  using System.Text;  using System.Text;
8  using System.Windows.Forms;  using System.Windows.Forms;
9  using EmuXPortal.Api;  using EmuXPortal.Api;
10    using EmuXPortal.Logging;
11    
12  namespace EmuXPortal  namespace EmuXPortal
13  {  {
14      public partial class Form1 : Form      public partial class Form1 : Form
15      {      {
16            IEmuConfig CurrentSelectedRom = null;
17            //PlatformControl CurrentPlatformControl = null;
18          public Form1()          public Form1()
19          {          {
20              InitializeComponent();              InitializeComponent();
21                platform_flow.Dock = DockStyle.Fill;
22                rom_flow.Dock = DockStyle.Fill;
23    
24              Config.LoadConfig();                          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          private void Form1_Shown(object sender, EventArgs e)          void platform_ctrl_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
45          {          {
46              Config.InitializePresentationForm(this);              PlatformControl c = sender as PlatformControl;
47              RomParser parser = new RomParser(Config.RomPath);              //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      }      }
148  }  }

Legend:
Removed from v.16  
changed lines
  Added in v.17

  ViewVC Help
Powered by ViewVC 1.1.22