Add project
This commit is contained in:
commit
7fcb279842
961 changed files with 370491 additions and 0 deletions
61
WebBrowser/LifeSpanHandler.cs
Normal file
61
WebBrowser/LifeSpanHandler.cs
Normal file
|
@ -0,0 +1,61 @@
|
|||
// LifeSpanHandler.cs
|
||||
using CefSharp;
|
||||
using EasyTabs;
|
||||
using System;
|
||||
using WebBrowser;
|
||||
|
||||
namespace DiamondCreeperBrowser
|
||||
{
|
||||
public class LifeSpanHandler : ILifeSpanHandler
|
||||
{
|
||||
// Load new URL (when clicking a link with target=_blank) in the same frame
|
||||
public bool OnBeforePopup(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, string targetUrl, string targetFrameName, WindowOpenDisposition targetDisposition, bool userGesture, IPopupFeatures popupFeatures, IWindowInfo windowInfo, IBrowserSettings browserSettings, ref bool noJavascriptAccess, out IWebBrowser newBrowser)
|
||||
{
|
||||
|
||||
Program.container.Invoke((Action)delegate
|
||||
{
|
||||
|
||||
EasyTabs.TitleBarTab tab = new EasyTabs.TitleBarTab(Program.container)
|
||||
{
|
||||
Content = new frmBrowser
|
||||
{
|
||||
Text = "New Tab"
|
||||
}
|
||||
};
|
||||
frmBrowser frmref = (frmBrowser)tab.Content;
|
||||
frmref.chromiumWebBrowser1.Load(targetUrl);
|
||||
Program.container.Tabs.Add(tab);
|
||||
Program.container.SelectedTab = tab;
|
||||
|
||||
|
||||
});
|
||||
|
||||
newBrowser = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
// If you don't implement all of the interface members in the custom class
|
||||
// you will find:
|
||||
// Error CS0535 'MyCustomLifeSpanHandler' does not implement interface member 'ILifeSpanHandler.OnAfterCreated(IWebBrowser, IBrowser)'
|
||||
|
||||
public bool DoClose(IWebBrowser chromiumWebBrowser, IBrowser browser)
|
||||
{
|
||||
// throw new NotImplementedException();
|
||||
if (browser.IsPopup)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void OnAfterCreated(IWebBrowser chromiumWebBrowser, IBrowser browser)
|
||||
{
|
||||
// throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void OnBeforeClose(IWebBrowser chromiumWebBrowser, IBrowser browser)
|
||||
{
|
||||
// throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
Reference in a new issue