mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-04 19:25:01 +00:00
165a05071d
- Create ChromiumHostControlBase as common base class for ChromiumHostControl and ChromiumWebBrowser - ChromiumHostControl is now the specific implementation for hosting popups Has AddressChanged, LoadingStateChanged, etc events
50 lines
1.6 KiB
C#
50 lines
1.6 KiB
C#
// Copyright © 2016 The CefSharp Authors. All rights reserved.
|
|
//
|
|
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
|
|
|
using System.Windows.Forms;
|
|
|
|
namespace CefSharp.WinForms.Example.Handlers
|
|
{
|
|
public class WinFormsDisplayHandler : CefSharp.WinForms.Handler.DisplayHandler
|
|
{
|
|
private Control parent;
|
|
private Form fullScreenForm;
|
|
|
|
protected override void OnFullscreenModeChange(IWebBrowser chromiumWebBrowser, IBrowser browser, bool fullscreen)
|
|
{
|
|
var webBrowser = (ChromiumWebBrowser)chromiumWebBrowser;
|
|
|
|
webBrowser.InvokeOnUiThreadIfRequired(() =>
|
|
{
|
|
if (fullscreen)
|
|
{
|
|
parent = webBrowser.Parent;
|
|
|
|
parent.Controls.Remove(webBrowser);
|
|
|
|
fullScreenForm = new Form();
|
|
fullScreenForm.FormBorderStyle = FormBorderStyle.None;
|
|
fullScreenForm.WindowState = FormWindowState.Maximized;
|
|
|
|
fullScreenForm.Controls.Add(webBrowser);
|
|
|
|
fullScreenForm.ShowDialog(parent.FindForm());
|
|
}
|
|
else
|
|
{
|
|
fullScreenForm.Controls.Remove(webBrowser);
|
|
|
|
parent.Controls.Add(webBrowser);
|
|
|
|
fullScreenForm.Close();
|
|
fullScreenForm.Dispose();
|
|
fullScreenForm = null;
|
|
}
|
|
});
|
|
|
|
base.OnFullscreenModeChange(chromiumWebBrowser, browser, fullscreen);
|
|
}
|
|
}
|
|
}
|