WinForms ChromiumWebBrowser - Change BrowserSettings property to use IBrowserSettings

Should resolve issue with WinForms Designer

Also make IBrowserSettings inherit from IDisposable.

Issue #2667
This commit is contained in:
Alex Maitland
2019-02-28 15:01:57 +10:00
parent 5e83050ae0
commit fd9d52ebeb
2 changed files with 10 additions and 4 deletions
+7 -3
View File
@@ -52,7 +52,7 @@ namespace CefSharp.WinForms
/// <summary>
/// Browser initialization settings
/// </summary>
private BrowserSettings browserSettings;
private IBrowserSettings browserSettings;
/// <summary>
/// The request context (we deliberately use a private variable so we can throw an exception if
/// user attempts to set after browser created)
@@ -72,7 +72,7 @@ namespace CefSharp.WinForms
/// </summary>
/// <value>The browser settings.</value>
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DefaultValue(null)]
public BrowserSettings BrowserSettings
public IBrowserSettings BrowserSettings
{
get { return browserSettings; }
set
@@ -82,6 +82,10 @@ namespace CefSharp.WinForms
throw new Exception("Browser has already been created. BrowserSettings must be " +
"set before the underlying CEF browser is created.");
}
if (value != null && value.GetType() != typeof(BrowserSettings))
{
throw new Exception(string.Format("BrowserSettings can only be of type {0} or null", typeof(BrowserSettings)));
}
browserSettings = value;
}
}
@@ -640,7 +644,7 @@ namespace CefSharp.WinForms
var windowInfo = new WindowInfo();
windowInfo.SetAsChild(Handle);
managedCefBrowserAdapter.CreateBrowser(windowInfo, browserSettings, (RequestContext)RequestContext, Address);
managedCefBrowserAdapter.CreateBrowser(windowInfo, (BrowserSettings)browserSettings, (RequestContext)RequestContext, Address);
if (browserSettings != null)
{
+3 -1
View File
@@ -2,12 +2,14 @@
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
using System;
namespace CefSharp
{
/// <summary>
/// Interface representing browser initialization settings.
/// </summary>
public interface IBrowserSettings
public interface IBrowserSettings : IDisposable
{
/// <summary>
/// StandardFontFamily