61 lines
No EOL
2 KiB
C#
61 lines
No EOL
2 KiB
C#
// LifeSpanHandler.cs
|
|
|
|
using System;
|
|
using CefSharp;
|
|
using EasyTabs;
|
|
|
|
namespace XeroBrowser
|
|
{
|
|
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
|
|
{
|
|
|
|
TitleBarTab tab = new 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();
|
|
}
|
|
}
|
|
} |