public override void SetNavigationBar() { NavigationBarControl.ShowBackButton(false); NavigationBarControl.ShowPageTitle(false); NavigationBarControl.ShowIntroLogo(true); NavigationBarControl.ShowSlideMenuButton(true); }
/// <summary> /// Manages the browser tabs /// </summary> private void ManageTabs() { // Close the app in case all tabs are closed this.browserTabControl.TabClosed += (object sender, EventArgs e) => { if (this.browserTabControl.TabCount == 0) { Environment.Exit(0); } }; // Start with one tab (Homepage) var webBrowser = new ChromiumWebBrowser(); webBrowser.BrowserSettings.FileAccessFromFileUrls = CefSharp.CefState.Enabled; // Enable loading local files through the browser var navigationBar = new NavigationBarControl(); BrowserTab browserTab = new BrowserTab(navigationBar, webBrowser); webBrowser.Address = GetInitialUrl(); Grid tabContent = CreateGrid(navigationBar, webBrowser); this.browserTabControl.AddTab(webBrowser, "Home page", tabContent); // Enable tab adding this.browserTabControl.NewTabButtonClick += (object sender, EventArgs e) => { this.AddNewTab(); }; }
} // Web Browser control /// <summary> /// Browser tab constructor /// </summary> /// <param name="navigationBar">Navigation bar control</param> /// <param name="webBrowser">Chromium web browser object</param> public BrowserTab(NavigationBarControl navigationBar, ChromiumWebBrowser webBrowser) { // Assign the properties this.NavigationBar = navigationBar; this.WebBrowser = webBrowser; this.Bind(); // Bind the Navigation bar and the web browser this.HandleEvents(); // Handle events of both NavigationBar and WebBrowser objects }
/// <summary> /// Creates a grid of the navigation bar combined /// </summary> /// <param name="navigationBar"></param> /// <param name="webBrowser"></param> /// <returns></returns> public static Grid CreateGrid(NavigationBarControl navigationBar, ChromiumWebBrowser webBrowser) { Grid grid = new Grid(); grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); grid.RowDefinitions.Add(new RowDefinition()); webBrowser.SetValue(Grid.RowProperty, 1); navigationBar.Height = 57; navigationBar.VerticalAlignment = VerticalAlignment.Top; grid.Children.Add(webBrowser); grid.Children.Add(navigationBar); return(grid); }
public void AddNewTab(string address = "") { var webBrowser = new ChromiumWebBrowser(); // In case no address was given use the default new tab address mentioned in user settings if (String.IsNullOrEmpty(address)) { address = UserSettings.Load().NewTabPage; } webBrowser.BrowserSettings.FileAccessFromFileUrls = CefSharp.CefState.Enabled; // Enable loading local files through the browser var navigationBar = new NavigationBarControl(); var browserTab = new BrowserTab(navigationBar, webBrowser); webBrowser.Address = address; Grid tabContent = CreateGrid(navigationBar, webBrowser); this.browserTabControl.AddTab(webBrowser, "New Tab", tabContent); }