SFML community forums

Bindings - other languages => DotNet => Topic started by: hechelion on May 27, 2022, 08:16:34 pm

Title: c# switch fullscreen/window
Post by: hechelion on May 27, 2022, 08:16:34 pm
Hi.

I would like to know how I can switch between fullscreen and windows mode but without having to restart the game (To implement a mode switch with Alt-Enter).

Searching in google I found that with C it can be done with "Window->create", but I have not been able to find how to do it with C# in .NET Core.

Thank in advance
Title: Re: c# switch fullscreen/window
Post by: hechelion on May 29, 2022, 05:12:41 am
After several trial and error. I have managed to switch between modes with the following code, I don't know if it will be optimal or if it will have some disadvantage, but for now it works.

if (Keyboard.IsKeyPressed(Keyboard.Key.Enter) == true && Keyboard.IsKeyPressed(Keyboard.Key.LAlt) == true) {
                    auxStyle = (auxStyle == Styles.Default)? Styles.Fullscreen: Styles.Default;
                    window.Close();
                    window = new RenderWindow(new VideoMode(oProperties.ScreenWidth, oProperties.ScreenHeight), "SFML running in .NET Core", auxStyle);
                    window.Closed += (_, __) => window.Close();
                } //Alternar ente pantalla completa y ventana con Alt-Enter
 
Title: Re: c# switch fullscreen/window
Post by: eXpl0it3r on May 31, 2022, 09:02:57 am
Yes, in C# you'll have to create a new window. Biggest down side of the current design is that you'll need to reassign the event handlers...
Title: Re: c# switch fullscreen/window
Post by: hechelion on June 01, 2022, 04:05:59 am
Yes, in C# you'll have to create a new window. Biggest down side of the current design is that you'll need to reassign the event handlers...

Thank.