private void SwitchTab(TabGroup tabToSwitchTo) { if (FocusedTab == tabToSwitchTo) { return; } //AB_searchBox.PlaceholderText = $"Search with {Settings.UserSettings.SearchEngine} or enter address"; // Hides all tabs. foreach (var tab in tabs) { tab.TabButton.Active = false; tab.TabRenderer.Frame.Visibility = Visibility.Collapsed; } // Shows the chosen tab. FocusedTab = tabToSwitchTo; FocusedTab.TabButton.Active = true; FocusedTab.TabRenderer.Frame.Visibility = Visibility.Visible; FocusedTab.TabRenderer.Focus(FocusState.Keyboard); // Simple hack to update the top bar buttons when switching between existing tabs. OnNavigationComplete?.Invoke(tabToSwitchTo, true); }
private void HandleNavigationComplete(TabGroup tab, bool isFocusedTab) { // If the tab group is the focued tab group, update the command bar. if (isFocusedTab) { AB_backButton.IsEnabled = tab.TabRenderer.CanGoBack; AB_forwardButton.IsEnabled = tab.TabRenderer.CanGoForward; AB_searchBox.Text = tab.TabRenderer.Uri; UpdateRefreshButton(false, tab.TabRenderer); } }
public async Task <TabGroup> AddNewTab(bool forceSwitch = false) { var developingTab = new TabGroup(); var newTabButtonFrame = new Frame { CacheSize = 1 }; tabButtonsStackPanel.Children.Add(newTabButtonFrame); Windows.UI.Xaml.Navigation.NavigatedEventHandler foo = null; // Recieves the reference to the newly created Tab Button UI Element. foo = delegate(object sender, Windows.UI.Xaml.Navigation.NavigationEventArgs e) { // Gets the reference to the newly created Tab Button UI Element. var createdTabButton = e.Content as TabButton; developingTab.TabButton = createdTabButton; // Subscribes to events. developingTab.TabButton.TabOpenClick += HandleOpenTabClick; developingTab.TabButton.TabCloseClick += HandleCloseTabClick; var tabButtonFrame = sender as Frame; tabButtonFrame.Navigated -= foo; }; newTabButtonFrame.Navigated += foo; // Creates a new Tab Button UI Element. newTabButtonFrame.Navigate(typeof(TabButton)); var newTabViewFrame = new Frame { CacheSize = 1 }; Grid.SetRow(newTabViewFrame, 0); pageViewer.Children.Add(newTabViewFrame); // Recieves the reference to the newly created Tab View UI Element. foo = delegate(object sender, Windows.UI.Xaml.Navigation.NavigationEventArgs e) { var createdTabView = e.Content as TabRenderer; createdTabView.Frame.Visibility = Visibility.Collapsed; developingTab.TabRenderer = createdTabView; // Subscribes to events. developingTab.TabRenderer.OnNavigationStart += HandleNavigationStart; developingTab.TabRenderer.OnNavigationComplete += HandleNavigationComplete; var tabViewFrame = sender as Frame; tabViewFrame.Navigated -= foo; }; newTabViewFrame.Navigated += foo; // Creates a new Tab View UI Element. newTabViewFrame.Navigate(typeof(TabRenderer)); tabs.Add(developingTab); developingTab.TabRenderer.Query(UserSettings.HomeURL); if (forceSwitch || UserSettings.SwitchToNewTab) { SwitchTab(developingTab); } return(developingTab); }
private void HandleCloseTabClick(TabGroup tab) { tabButtonsStackPanel.Children.Remove(tab.TabButton.Frame); pageViewer.Children.Remove(tab.TabRenderer.Frame); }