private async void OpenFileItem_Click(object sender, RoutedEventArgs e) { var picker = new Windows.Storage.Pickers.FileOpenPicker(); picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail; picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary; picker.FileTypeFilter.Add(".js"); picker.FileTypeFilter.Add(".cs"); picker.FileTypeFilter.Add(".html"); picker.FileTypeFilter.Add(".scss"); picker.FileTypeFilter.Add(".fs"); picker.FileTypeFilter.Add(".css"); picker.FileTypeFilter.Add(".xml"); picker.FileTypeFilter.Add(".ts"); picker.FileTypeFilter.Add(".json"); picker.FileTypeFilter.Add(".py"); Windows.Storage.StorageFile file = await picker.PickSingleFileAsync(); if (file != null) { CodeEditor.UniversalEditor.Text = await FileIO.ReadTextAsync(file); CodeEditor.UniversalEditor.Text = await FileIO.ReadTextAsync(file); CodeEditor.LocalFile = file; TabViewItem ee = Tabs.SelectedItem as TabViewItem; ee.Header = file.Name; } else { var messageDialog = new MessageDialog("Cancelled"); await messageDialog.ShowAsync(); } }
public static void SetSelectedItem(TabViewItem item) { int index = IndexOfItem(item); Debug.Assert(index >= 0 && index < CustomTabViewItems.Count); SelectedIndex = index; }
private TabViewItem CreateNewTab(CWebShellInfo info, string Plugin) { TabViewItem newItem = new TabViewItem(); newItem.Header = info.Url; switch (Plugin) { case "FileManager": newItem.IconSource = new Microsoft.UI.Xaml.Controls.SymbolIconSource() { Symbol = Symbol.Folder }; var page = new Plugins.FileManagerPage(); page.SetInfo(info).ConfigureAwait(false); newItem.Content = page; break; case "RemoteShell": newItem.IconSource = new Microsoft.UI.Xaml.Controls.SymbolIconSource() { Symbol = Symbol.PostUpdate }; newItem.Content = new Plugins.TerminalPage(); break; } // The content of the tab is often a frame that contains a page, though it could be any UIElement. return(newItem); }
private TabViewItem CreateNewTab(Uri uri) { TabContentControl tabContent = new TabContentControl(uri); TabViewItem newItem = new TabViewItem() { Header = "New Tab", IconSource = new Microsoft.UI.Xaml.Controls.SymbolIconSource() { Symbol = Symbol.Document }, Content = tabContent }; // attach title changed event tabContent.DocumentTitleChangedEvent += (object sender, string title) => { newItem.Header = title; // update newTab Header }; // attach new window requested event tabContent.NewWindowRequested += (WebView sender, WebViewNewWindowRequestedEventArgs args) => { TabViewControl.TabItems.Add(CreateNewTab(args.Uri)); }; return(newItem); }
public static void RemoveChapter(TabViewItem item) { int index = IndexOfItem(item); Debug.Assert(index >= 0); CustomTabViewItems.RemoveAt(index); }
public void OpenNewPage(string uriString = null) { if (uriString == null) { uriString = defaultPageUri; } Uri uri; try { uri = new Uri(uriString); } catch (Exception e) { Debug.WriteLine(e); return; } var webView = new WebView { Source = uri }; webView.NavigationCompleted += WebView_NavigationCompleted; var newTab = new TabViewItem { Content = webView, Header = uriString }; tabView.TabItems.Add(newTab); tabView.SelectedItem = newTab; }
private async Task InitializeAsync(TabViewItem tabViewItem) { if (tabViewItem.Content.BindingContext is IInitialize viewModel) { await viewModel.InitializeAsync().ConfigureAwait(false); } }
private TabViewItem CreateNewTVI(string header, string dataContext) { var newTab = new TabViewItem() { IconSource = new Microsoft.UI.Xaml.Controls.SymbolIconSource() { Symbol = Symbol.Placeholder }, Header = header, Content = new MyTabContentControl() { DataContext = dataContext } }; var contextFlyout = new MenuFlyout(); var moveToNewWindowFlyout = new MenuFlyoutItem(); moveToNewWindowFlyout.Text = "Move to new window"; moveToNewWindowFlyout.Click += MoveToNewWindowFlyout_Click; contextFlyout.Items.Add(moveToNewWindowFlyout); newTab.ContextFlyout = contextFlyout; void MoveToNewWindowFlyout_Click(object _sender, RoutedEventArgs e) { MoveTabToNewWindow(newTab); } return(newTab); }
private TabViewItem CreateNewTab(int index) { TabViewItem newItem = new TabViewItem(); newItem.Header = $"Document {index}"; newItem.IconSource = new Microsoft.UI.Xaml.Controls.SymbolIconSource() { Symbol = Symbol.Document }; // The content of the tab is often a frame that contains a page, though it could be any UIElement. Frame frame = new Frame(); switch (index % 3) { case 0: frame.Navigate(typeof(SamplePage1)); break; case 1: frame.Navigate(typeof(SamplePage2)); break; case 2: frame.Navigate(typeof(SamplePage3)); break; } newItem.Content = frame; return(newItem); }
private static void OnHideHeaderToolTipChanged(TabViewItem control, DependencyPropertyChangedEventArgs e) { if (ToolTipService.GetToolTip(control) is ToolTip tooltip) { tooltip.Opened += (s, e) => tooltip.IsOpen = false; } }
private async void poluchatel() { history = new List <History>(); klad = new List <Kladka>(); zapis = new History(); kladadd = new Kladka(); findsys = new FindSystem(); StorageFolder folder = ApplicationData.Current.LocalFolder; StorageFile file_History = await folder.CreateFileAsync("db_history.xml", CreationCollisionOption.OpenIfExists); StorageFile file_Kladka = await folder.CreateFileAsync("db_kladka.xml", CreationCollisionOption.OpenIfExists); StorageFile file_FindSys = await folder.CreateFileAsync("db_findsys.xml", CreationCollisionOption.OpenIfExists); try { XmlSerializer xml_deser_history = new XmlSerializer(typeof(List <History>)); XmlSerializer xml_deser_kladka = new XmlSerializer(typeof(List <Kladka>)); XmlSerializer xml_deser_findsys = new XmlSerializer(typeof(FindSystem)); using (Stream stream_deser_history = await file_History.OpenStreamForReadAsync()) { history = (List <History>)xml_deser_history.Deserialize(stream_deser_history); } using (Stream stream_deser_kladka = await file_Kladka.OpenStreamForReadAsync()) { klad = (List <Kladka>)xml_deser_kladka.Deserialize(stream_deser_kladka); } using (Stream stream_deser_findsys = await file_FindSys.OpenStreamForReadAsync()) { findsys = (FindSystem)xml_deser_findsys.Deserialize(stream_deser_findsys); } } catch (Exception e) { var msg = new MessageDialog(e.ToString()).ShowAsync(); otpravitel_find_sys("https://yandex.ru"); otpravitel_History(); otpravitel_kladki(); } TabViewItem tab = new TabViewItem(); tab.Header = "Новая вкладка"; WebView web = new WebView(); tab.Content = web; tabView.TabItems.Add(tab); web.Navigate(new Uri(findsys.findsystem)); web.NavigationStarting += Web_SetAdress; web.NavigationFailed += Web_Send; web.NewWindowRequested += Web_OpenWindow; }
public TabViewItemExample() { InitializeComponent(); // >> tabview-features-tabviewitem-csharp RadTabView tabView = new RadTabView(); TabViewItem homeTab = new TabViewItem() { HeaderText = "Home", Content = new Label() { Text = "This is the content of the Home tab", Margin = new Thickness(10) }, }; TabViewItem viewTab = new TabViewItem() { HeaderText = "View", Content = new Label() { Text = "This is the content of the View tab", Margin = new Thickness(10) }, }; StackLayout folderTabHeaderPanel = new StackLayout() { Orientation = StackOrientation.Horizontal, Margin = new Thickness(5, 0, 0, 0), }; folderTabHeaderPanel.Children.Add(new ContentView() { BackgroundColor = (Color)(new ColorTypeConverter()).ConvertFromInvariantString("#CA5100"), WidthRequest = 10, HeightRequest = 10, VerticalOptions = LayoutOptions.Center, }); folderTabHeaderPanel.Children.Add(new Label() { Text = "Folder" }); TabViewItem folderTab = new TabViewItem() { Header = new TabViewHeaderItem() { Content = folderTabHeaderPanel }, Content = new Label() { Text = "This is the content of the Folder tab", Margin = new Thickness(10) }, }; tabView.Items.Add(homeTab); tabView.Items.Add(viewTab); tabView.Items.Add(folderTab); // << tabview-features-tabviewitem-csharp }
private void ClosePage(TabViewItem tabItem) { var frame = tabItem.Content as MyFrame; frame.Close(); tabView.TabItems.Remove(tabItem); GC.Collect(); }
private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) { CodeEditor.UniversalEditor.CodeLanguage = ComboLanguageBox.SelectedItem.ToString(); switch (ComboLanguageBox.SelectedItem.ToString()) { case "css": CodeEditor.Fileextension = ".css"; break; case "scss": CodeEditor.Fileextension = ".scss"; break; case "json": CodeEditor.Fileextension = ".json"; break; case "javascript": CodeEditor.Fileextension = ".js"; break; case "typescript": CodeEditor.Fileextension = ".ts"; break; case "html": CodeEditor.Fileextension = ".html"; break; case "python": CodeEditor.Fileextension = ".py"; break; case "xml": CodeEditor.Fileextension = ".xml"; break; case "csharp": CodeEditor.Fileextension = ".cs"; break; case "fsharp": CodeEditor.Fileextension = ".fs"; break; } if (string.IsNullOrEmpty(DocumentName.Text) == true) { CodeEditor.NameOfDocument = "New Document"; TabViewItem Tab = MainPage.TabsMain.SelectedItem as TabViewItem; Tab.Header = "New Document" + CodeEditor.Fileextension; } else { CodeEditor.NameOfDocument = DocumentName.Text; TabViewItem Tab = MainPage.TabsMain.SelectedItem as TabViewItem; Tab.Header = DocumentName.Text + CodeEditor.Fileextension; } }
static ISelectionItemProvider GetProviderFromTVI(TabViewItem item) { var peer = FrameworkElementAutomationPeer.CreatePeerForElement(item); var provider = peer.GetPattern(PatternInterface.SelectionItem) as ISelectionItemProvider; Verify.IsNotNull(provider); return(provider); }
/// <summary> /// /// </summary> /// <param name="eventArgs"></param> private void OnTabViewTabCloseRequested(TabViewTabCloseRequestedEventArgs eventArgs) { TabUiItem tabUiItem = (eventArgs.Item as TabUiItem); TabViewItem tabViewItem = (eventArgs.Tab as TabViewItem); this.CurrentTabUiItems.Remove(tabUiItem); this.CheckTabItemsEmptyTabs(); }
private static void RemoveTabViewItem(RadTabView tabView, int i) { TabViewItem tabItem = tabView.Items[i]; tabItem.BindingContext = null; tabItem.Header.ControlTemplate = null; tabItem.Content = null; tabView.Items.RemoveAt(i); }
private void TabViewItem_DragEnter(object sender, DragEventArgs e) { e.AcceptedOperation = ((sender as TabViewItem).DataContext as TabItem).Control.TabItemContent.TabItemDragOver(sender, e); if (e.AcceptedOperation != DataPackageOperation.None) { HorizontalTabView.CanReorderTabs = false; tabHoverTimer.Start(); hoveredTabViewItem = sender as TabViewItem; } }
private static TabViewItem CreateTabViewItem(string name, bool closable = true, bool enabled = true) { var tabViewItem = new TabViewItem(); tabViewItem.Header = name; tabViewItem.IsClosable = closable; tabViewItem.IsEnabled = enabled; return(tabViewItem); }
private static void InsertTabViewItem(RadTabView tabView, object item, int index) { TabViewItem tabItem = new TabViewItem(); tabItem.Header.ControlTemplate = GetItemHeaderTemplate(tabView); tabItem.BindingContext = item; tabItem.Content = new BindableView { ControlTemplate = GetItemContentTemplate(tabView) }; tabView.Items.Insert(index, tabItem); }
private TabView GetParentTabView() { TabView parentTabView = null; TabViewItem tabViewItem = Owner as TabViewItem; if (tabViewItem != null) { parentTabView = tabViewItem.GetParentTabView(); } return(parentTabView); }
private void Tabview_AddTabButtonClick(TabView sender, object args) { TabViewItem item = new TabViewItem(); item.IconSource = new Microsoft.UI.Xaml.Controls.SymbolIconSource { Symbol = Symbol.Accept }; item.Header = "New Tab " + _newTabNumber++; item.Content = item.Header; sender.TabItems.Add(item); }
private void TabView_AddTabButtonClick(TabView sender, object args) { var frame = new Frame(); frame.Navigate(typeof(TestPage)); var tab = new TabViewItem { Header = "Not broken", Content = frame }; sender.TabItems.Add(tab); }
public void AddButtonClick(object sender, object e) { if (Tabs != null) { TabViewItem item = new TabViewItem(); item.Header = "New Tab " + _newTabNumber; item.Content = item.Header; Tabs.TabItems.Add(item); _newTabNumber++; } }
public void TabView_AddTabButtonClick(TabView sender, object args) { var frame = new Windows.UI.Xaml.Controls.Frame(); frame.Navigate(typeof(TestPage)); var tab = new TabViewItem { Header = "Broken", Content = frame }; Tabs.Add(tab); }
public void LoadSourceCode() { string folderPath = SampleManager.Current.SelectedSample.Path; // Source code of the file. string source; // Create a new list of TabViewItems. tabs = new List <TabViewItem>(); // Loop through all .cs and .xaml files. foreach (string filepath in Directory.GetFiles(folderPath) .Where(candidate => candidate.EndsWith(".cs") || candidate.EndsWith(".xaml"))) { // Get the source text from the file. source = File.ReadAllText(filepath); // Create a new tab. TabViewItem newTab = new TabViewItem(); // Set the tab text to the file name. newTab.Header = Path.GetFileName(filepath); // Create the code viewer. Monaco.CodeEditor viewer = new Monaco.CodeEditor(); viewer.Options.ReadOnly = true; viewer.Text = source; // Change Monaco language for C# files. if (filepath.EndsWith(".cs")) { viewer.CodeLanguage = "csharp"; } // Adjust tabs for dark mode. if (App.Current.RequestedTheme == Windows.UI.Xaml.ApplicationTheme.Dark) { Tabs.RequestedTheme = Windows.UI.Xaml.ElementTheme.Dark; newTab.RequestedTheme = Windows.UI.Xaml.ElementTheme.Dark; } // Set the tabs content to the code viewer. newTab.Content = viewer; // Add the tab to the beginning of the list. tabs.Insert(0, newTab); } // Set the Tab source to the list of tabs. Tabs.ItemsSource = tabs; }
private void TabView_AddTabButtonClick_1(Microsoft.UI.Xaml.Controls.TabView sender, object args) { TabViewItem tab = new TabViewItem(); tab.Header = "Новая вкладка"; WebView web = new WebView(); tab.Content = web; sender.TabItems.Add(tab); web.Navigate(new Uri(findsys.findsystem)); web.NavigationStarting += Web_SetAdress; web.NavigationFailed += Web_Send; web.NewWindowRequested += Web_OpenWindow; }
private static TabViewItem CreateTabViewItem(string name, Symbol icon, bool closable = true, bool enabled = true) { var tabViewItem = new TabViewItem(); tabViewItem.Header = name; tabViewItem.IconSource = new Microsoft.UI.Xaml.Controls.SymbolIconSource() { Symbol = icon }; tabViewItem.IsClosable = closable; tabViewItem.IsEnabled = enabled; return(tabViewItem); }
private void TabViewItem_DragEnter(object sender, DragEventArgs e) { if (e.DataView.AvailableFormats.Contains(StandardDataFormats.StorageItems)) { HorizontalTabView.CanReorderTabs = false; e.AcceptedOperation = DataPackageOperation.Move; tabHoverTimer.Start(); hoveredTabViewItem = sender as TabViewItem; } else { e.AcceptedOperation = DataPackageOperation.None; } }
public static int IndexOfItem(TabViewItem item) { int index = -1; for (int i = 0; i < CustomTabViewItems.Count; i++) { if (CustomTabViewItems[i].TabItem == item) { index = i; break; } } return(index); }