Exemple #1
0
 /// <summary>
 /// Destroys the current Windows Form and releases its resources.
 /// </summary>
 private static void DestroyForm()
 {
     if(form != null) {
         form.Hide();															// Hide The Form
         form.Close();															// Close And Dispose Of The Form
         form = null;
     }
     if(view != null) {
         view.Dispose();
         view = null;
     }
     GC.Collect();
 }
Exemple #2
0
        /// <summary>
        /// Cleans up either unmanaged resources or managed and unmanaged resources.
        /// </summary>
        /// <remarks>
        /// <para>
        /// If disposing equals true, the method has been called directly or indirectly by a user's 
        /// code.  Managed and unmanaged resources can be disposed.
        /// </para>
        /// <para>
        /// If disposing equals false, the method has been called by the runtime from inside the 
        /// finalizer and you should not reference other objects.  Only unmanaged resources can 
        /// be disposed.
        /// </para>
        /// </remarks>
        /// <param name="disposing">Was Dispose called manually?</param>
        private static void Dispose(bool disposing)
        {
            if(!isDisposed) {															// Check To See If Dispose Has Already Been Called
                if(disposing) {															// If disposing Equals true, Dispose All Managed And Unmanaged Resources
                    if(timer != null) {
                        timer.Dispose();
                    }
                    if(form != null) {
                        form.Close();
                    }
                    if(view != null) {
                        view.Dispose();
                    }
                    if(model != null) {
                        model.Dispose();
                    }
                }

                // Release Any Unmanaged Resources Here, If disposing Was false, Only The Following Code Is Executed
                isRunning = false;
                timer = null;
                form = null;
                view = null;
                model = null;
            }
            isDisposed = true;															// Mark As disposed
        }
Exemple #3
0
        /// <summary>
        /// Creates either a fullscreen form or the user-supplied windowed form, based on the
        /// <see cref="IsFullscreen" /> property.
        /// </summary>
        private static void CreateForm()
        {
            try {
                if(model != null) {
                    view = new View(model);												// Create A New OpenGL View
                    view.Context.Grab();												// Grab The OpenGL Context
                    model.Initialize();													// Run Model's Initialize()
                    OpenGLException.Assert();											// Check For Any OpenGL Errors

                    if(isFullscreen) {													// If We're In Fullscreen Mode
                        form = new ScreenForm(width, height);							// Create A New Fullscreen Form
                        App.View.Dock = DockStyle.Fill;									// Fill It With view
                        form.Controls.AddRange(new Control[] { view });					// Add view
                        form.Show();													// Show The Fullscreen Form
                    }
                    else {																// Otherwise
                        model.WindowsForm();											// Create The User's Defined Windows Form
                    }
                }
                if(isFullscreen) {														// If We're In Fullscreen Mode
                    if(showCursorFullscreen) {											// If We're Supposed To Show Cursor
                        Cursor.Show();													// Show It
                    }
                    else {																// Otherwise
                        Cursor.Hide();													// Hide It
                    }
                }
                else {																	// Else We're In Windowed Mode
                    if(showCursorWindowed) {											// If We're Supposed To Show Cursor
                        Cursor.Show();													// Show It
                    }
                    else {																// Otherwise
                        Cursor.Hide();													// Hide It
                    }
                }
            }
            catch(Exception e) {
                // Handle Any Exceptions While Creating The Application's Form, Exit App
                string errorMsg = "A Basecode Error Occurred While Creating The Application's Form:\n\nStack Trace:\n\t" + e.StackTrace + "\n";
                MessageBox.Show(errorMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                App.Terminate();
            }
        }