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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 180 - (hide annotations) (download)
Mon Aug 4 07:31:53 2014 UTC (5 years, 11 months ago) by william
Original Path: trunk/EmuXPortal/Form1.cs
File size: 28348 byte(s)

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 60 using System.Reflection;
13     using System.Threading;
14 william 4
15     namespace EmuXPortal
16     {
17     public partial class Form1 : Form
18     {
19 william 17 IEmuConfig CurrentSelectedRom = null;
20 william 31 PlatformControl CurrentPlatformControl = null;
21     GameControl CurrentGameControl = null;
22 william 112 logger log = new logger();
23 william 4 public Form1()
24     {
25     InitializeComponent();
26 william 17 platform_flow.Dock = DockStyle.Fill;
27     rom_flow.Dock = DockStyle.Fill;
28 william 112 log.OpenLog();
29 william 4 }
30 william 17
31     private void Form1_Load(object sender, EventArgs e)
32     {
33 william 112 Config.LoadConfig(log);
34 william 172 Config.InitializePresentationForm(log,this);
35 william 17 }
36 william 60 private void Form1_Shown(object sender, EventArgs e) { platform_flow.Visible = true; Cursor.Hide(); }
37 william 17 void platform_ctrl_LostFocus(object sender, EventArgs e)
38     {
39     PlatformControl c = sender as PlatformControl;
40     c.BorderStyle = BorderStyle.None;
41     }
42 william 13
43 william 17 void platform_ctrl_GotFocus(object sender, EventArgs e)
44 william 13 {
45 william 17 PlatformControl c = sender as PlatformControl;
46     c.BorderStyle = BorderStyle.FixedSingle;
47 william 31 CurrentPlatformControl = c;
48 william 13 }
49 william 168 void game_ctrl_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
50     {
51     GameControl c = sender as GameControl;
52 william 17
53 william 168 int changeAmount = 0;
54     int currentPosition = 0;
55 william 180 if (e.KeyCode == Keys.Up)
56     {
57     int index = 0;
58     var ctl = game_ctrl_get_selected(out index);
59     if (index == 0)
60     {
61     rom_flow.Controls[index].Select();
62     rom_flow.ScrollControlIntoView(rom_flow.Controls[index]);
63     }
64     else
65     {
66     rom_flow.Controls[index].Select();
67     rom_flow.ScrollControlIntoView(rom_flow.Controls[index]);
68     }
69     }
70     if (e.KeyCode == Keys.Down)
71     {
72     int index = 0;
73     var ctl = game_ctrl_get_selected(out index);
74     if (index == rom_flow.Controls.Count)
75     {
76     rom_flow.Controls[0].Select();
77     rom_flow.ScrollControlIntoView(rom_flow.Controls[0]);
78     }
79     else
80     {
81     rom_flow.Controls[index].Select();
82     rom_flow.ScrollControlIntoView(rom_flow.Controls[index]);
83     }
84     }
85 william 168
86     if (e.KeyCode == Keys.F && e.Modifiers.HasFlag(Keys.Control))
87     {
88     IRomConfig config = c.Tag as IRomConfig;
89     if (config == null)
90     {
91     log.WriteLine("Unable to add/remove from/to favorites (config is null): {0} [{1}]", config.RomTitle, config.RomFile);
92     }
93     else
94     {
95 william 169 var isFavorite = RomFavorite.IsFavorite(log, config);
96 william 168 if (isFavorite)
97     {
98     // add to favorites
99     log.WriteLine("Removing from favorites: {0} [{1}]", config.RomTitle, config.RomFile);
100 william 169 if (!RomFavorite.RemoveFavorite(log, config))
101 william 168 {
102     log.WriteLine("Failed to remove from favorites: {0} [{1}]", config.RomTitle, config.RomFile);
103     }
104     else
105     {
106     log.WriteLine("Removed from favorites: {0} [{1}]", config.RomTitle, config.RomFile);
107 william 177 if (config.Config.PlatformNameShort == "Favorites")
108 william 176 {
109 william 177 var parent = c.Parent;
110     if (parent != null)
111 william 176 {
112 william 177 parent.Controls.Remove(c);
113     if (parent.Controls.Count > 0)
114 william 176 {
115 william 177 var next_ctrl = parent.Controls[0];
116     if (next_ctrl != null)
117     {
118     next_ctrl.Select();
119     }
120 william 176 }
121     }
122 william 177 }
123 william 168 }
124     }
125     else
126     {
127     // add to favorites
128     log.WriteLine("Adding to favorites: {0} [{1}]", config.RomTitle, config.RomFile);
129 william 169 if (!RomFavorite.AddFavorite(log,config))
130 william 168 {
131     log.WriteLine("Failed to add to favorites: {0} [{1}]", config.RomTitle, config.RomFile);
132     }
133     else
134     {
135     log.WriteLine("Added to favorites: {0} [{1}]", config.RomTitle, config.RomFile);
136     }
137     }
138     log.WriteLine("Updateing favorites");
139 william 169 if (!RomFavorite.UpdateFavorites(log))
140 william 168 {
141     log.WriteLine("Failed to update favorites");
142     }
143     else
144     {
145     log.WriteLine("Updated favorites");
146     }
147     }
148     return; // stop processing other keys
149    
150     }
151     if (e.KeyCode == Keys.Home)
152     {
153     rom_flow.Controls[0].Select();
154     rom_flow.ScrollControlIntoView(rom_flow.Controls[0]);
155     }
156     if (e.KeyCode == Keys.End)
157     {
158     rom_flow.Controls[rom_flow.Controls.Count - 1].Select();
159     rom_flow.ScrollControlIntoView(rom_flow.Controls[rom_flow.Controls.Count - 1]);
160     }
161     if (e.KeyCode == Keys.PageUp)
162     {
163     changeAmount = rom_flow.VerticalScroll.LargeChange;
164     currentPosition = rom_flow.VerticalScroll.Value;
165     if ((currentPosition - changeAmount) > rom_flow.VerticalScroll.Minimum)
166     {
167     try
168     {
169 william 179 rom_flow.VerticalScroll.Value -= changeAmount;
170 william 168 }
171     catch
172     {
173     rom_flow.Controls[0].Select();
174 william 179 rom_flow.ScrollControlIntoView(rom_flow.Controls[0]);
175 william 168 rom_flow.PerformLayout();
176     return;
177     }
178     }
179     else
180     {
181     rom_flow.Controls[0].Select();
182 william 179 rom_flow.ScrollControlIntoView(rom_flow.Controls[0]);
183 william 168 }
184     GameControl s = game_ctrl_get_last_visible();
185     s.Select();
186     rom_flow.ScrollControlIntoView(s);
187     rom_flow.PerformLayout();
188     }
189     if (e.KeyCode == Keys.PageDown)
190     {
191     changeAmount = rom_flow.VerticalScroll.LargeChange;
192     currentPosition = rom_flow.VerticalScroll.Value;
193     if ((currentPosition - changeAmount) < rom_flow.VerticalScroll.Maximum)
194     {
195     rom_flow.VerticalScroll.Value += changeAmount;
196     }
197     else
198     {
199     rom_flow.VerticalScroll.Value = rom_flow.VerticalScroll.Maximum;
200     }
201     GameControl s = game_ctrl_get_last_visible();
202     s.Select();
203     rom_flow.ScrollControlIntoView(s);
204     rom_flow.PerformLayout();
205     }
206    
207     if (e.KeyCode == Keys.Enter)
208     {
209     IRomConfig config = c.Tag as IRomConfig;
210    
211     Process p = new Process();
212    
213     p.StartInfo.FileName = config.Config.GameExe == "" ? config.Config.EmuPath : config.Config.GameExe;
214     p.StartInfo.Arguments = config.Config.GameExeArgs == "" ? EmuConfigLoader.GetEMUOptions(log, config) : config.Config.GameExeArgs;
215     p.Start();
216    
217     // minimize EmuXPortal
218     this.WindowState = FormWindowState.Minimized;
219     // wait for exit of game
220     p.WaitForExit();
221     // maximize EmuXPortal
222     this.WindowState = FormWindowState.Maximized;
223     }
224     if (e.KeyCode == Keys.Back)
225     {
226     rom_flow.Visible = false;
227     platform_flow.Visible = true;
228     }
229    
230     if ((e.KeyCode >= Keys.A && e.KeyCode <= Keys.Z) ||
231     (e.KeyCode >= Keys.D0 && e.KeyCode <= Keys.D9))
232     {
233     char t = (char)e.KeyCode;
234     GameControl ctrl = (rom_flow.GetNextControl(CurrentPlatformControl, true) as GameControl);
235     if (ctrl == null) { ctrl = (rom_flow.GetNextControl(rom_flow.Controls[0], true) as GameControl); }
236     bool found = false;
237     GameControl pc = CurrentGameControl;
238     bool wrapped = false;
239     bool not_found = true;
240     while (!found)
241     {
242     if (wrapped)
243     {
244     foreach (Control ctl in rom_flow.Controls)
245     {
246     GameControl p_ctl = ctl as GameControl; if (p_ctl.GameName.ToLower().StartsWith(t.ToString().ToLower())) { not_found = false; }
247     }
248     if (not_found) { found = true; }
249     }
250     ctrl = (rom_flow.GetNextControl(pc, true) as GameControl);
251     if (ctrl == null)
252     {
253     ctrl = rom_flow.Controls[0] as GameControl;
254     wrapped = true;
255     }
256     if (ctrl.GameName.ToLower().StartsWith(t.ToString().ToLower()))
257     {
258     rom_flow.ScrollControlIntoView(ctrl);
259     ctrl.Select();
260     found = true;
261     }
262     pc = ctrl;
263     }
264     }
265     }
266 william 17 void platform_ctrl_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
267     {
268     PlatformControl c = sender as PlatformControl;
269 william 60 int changeAmount = 0;
270     int currentPosition = 0;
271 william 180 if (e.KeyCode == Keys.Up)
272     {
273     int index = 0;
274     var ctl = platform_ctrl_get_selected(out index);
275     if (index == 0)
276     {
277     platform_flow.Controls[index].Select();
278     platform_flow.ScrollControlIntoView(platform_flow.Controls[index]);
279     }
280     else
281     {
282     platform_flow.Controls[index].Select();
283     platform_flow.ScrollControlIntoView(platform_flow.Controls[index]);
284     }
285     }
286     if (e.KeyCode == Keys.Down)
287     {
288     int index = 0;
289     var ctl = platform_ctrl_get_selected(out index);
290     if (index == platform_flow.Controls.Count)
291     {
292     platform_flow.Controls[0].Select();
293     platform_flow.ScrollControlIntoView(platform_flow.Controls[0]);
294     }
295     else
296     {
297     platform_flow.Controls[index ].Select();
298     platform_flow.ScrollControlIntoView(platform_flow.Controls[index]);
299     }
300     }
301 william 60 if (e.KeyCode == Keys.Home)
302     {
303     platform_flow.Controls[0].Select();
304     platform_flow.ScrollControlIntoView(platform_flow.Controls[0]);
305     }
306     if (e.KeyCode == Keys.End)
307     {
308     platform_flow.Controls[platform_flow.Controls.Count -1].Select();
309     platform_flow.ScrollControlIntoView(platform_flow.Controls[platform_flow.Controls.Count - 1]);
310     }
311     if (e.KeyCode == Keys.PageUp)
312     {
313     changeAmount = platform_flow.VerticalScroll.LargeChange;
314     currentPosition = platform_flow.VerticalScroll.Value;
315     if ((currentPosition - changeAmount) > platform_flow.VerticalScroll.Minimum)
316     {
317     platform_flow.VerticalScroll.Value -= changeAmount;
318     }
319     else
320     {
321     platform_flow.VerticalScroll.Value = platform_flow.VerticalScroll.Minimum;
322     }
323     PlatformControl s = platform_ctrl_get_last_visible();
324     s.Select();
325     platform_flow.ScrollControlIntoView(s);
326     platform_flow.PerformLayout();
327     }
328     if (e.KeyCode == Keys.PageDown)
329 william 180 {
330 william 60 changeAmount = platform_flow.VerticalScroll.LargeChange;
331     currentPosition = platform_flow.VerticalScroll.Value;
332     if ((currentPosition - changeAmount) < platform_flow.VerticalScroll.Maximum)
333     {
334     try
335     {
336     platform_flow.VerticalScroll.Value += changeAmount;
337     }
338     catch
339     {
340     platform_flow.Controls[0].Select();
341     platform_flow.ScrollControlIntoView(platform_flow.Controls[0]);
342     rom_flow.PerformLayout();
343     return;
344     }
345     }
346     else
347     {
348     platform_flow.Controls[0].Select();
349     platform_flow.ScrollControlIntoView(platform_flow.Controls[0]);
350     }
351     PlatformControl s = platform_ctrl_get_last_visible();
352     s.Select();
353     platform_flow.ScrollControlIntoView(s);
354     platform_flow.PerformLayout();
355     }
356 william 17 if (e.KeyCode == Keys.Enter)
357     {
358     // load this platform
359     platform_flow.Visible = false;
360     CurrentSelectedRom = c.Tag as IEmuConfig;
361     rom_flow.Visible = true;
362     rom_flow.BringToFront();
363 william 25 }
364     if (e.KeyCode == Keys.Back)
365     {
366     this.Close();
367     }
368 william 30 if ((e.KeyCode >= Keys.A && e.KeyCode <= Keys.Z) ||
369     (e.KeyCode >= Keys.D0 && e.KeyCode <= Keys.D9))
370     {
371     char t = (char)e.KeyCode;
372 william 31 PlatformControl ctrl = (platform_flow.GetNextControl(CurrentPlatformControl, true) as PlatformControl);
373     if (ctrl == null) { ctrl = (platform_flow.GetNextControl(platform_flow.Controls[0], true) as PlatformControl); }
374     bool found = false;
375     PlatformControl pc = CurrentPlatformControl;
376     bool wrapped = false;
377     bool not_found = true;
378     while (!found)
379 william 30 {
380 william 31 if (wrapped)
381 william 30 {
382 william 31 foreach (Control ctl in platform_flow.Controls)
383     {
384     PlatformControl p_ctl = ctl as PlatformControl; if (p_ctl.PlatformName.ToLower().StartsWith(t.ToString().ToLower())) { not_found = false; }
385     }
386     if (not_found) { found = true; }
387 william 30 }
388 william 31 ctrl = (platform_flow.GetNextControl(pc, true) as PlatformControl);
389     if (ctrl == null)
390     {
391     ctrl = platform_flow.Controls[0] as PlatformControl;
392     wrapped = true;
393     }
394     if (ctrl.PlatformName.ToLower().StartsWith(t.ToString().ToLower()))
395     {
396     platform_flow.ScrollControlIntoView(ctrl);
397     ctrl.Select();
398     found = true;
399     }
400     pc = ctrl;
401 william 30 }
402     }
403 william 17 }
404    
405     private void platform_flow_VisibleChanged(object sender, EventArgs e)
406     {
407     if (!platform_flow.Visible) return;
408     platform_flow.Controls.Clear();
409     platform_flow.BringToFront();
410 william 37 Stopwatch t = new Stopwatch();
411     t.Start();
412 william 60 platformWorker.RunWorkerAsync(t);
413 william 17 }
414    
415     private void rom_flow_VisibleChanged(object sender, EventArgs e)
416     {
417     if (!rom_flow.Visible) return;
418     rom_flow.Controls.Clear();
419     rom_flow.BringToFront();
420 william 37 Stopwatch t = new Stopwatch();
421     t.Start();
422 william 60 gameWorker.RunWorkerAsync(t);
423 william 17 }
424    
425     void game_ctrl_LostFocus(object sender, EventArgs e)
426     {
427     GameControl c = sender as GameControl;
428     c.BorderStyle = BorderStyle.None;
429     }
430    
431     void game_ctrl_GotFocus(object sender, EventArgs e)
432     {
433     GameControl c = sender as GameControl;
434     c.BorderStyle = BorderStyle.FixedSingle;
435 william 31 CurrentGameControl = c;
436 william 17 }
437    
438 william 60 private GameControl game_ctrl_get_last_visible()
439     {
440     GameControl s = new GameControl();
441     foreach (GameControl c in rom_flow.Controls)
442     {
443     if (c.Bounds.IntersectsWith(rom_flow.Bounds))
444     s = c;
445     }
446     return s;
447     }
448 william 180 private GameControl game_ctrl_get_selected(out int index)
449     {
450     index = rom_flow.Controls.IndexOf(CurrentGameControl);
451     return CurrentGameControl;
452     }
453     private PlatformControl platform_ctrl_get_selected(out int index)
454     {
455     index = platform_flow.Controls.IndexOf(CurrentPlatformControl);
456     return CurrentPlatformControl;
457     }
458 william 60 private PlatformControl platform_ctrl_get_last_visible()
459     {
460     PlatformControl s = new PlatformControl();
461     foreach (PlatformControl c in platform_flow.Controls)
462     {
463     if (c.Bounds.IntersectsWith(platform_flow.Bounds))
464     s = c;
465     }
466     return s;
467     }
468 william 168
469 william 60
470     #region Background Workers
471    
472     private int GetFormWidth()
473     {
474     if (this.InvokeRequired)
475     {
476     return Convert.ToInt32(this.Invoke((MethodInvoker)delegate() { GetFormWidth(); }));
477     }
478     else
479     {
480     return this.Width;
481     }
482     }
483 william 113 //private void AddPlatformControl(Control c)
484     //{
485     // if (platform_flow.InvokeRequired) { platform_flow.Invoke((MethodInvoker)delegate() { AddPlatformControl(c); }); }
486     // else
487     // {
488     // platform_flow.Controls.Add(c);
489     // }
490     //}
491     //private void UpdatePlatformControls()
492     //{
493     // //if (platform_flow.InvokeRequired) { platform_flow.Invoke((MethodInvoker)delegate() { UpdatePlatformControls(); }); }
494     // //else { this.Update(); }
495     //}
496     //private void AddGameControl(Control c)
497     //{
498     // if (rom_flow.InvokeRequired) { rom_flow.Invoke((MethodInvoker)delegate() { AddGameControl(c); }); }
499     // else
500     // {
501     // rom_flow.Controls.Add(c);
502     // }
503     //}
504     //private void UpdateGameControls()
505     //{
506     // //if (rom_flow.InvokeRequired) { rom_flow.Invoke((MethodInvoker)delegate() { UpdateGameControls(); }); }
507     // //else { this.Update(); }
508     //}
509 william 60 #region gameWorker
510 william 110 private static Image DefaultGameImage = Properties.Resources.DefaultGameImage;
511 william 137 private object gameimage_lock = new object();
512 william 60 private void gameWorker_DoWork(object sender, DoWorkEventArgs e)
513     {
514     Stopwatch t = e.Argument as Stopwatch;
515 william 112 RomParser parser = new RomParser(log, CurrentSelectedRom);
516 william 60
517     ProgressBar bar = new ProgressBar();
518 william 113 if (rom_flow.InvokeRequired) { rom_flow.Invoke((MethodInvoker)delegate() { rom_flow.Controls.Add(bar); }); }
519     else { rom_flow.Controls.Add(bar); }
520     //UpdateGameControls();
521     //Application.DoEvents();
522     //Thread.Sleep(10);
523 william 60 bar.Invoke(new MethodInvoker(delegate
524     {
525     //bar.Message = "Please Wait...";
526     //bar.ShowPercentageLabel = true;
527     bar.Margin = new System.Windows.Forms.Padding(0);
528     bar.Size = new Size(GetFormWidth() - 25, 100);
529     }));
530    
531     double count = 0;
532     double total_count = parser.Roms.Count;
533     foreach (IRomConfig config in parser.Roms)
534     {
535     GameControl game_ctrl = new GameControl();
536     game_ctrl.Dock = DockStyle.Top;
537     game_ctrl.Width = this.Width - 10;
538     game_ctrl.Tag = config;
539 william 137 try
540     {
541     lock (gameimage_lock)
542     {
543     game_ctrl.GameImage = config.RomImage == null ? (Image)DefaultGameImage.Clone() : (Image)config.RomImage.Clone();
544     config.ReleaseRomImageResource();
545     }
546     }
547     catch (Exception ex)
548     {
549     throw ex;
550 william 178 }
551     if (CurrentSelectedRom.PlatformNameShort == "Favorites")
552     {
553     //game_ctrl.GameName = config.RomTitle;
554     game_ctrl.GameName = RomFavorite.GetRomTitleFromConfig(config);
555     }
556     else
557     {
558     game_ctrl.GameName = config.RomTitle;
559 william 137 }
560 william 60 game_ctrl.PreviewKeyDown += new PreviewKeyDownEventHandler(game_ctrl_PreviewKeyDown);
561     game_ctrl.GotFocus += new EventHandler(game_ctrl_GotFocus);
562     game_ctrl.LostFocus += new EventHandler(game_ctrl_LostFocus);
563 william 113 if (rom_flow.InvokeRequired) { rom_flow.Invoke((MethodInvoker)delegate() { rom_flow.Controls.Add(game_ctrl); }); }
564     else { rom_flow.Controls.Add(game_ctrl); }
565     //UpdateGameControls();
566     //Application.DoEvents();
567     //int percent = (int)(100.0 * (count / total_count));
568     //log.WriteLine("gameWorker_DoWork(): count={0} total={1} percent={2}", count, total_count, (int)(100.0 * (count / total_count)));
569 william 60 bar.Invoke(new MethodInvoker(delegate
570     {
571 william 113 bar.Value = (int)(100.0 * (count / total_count));
572 william 60 }));
573     count++;
574     }
575     e.Result = t;
576 william 105 parser.Dispose();
577 william 60 }
578     private void gameWorker_ProgressChanged(object sender, ProgressChangedEventArgs e) { }
579     private void gameWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
580     {
581     Stopwatch t = e.Result as Stopwatch;
582     rom_flow.Controls.RemoveAt(0);
583     rom_flow.Controls[0].Select();
584     (rom_flow.Controls[0] as GameControl).BorderStyle = BorderStyle.FixedSingle;
585     t.Stop();
586 william 112 log.WriteLine("RomParser took: {0}s to parse roms", (int)t.Elapsed.TotalSeconds);
587 william 60 }
588     #endregion
589     #region platformWorker
590 william 110 private static Image DefaultPlatformImage = Properties.Resources.DefaultPlatformImage;
591 william 137 private object platformimage_lock = new object();
592 william 60 private void platformWorker_DoWork(object sender, DoWorkEventArgs e)
593     {
594     Stopwatch t = e.Argument as Stopwatch;
595 william 112 PlatformParser parser = new PlatformParser(log, Config.RomPath);
596 william 60 double count = 0;
597     double total_count = parser.Platforms.Count;
598     ProgressBar bar = new ProgressBar();
599 william 113 if (platform_flow.InvokeRequired) { platform_flow.Invoke((MethodInvoker)delegate() { platform_flow.Controls.Add(bar); }); }
600     else { platform_flow.Controls.Add(bar); }
601     //UpdatePlatformControls();
602     //Application.DoEvents();
603     //Thread.Sleep(10);
604 william 60 bar.Invoke(new MethodInvoker(delegate
605     {
606     bar.Margin = new System.Windows.Forms.Padding(0);
607     bar.Size = new Size(GetFormWidth() - 25, 100);
608     }));
609     foreach (IEmuConfig config in parser.Platforms)
610     {
611     PlatformControl platform_ctrl = new PlatformControl();
612     platform_ctrl.Dock = DockStyle.Top;
613     platform_ctrl.Width = this.Width - 10;
614     platform_ctrl.Tag = config;
615 william 137 try
616     {
617     lock (platformimage_lock)
618     {
619 william 138 platform_ctrl.PlatformImage = config.PlatformImage == null ? (Image)DefaultPlatformImage.Clone() : (Image)config.PlatformImage.Clone();
620 william 137 config.ReleasePlatformImageResource();
621     }
622     }
623     catch (Exception ex)
624     {
625     throw ex;
626     }
627 william 60 platform_ctrl.PlatformName = config.ToString();
628     platform_ctrl.PreviewKeyDown += new PreviewKeyDownEventHandler(platform_ctrl_PreviewKeyDown);
629     platform_ctrl.GotFocus += new EventHandler(platform_ctrl_GotFocus);
630     platform_ctrl.LostFocus += new EventHandler(platform_ctrl_LostFocus);
631 william 113 if (platform_flow.InvokeRequired) { platform_flow.Invoke((MethodInvoker)delegate() { platform_flow.Controls.Add(platform_ctrl); }); }
632     else { platform_flow.Controls.Add(platform_ctrl); }
633     //Application.DoEvents();
634     //int percent = (int)(100.0 * (count / total_count));
635     //log.WriteLine("platformWorker_DoWork(): count={0} total={1} percent={2}", count, total_count, (int)(100.0 * (count / total_count)));
636 william 60 bar.Invoke(new MethodInvoker(delegate
637     {
638 william 113 bar.Value = (int)(100.0 * (count / total_count));
639 william 60 }));
640     count++;
641     }
642     e.Result = t;
643 william 105 parser.Dispose();
644 william 60 }
645     private void platformWorker_ProgressChanged(object sender, ProgressChangedEventArgs e) { }
646     private void platformWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
647     {
648     Stopwatch t = e.Result as Stopwatch;
649     platform_flow.Controls.RemoveAt(0);
650     platform_flow.Controls[0].Select();
651     (platform_flow.Controls[0] as PlatformControl).BorderStyle = BorderStyle.FixedSingle;
652 william 112 log.WriteLine("PlatformParser took: {0}s to parse platforms", (int)t.Elapsed.TotalSeconds);
653 william 60 }
654     #endregion
655    
656     private void Form1_FormClosed(object sender, FormClosedEventArgs e)
657     {
658     Cursor.Show();
659 william 112 log.CloseLog();
660 william 60 }
661     #endregion
662 william 4 }
663     }

  ViewVC Help
Powered by ViewVC 1.1.22