Skip to content

Commit 02e1d81

Browse files
bobidahbobidah
authored andcommitted
Adding a basic Fullscreen mode (F11 to toggle)
1 parent 61d3fa7 commit 02e1d81

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

src/MainForm.cs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using System.Reflection;
1616
using SharpBrowser.Browser;
1717
using SharpBrowser.Browser.Model;
18+
using System.Windows.Forms.VisualStyles;
1819

1920
namespace SharpBrowser {
2021

@@ -94,6 +95,7 @@ private void InitHotkeys() {
9495
KeyboardHandler.AddHotKey(this, OpenSearch, Keys.F, true);
9596
KeyboardHandler.AddHotKey(this, CloseSearch, Keys.Escape);
9697
KeyboardHandler.AddHotKey(this, StopActiveTab, Keys.Escape);
98+
KeyboardHandler.AddHotKey(this, ToggleFullscreen, Keys.F11);
9799

98100

99101
}
@@ -193,7 +195,7 @@ private void ConfigureBrowser(ChromiumWebBrowser browser) {
193195
//config.WebSecurity = WebSecurity.ToCefState();
194196
config.WebGl = BrowserConfig.WebGL.ToCefState();
195197
//config.ApplicationCache = ApplicationCache.ToCefState();
196-
198+
197199
browser.BrowserSettings = config;
198200

199201
}
@@ -421,6 +423,28 @@ public void CloseActiveTab() {
421423
}
422424
}
423425
}
426+
private FormWindowState oldWindowState;
427+
private FormBorderStyle oldBorderStyle;
428+
private bool isFullScreen = false;
429+
430+
private void ToggleFullscreen()
431+
{
432+
433+
if (!isFullScreen)
434+
{
435+
oldWindowState = this.WindowState;
436+
oldBorderStyle = this.FormBorderStyle;
437+
this.FormBorderStyle = FormBorderStyle.None;
438+
this.WindowState = FormWindowState.Maximized;
439+
isFullScreen = true;
440+
}
441+
else
442+
{
443+
this.FormBorderStyle = oldBorderStyle;
444+
this.WindowState = oldWindowState;
445+
isFullScreen = false;
446+
}
447+
}
424448

425449
private void OnTabClosed(object sender, EventArgs e) {
426450

0 commit comments

Comments
 (0)