예제 #1
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.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();
        }
예제 #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 WinFormsGameWindow(WinFormsGamePlatform platform)
        {
            _platform = platform;
            Game      = platform.Game;

            _form = new WinFormsGameForm();

            // When running unit tests this can return null.
            var assembly = Assembly.GetEntryAssembly();

            if (assembly != null)
            {
                _form.Icon = Icon.ExtractAssociatedIcon(assembly.Location);
            }

            _form.MaximizeBox     = false;
            _form.FormBorderStyle = FormBorderStyle.FixedSingle;
            _form.StartPosition   = FormStartPosition.CenterScreen;

            // Capture mouse and keyboard events.
            _form.MouseDown  += OnMouseState;
            _form.MouseMove  += OnMouseState;
            _form.MouseUp    += OnMouseState;
            _form.MouseWheel += OnMouseState;
            _form.KeyDown    += OnKeyDown;
            _form.KeyUp      += OnKeyUp;
            _form.MouseEnter += OnMouseEnter;
            _form.MouseLeave += OnMouseLeave;

            _form.Activated         += OnActivated;
            _form.Deactivate        += OnDeactivate;
            _form.ClientSizeChanged += OnClientSizeChanged;

            _form.KeyPress += OnKeyPress;
        }
예제 #4
0
        internal WinFormsGameWindow(WinFormsGamePlatform platform)
        {
            _platform = platform;
            Game      = platform.Game;

            _form                 = new Form();
            _form.Icon            = Icon.ExtractAssociatedIcon(Assembly.GetEntryAssembly().Location);
            _form.MaximizeBox     = false;
            _form.FormBorderStyle = FormBorderStyle.FixedSingle;
            _form.StartPosition   = FormStartPosition.CenterScreen;

            Mouse.SetWindows(_form);

            // Capture mouse and keyboard events.
            _form.MouseDown  += OnMouseState;
            _form.MouseMove  += OnMouseState;
            _form.MouseUp    += OnMouseState;
            _form.MouseWheel += OnMouseState;
            _form.KeyDown    += OnKeyDown;
            _form.KeyUp      += OnKeyUp;
            _form.MouseEnter += OnMouseEnter;
            _form.MouseLeave += OnMouseLeave;
            Keyboard.SetKeys(_keyState);

            _form.Activated         += OnActivated;
            _form.Deactivate        += OnDeactivate;
            _form.ClientSizeChanged += OnClientSizeChanged;
        }
예제 #5
0
 void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (Form != null)
         {
             UnregisterFromAllWindows();
             Form.Dispose();
             Form = null;
         }
     }
     _platform    = null;
     Game         = null;
     Mouse.Window = null;
 }
 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);
 }
        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.ControlBox = false; //###PROCFXGEN###
            _form.TopMost    = true;  //###PROCFXGEN###

            _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();
        }
예제 #8
0
        internal WinFormsGameWindow(WinFormsGamePlatform platform)
        {
            _platform = platform;
            Game      = platform.Game;

            Form = new WinFormsGameForm(this);
            ChangeClientSize(new Size(GraphicsDeviceManager.DefaultBackBufferWidth, GraphicsDeviceManager.DefaultBackBufferHeight));

            SetIcon();
            Title = MonoGame.Framework.Utilities.AssemblyHelper.GetDefaultWindowTitle();

            Form.MaximizeBox     = false;
            Form.FormBorderStyle = FormBorderStyle.FixedSingle;
            Form.StartPosition   = FormStartPosition.Manual;

            // Capture mouse events.
            Mouse.WindowHandle         = Form.Handle;
            Form.MouseWheel           += OnMouseScroll;
            Form.MouseHorizontalWheel += OnMouseHorizontalScroll;
            Form.MouseEnter           += OnMouseEnter;
            Form.MouseLeave           += OnMouseLeave;

            _resizeTickTimer = new System.Timers.Timer(1)
            {
                SynchronizingObject = Form, AutoReset = false
            };
            _resizeTickTimer.Elapsed += OnResizeTick;

            Form.Activated   += OnActivated;
            Form.Deactivate  += OnDeactivate;
            Form.Resize      += OnResize;
            Form.ResizeBegin += OnResizeBegin;
            Form.ResizeEnd   += OnResizeEnd;

            Form.KeyPress += OnKeyPress;

            RegisterToAllWindows();
        }
        internal WinFormsGameWindow(WinFormsGamePlatform platform)
        {
            _platform = platform;
            Game      = platform.Game;

            _form = new WinFormsGameForm();

            // When running unit tests this can return null.
            var assembly = Assembly.GetEntryAssembly();

            if (assembly != null)
            {
                _form.Icon = Icon.ExtractAssociatedIcon(assembly.Location);
            }

            _form.MaximizeBox     = false;
            _form.FormBorderStyle = FormBorderStyle.FixedSingle;
            _form.StartPosition   = FormStartPosition.CenterScreen;

            // Capture mouse events.
            _form.MouseDown  += OnMouseState;
            _form.MouseMove  += OnMouseState;
            _form.MouseUp    += OnMouseState;
            _form.MouseWheel += OnMouseState;
            _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;
        }
예제 #10
0
 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);
 }
예제 #11
0
        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();
        }
예제 #12
0
        internal WinFormsGameWindow(WinFormsGamePlatform platform)
        {
            _platform = platform;
            Game = platform.Game;

            _form = new WinFormsGameForm();
            
            // When running unit tests this can return null.
            var assembly = Assembly.GetEntryAssembly();
            if (assembly != null)
                _form.Icon = Icon.ExtractAssociatedIcon(assembly.Location);

            _form.MaximizeBox = false;
            _form.FormBorderStyle = FormBorderStyle.FixedSingle;
            _form.StartPosition = FormStartPosition.CenterScreen;           

            // Capture mouse and keyboard events.
            _form.MouseDown += OnMouseState;
            _form.MouseMove += OnMouseState;
            _form.MouseUp += OnMouseState;
            _form.MouseWheel += OnMouseState;
            _form.KeyDown += OnKeyDown;
            _form.KeyUp += OnKeyUp;
            _form.MouseEnter += OnMouseEnter;
            _form.MouseLeave += OnMouseLeave;            

            _form.Activated += OnActivated;
            _form.Deactivate += OnDeactivate;
            _form.ClientSizeChanged += OnClientSizeChanged;

            _form.KeyPress += OnKeyPress;
        }