void Dispose(bool disposing) { if (disposing) { if (_form != null) { UnregisterFromAllWindows(); _form.Dispose(); _form = null; } } _platform = null; Game = null; Mouse.SetWindows(null); Device.KeyboardInput -= OnRawKeyEvent; Device.RegisterDevice(UsagePage.Generic, UsageId.GenericKeyboard, DeviceFlags.Remove); }
void Dispose(bool disposing) { if (disposing) { if (_form != null) { UnregisterFromAllWindows(); _form.Dispose(); _form = null; } } }
internal WinFormsGameWindow(WinFormsGamePlatform platform) { _platform = platform; Game = platform.Game; _form = new WinFormsGameForm(this); // When running unit tests this can return null. var assembly = Assembly.GetEntryAssembly(); if (assembly != null) _form.Icon = Icon.ExtractAssociatedIcon(assembly.Location); Title = Utilities.AssemblyHelper.GetDefaultWindowTitle(); _form.MaximizeBox = false; _form.FormBorderStyle = FormBorderStyle.FixedSingle; _form.StartPosition = FormStartPosition.CenterScreen; // Capture mouse events. _form.MouseWheel += OnMouseScroll; _form.MouseEnter += OnMouseEnter; _form.MouseLeave += OnMouseLeave; // Use RawInput to capture key events. Device.RegisterDevice(UsagePage.Generic, UsageId.GenericKeyboard, DeviceFlags.None); Device.KeyboardInput += OnRawKeyEvent; _form.Activated += OnActivated; _form.Deactivate += OnDeactivate; _form.ClientSizeChanged += OnClientSizeChanged; _form.KeyPress += OnKeyPress; RegisterToAllWindows(); }
public void Dispose() { if (_form != null) { _form.Dispose(); _form = null; } }