| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Diagnostics;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Windows.Forms;
- using Chromium;
- using Chromium.Event;
- using Chromium.WebBrowser;
- using Chromium.WebBrowser.Event;
- using CoreFS.CA06;using Pur.Entity;using Pur.Entity;
- namespace Pur.Pop_upWindow
- {
- public partial class FrmWebBase : FrmPmsBase
- {
- private string url;
- public string Url
- {
- get { return url; }
- set { url = value; }
- }
- Chromium.WebBrowser.ChromiumWebBrowser WebBrowser = null;
- public FrmWebBase()
- {
- InitializeComponent();
- InitBrowser();
- WebBrowser = new Chromium.WebBrowser.ChromiumWebBrowser();
- WebBrowser.BackColor = System.Drawing.Color.White;
- WebBrowser.Dock = System.Windows.Forms.DockStyle.Fill;
- WebBrowser.Location = new System.Drawing.Point(0, 0);
- WebBrowser.Name = "WebBrowser";
- WebBrowser.RemoteCallbackInvokeMode = Chromium.WebBrowser.JSInvokeMode.Inherit;
- WebBrowser.Size = new System.Drawing.Size(1370, 520);
- WebBrowser.TabIndex = 2;
- WebBrowser.Text = "浏览";
- WebBrowser.ContextMenuHandler.OnBeforeContextMenu += (s, e1) =>
- {
- return;
- };
- this.Controls.Add(WebBrowser);
- WebBrowser.LifeSpanHandler.OnBeforePopup += (s, e1) =>
- {
- var ff = e1.PopupFeatures.AdditionalFeatures;
- };
- }
-
- private void FrmWebBase_Load(object sender, EventArgs e)
- {
- //WebBrowser.LoadUrl("http://music.baidu.com/");
- //WebBrowser.LoadUrl("http://localhost:8080/CoreBaseWeb/manager/login");
- OpenUrl();
- //WebBrowser webBrowser1 = new WebBrowser();
- //this.Controls.Add(webBrowser1);
- //webBrowser1.Dock = DockStyle.Fill;
- //webBrowser1.Navigate(url);
- }
- public void OpenUrl()
- {
- WebBrowser.LoadUrl(url);
- }
- private static void InitBrowser()
- {
- if (string.IsNullOrEmpty(CfxRuntime.LibCefDirPath))
- {
- var assemblyDir = System.IO.Path.GetDirectoryName(new System.Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath);
- Environment.CurrentDirectory = System.IO.Path.Combine(assemblyDir, @".\");
- if (CfxRuntime.PlatformArch == CfxPlatformArch.x64)
- CfxRuntime.LibCefDirPath = @"cef64";
- else
- CfxRuntime.LibCefDirPath = @"cef";
- Chromium.WebBrowser.ChromiumWebBrowser.OnBeforeCfxInitialize += ChromiumWebBrowser_OnBeforeCfxInitialize;
- ChromiumWebBrowser.OnBeforeCommandLineProcessing += ChromiumWebBrowser_OnBeforeCommandLineProcessing;
- Chromium.WebBrowser.ChromiumWebBrowser.Initialize();
- }
- }
- static void ChromiumWebBrowser_OnBeforeCommandLineProcessing(CfxOnBeforeCommandLineProcessingEventArgs e)
- {
- Console.WriteLine("ChromiumWebBrowser_OnBeforeCommandLineProcessing");
- Console.WriteLine(e.CommandLine.CommandLineString);
- }
- static void ChromiumWebBrowser_OnBeforeCfxInitialize(OnBeforeCfxInitializeEventArgs e)
- {
- e.Settings.LocalesDirPath = System.IO.Path.GetFullPath(@"cef\Resources\locales");
- e.Settings.ResourcesDirPath = System.IO.Path.GetFullPath(@"cef\Resources");
- e.Settings.LogSeverity = CfxLogSeverity.Verbose;
- e.Settings.BrowserSubprocessPath = System.IO.Path.GetFullPath(@"chromiumfxDemo.exe");
- }
- }
- }
|