/// <summary> /// Initializes a new instance of the <see cref="Context" /> class. /// </summary> public Context() { // Create our timer object. _timer = new GorgonTimer(); // Create the splash screen and the main interface. _splashScreen = new formSplash(); MainForm = new formMain(); // Note that we're assign this to the inherited property 'MainForm'. // This how the application context knows which form controls the application. RunMe(); }
/// <summary> /// Function to begin the execution of the application context. /// </summary> public void RunMe() { string annoyUser = "******"; int counter = 0; try { _timer.Reset(); _splashScreen.Show(); _splashScreen.UpdateText("This is the splash screen."); // Fade in the splash screen about 10% every 7 milliseconds. while (_splashScreen.Opacity < 1) { if (!(_timer.Milliseconds > 7)) { continue; } _timer.Reset(); _splashScreen.Opacity += 0.01; } // Annoy the user. They're asking for it. while (counter < 5) { while (_timer.Seconds > 1) { if (annoyUser.Length < 50) { annoyUser += "."; } else { annoyUser = "******"; } _splashScreen.UpdateText(annoyUser); _timer.Reset(); counter++; } } // Fade it out. while (_splashScreen.Opacity > 0.02) { if (!(_timer.Milliseconds > 5)) { continue; } _timer.Reset(); _splashScreen.Opacity -= 0.01; } // Resize the main form to 640 x 480. MainForm.KeyDown += MainForm_KeyDown; MainForm.ClientSize = new Size(640, 480); MainForm.Show(); } catch (Exception ex) { // If we get an error, then leave the application. GorgonDialogs.ErrorBox(MainForm, ex); if (MainForm != null) { MainForm.Dispose(); } MainForm = null; } finally { // We don't need this any more. if (_splashScreen != null) { _splashScreen.Dispose(); } _splashScreen = null; } }