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

📄 adbarimp.cs

📁 破解的飞信源代码
💻 CS
字号:
namespace Imps.Client.Pc
{
    using Imps.Client;
    using Imps.Client.Core;
    using Imps.Client.Pc.BizControls;
    using Imps.Client.Pc.BizControls.NotifyWindows;
    using Imps.Client.Resource;
    using Imps.Client.Utils;
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;

    public class AdBarImp : Panel, IAdBar
    {
        private IFrameworkWindow _framework;
        private BWebBrowser innerBrowser;
        private bool innerNavigate;
        private PictureBox innerPicBox;

        public AdBarImp(IFrameworkWindow framework)
        {
            this._framework = framework;
            this._framework.AccountManager.CurrentUser.AdManager.AdBarUrlChanged += new EventHandler(this.AdBarUrl_Changed);
            this._framework.AccountManager.CurrentUser.AdManager.AdNotifyUrlChanged += new EventHandler(this.AdNotifyUrl_Changed);
            base.SetStyle(ControlStyles.ResizeRedraw, false);
            this.InitializeComponent();
            this.innerPicBox.Image = ImpsResources.GetImage("Images.ad.gif");
            this.innerPicBox.Cursor = Cursors.Hand;
            this.innerPicBox.Click += new EventHandler(this.innerPicBox_Click);
            base.SizeChanged += new EventHandler(this.AdBarImp_SizeChanged);
            this.innerPicBox.Dock = DockStyle.Fill;
        }

        private void AdBarImp_SizeChanged(object sender, EventArgs e)
        {
            int width = SystemInformation.Border3DSize.Width;
            int height = SystemInformation.Border3DSize.Height;
            this.innerBrowser.Location = new System.Drawing.Point(-width, -height);
            this.innerBrowser.Size = new Size(base.Size.Width + (width * 2), base.Size.Height + (height * 2));
        }

        private void AdBarUrl_Changed(object sender, EventArgs e)
        {
            try
            {
                ClientLogger.WriteBizOperation("设置TargetUrl", this.InnerAdManager.AdBarUrl);
                this.TargetUrl = this.InnerAdManager.AdBarUrl;
            }
            catch
            {
            }
        }

        private void AdNotifyUrl_Changed(object sender, EventArgs e)
        {
            try
            {
                SystemInfoNotify notifyWindow = new SystemInfoNotify(AppDictionary.CurrentClientName, this.InnerAdManager.AdNotifyUrl);
                notifyWindow.Click += new EventHandler(this.notifyWnd_Click);
                NotifyWindowManager.Add(notifyWindow);
            }
            catch
            {
            }
        }

        private void InitializeComponent()
        {
            this.innerBrowser = new BWebBrowser();
            this.innerPicBox = new PictureBox();
            this.innerPicBox.BeginInit();
            base.SuspendLayout();
            this.innerBrowser.set_AllowWebBrowserDrop(false);
            this.innerBrowser.set_IsWebBrowserContextMenuEnabled(false);
            this.innerBrowser.Location = new System.Drawing.Point(0x20, 5);
            this.innerBrowser.set_MinimumSize(new Size(20, 20));
            this.innerBrowser.Name = "innerBrowser";
            this.innerBrowser.set_ScriptErrorsSuppressed(true);
            this.innerBrowser.set_ScrollBarsEnabled(false);
            this.innerBrowser.Size = new Size(0x102, 0x44);
            this.innerBrowser.TabIndex = 0;
            this.innerBrowser.set_WebBrowserShortcutsEnabled(false);
            this.innerBrowser.NavigateError += new EventHandler<BWebBrowserNavigatingEventArgs>(this, (IntPtr) this.innerBrowser_NavigateError);
            this.innerBrowser.add_Navigated(new WebBrowserNavigatedEventHandler(this, (IntPtr) this.innerBrowser_Navigated));
            this.innerBrowser.Visible = false;
            this.innerPicBox.Location = new System.Drawing.Point(0x20, 5);
            this.innerPicBox.Name = "innerPicBox";
            this.innerPicBox.Size = new Size(100, 50);
            this.innerPicBox.TabIndex = 0;
            this.innerPicBox.TabStop = false;
            this.innerPicBox.Size = new Size(0x102, 0x44);
            this.innerPicBox.BorderStyle = BorderStyle.None;
            this.innerPicBox.Visible = true;
            this.BackColor = Color.Transparent;
            base.Controls.Add(this.innerBrowser);
            base.Controls.Add(this.innerPicBox);
            base.set_Padding(new Padding(5));
            base.Size = new Size(0x142, 0x4e);
            this.innerPicBox.EndInit();
            base.ResumeLayout(false);
        }

        private void innerBrowser_Navigated(object sender, WebBrowserNavigatedEventArgs e)
        {
            this.innerNavigate = false;
            base.Enabled = true;
        }

        private void innerBrowser_NavigateError(object sender, BWebBrowserNavigatingEventArgs e)
        {
            ClientLogger.WriteBizOperation("ywq", "触发Browser NavigateError事件");
            this.NavigateToUrl(string.Empty);
        }

        private void innerBrowser_Navigating(object sender, WebBrowserNavigatingEventArgs e)
        {
            if (!this.innerNavigate)
            {
                try
                {
                    if (e.get_Url().Scheme == Uri.UriSchemeHttp)
                    {
                        e.Cancel = true;
                        ShellHelper.StartUri(e.get_Url());
                    }
                }
                catch (Exception exception)
                {
                    UiErrorHelper.HandExceptionSafely(this._framework, exception);
                }
            }
        }

        private void innerBrowser_NewWindow(object sender, CancelEventArgs e)
        {
            try
            {
                string url = this.innerBrowser.get_StatusText();
                if (IsValidUrl(url))
                {
                    e.Cancel = true;
                    ShellHelper.StartUrl(url);
                }
            }
            catch (Exception exception)
            {
                UiErrorHelper.HandExceptionSafely(this._framework, exception);
            }
        }

        private void innerPicBox_Click(object sender, EventArgs e)
        {
            try
            {
                string url = this._framework.AccountManager.CurrentUser.Configuration.SystemSetting.ServerUriSetting.UriPortal;
                if (IsValidUrl(url))
                {
                    ShellHelper.StartUrl(url);
                }
            }
            catch (Exception exception)
            {
                UiErrorHelper.HandExceptionSafely(this._framework, exception);
            }
        }

        private static bool IsValidUrl(string url)
        {
            if (string.IsNullOrEmpty(url))
            {
                return false;
            }
            int length = url.IndexOf(Uri.SchemeDelimiter);
            if (length <= 0)
            {
                return false;
            }
            return Uri.CheckSchemeName(url.Substring(0, length));
        }

        private void NavigateToUrl(string url)
        {
            if (IsValidUrl(url))
            {
                base.SuspendLayout();
                this.innerPicBox.Visible = false;
                Image image = this.innerPicBox.Image;
                this.innerPicBox.Image = null;
                if (image != null)
                {
                    image.Dispose();
                }
                ClientLogger.WriteBizOperation("ywq", "置NavigateToUrl:innerBrower可见");
                this.innerBrowser.Visible = true;
                base.ResumeLayout(true);
                ClientLogger.WriteBizOperation("ywq--NavigateToUrl:Navigate", url);
                base.Enabled = false;
                this.innerBrowser.Navigate(url);
            }
            else
            {
                ClientLogger.WriteBizOperation("ywq--非法url", url);
                base.SuspendLayout();
                ClientLogger.WriteBizOperation("ywq", "置NavigateToUrl:innerBrower不可见,Navigate(balnk)");
                this.innerBrowser.Visible = false;
                this.innerPicBox.Image = ImpsResources.GetImage("Images.ad.gif");
                this.innerPicBox.Visible = true;
                base.Enabled = true;
                this.innerBrowser.Navigate("about:blank");
                base.ResumeLayout(true);
            }
        }

        private void notifyWnd_Click(object sender, EventArgs e)
        {
            try
            {
                ((SystemInfoNotify) sender).Close();
            }
            catch
            {
            }
        }

        public Control Bar
        {
            get
            {
                return this;
            }
        }

        private AdManager InnerAdManager
        {
            get
            {
                return this._framework.AccountManager.CurrentUser.AdManager;
            }
        }

        public string TargetUrl
        {
            get
            {
                return this.innerBrowser.get_Url().AbsoluteUri;
            }
            set
            {
                this.innerNavigate = true;
                this.NavigateToUrl(value);
            }
        }
    }
}

⌨️ 快捷键说明

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