public void CreateNewTab(int?InsertIndex, params string[] Path) { int Index = InsertIndex ?? (TabViewControl?.TabItems.Count ?? 0); try { if (CreateNewTabCore(Path) is TabViewItem Item) { TabViewControl.TabItems.Insert(Index, Item); TabViewControl.UpdateLayout(); TabViewControl.SelectedItem = Item; } } catch (Exception ex) { if (CreateNewTabCore() is TabViewItem Item) { TabViewControl.TabItems.Insert(Index, Item); TabViewControl.UpdateLayout(); TabViewControl.SelectedItem = Item; } LogTracer.Log(ex, "Error happened when try to create a new tab"); } }
public async Task CreateNewTabAndOpenTargetFolder(string Path) { if (CreateNewTab(await StorageFolder.GetFolderFromPathAsync(Path)) is TabViewItem Item) { TabViewControl.TabItems.Add(Item); TabViewControl.UpdateLayout(); TabViewControl.SelectedItem = Item; if (TabViewControl.TabItems.Count > 1) { foreach (TabViewItem Tab in TabViewControl.TabItems) { Tab.IsClosable = true; } } } }
public void CreateNewTabAndOpenTargetFolder(string Path, int?InsertIndex = null) { int Index = InsertIndex ?? (TabViewControl?.TabItems.Count ?? 0); try { if (string.IsNullOrWhiteSpace(Path)) { if (CreateNewTab() is TabViewItem Item) { TabViewControl.TabItems.Insert(Index, Item); TabViewControl.UpdateLayout(); TabViewControl.SelectedItem = Item; } } else { if (CreateNewTab(Path) is TabViewItem Item) { TabViewControl.TabItems.Insert(Index, Item); TabViewControl.UpdateLayout(); TabViewControl.SelectedItem = Item; } } } catch (Exception ex) { if (CreateNewTab() is TabViewItem Item) { TabViewControl.TabItems.Insert(Index, Item); TabViewControl.UpdateLayout(); TabViewControl.SelectedItem = Item; } LogTracer.Log(ex, "Error happened when try to create a new tab"); } }
public async Task CreateNewTabAndOpenTargetFolder(string Path, int?InsertIndex = null) { int Index = InsertIndex ?? (TabViewControl?.TabItems.Count ?? 0); try { if (string.IsNullOrWhiteSpace(Path)) { if (CreateNewTab() is TabViewItem Item) { //预览版TabView在没有子Item时会崩溃,此方案作为临时解决方案 if (TabViewControl == null) { _ = FindName(nameof(TabViewControl)); } TabViewControl.TabItems.Insert(Index, Item); TabViewControl.UpdateLayout(); TabViewControl.SelectedItem = Item; } } else { if (WIN_Native_API.CheckIfHidden(Path)) { QueueContentDialog Dialog = new QueueContentDialog { Title = Globalization.GetString("Common_Dialog_ErrorTitle"), Content = Globalization.GetString("QueueDialog_ItemHidden_Content"), CloseButtonText = Globalization.GetString("Common_Dialog_CloseButton") }; _ = await Dialog.ShowAsync().ConfigureAwait(true); //预览版TabView在没有子Item时会崩溃,此方案作为临时解决方案 if (TabViewControl == null) { _ = FindName(nameof(TabViewControl)); if (CreateNewTab() is TabViewItem EmptyItem) { TabViewControl.TabItems.Insert(Index, EmptyItem); TabViewControl.UpdateLayout(); TabViewControl.SelectedItem = EmptyItem; } } } else { StorageFolder TargetFolder = await StorageFolder.GetFolderFromPathAsync(Path); if (CreateNewTab(TargetFolder) is TabViewItem Item) { //预览版TabView在没有子Item时会崩溃,此方案作为临时解决方案 if (TabViewControl == null) { _ = FindName(nameof(TabViewControl)); } TabViewControl.TabItems.Insert(Index, Item); TabViewControl.UpdateLayout(); TabViewControl.SelectedItem = Item; } } } } catch (Exception ex) { if (CreateNewTab() is TabViewItem Item) { //预览版TabView在没有子Item时会崩溃,此方案作为临时解决方案 if (TabViewControl == null) { _ = FindName(nameof(TabViewControl)); } TabViewControl.TabItems.Insert(Index, Item); TabViewControl.UpdateLayout(); TabViewControl.SelectedItem = Item; } LogTracer.Log(ex, "Error happened when try to create a new tab"); } }