Exemple #1
0
        private void SwitchTabs(string name, ToolStripButton btn)
        {
            try
            {
                csExWB.cEXWB pWB = FindBrowser(name);
                if (pWB == null)
                    return;

                //Uncheck last one
                if (m_iCountWB > 1)
                    ((ToolStripButton)tsWBTabs.Items[m_iCurTab]).Checked = false;
                m_iCurTab = tsWBTabs.Items.IndexOf(btn);

                m_CurWB = pWB;
                tsBtnBack.Enabled = m_CurWB.CanGoBack;
                tsBtnForward.Enabled = m_CurWB.CanGoForward;
                m_CurWB.BringToFront();
                m_CurWB.SetFocus();
                this.Text = m_CurWB.GetTitle(true);
                if (this.Text.Length == 0)
                    this.Text = m_Blank;
                if (btn != null)
                {
                    btn.Checked = true;
                    btn.Text = this.Text;
                    if (btn.Text.Length > m_MaxTextLen)
                        btn.Text = btn.Text.Substring(0, m_MaxTextLen) + "...";
                    btn.ToolTipText = HttpUtility.UrlDecode(m_CurWB.LocationUrl);
                    this.comboURL.Text = btn.ToolTipText;
                }

                //Uncheck all menu items first
                foreach (ToolStripItem item in ctxMnuOpenWBs.Items)
                {
                    if (item is ToolStripMenuItem)
                        ((ToolStripMenuItem)item).Checked = false;
                }
                //Find target menu item
                ToolStripMenuItem menu = FindWBMenu(name);
                m_iCurMenu = ctxMnuOpenWBs.Items.IndexOf((ToolStripItem)menu);
                if (menu != null)
                {
                    if (btn != null)
                        menu.Text = btn.Text;
                    menu.Checked = true;
                }
                //Reset and hide progressbar
                //If page is in the process of loading then the progressbar
                //will be adjusted
                tsProgress.Value = 0;
                tsProgress.Maximum = 0;
                tsProgress.Visible = false;

                //update SecureLockIcon state
                UpdateSecureLockIcon(m_CurWB.SecureLockIcon);
            }
            catch (Exception ee)
            {
                AllForms.m_frmLog.AppendToLog("SwitchingTabs\r\n" + ee.ToString());
            }
        }
Exemple #2
0
        /// <summary>
        /// Close all browsers except the first one from design time
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsMnuCloasAllWBs_Click(object sender, EventArgs e)
        {
            if (m_iCountWB == 1)
                return;
            try
            {
                foreach (ToolStripMenuItem item in ctxMnuOpenWBs.Items)
                {
                    RemoveBrowser2(item.Name, false);
                }
                ctxMnuOpenWBs.Items.Clear();

                m_CurWB = cEXWB1;
                m_CurWB.BringToFront();
                m_CurWB.SetFocus();

                m_tsBtnFirstTab.Checked = true;
                m_iCurTab = tsWBTabs.Items.IndexOf((ToolStripItem)m_tsBtnFirstTab);

                string text = m_CurWB.GetTitle(true);
                if (text.Length == 0)
                    text = m_Blank;
                ToolStripMenuItem menu = new ToolStripMenuItem(text, m_imgUnLock);
                menu.Name = m_tsBtnFirstTab.Name;
                menu.Checked = true;
                ctxMnuOpenWBs.Items.Add((ToolStripItem)menu);
                m_iCurMenu = ctxMnuOpenWBs.Items.Count - 1;

                tsBtnOpenWBs.Text = m_iCountWB.ToString() + " open tab(s)";
            }
            catch (Exception ee)
            {
                AllForms.m_frmLog.AppendToLog("tsMnuCloasAllWBs_Click\r\n" + ee.ToString());
            }
        }
Exemple #3
0
        private bool AddNewBrowser(string TabText, string TabTooltip, string Url, bool BringToFront)
        {
            //Copy flags
            int iDochostUIFlag = (int)(DOCHOSTUIFLAG.NO3DBORDER |
                        DOCHOSTUIFLAG.FLAT_SCROLLBAR | DOCHOSTUIFLAG.THEME);
            int iDocDlCltFlag = (int)(DOCDOWNLOADCTLFLAG.DLIMAGES |
                        DOCDOWNLOADCTLFLAG.BGSOUNDS | DOCDOWNLOADCTLFLAG.VIDEOS);

            if (m_CurWB != null)
            {
                iDochostUIFlag = m_CurWB.WBDOCHOSTUIFLAG;
                iDocDlCltFlag = m_CurWB.WBDOCDOWNLOADCTLFLAG;
            }

            csExWB.cEXWB pWB = null;

            int i = m_iCountWB + 1;
            string sname = "cEXWB" + i.ToString();

            try
            {
                ToolStripButton btn = new ToolStripButton();
                btn.ImageAlign = ContentAlignment.MiddleCenter;
                btn.ImageScaling = ToolStripItemImageScaling.None;
                btn.TextAlign = ContentAlignment.TopLeft;
                btn.TextImageRelation = TextImageRelation.TextAboveImage;
                btn.Name = sname;
                if (TabText.Length > 0)
                    btn.Text = TabText;
                else
                    btn.Text = m_Blank;
                btn.Image = m_BlankImage;
                if (TabTooltip.Length > 0)
                    btn.ToolTipText = TabTooltip;
                btn.AutoToolTip = true;
                btn.MouseUp += new MouseEventHandler(this.tsWBTabs_ToolStripButtonCtxMenuHandler);
                tsWBTabs.Items.Add(btn);

                //Create and setup browser
                pWB = new csExWB.cEXWB();

                //pWB.Dock = cEXWB1.Dock;
                pWB.Anchor = cEXWB1.Anchor;
                pWB.Name = sname;
                pWB.Location = cEXWB1.Location;
                pWB.Size = cEXWB1.Size;

                pWB.RegisterAsBrowser = true;
                pWB.WBDOCDOWNLOADCTLFLAG = iDocDlCltFlag;
                pWB.WBDOCHOSTUIFLAG = iDochostUIFlag;
                pWB.FileDownloadDirectory = cEXWB1.FileDownloadDirectory;

                //Add events, using the same eventhandlers for all browsers
                pWB.TitleChange += new csExWB.TitleChangeEventHandler(this.cEXWB1_TitleChange);
                pWB.StatusTextChange += new csExWB.StatusTextChangeEventHandler(this.cEXWB1_StatusTextChange);
                pWB.CommandStateChange += new csExWB.CommandStateChangeEventHandler(this.cEXWB1_CommandStateChange);
                pWB.WBKeyDown += new csExWB.WBKeyDownEventHandler(this.cEXWB1_WBKeyDown);
                pWB.WBEvaluteNewWindow += new csExWB.EvaluateNewWindowEventHandler(this.cEXWB1_WBEvaluteNewWindow);
                pWB.BeforeNavigate2 += new csExWB.BeforeNavigate2EventHandler(this.cEXWB1_BeforeNavigate2);
                pWB.ProgressChange += new csExWB.ProgressChangeEventHandler(this.cEXWB1_ProgressChange);
                pWB.NavigateComplete2 += new csExWB.NavigateComplete2EventHandler(this.cEXWB1_NavigateComplete2);
                pWB.DownloadBegin += new csExWB.DownloadBeginEventHandler(this.cEXWB1_DownloadBegin);
                pWB.ScriptError += new csExWB.ScriptErrorEventHandler(this.cEXWB1_ScriptError);
                pWB.DownloadComplete += new csExWB.DownloadCompleteEventHandler(this.cEXWB1_DownloadComplete);
                pWB.StatusTextChange += new csExWB.StatusTextChangeEventHandler(this.cEXWB1_StatusTextChange);
                pWB.DocumentCompleteEX += new csExWB.DocumentCompleteExEventHandler(this.cEXWB1_DocumentCompleteEX);
                pWB.WBDragDrop += new csExWB.WBDropEventHandler(cEXWB1_WBDragDrop);
                pWB.SetSecureLockIcon += new csExWB.SetSecureLockIconEventHandler(this.cEXWB1_SetSecureLockIcon);
                pWB.NavigateError += new csExWB.NavigateErrorEventHandler(this.cEXWB1_NavigateError);
                pWB.WBSecurityProblem += new csExWB.SecurityProblemEventHandler(this.cEXWB1_WBSecurityProblem);
                pWB.NewWindow2 += new csExWB.NewWindow2EventHandler(this.cEXWB1_NewWindow2);
                pWB.DocumentComplete += new csExWB.DocumentCompleteEventHandler(this.cEXWB1_DocumentComplete);
                pWB.NewWindow3 += new csExWB.NewWindow3EventHandler(this.cEXWB1_NewWindow3);
                pWB.WBKeyUp += new csExWB.WBKeyUpEventHandler(this.cEXWB1_WBKeyUp);
                pWB.WindowClosing += new csExWB.WindowClosingEventHandler(this.cEXWB1_WindowClosing);
                pWB.WBContextMenu += new csExWB.ContextMenuEventHandler(this.cEXWB1_WBContextMenu);
                pWB.WBDocHostShowUIShowMessage += new csExWB.DocHostShowUIShowMessageEventHandler(this.cEXWB1_WBDocHostShowUIShowMessage);
                pWB.FileDownload += new csExWB.FileDownloadEventHandler(this.cEXWB1_FileDownload);
                pWB.WBAuthenticate += new csExWB.AuthenticateEventHandler(this.cEXWB1_WBAuthenticate);
                pWB.WBStop += new csExWB.StopEventHandler(cEXWB1_WBStop);

                pWB.FileDownloadExStart += new csExWB.FileDownloadExEventHandler(cEXWB1_FileDownloadExStart);
                pWB.FileDownloadExEnd += new csExWB.FileDownloadExEndEventHandler(cEXWB1_FileDownloadExEnd);
                pWB.FileDownloadExProgress += new csExWB.FileDownloadExProgressEventHandler(cEXWB1_FileDownloadExProgress);
                pWB.FileDownloadExError += new csExWB.FileDownloadExErrorEventHandler(cEXWB1_FileDownloadExError);
                pWB.FileDownloadExAuthenticate += new csExWB.FileDownloadExAuthenticateEventHandler(cEXWB1_FileDownloadExAuthenticate);
                pWB.FileDownloadExDownloadFileFullyWritten += new csExWB.FileDownloadExDownloadFileFullyWrittenEventHandler(cEXWB1_FileDownloadExDownloadFileFullyWritten);

                pWB.WBStop += new csExWB.StopEventHandler(cEXWB1_WBStop);
                //pWB.ProcessUrlAction += new csExWB.ProcessUrlActionEventHandler(cEXWB1_ProcessUrlAction);

                pWB.WBLButtonDown += new csExWB.HTMLMouseEventHandler(cEXWB1_WBLButtonDown);
                pWB.WBLButtonUp += new csExWB.HTMLMouseEventHandler(cEXWB1_WBLButtonUp);
                //pWB.WBMouseMove += new csExWB.HTMLMouseEventHandler(cEXWB1_WBMouseMove);

                ////pWB.RegisterAsBrowser = true;

                //Add to controls collection
                //this.Controls.Add(pWB);
                this.toolStripContainer1.ContentPanel.Controls.Add(pWB);

                ToolStripMenuItem menu = new ToolStripMenuItem(btn.Text, m_imgUnLock);
                menu.Name = sname;
                ctxMnuOpenWBs.Items.Add((ToolStripItem)menu);

                if (BringToFront)
                {
                    //Uncheck last tab
                    ((ToolStripButton)tsWBTabs.Items[m_iCurTab]).Checked = false;
                    btn.Checked = true;

                    ((ToolStripMenuItem)ctxMnuOpenWBs.Items[m_iCurMenu]).Checked = false;
                    m_iCurMenu = ctxMnuOpenWBs.Items.Count - 1;
                    menu.Checked = true;

                    //Adjust current browser pointer
                    m_CurWB = pWB;
                    //Adjust current tab index
                    m_iCurTab = tsWBTabs.Items.Count - 1;
                    //Reset and hide progressbar
                    tsProgress.Value = 0;
                    tsProgress.Maximum = 0;
                    tsProgress.Visible = false;
                    //Bring to front
                    pWB.BringToFront();
                }
                //Increase count
                m_iCountWB++;
                tsBtnOpenWBs.Text = m_iCountWB.ToString() + " open tab(s)";

                if (Url.Length > 0)
                    pWB.Navigate(Url);
            }
            catch (Exception ee)
            {
                AllForms.m_frmLog.AppendToLog("AddNewBrowser\r\n" + ee.ToString());
                return false;
            }

            return true;
        }