ab56a9bcf7
SVN-Revision: r240
100 lines
3.3 KiB
C#
100 lines
3.3 KiB
C#
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Runtime.InteropServices;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Windows.Forms;
|
|
using Lskj.Control.Model;
|
|
using Lskj.Model;
|
|
using Lskj.Business.Impl;
|
|
using Lskj.Util;
|
|
using System.Web;
|
|
using Lskj.Business;
|
|
using Lskj.Control;
|
|
using Xilium.CefGlue;
|
|
using Lskj.Control.BrowserSetting2;
|
|
using System.Net;
|
|
|
|
namespace Lskj.Control
|
|
{
|
|
public partial class FrmWebBrowser2 : UserControl
|
|
{
|
|
public DynamicPubBrowerModel PubBrowerModel;
|
|
public CefBrowser cefBrowserSettings;
|
|
/// <summary>
|
|
/// 是否允许下载
|
|
/// </summary>
|
|
public bool AllowDownload = true;
|
|
|
|
public FrmWebBrowser2()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
void Form1_FormClosed(object sender, FormClosedEventArgs e)
|
|
{
|
|
//CefRuntime.Shutdown();
|
|
}
|
|
public void FrmLoad(string url, int RightKeyFlag = 0)
|
|
{
|
|
var cefWindowInfo = CefWindowInfo.Create();
|
|
cefWindowInfo.SetAsChild(this.Handle, new CefRectangle(0, 0, this.Width, this.Height));
|
|
var bsClient = new BsClient(RightKeyFlag, this.AllowDownload);
|
|
bsClient.OnCreated += bsClient_OnCreated;
|
|
var cefBrowserSettings = new CefBrowserSettings() { };
|
|
//Url = "https://ie.icoa.cn/";
|
|
CefBrowserHost.CreateBrowser(cefWindowInfo, bsClient, cefBrowserSettings, url);
|
|
//清除所有Cookie
|
|
var cookieManager = CefCookieManager.GetGlobal(null);
|
|
cookieManager.DeleteCookies("", "", null);
|
|
}
|
|
private void bsClient_OnCreated(object sender, EventArgs e)
|
|
{
|
|
cefBrowserSettings = (CefBrowser)sender;
|
|
var handle = cefBrowserSettings.GetHost().GetWindowHandle();
|
|
ResizeWindow(handle, this.Width, this.Height);
|
|
}
|
|
protected override void OnResize(EventArgs e)
|
|
{
|
|
base.OnResize(e);
|
|
if (cefBrowserSettings != null)
|
|
{
|
|
ResizeWindow(cefBrowserSettings.GetHost().GetWindowHandle(), Width, Height);
|
|
}
|
|
}
|
|
public void ResizeWindow(IntPtr handle, int width, int height)
|
|
{
|
|
if (handle != IntPtr.Zero)
|
|
{
|
|
NativeMethod.SetWindowPos(handle, IntPtr.Zero,
|
|
0, 0, width, height,
|
|
0x0002 | 0x0004
|
|
);
|
|
}
|
|
}
|
|
public void LoadUrl(string url)
|
|
{
|
|
if (cefBrowserSettings != null)
|
|
{
|
|
cefBrowserSettings.GetMainFrame().LoadUrl(url);
|
|
}
|
|
}
|
|
public void LoadRequest(string url, string dataStr)
|
|
{
|
|
BrowserSetting2.HttpTools.setting("application/x-www-form-urlencoded", null, null);
|
|
Dictionary<string, string> dataDic = new Dictionary<string, string>();
|
|
dataDic.Add("billCode", dataStr);
|
|
HttpWebResponse webResponse = BrowserSetting2.HttpTools.Post(url, "", dataDic, null, HttpTools.Method.POST);
|
|
if (webResponse != null)
|
|
{
|
|
cefBrowserSettings.GetMainFrame().LoadUrl(webResponse.ResponseUri.AbsoluteUri);
|
|
}
|
|
}
|
|
}
|
|
}
|