Esempio n. 1
0
 private SuperTabItem GetTabItem(CefWebBrowserX cefWebBrowerX)
 {
     foreach (SuperTabItem item in this.superTabControlX.Tabs)
     {
         var browser = item.AttachedControl.Controls[0] as CefWebBrowserX;
         if (browser != null && browser == cefWebBrowerX)
         {
             return(item);
         }
     }
     return(null);
 }
Esempio n. 2
0
        public void OpenUrl(string url, string injectScript = null, bool forceNewTab = false)
        {
            CefWebBrowserX cefWebBrowerX = null;

            if (this.superTabControlX.Tabs.Count > 0 && !forceNewTab)
            {
                var superItem = this.superTabControlX.SelectedTab;
                cefWebBrowerX = superItem.AttachedControl.Controls[0] as CefWebBrowserX;
                cefWebBrowerX.OpenUrl(url, injectScript);
            }
            else
            {
                cefWebBrowerX = NewBrowser(url, false, injectScript);
            }
        }
Esempio n. 3
0
        public CefWebBrowserX NewBrowser(string url = null, bool selected = false, string injectScript = null)
        {
            try
            {
                var superItem = new SuperTabItem();
                superItem.Text    = "空白页";
                superItem.TabFont = new Font("微软雅黑", 9f);

                SuperTabControlPanel superTabControlPanel = new SuperTabControlPanel();
                superItem.AttachedControl    = superTabControlPanel;
                superTabControlPanel.TabItem = superItem;

                CefWebBrowserX cefWebBrowerX = new CefWebBrowserX();
                cefWebBrowerX.Dock = DockStyle.Fill;

                cefWebBrowerX.NewNavigateBrowser  += cefWebBrowerX_NewTabEvent;
                cefWebBrowerX.LoadingStateChanged += cefWebBrowerX_LoadingStateChanged;
                cefWebBrowerX.FrameLoadStart      += cefWebBrowerX_FrameLoadStart;
                cefWebBrowerX.CreateTab           += cefWebBrowerX_CreateTab;
                cefWebBrowerX.TitleChanged        += cefWebBrowerX_TitleChanged;

                superTabControlPanel.Controls.Add(cefWebBrowerX);
                this.superTabControlX.Tabs.Add(superItem);
                if (selected)
                {
                    this.superTabControlX.SelectedTab = superItem;
                }
                this.superTabControlX.Controls.Add(superTabControlPanel);

                cefWebBrowerX.OpenUrl(url, injectScript);
                return(cefWebBrowerX);
            }
            catch (Exception ex)
            {
                MessageBox.Show("打开页面异常:" + ex.Message + "\r\n" + ex.StackTrace);
                return(null);
            }
            finally
            {
            }
        }