/// <summary> /// Raises the <see cref="E:System.Windows.Forms.Form.FormClosing" /> event. /// </summary> /// <param name="e">A <see cref="T:System.Windows.Forms.FormClosingEventArgs" /> that contains the event data.</param> protected override void OnFormClosing(FormClosingEventArgs e) { base.OnFormClosing(e); if (_cursor != null) { _cursor.Dispose(); _cursor = null; } if (_spray == null) { return; } _spray.Dispose(); _spray = null; }
/// <summary> /// Raises the <see cref="E:System.Windows.Forms.Form.Load" /> event. /// </summary> /// <param name="e">An <see cref="T:System.EventArgs" /> that contains the event data.</param> protected override void OnLoad(EventArgs e) { base.OnLoad(e); try { // Set our default cursor. _currentCursor = Resources.hand_icon; // Load our raw input plug-in assembly. Gorgon.PlugIns.LoadPlugInAssembly(Program.PlugInPath + "Gorgon.Input.Raw.DLL"); // Create our input factory. _factory = GorgonInputFactory.CreateInputFactory("GorgonLibrary.Input.GorgonRawPlugIn"); // Get our device info. // This function is called when the factory is created. // However, I'm calling it here just to show that it exists. _factory.EnumerateDevices(); // Validate, even though it's highly unlikely we'll run into these. if (_factory.PointingDevices.Count == 0) { GorgonDialogs.ErrorBox(this, "There were no mice detected on this computer. The application requires a mouse."); Gorgon.Quit(); } if (_factory.KeyboardDevices.Count == 0) { GorgonDialogs.ErrorBox(this, "There were no keyboards detected on this computer. The application requires a keyboard."); Gorgon.Quit(); } // Get our input devices. CreateMouse(); CreateKeyboard(); CreateJoystick(); // When the display area changes size, update the spray effect // and limit the mouse. panelDisplay.Resize += panelDisplay_Resize; // Set the initial range of the mouse cursor. _mouse.PositionRange = Rectangle.Round(panelDisplay.ClientRectangle); // Set up our spray object. _spray = new Spray(panelDisplay.ClientSize); _cursor = new MouseCursor(panelDisplay) { Hotspot = new Point(-16, -3) }; // Set up our idle method. Gorgon.ApplicationIdleLoopMethod = Idle; } catch (Exception ex) { // We do this here instead of just calling the dialog because this // function will send the exception to the Gorgon log file. GorgonException.Catch(ex, () => GorgonDialogs.ErrorBox(this, ex)); Gorgon.Quit(); } }