Example #1
0
 /// <summary>
 /// Changes the local TabIcon for the TabBrowser
 /// </summary>
 /// <param name="icon">A image of the browser icon</param>
 public void ChangeTabIcon(Image ico)
 {
     mainTabPage.ChangeTabIcon(ico);
 }
Example #2
0
        public MaterialTabPage getIBrowserTab(BrowserType browserType, string URL, Size defaultSize)
        {
            // TabPage //
            tabPage.Size      = defaultSize;
            tabPage.BackColor = Color.White;
            //tabPage.ChangeTabIcon(Image.FromFile(Application.StartupPath + "\\settingslogo.ico"));

            // BrowserHandler //
            BrowserHeader          = new Igloo.Control.Browser.IBrowserHeader(defaultSize.Width);
            BrowserHeader.Anchor   = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
            BrowserHeader.Location = new Point(0, 0);

            tabPage.Controls.Add(BrowserHeader);

            // Browser Panel //
            pnl.Location  = new Point(0, BrowserHeader.Height);
            pnl.Size      = new Size(tabPage.Width, tabPage.Height - BrowserHeader.Height);
            pnl.Anchor    = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom);
            pnl.BackColor = Color.White;

            tabPage.Controls.Add(pnl);

            // IBrowser //
            GenerateBrowserHandle();

            //Initialize the browser
            browser.CreateBrowserHandle(URL, tabPage);

            //Setting the browser event's
            BrowserHeader.SendForwardClick += ((obj, args) => { browser.OnForward(); });
            BrowserHeader.SendBackClick    += ((obj, args) => { browser.OnBack(); });
            BrowserHeader.VPNButtonClicked += ((obj, args) =>
            {
                bool vpnSuc = browser.ToggleVPNService();

                if (vpnSuc)
                {
                    if (browser.GetVPNStatus())
                    {
                        BrowserHeader.ChangeVPNStatus(true);
                    }
                    else
                    {
                        BrowserHeader.ChangeVPNStatus(false);
                    }
                }
            });
            BrowserHeader.TextSearch_EnterPressed += ((obj, args) =>
            {
                string searchEntry = null;

                if (!CheckURLValid(BrowserHeader.GetTXTSearchValue()))
                {
                    searchEntry = GetSearchLink(BrowserHeader.GetTXTSearchValue());
                }
                else
                {
                    searchEntry = BrowserHeader.GetTXTSearchValue();
                }

                browser.Navigate(searchEntry);
            });
            BrowserHeader.SettingsClicked += ((obj, args) =>
            {
                //Modifying the settings form
                SettingsForm settings = new SettingsForm();
                settings.TopLevel = false;
                settings.Visible = true;
                settings.FormBorderStyle = FormBorderStyle.None;
                settings.Dock = DockStyle.Fill;

                //Setting TabControl as local var
                MaterialTabControl parentControl = (MaterialTabControl)tabPage.Parent;

                //Creating a new MaterialTabPage and adding the form as a control
                MaterialTabPage settingsTab = new MaterialTabPage();
                settingsTab.Text = ResourceInformation.ApplicationName + " Settings";
                settingsTab.Controls.Add(settings);

                //Add MaterialTabPage to the TabControl and select that tab
                parentControl.TabPages.Add(settingsTab);
                parentControl.SelectTab(settingsTab);

                //Change the tab icon
                settingsTab.ChangeTabIcon(Image.FromFile(Application.StartupPath + "\\settingslogo.ico"));
            });
            BrowserHeader.SendReloadClick += ((obj, args) =>
            {
                //Check if the browser is loading
                if (browser.IsLoading())
                {
                    //Stop loading the page
                    ((ChromiumWebBrowser)browser.GetBrowser()).GetBrowser().StopLoad();
                }
                else
                {
                    //Reload the page
                    ((ChromiumWebBrowser)browser.GetBrowser()).GetBrowser().Reload();
                }
            });
            browser.OnTitleChange += ((obj, args) =>
            {
                DocumentTitleChange e = args;

                //Change the text of the TabPage to the title.
                tabPage.Text = e.DocumentTitle;
            });
            browser.OnDocumentURLChange += ((obj, args) =>
            {
                DocumentURLChange e = args;

                //Change the text of the Search Bar
                BrowserHeader.ChangeTXTSearchValue(e.DocumentURL);
            });
            browser.LoadingStateChanged += ((obj, args) =>
            {
                //Chanes the look of the reload button depending on the status of the browser
                BrowserHeader.ChangeReloadStatus(browser.IsLoading());

                //Changes the IHeaderBrowser button status's
                Action action = new Action(() =>
                {
                    BrowserHeader.CanGoBackBool(browser.IsBackAvailiable());
                    BrowserHeader.CanGoForwardBool(browser.IsForwardAvailable());
                }); BrowserHeader.Invoke(new MethodInvoker(action));
            });

            pnl.Controls.Add(browser.GetBrowser());

            //Send the browser to the home page
            Console.WriteLine(URL);
            if (URL != null)
            {
                Console.WriteLine("Url is not null"); browser.Navigate(URL);
            }
            else
            {
                browser.Navigate("google.com");
            }

            return(tabPage);
        }