Exemple #1
0
        /// <summary>
        /// Adds a tab to the tab control that contains the settings page.
        /// </summary>
        private void AddSettingsTab()
        {
            // New tab
            var settingsTab = new muxc.TabViewItem();

            // Name the header "Settings"
            settingsTab.Header = "Settings";
            // name the tab
            settingsTab.Name = "settingsTab";
            // Change the tab icon.
            settingsTab.IconSource = new muxc.SymbolIconSource()
            {
                Symbol = Symbol.Setting
            };

            // Create a frame instance
            Frame frame = new Frame();

            // Add the frame to the tab
            settingsTab.Content = frame;

            // Navigate the frame to the settings page.
            frame.Navigate(typeof(SettingsPage));

            // Add the tab to the tab control.
            TabControl.TabItems.Add(settingsTab);

            // Set the newly created tab as the selected tab.
            TabControl.SelectedItem = settingsTab;
        }
Exemple #2
0
        private void AddNewTab(Uri Url)
        {
            var newTab = new muxc.TabViewItem();

            newTab.IconSource = new muxc.SymbolIconSource()
            {
                Symbol = Symbol.Document
            };
            newTab.Header = "New Tab";

            WebView webView = new WebView();

            webView.IsRightTapEnabled = true;

            newTab.Content = webView;
            webView.Navigate(Url);

            TabControl.TabItems.Add(newTab);

            TabControl.SelectedItem = newTab;

            webView.NavigationCompleted += BrowserNaviagted;
            webView.NewWindowRequested  += NewWindowRequested;

            currentSelectedTab     = newTab;
            currentSelectedWebView = webView;
        }
Exemple #3
0
        /// <summary>
        /// Navigate the webBrowser home.
        /// </summary>
        private async void GetHome()
        {
            // Try navigate home
            try
            {
                DataTransfer dt = new DataTransfer();

                homeName = await dt.GetHomeAttribute("name");

                homeUrl = await dt.GetHomeAttribute("url");
            }
            catch (Exception ex)
            {
                // Show a error message if there is an issue.
                MessageDialog msg = new MessageDialog(ex.Message);
                await msg.ShowAsync();
            }

            // See if the homeUrl and homeName are not null.
            if (!string.IsNullOrEmpty(homeUrl) || !string.IsNullOrEmpty(homeName))
            {
                // Naviaget home if they aren't.
                NavigateHome();
            }

            currentSelectedTab     = defaultTab;
            currentSelectedWebView = webBrowser;
        }
Exemple #4
0
        private void TabControl_TabCloseRequested(muxc.TabView sender, muxc.TabViewTabCloseRequestedEventArgs args)
        {
            sender.TabItems.Remove(args.Tab);
            currentSelectedTab     = null;
            currentSelectedWebView = null;

            if (args.Tab.Name == "settingsTab")
            {
                settingTabCount = 0;
            }
        }
Exemple #5
0
        private void TabViewControl_AddTabButtonClick(muxc.TabView sender, object args)
        {
            var newTab = new muxc.TabViewItem();

            newTab.Header = "Nowe SVG";
            Frame newFrame = new Frame();

            newTab.Content = newFrame;
            newFrame.Navigate(typeof(NavPage));
            sender.TabItems.Add(newTab);
            TabViewControl.SelectedItem = newTab;
        }
Exemple #6
0
        private void TabView_AddTabButtonClick(MUXC.TabView sender, object args)
        {
            var newTab = new MUXC.TabViewItem();

            newTab.IconSource = new MUXC.SymbolIconSource()
            {
                Symbol = Symbol.Document
            };
            newTab.Header = "New Document";

            // The Content of a TabViewItem is often a frame which hosts a page.

            sender.TabItems.Add(newTab);
        }
        TabViewItem CreateNewTab(TabViewItemDataTemplate _i)
        {
            TabViewItem newItem = new TabViewItem
            {
                Header     = _i.Header,
                Content    = _i.Content,
                IconSource = new Microsoft.UI.Xaml.Controls.SymbolIconSource()
                {
                    Symbol = _i.Symbol
                },
                IsClosable = false
            };

            return(newItem);
        }
Exemple #8
0
        //创建一个新tab。
        private muxc.TabViewItem createTabViewItem(CodeEditSessionInfo session)
        {
            var newTab = new muxc.TabViewItem()
            {
                Header     = "与" + session.Contact.DisplayName + "聊天中的代码",
                IsClosable = true,
                IconSource = new muxc.SymbolIconSource()
                {
                    Symbol = Symbol.Document
                },
                Content = "",
                Tag     = session
            };

            return(newTab);
        }
    public async System.Threading.Tasks.Task CloseTab(winui.Controls.TabViewItem tab, bool dispose = true)
    {
        if (tab is null)
        {
            return;
        }
        if (dispose)
        {
            //((tab?.Content as Frame)?.Content as BookFixed3Viewer)?.CloseOperation();
            ((tab?.Content as Frame)?.Content as IDisposable)?.Dispose();
            ((tab?.Content as Frame)?.Content as IDisposableBasic)?.DisposeBasic();
            (tab?.Content as Frame)?.Navigate(typeof(Page));
        }

        if (tab.IsClosable)
        {
            TabViewMain.TabItems.Remove(tab);
        }

        if (TabViewMain.TabItems.Count == 0)
        {
            //https://github.com/microsoft/Xaml-Controls-Gallery/blob/master/XamlControlsGallery/TabViewPages/TabViewWindowingSamplePage.xaml.cs
            //This is far from smartness. But this is in microsoft repo.
            //There should be a way to detect this is mainwindow or not, but I dont know.
            if (RootAppWindow != null)
            {
                await RootAppWindow.CloseAsync();
            }
            else
            {
                try
                {
                    //I need to close only main window. But error occurs and I have no idea how to fix it...
                    //Closing main window is not allowed.
                    //There is a question but no answer.
                    //https://stackoverflow.com/questions/39944258/closing-main-window-is-not-allowed

                    //Application.Current.Exit();
                    //Window.Current.Close();
                    //OpenTabWeb("https://www.google.com/");
                }
                catch (InvalidOperationException)
                {
                }
            }
        }
    }
Exemple #10
0
        private Microsoft.UI.Xaml.Controls.TabViewItem CreateDefaultTab()
        {
            Frame frame = new Frame();

            frame.Navigate(typeof(MainPage));

            var tabViewItem = new Microsoft.UI.Xaml.Controls.TabViewItem
            {
                Header     = "Home",
                IconSource = new Microsoft.UI.Xaml.Controls.SymbolIconSource {
                    Symbol = Symbol.Home
                },
                Content = frame,
            };

            return(tabViewItem);
        }
Exemple #11
0
    public (Frame, winui.Controls.TabViewItem) OpenTab(string titleId)
    {
        var newTab      = new winui.Controls.TabViewItem();
        var titleString = UIHelper.GetTitleByResource(titleId);

        newTab.Header = string.IsNullOrWhiteSpace(titleString) ? "New Tab" : titleString;

        Frame frame = new();

        newTab.Content = frame;

        TabViewMain.TabItems.Add(newTab);
        TabViewMain.SelectedItem = newTab;

        frame.Focus(FocusState.Programmatic);

        return(frame, newTab);
    }
Exemple #12
0
        private void TabView_AddTabButtonClick(muxc.TabView sender, object args)
        {
            var newTab = new muxc.TabViewItem();

            newTab.IconSource = new muxc.SymbolIconSource()
            {
                Symbol = Symbol.Document
            };
            newTab.Header = "Explore";

            // The Content of a TabViewItem is often a frame which hosts a page.
            Frame frame = new Frame();

            newTab.Content = frame;
            frame.Navigate(typeof(Page));

            sender.TabItems.Add(newTab);
        }
Exemple #13
0
        private TabViewItem CreateNewTab(string url)
        {
            var newTab = new muxc.TabViewItem();

            newTab.IconSource = new muxc.SymbolIconSource()
            {
                Symbol = Symbol.Document
            };
            newTab.Header = "New Document";

            // The Content of a TabViewItem is often a frame which hosts a page.
            Frame frame = new Frame();

            newTab.Content = frame;
            frame.Navigate(typeof(BrowserTab), url);
            //new MessageDialog(MyTabView.Height.ToString(), "消息提示").ShowAsync();
            return(newTab);
        }
Exemple #14
0
        private async void SymbolsTab_AddTabButtonClick(WinUI.TabView sender, object args)
        {
            var textBox = new TextBox {
                AcceptsReturn = false, Text = "GOOGL"
            };
            var dialog = new ContentDialog
            {
                Content = textBox,
                Title   = "Add a new stock symbol",
                IsSecondaryButtonEnabled = true,
                PrimaryButtonText        = "Let's see",
                SecondaryButtonText      = "No thanks"
            };

            if (await dialog.ShowAsync() == ContentDialogResult.Primary)
            {
                var newTab = new WinUI.TabViewItem();
                newTab.Header = textBox.Text;
                sender.TabItems.Add(newTab);
                sender.SelectedIndex = sender.TabItems.Count - 1;
            }
        }
Exemple #15
0
        private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            currentSelectedTab = TabControl.SelectedItem as muxc.TabViewItem;
            if (currentSelectedTab != null)
            {
                currentSelectedWebView = currentSelectedTab.Content as WebView;
            }

            if (currentSelectedWebView != null)
            {
                AppTitle.Text = "Pulse Ignite Browser | " + currentSelectedWebView.DocumentTitle;
            }

            if (!statusText.Text.Contains("BlankPage") && currentSelectedWebView != null)
            {
                statusText.Text = currentSelectedWebView.Source.AbsoluteUri;
            }
            else
            {
                statusText.Text = "Blank Page";
            }
        }
Exemple #16
0
        private void TabControl_AddTabButtonClick(muxc.TabView sender, object args)
        {
            var newTab = new muxc.TabViewItem();

            newTab.IconSource = new muxc.SymbolIconSource()
            {
                Symbol = Symbol.Document
            };
            newTab.Header = "Blank Page";

            WebView webView = new WebView();

            string path = $"ms-appx-web:///Assets/BlankPage.html";


            newTab.Content = webView;
            webView.Navigate(new Uri(path));

            sender.TabItems.Add(newTab);

            sender.SelectedItem = newTab;
        }
Exemple #17
0
 internal TabViewTabDragCompletedEventArgs(DragItemsCompletedEventArgs args, object item, TabViewItem tab)
 {
     _args = args;
     Item  = item;
     Tab   = tab;
 }
Exemple #18
0
 internal TabViewTabDragCompletedEventArgs(DataPackageOperation dropResult, object item, TabViewItem tab)
 {
     DropResult = dropResult;
     Item       = item;
     Tab        = tab;
 }
Exemple #19
0
 internal TabViewTabDragStartingEventArgs(DragItemsStartingEventArgs args, object item, TabViewItem tab)
 {
     _args = args;
     Item  = item;
     Tab   = tab;
 }
 internal TabViewTabDragStartingEventArgs(DataPackage data, object item, TabViewItem tab)
 {
     Data = data;
     Item = item;
     Tab  = tab;
 }
Exemple #21
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            var ctvi = e.Parameter as Microsoft.UI.Xaml.Controls.TabViewItem;

            currentTabVI = ctvi;
        }