Пример #1
0
        void toolStripButton_MouseLeave(object sender, EventArgs e)
        {
            ToolStripButton    toolStripButton = (ToolStripButton)sender;
            WebBrowserProperty property        = (WebBrowserProperty)(toolStripButton).Tag;

            property.isInClose = false;
            toolStrip3.Refresh();
        }
Пример #2
0
        void toolStripButton_MouseUp(object sender, MouseEventArgs e)
        {
            ToolStripButton toolStripButton = (ToolStripButton)sender;

            if (toolStripButton == toolStripButton9)
            {
                AxSHDocVw.AxWebBrowser webBrowser = IniWebBrowser();
                webBrowser.GoHome();
                currentWebBrowser = webBrowser;
            }
            else if (e.Button == MouseButtons.Right)
            {
                WebBrowserProperty property = (WebBrowserProperty)((ToolStripButton)sender).Tag;
                Controls.Remove(property.webBrowser);
                property.webBrowser.Dispose();
                toolStrip3.Items.Remove(property.toolStripButton);
                Application.DoEvents();
                Control webBrowser = Control.FromChildHandle(WinDll.WindowFromPoint(PointToScreen(new Point(panel2.Location.X + 10, panel2.Location.Y + 10))));
                if (webBrowser.ToString() == "AxSHDocVw.AxWebBrowser")
                {
                    toolStripButton_MouseUp(((WebBrowserProperty)webBrowser.Tag).toolStripButton, new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0));
                }
                else
                {
                    toolStripButton_MouseUp(toolStripButton9, new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0));
                }
            }
            else if (e.Button == MouseButtons.Left)
            {
                if (e.X > toolStripButton.Size.Width - closeLeft)
                {
                    toolStripButton_MouseUp(sender, new MouseEventArgs(MouseButtons.Right, 0, 0, 0, 0));
                }
                else
                {
                    WebBrowserProperty property = (WebBrowserProperty)(toolStripButton).Tag;
                    WebBrowserProperty.frontProperty = property;
                    foreach (ToolStripButton tsb in toolStrip3.Items)
                    {
                        tsb.Checked = false;
                    }
                    ((ToolStripButton)sender).Checked = true;
                    //设置标题和地址
                    if (e.Clicks != -1)
                    {
                        Text = WebBrowserProperty.frontProperty.siteTitle + " - so浏览器 2011 正式版";
                        toolStripComboBox1.Text    = WebBrowserProperty.frontProperty.webBrowser.LocationURL;
                        toolStripButton1.Enabled   = 后退BToolStripMenuItem.Enabled = WebBrowserProperty.frontProperty.canBack;
                        toolStripButton2.Enabled   = 前进FToolStripMenuItem.Enabled = WebBrowserProperty.frontProperty.canForward;
                        toolStripStatusLabel1.Text = WebBrowserProperty.frontProperty.statusText;
                    }
                    //设置前端显示
                    WebBrowserProperty.frontProperty.webBrowser.BringToFront();
                }
            }
        }
Пример #3
0
        private void axWebBrowser1_StatusTextChange(object sender, AxSHDocVw.DWebBrowserEvents2_StatusTextChangeEvent e)
        {
            AxSHDocVw.AxWebBrowser webBrowser = (AxSHDocVw.AxWebBrowser)sender;
            WebBrowserProperty     property   = (WebBrowserProperty)webBrowser.Tag;

            property.statusText = e.text;
            if (webBrowser == WebBrowserProperty.frontProperty.webBrowser)
            {
                toolStripStatusLabel1.Text = e.text;
            }
        }
Пример #4
0
        void toolStripButton_MouseMove(object sender, MouseEventArgs e)
        {
            ToolStripButton    toolStripButton = (ToolStripButton)sender;
            WebBrowserProperty property        = (WebBrowserProperty)(toolStripButton).Tag;

            if (e.X > toolStripButton.Size.Width - closeLeft ^ property.isInClose)
            {
                property.isInClose = !property.isInClose;
                toolStrip3.Refresh();
            }
        }
Пример #5
0
        private void axWebBrowser1_TitleChange(object sender, AxSHDocVw.DWebBrowserEvents2_TitleChangeEvent e)
        {
            AxSHDocVw.AxWebBrowser webBrowser = (AxSHDocVw.AxWebBrowser)sender;
            WebBrowserProperty     property   = (WebBrowserProperty)webBrowser.Tag;

            property.siteTitle                   = e.text;
            property.toolStripButton.Text        = GetSubstring(e.text, 25);
            property.toolStripButton.ToolTipText = e.text;
            if (webBrowser == WebBrowserProperty.frontProperty.webBrowser)
            {
                Text = e.text + " - so浏览器 2011 正式版";
                toolStripComboBox1.Text = webBrowser.LocationURL;
            }
        }
Пример #6
0
        void toolStripButton_Paint(object sender, PaintEventArgs e)
        {
            ToolStripButton toolStripButton = (ToolStripButton)sender;

            toolStripButton.TextAlign = ContentAlignment.MiddleLeft;
            WebBrowserProperty property = (WebBrowserProperty)(toolStripButton).Tag;
            Graphics           g        = e.Graphics;

            if (property.isInClose)
            {
                g.FillEllipse(Brushes.DarkRed, new Rectangle(toolStripButton.Size.Width - closeLeft, closeTop, closeWidth, closeWidth));
            }
            g.DrawLine(property.isInClose ? new Pen(Color.White, 2) : new Pen(Color.Gray, 2), new Point(toolStripButton.Size.Width - closeLeft + 2, closeTop + 2), new Point(toolStripButton.Size.Width - closeLeft + closeWidth - 2, closeWidth + closeTop - 2));
            g.DrawLine(property.isInClose ? new Pen(Color.White, 2) : new Pen(Color.Gray, 2), new Point(toolStripButton.Size.Width - closeLeft + 2, closeWidth + closeTop - 2), new Point(toolStripButton.Size.Width - closeLeft + closeWidth - 2, closeTop + 2));
        }
Пример #7
0
        private AxSHDocVw.AxWebBrowser IniWebBrowser()
        {
            //初始化浏览器
            AxSHDocVw.AxWebBrowser webBrowser = new AxSHDocVw.AxWebBrowser();
            webBrowser.Dock                = System.Windows.Forms.DockStyle.Fill;
            webBrowser.NewWindow2         += new AxSHDocVw.DWebBrowserEvents2_NewWindow2EventHandler(this.axWebBrowser1_NewWindow2);
            webBrowser.ProgressChange     += new AxSHDocVw.DWebBrowserEvents2_ProgressChangeEventHandler(this.axWebBrowser1_ProgressChange);
            webBrowser.StatusTextChange   += new AxSHDocVw.DWebBrowserEvents2_StatusTextChangeEventHandler(this.axWebBrowser1_StatusTextChange);
            webBrowser.CommandStateChange += new AxSHDocVw.DWebBrowserEvents2_CommandStateChangeEventHandler(this.axWebBrowser1_CommandStateChange);
            webBrowser.TitleChange        += new AxSHDocVw.DWebBrowserEvents2_TitleChangeEventHandler(this.axWebBrowser1_TitleChange);
            webBrowser.SetSecureLockIcon  += new AxSHDocVw.DWebBrowserEvents2_SetSecureLockIconEventHandler(this.axWebBrowser1_SetSecureLockIcon);
            webBrowser.WindowClosing      += new AxSHDocVw.DWebBrowserEvents2_WindowClosingEventHandler(webBrowser_WindowClosing);
            webBrowser.BeforeNavigate2    += new AxSHDocVw.DWebBrowserEvents2_BeforeNavigate2EventHandler(webBrowser_BeforeNavigate2);
            panel2.Controls.Add(webBrowser);
            Application.DoEvents();
            webBrowser.Silent = true;
            //初始化标签页
            ToolStripButton toolStripButton = new ToolStripButton("新标签页        ", imageList1.Images[0]);

            toolStripButton.AutoSize = false;
            toolStripButton.Width    = 200;
            toolStripButton.MouseUp += new MouseEventHandler(toolStripButton_MouseUp);
            toolStripButton.Margin   = new Padding(0, 0, 5, 0);
            //toolStripButton.BackColor = Color.FromArgb(216, 229, 250);
            toolStripButton.BackColor   = Color.FromArgb(254, 254, 255);
            toolStripButton.Paint      += new PaintEventHandler(toolStripButton_Paint);
            toolStripButton.MouseMove  += new MouseEventHandler(toolStripButton_MouseMove);
            toolStripButton.MouseLeave += new EventHandler(toolStripButton_MouseLeave);
            toolStrip3.Items.Insert(toolStrip3.Items.Count - 2, toolStripButton);
            //定义对应属性
            WebBrowserProperty property = new WebBrowserProperty();

            property.toolStripButton = toolStripButton;
            property.webBrowser      = webBrowser;
            webBrowser.Tag           = property;
            toolStripButton.Tag      = property;
            //设为当前焦点
            toolStripButton_MouseUp(toolStripButton, new MouseEventArgs(MouseButtons.Left, -1, 0, 0, 0));
            return(webBrowser);
        }
Пример #8
0
        private void axWebBrowser1_CommandStateChange(object sender, AxSHDocVw.DWebBrowserEvents2_CommandStateChangeEvent e)
        {
            AxSHDocVw.AxWebBrowser webBrowser = (AxSHDocVw.AxWebBrowser)sender;
            WebBrowserProperty     property   = (WebBrowserProperty)webBrowser.Tag;

            switch ((CommandStateChangeConstants)e.command)
            {
            case CommandStateChangeConstants.CSC_NAVIGATEBACK:
                property.canBack = e.enable;
                if (webBrowser == WebBrowserProperty.frontProperty.webBrowser)
                {
                    toolStripButton1.Enabled = 后退BToolStripMenuItem.Enabled = e.enable;
                }
                break;

            case CommandStateChangeConstants.CSC_NAVIGATEFORWARD:
                property.canForward = e.enable;
                if (webBrowser == WebBrowserProperty.frontProperty.webBrowser)
                {
                    toolStripButton2.Enabled = 前进FToolStripMenuItem.Enabled = e.enable;
                }
                break;
            }
        }