拍单功能继续优化
This commit is contained in:
1 parent
29042424dc
commit
34c51c6fcd
64 files changed
+7138
-305
No files matched your search
@@ -0,0 +1,82 @@
|
||||
using CefSharp;
|
||||
using CefSharp.WinForms;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Work._29Tools.CefTools
|
||||
{
|
||||
public enum PopWindowType
|
||||
{
|
||||
NewWindow,
|
||||
SelfWindow,
|
||||
NewTitleWindow,
|
||||
}
|
||||
public class PopData
|
||||
{
|
||||
public string Url { get; set; }
|
||||
}
|
||||
public class LifeSpanHandlerLocal : ILifeSpanHandler
|
||||
{
|
||||
private PopWindowType popWindowType = PopWindowType.NewWindow;
|
||||
public event EventHandler<PopData> OnPop;
|
||||
public ChromiumWebBrowser parent;
|
||||
public LifeSpanHandlerLocal()
|
||||
{
|
||||
}
|
||||
|
||||
public LifeSpanHandlerLocal(PopWindowType _popWindowType)
|
||||
{
|
||||
popWindowType = _popWindowType;
|
||||
}
|
||||
|
||||
public bool DoClose(IWebBrowser browserControl, IBrowser browser)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void OnAfterCreated(IWebBrowser chromiumWebBrowser, IBrowser browser)
|
||||
{
|
||||
if (!browser.IsDisposed && browser.IsPopup)
|
||||
{
|
||||
//GlobalFormConfig.MainFormInstance.InvokeOnUiThreadIfRequired(() =>
|
||||
//{
|
||||
// // 修改窗体左上角的图标
|
||||
// IntPtr handle = browser.GetHost().GetWindowHandle();
|
||||
// PInvokeHelper.SendMessage(handle, 0x80, IntPtr.Zero, NaiBaGlobalConfig.SoftwareConfig.LogoIcon.Handle);
|
||||
//});
|
||||
}
|
||||
}
|
||||
|
||||
public void OnBeforeClose(IWebBrowser browserControl, IBrowser browser)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public bool OnBeforePopup(IWebBrowser browserControl, IBrowser browser, IFrame frame, string targetUrl, string targetFrameName, WindowOpenDisposition targetDisposition, bool userGesture, IPopupFeatures popupFeatures, IWindowInfo windowInfo, IBrowserSettings browserSettings, ref bool noJavascriptAccess, out IWebBrowser newBrowser)
|
||||
{
|
||||
if (popWindowType == PopWindowType.NewWindow)
|
||||
{
|
||||
newBrowser = null;
|
||||
return false;
|
||||
}
|
||||
else if (popWindowType == PopWindowType.NewTitleWindow && popupFeatures.IsPopup)
|
||||
{
|
||||
PopData p = new PopData() { Url = targetUrl };
|
||||
if (OnPop != null)
|
||||
OnPop(this, p);
|
||||
newBrowser = null;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 不打开新的 tab
|
||||
browser.MainFrame.LoadUrl(targetUrl);
|
||||
newBrowser = null;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user