⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bwebbrowser.cs

📁 破解的飞信源代码
💻 CS
📖 第 1 页 / 共 2 页
字号:
namespace Imps.Client.Pc.BizControls
{
    using Imps.Client.Utils;
    using System;
    using System.Runtime.CompilerServices;
    using System.Runtime.InteropServices;
    using System.Security.Permissions;
    using System.Windows.Forms;

    public class BWebBrowser : WebBrowser
    {
        private Imps.Client.Pc.BizControls.UnsafeNativeMethods.IWebBrowser2 axIWebBrowser2;
        private AxHost.ConnectionPointCookie cookie;
        private BWebBrowserEvents events;

        public event EventHandler DownloadComplete;

        public event EventHandler Downloading;

        public event EventHandler<BWebBrowserNavigatingEventArgs> NavigateError;

        public event EventHandler Quit;

        public event EventHandler<BWebBrowserNavigatingEventArgs> StartNavigate;

        public event EventHandler<BWebBrowserNavigatingEventArgs> StartNewWindow;

        public BWebBrowser()
        {
            base.set_AllowWebBrowserDrop(false);
            base.set_IsWebBrowserContextMenuEnabled(false);
        }

        [PermissionSet(SecurityAction.LinkDemand, Name="FullTrust")]
        protected override void AttachInterfaces(object nativeActiveXObject)
        {
            this.axIWebBrowser2 = (Imps.Client.Pc.BizControls.UnsafeNativeMethods.IWebBrowser2) nativeActiveXObject;
            base.AttachInterfaces(nativeActiveXObject);
        }

        [PermissionSet(SecurityAction.LinkDemand, Name="FullTrust")]
        protected override void CreateSink()
        {
            base.CreateSink();
            this.events = new BWebBrowserEvents(this);
            this.cookie = new AxHost.ConnectionPointCookie(base.get_ActiveXInstance(), this.events, typeof(Imps.Client.Pc.BizControls.UnsafeNativeMethods.DWebBrowserEvents2));
        }

        [PermissionSet(SecurityAction.LinkDemand, Name="FullTrust")]
        protected override void DetachInterfaces()
        {
            this.axIWebBrowser2 = null;
            base.DetachInterfaces();
        }

        [PermissionSet(SecurityAction.LinkDemand, Name="FullTrust")]
        protected override void DetachSink()
        {
            if (this.cookie != null)
            {
                this.cookie.Disconnect();
                this.cookie = null;
            }
        }

        protected virtual void OnDownloadComplete(EventArgs e)
        {
            if (this.DownloadComplete != null)
            {
                this.DownloadComplete(this, e);
            }
        }

        protected void OnDownloading(EventArgs e)
        {
            if (this.Downloading != null)
            {
                this.Downloading(this, e);
            }
        }

        protected void OnNavigateError(BWebBrowserNavigatingEventArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }
            if (this.NavigateError != null)
            {
                this.NavigateError.Invoke(this, e);
            }
        }

        protected void OnQuit()
        {
            EventHandler quit = this.Quit;
            if (quit != null)
            {
                quit(this, EventArgs.Empty);
            }
        }

        protected void OnStartNavigate(BWebBrowserNavigatingEventArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }
            if (this.StartNavigate != null)
            {
                this.StartNavigate.Invoke(this, e);
            }
        }

        protected void OnStartNewWindow(BWebBrowserNavigatingEventArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }
            if (this.StartNewWindow != null)
            {
                this.StartNewWindow.Invoke(this, e);
            }
        }

        [PermissionSet(SecurityAction.LinkDemand, Name="FullTrust")]
        protected override void WndProc(ref Message m)
        {
            if (m.Msg == 0x210)
            {
                int num2 = m.WParam.ToInt32() & 0xffff;
                if (num2 == 2)
                {
                    this.OnQuit();
                }
            }
            if (m.Msg != 6)
            {
                base.WndProc(ref m);
            }
        }

        public object Application
        {
            get
            {
                return this.axIWebBrowser2.Application;
            }
        }

        private class BWebBrowserEvents : Imps.Client.Pc.BizControls.UnsafeNativeMethods.DWebBrowserEvents2
        {
            private BWebBrowser _Browser;

            public BWebBrowserEvents()
            {
            }

            public BWebBrowserEvents(BWebBrowser browser)
            {
                this._Browser = browser;
            }

            public void BeforeNavigate2(object pDisp, ref object URL, ref object flags, ref object targetFrameName, ref object postData, ref object headers, ref bool cancel)
            {
                Uri url = new Uri(URL.ToString());
                string frame = null;
                if (targetFrameName != null)
                {
                    frame = targetFrameName.ToString();
                }
                BWebBrowserNavigatingEventArgs e = new BWebBrowserNavigatingEventArgs(pDisp, url, frame, UrlContext.None);
                this._Browser.OnStartNavigate(e);
                cancel = e.Cancel;
                pDisp = e.AutomationObject;
            }

            public void ClientToHostWindow(ref int CX, ref int CY)
            {
            }

            public void CommandStateChange(int Command, bool Enable)
            {
            }

            public void DocumentComplete(object pDisp, ref object URL)
            {
            }

            public void DownloadBegin()
            {
                this._Browser.OnDownloading(EventArgs.Empty);
            }

            public void DownloadComplete()
            {
                this._Browser.OnDownloadComplete(EventArgs.Empty);
            }

            public void FileDownload(ref bool cancel)
            {
            }

            public void NavigateComplete2(object pDisp, ref object URL)
            {
            }

            public void NavigateError(object pDisp, ref object URL, ref object frame, ref object statusCode, ref bool cancel)
            {
                ClientLogger.WriteBizOperation("ywq", "DWebBrowser内部触发NavigateError事件");
                Uri url = new Uri(URL.ToString());
                string text = null;
                if (frame != null)
                {
                    text = frame.ToString();
                }
                int num = 0;
                if (statusCode != null)
                {
                    try
                    {
                        num = Convert.ToInt32(statusCode);
                    }
                    catch
                    {
                    }
                }
                BWebBrowserNavigatingEventArgs e = new BWebBrowserNavigatingEventArgs(pDisp, url, text, UrlContext.None, num);
                this._Browser.OnNavigateError(e);
                cancel = e.Cancel;
                pDisp = e.AutomationObject;
            }

            public void NewWindow2(ref object pDisp, ref bool cancel)
            {
                BWebBrowserNavigatingEventArgs e = new BWebBrowserNavigatingEventArgs(pDisp, null, null, UrlContext.None);
                this._Browser.OnStartNewWindow(e);
                cancel = e.Cancel;
                pDisp = e.AutomationObject;
            }

            public void NewWindow3(ref object ppDisp, ref bool Cancel, uint dwFlags, string bstrUrlContext, string bstrUrl)
            {
                BWebBrowserNavigatingEventArgs e = new BWebBrowserNavigatingEventArgs(ppDisp, new Uri(bstrUrl), null, (UrlContext) dwFlags);
                this._Browser.OnStartNewWindow(e);
                Cancel = e.Cancel;
                ppDisp = e.AutomationObject;
            }

            public void OnFullScreen(bool fullScreen)
            {
            }

            public void OnMenuBar(bool menuBar)
            {
            }

            public void OnQuit()
            {
            }

            public void OnStatusBar(bool statusBar)
            {
            }

            public void OnTheaterMode(bool theaterMode)
            {
            }

            public void OnToolBar(bool toolBar)
            {
            }

            public void OnVisible(bool visible)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -