예제 #1
0
 internal void Initialize(int width, int height)
 {
     Form.ClientSize = new Size(width, height);
     if (!_wasMoved)
     {
         Form.CenterOnPrimaryMonitor();
     }
 }
예제 #2
0
        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();
        }
예제 #3
0
        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();
            }
        }
예제 #4
0
        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;
        }