I have been having trouble trying to implement an event using monogame and c#. Currently when my window is resized i call an event:
this.Window.ClientSizeChanged += new EventHandler<EventArgs>(Window_ClientSizeChanged);
void Window_ClientSizeChanged(object sender, EventArgs e)
{
int width = Window.ClientBounds.Width;
int height = Window.ClientBounds.Height;
if (width > 0 && height > 0)
{
graphics.PreferredBackBufferWidth = width;
graphics.PreferredBackBufferHeight = height;
graphics.ApplyChanges();
}
}
This is all fine and resizes my window correctly and updates the width/height. However it is not triggered in the event that my window is resized via a user clicking the maximize/minimize button on the window frame.
After spending some time looking into some solutions the only suggestion to implement a maximize event was from here:
Form form = (Form)Control.FromHandle(Window.Handle);
form.WindowState = FormWindowState.Maximized;
However this is a solution im not particularly fond of as it relies on the inclusion of System.Windows.Forms and since i may one day want to build for other platforms id rather not include any specific windows libraries.
Is there any monogame functionality that handles the maximize/minimize event calls for each platform or is it up to the end user to implement such functionality?