internal void Initialize(int width, int height) { Form.ClientSize = new Size(width, height); if (!_wasMoved) { Form.CenterOnPrimaryMonitor(); } }
internal WinFormsGameWindow(WinFormsGamePlatform platform) { _platform = platform; Game = platform.Game; Form = new WinFormsGameForm(this); Form.ClientSize = new Size(GraphicsDeviceManager.DefaultBackBufferWidth, GraphicsDeviceManager.DefaultBackBufferHeight); SetIcon(); Title = Utilities.AssemblyHelper.GetDefaultWindowTitle(); Form.MaximizeBox = false; Form.FormBorderStyle = FormBorderStyle.FixedSingle; Form.StartPosition = FormStartPosition.Manual; // Capture mouse events. Form.MouseWheel += OnMouseScroll; Form.MouseEnter += OnMouseEnter; Form.MouseLeave += OnMouseLeave; Form.Activated += OnActivated; Form.Deactivate += OnDeactivate; Form.ResizeEnd += OnResizeEnd; Form.KeyPress += OnKeyPress; RegisterToAllWindows(); Form.CenterOnPrimaryMonitor(); }
internal void ChangeClientSize(Size clientBounds) { if (this.Form.ClientSize != clientBounds) { this.Form.ClientSize = clientBounds; } // if the window wasn't moved manually and it's resized, it should be centered if (!_wasMoved) { Form.CenterOnPrimaryMonitor(); } }
internal void ChangeClientSize(Size clientBounds) { var prevIsResizing = Form.IsResizing; // make sure we don't see the events from this as a user resize Form.IsResizing = true; if (this.Form.ClientSize != clientBounds) { this.Form.ClientSize = clientBounds; } // if the window wasn't moved manually and it's resized, it should be centered if (!_wasMoved) { Form.CenterOnPrimaryMonitor(); } Form.IsResizing = prevIsResizing; }