protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
        {
            navArgs = eventArgs.Parameter?.ToString();

            if (TabStrip.TabItems.Count >= 1)
            {
                return;
            }

            if (string.IsNullOrEmpty(navArgs))
            {
                AddNewTab(typeof(ModernShellPage), "New tab");
            }
            else
            {
                AddNewTab(typeof(ModernShellPage), navArgs);
            }

            Microsoft.UI.Xaml.Controls.FontIconSource icon = new Microsoft.UI.Xaml.Controls.FontIconSource();
            icon.Glyph = "\xE713";
            if ((tabView.SelectedItem as TabViewItem).Header.ToString() != ResourceController.GetTranslation("SidebarSettings/Text") && (tabView.SelectedItem as TabViewItem).IconSource != icon)
            {
                App.CurrentInstance = ItemViewModel.GetCurrentSelectedTabInstance <ModernShellPage>();
            }
        }
        public void TabStrip_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (TabStrip.SelectedItem == null)
            {
                if (e.RemovedItems.Count > 0)
                {
                    var itemToReselect = e.RemovedItems[0];
                    if (TabStrip.TabItems.Contains(itemToReselect))
                    {
                        TabStrip.SelectedItem = itemToReselect;
                    }
                }
            }
            else
            {
                if ((tabView.SelectedItem as TabViewItem).Header.ToString() == "Settings")
                {
                    App.InteractionViewModel.TabsLeftMargin   = new Thickness(0, 0, 0, 0);
                    App.InteractionViewModel.LeftMarginLoaded = false;
                }
                else
                {
                    App.InteractionViewModel.TabsLeftMargin   = new Thickness(200, 0, 0, 0);
                    App.InteractionViewModel.LeftMarginLoaded = true;
                }

                Microsoft.UI.Xaml.Controls.FontIconSource icon = new Microsoft.UI.Xaml.Controls.FontIconSource();
                icon.Glyph = "\xE713";
                if ((tabView.SelectedItem as TabViewItem).Header.ToString() != "Settings" && (tabView.SelectedItem as TabViewItem).IconSource != icon)
                {
                    App.CurrentInstance = ItemViewModel.GetCurrentSelectedTabInstance <ModernShellPage>();
                }
            }
        }
Esempio n. 3
0
        private FontIconSource MakeFontIcon()
        {
            FontIconSource iconSource = new FontIconSource();

            iconSource.Glyph      = "99+";
            iconSource.FontFamily = new FontFamily("XamlAutoFontFamily");
            iconSource.Foreground = iconForegroundBrush;
            return(iconSource);
        }
Esempio n. 4
0
        public void TabStrip_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (TabStrip.SelectedItem == null)
            {
                if (e.RemovedItems.Count > 0)
                {
                    var itemToReselect = e.RemovedItems[0];
                    if (TabStrip.TabItems.Contains(itemToReselect))
                    {
                        TabStrip.SelectedItem = itemToReselect;
                    }
                }
            }
            else
            {
                Microsoft.UI.Xaml.Controls.FontIconSource icon = new Microsoft.UI.Xaml.Controls.FontIconSource();
                icon.Glyph = "\xE713";
                if ((tabView.SelectedItem as TabViewItem).Header.ToString() != ResourceController.GetTranslation("SidebarSettings/Text") && (tabView.SelectedItem as TabViewItem).IconSource != icon)
                {
                    App.CurrentInstance = GetCurrentSelectedTabInstance <ModernShellPage>();
                }

                if ((tabView.SelectedItem as TabViewItem).Header.ToString() == ResourceController.GetTranslation("SidebarSettings/Text"))
                {
                    App.InteractionViewModel.TabsLeftMargin   = new Thickness(0, 0, 0, 0);
                    App.InteractionViewModel.LeftMarginLoaded = false;
                }
                else
                {
                    if (App.CurrentInstance != null)
                    {
                        if ((tabView.SelectedItem as TabViewItem).Header.ToString() == ResourceController.GetTranslation("NewTab"))
                        {
                            App.CurrentInstance.InstanceViewModel.IsPageTypeNotHome = false;
                        }
                        else
                        {
                            App.CurrentInstance.InstanceViewModel.IsPageTypeNotHome = true;
                        }
                        if ((tabView.SelectedItem as TabViewItem).Header.ToString() ==
                            ApplicationData.Current.LocalSettings.Values.Get("RecycleBin_Title", "Recycle Bin"))
                        {
                            App.CurrentInstance.InstanceViewModel.IsPageTypeNotRecycleBin = false;
                        }
                        else
                        {
                            App.CurrentInstance.InstanceViewModel.IsPageTypeNotRecycleBin = true;
                        }
                    }

                    App.InteractionViewModel.TabsLeftMargin   = new Thickness(200, 0, 0, 0);
                    App.InteractionViewModel.LeftMarginLoaded = true;
                }
            }
        }
        public void FontIconSourceTest()
        {
            FontIconSource iconSource = null;

            RunOnUIThread.Execute(() =>
            {
                iconSource = new FontIconSource();

                // IconSource.Foreground should be null to allow foreground inheritance from
                // the parent to work.
                Verify.AreEqual(iconSource.Foreground, null);

                Log.Comment("Validate the defaults match FontIcon.");

                var icon = new FontIcon();
                Verify.AreEqual(icon.Glyph, iconSource.Glyph);
                Verify.AreEqual(icon.FontSize, iconSource.FontSize);
                Verify.AreEqual(icon.FontStyle, iconSource.FontStyle);
                Verify.AreEqual(icon.FontWeight.Weight, iconSource.FontWeight.Weight);
                Verify.AreEqual(icon.FontFamily.Source, iconSource.FontFamily.Source);
                Verify.AreEqual(icon.IsTextScaleFactorEnabled, iconSource.IsTextScaleFactorEnabled);
                Verify.AreEqual(icon.MirroredWhenRightToLeft, iconSource.MirroredWhenRightToLeft);

                Log.Comment("Validate that you can change the properties.");

                iconSource.Foreground = new SolidColorBrush(Windows.UI.Colors.Red);
                iconSource.Glyph      = "&#xE114;";
                iconSource.FontSize   = 25;
                iconSource.FontStyle  = FontStyle.Oblique;
                iconSource.FontWeight = new FontWeight()
                {
                    Weight = 250
                };
                iconSource.FontFamily = new FontFamily("Segoe UI Symbol");
                iconSource.IsTextScaleFactorEnabled = true;
                iconSource.MirroredWhenRightToLeft  = true;
            });
            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                Verify.IsTrue(iconSource.Foreground is SolidColorBrush);
                Verify.AreEqual(Windows.UI.Colors.Red, (iconSource.Foreground as SolidColorBrush).Color);
                Verify.AreEqual("&#xE114;", iconSource.Glyph);
                Verify.AreEqual(25, iconSource.FontSize);
                Verify.AreEqual(FontStyle.Oblique, iconSource.FontStyle);
                Verify.AreEqual(250, iconSource.FontWeight.Weight);
                Verify.AreEqual("Segoe UI Symbol", iconSource.FontFamily.Source);
                Verify.AreEqual(true, iconSource.IsTextScaleFactorEnabled);
                Verify.AreEqual(true, iconSource.MirroredWhenRightToLeft);
            });
        }
Esempio n. 6
0
        private void SetSelectedTabInfoForSearchResults()
        {
            var selectedTabItem = MainPage.AppInstances[App.InteractionViewModel.TabStripSelectedIndex];

            selectedTabItem.AllowStorageItemDrop = false;
            string tabLocationHeader = "SearchTabHeaderText".GetLocalized();

            Microsoft.UI.Xaml.Controls.FontIconSource fontIconSource = new Microsoft.UI.Xaml.Controls.FontIconSource();
            fontIconSource.Glyph      = "\xEB51";
            fontIconSource.FontFamily = App.Current.Resources["FluentUIGlyphs"] as FontFamily;

            selectedTabItem.Header     = tabLocationHeader;
            selectedTabItem.IconSource = fontIconSource;
        }
Esempio n. 7
0
        public void TabStrip_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (TabStrip.SelectedItem == null)
            {
                if (e.RemovedItems.Count > 0)
                {
                    var itemToReselect = e.RemovedItems[0];
                    if (TabStrip.TabItems.Contains(itemToReselect))
                    {
                        TabStrip.SelectedItem = itemToReselect;
                    }
                }
            }
            else
            {
                Microsoft.UI.Xaml.Controls.FontIconSource icon = new Microsoft.UI.Xaml.Controls.FontIconSource();
                icon.Glyph = "\xE713";
                if ((tabView.SelectedItem as TabViewItem).Header.ToString() != ResourceController.GetTranslation("SidebarSettings/Text") && (tabView.SelectedItem as TabViewItem).IconSource != icon)
                {
                    App.CurrentInstance = GetCurrentSelectedTabInstance <ModernShellPage>();
                }

                if ((tabView.SelectedItem as TabViewItem).Header.ToString() == ResourceController.GetTranslation("SidebarSettings/Text"))
                {
                    App.InteractionViewModel.TabsLeftMargin   = new Thickness(0, 0, 0, 0);
                    App.InteractionViewModel.LeftMarginLoaded = false;
                }
                else
                {
                    if (App.CurrentInstance != null)
                    {
                        if ((tabView.SelectedItem as TabViewItem).Header.ToString() == ResourceController.GetTranslation("NewTab"))
                        {
                            App.CurrentInstance.InstanceViewModel.IsPageTypeNotHome = false;
                        }
                        else
                        {
                            App.CurrentInstance.InstanceViewModel.IsPageTypeNotHome = true;
                        }
                        App.CurrentInstance.InstanceViewModel.IsPageTypeRecycleBin =
                            App.CurrentInstance?.FilesystemViewModel?.WorkingDirectory?.StartsWith(App.AppSettings.RecycleBinPath) ?? false;
                        App.CurrentInstance.InstanceViewModel.IsPageTypeMtpDevice =
                            App.CurrentInstance?.FilesystemViewModel?.WorkingDirectory?.StartsWith("\\\\?\\") ?? false;
                    }

                    App.InteractionViewModel.TabsLeftMargin   = new Thickness(200, 0, 0, 0);
                    App.InteractionViewModel.LeftMarginLoaded = true;
                }
            }
        }
        public void TabStrip_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var resourceLoader = Windows.ApplicationModel.Resources.ResourceLoader.GetForViewIndependentUse();

            if (TabStrip.SelectedItem == null)
            {
                if (e.RemovedItems.Count > 0)
                {
                    var itemToReselect = e.RemovedItems[0];
                    if (TabStrip.TabItems.Contains(itemToReselect))
                    {
                        TabStrip.SelectedItem = itemToReselect;
                    }
                }
            }
            else
            {
                if ((tabView.SelectedItem as TabViewItem).Header.ToString() == resourceLoader.GetString("SidebarSettings/Text"))
                {
                    App.InteractionViewModel.TabsLeftMargin   = new Thickness(0, 0, 0, 0);
                    App.InteractionViewModel.LeftMarginLoaded = false;
                }
                else
                {
                    if ((tabView.SelectedItem as TabViewItem).Header.ToString() == "New tab")
                    {
                        App.InteractionViewModel.IsPageTypeNotHome = false;
                    }
                    else
                    {
                        App.InteractionViewModel.IsPageTypeNotHome = true;
                    }

                    App.InteractionViewModel.TabsLeftMargin   = new Thickness(200, 0, 0, 0);
                    App.InteractionViewModel.LeftMarginLoaded = true;
                }

                Microsoft.UI.Xaml.Controls.FontIconSource icon = new Microsoft.UI.Xaml.Controls.FontIconSource();
                icon.Glyph = "\xE713";
                if ((tabView.SelectedItem as TabViewItem).Header.ToString() != resourceLoader.GetString("SidebarSettings/Text") && (tabView.SelectedItem as TabViewItem).IconSource != icon)
                {
                    App.CurrentInstance = ItemViewModel.GetCurrentSelectedTabInstance <ModernShellPage>();
                }
            }
        }
Esempio n. 9
0
        protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
        {
            navArgs = eventArgs.Parameter?.ToString();

            if (string.IsNullOrEmpty(navArgs))
            {
                AddNewTab(typeof(ProHome), "Start");
            }
            else
            {
                AddNewTab(typeof(ProHome), navArgs);
            }

            Microsoft.UI.Xaml.Controls.FontIconSource icon = new Microsoft.UI.Xaml.Controls.FontIconSource();
            icon.Glyph = "\xE713";
            if ((tabView.SelectedItem as TabViewItem).Header.ToString() != "Settings" && (tabView.SelectedItem as TabViewItem).IconSource != icon)
            {
                App.selectedTabInstance = ItemViewModel.GetCurrentSelectedTabInstance <ProHome>();
            }
        }
Esempio n. 10
0
        public void TabStrip_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (App.InteractionViewModel.TabStripSelectedIndex >= 0 && App.InteractionViewModel.TabStripSelectedIndex < Items.Count)
            {
                Microsoft.UI.Xaml.Controls.FontIconSource icon = new Microsoft.UI.Xaml.Controls.FontIconSource();
                icon.Glyph = "\xE713";
                if (Items[App.InteractionViewModel.TabStripSelectedIndex].Header.ToString() != "SidebarSettings/Text".GetLocalized() &&
                    Items[App.InteractionViewModel.TabStripSelectedIndex].IconSource != icon)
                {
                    App.CurrentInstance = GetCurrentSelectedTabInstance <ModernShellPage>();
                }

                if (Items[App.InteractionViewModel.TabStripSelectedIndex].Header.ToString() == "SidebarSettings/Text".GetLocalized())
                {
                    App.InteractionViewModel.TabsLeftMargin   = new Thickness(0, 0, 0, 0);
                    App.InteractionViewModel.LeftMarginLoaded = false;
                }
                else
                {
                    if (App.CurrentInstance != null)
                    {
                        if (Items[App.InteractionViewModel.TabStripSelectedIndex].Header.ToString() == "NewTab".GetLocalized())
                        {
                            App.CurrentInstance.InstanceViewModel.IsPageTypeNotHome = false;
                        }
                        else
                        {
                            App.CurrentInstance.InstanceViewModel.IsPageTypeNotHome = true;
                        }

                        App.CurrentInstance.InstanceViewModel.IsPageTypeRecycleBin =
                            App.CurrentInstance?.FilesystemViewModel?.WorkingDirectory?.StartsWith(App.AppSettings.RecycleBinPath) ?? false;
                        App.CurrentInstance.InstanceViewModel.IsPageTypeMtpDevice =
                            App.CurrentInstance?.FilesystemViewModel?.WorkingDirectory?.StartsWith("\\\\?\\") ?? false;
                    }

                    App.InteractionViewModel.TabsLeftMargin   = new Thickness(0, 0, 0, 0);
                    App.InteractionViewModel.LeftMarginLoaded = true;
                }
            }
        }
Esempio n. 11
0
		public Task<Microsoft.UI.Xaml.Controls.IconSource> LoadIconSourceAsync(ImageSource imagesource, CancellationToken cancellationToken = default(CancellationToken))
		{
			Microsoft.UI.Xaml.Controls.IconSource image = null;

			if (imagesource is FontImageSource fontImageSource)
			{
				image = new WFontIconSource
				{
					Glyph = fontImageSource.Glyph,
					FontSize = fontImageSource.Size,
					Foreground = fontImageSource.Color.ToBrush()
				};

				var uwpFontFamily = fontImageSource.FontFamily.ToFontFamily();

				if (!string.IsNullOrEmpty(uwpFontFamily.Source))
					((WFontIconSource)image).FontFamily = uwpFontFamily;
			}

			return Task.FromResult(image);
		}
        protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
        {
            var resourceLoader = Windows.ApplicationModel.Resources.ResourceLoader.GetForViewIndependentUse();

            navArgs = eventArgs.Parameter?.ToString();

            if (string.IsNullOrEmpty(navArgs))
            {
                AddNewTab(typeof(ModernShellPage), "New tab");
            }
            else
            {
                AddNewTab(typeof(ModernShellPage), navArgs);
            }

            Microsoft.UI.Xaml.Controls.FontIconSource icon = new Microsoft.UI.Xaml.Controls.FontIconSource();
            icon.Glyph = "\xE713";
            if ((tabView.SelectedItem as TabViewItem).Header.ToString() != resourceLoader.GetString("SidebarSettings/Text") && (tabView.SelectedItem as TabViewItem).IconSource != icon)
            {
                App.CurrentInstance = ItemViewModel.GetCurrentSelectedTabInstance <ModernShellPage>();
            }
        }
Esempio n. 13
0
 public void TabStrip_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (TabStrip.SelectedItem == null)
     {
         if (e.RemovedItems.Count > 0)
         {
             var itemToReselect = e.RemovedItems[0];
             if (TabStrip.TabItems.Contains(itemToReselect))
             {
                 TabStrip.SelectedItem = itemToReselect;
             }
         }
     }
     else
     {
         Microsoft.UI.Xaml.Controls.FontIconSource icon = new Microsoft.UI.Xaml.Controls.FontIconSource();
         icon.Glyph = "\xE713";
         if ((tabView.SelectedItem as TabViewItem).Header.ToString() != "Settings" && (tabView.SelectedItem as TabViewItem).IconSource != icon)
         {
             App.selectedTabInstance = ItemViewModel.GetCurrentSelectedTabInstance <ProHome>();
         }
     }
 }
        public void InfoBadgeSupportsAllIconTypes()
        {
            InfoBadge          infoBadge          = null;
            SymbolIconSource   symbolIconSource   = null;
            PathIconSource     pathIconSource     = null;
            AnimatedIconSource animatedIconSource = null;
            BitmapIconSource   bitmapIconSource   = null;
            ImageIconSource    imageIconSource    = null;
            FontIconSource     fontIconSource     = null;

            RunOnUIThread.Execute(() =>
            {
                infoBadge               = new InfoBadge();
                symbolIconSource        = new SymbolIconSource();
                symbolIconSource.Symbol = Symbol.Setting;

                fontIconSource            = new FontIconSource();
                fontIconSource.Glyph      = "99+";
                fontIconSource.FontFamily = new FontFamily("XamlAutoFontFamily");

                bitmapIconSource = new BitmapIconSource();
                bitmapIconSource.ShowAsMonochrome = false;
                Uri bitmapUri = new Uri("ms-appx:/Assets/ingredient1.png");
                bitmapIconSource.UriSource = bitmapUri;

                imageIconSource             = new ImageIconSource();
                var imageUri                = new Uri("https://raw.githubusercontent.com/DiemenDesign/LibreICONS/master/svg-color/libre-camera-panorama.svg");
                imageIconSource.ImageSource = new SvgImageSource(imageUri);

                pathIconSource = new PathIconSource();
                var geometry   = new RectangleGeometry();
                geometry.Rect  = new Windows.Foundation.Rect {
                    Width = 5, Height = 2, X = 0, Y = 0
                };
                pathIconSource.Data = geometry;

                animatedIconSource        = new AnimatedIconSource();
                animatedIconSource.Source = new AnimatedSettingsVisualSource();

                Content = infoBadge;
                Content.UpdateLayout();
            });

            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                Log.Comment("Switch to Symbol Icon");
                infoBadge.IconSource = symbolIconSource;
                Content.UpdateLayout();

                Log.Comment("Switch to Path Icon");
                infoBadge.IconSource = pathIconSource;
                Content.UpdateLayout();

                Log.Comment("Switch to Font Icon");
                infoBadge.IconSource = fontIconSource;
                Content.UpdateLayout();

                Log.Comment("Switch to bitmap Icon");
                infoBadge.IconSource = bitmapIconSource;
                Content.UpdateLayout();

                Log.Comment("Switch to Image Icon");
                infoBadge.IconSource = imageIconSource;
                Content.UpdateLayout();

                Log.Comment("Switch to Animated Icon");
                infoBadge.IconSource = animatedIconSource;
                Content.UpdateLayout();
            });
        }
Esempio n. 15
0
        public async void SetSelectedTabInfo(string text, string currentPathForTabIcon = null)
        {
            string tabLocationHeader;

            Microsoft.UI.Xaml.Controls.FontIconSource fontIconSource = new Microsoft.UI.Xaml.Controls.FontIconSource();
            Microsoft.UI.Xaml.Controls.IconSource     tabIcon;

            if (currentPathForTabIcon == null && text == ResourceController.GetTranslation("SidebarSettings/Text"))
            {
                tabLocationHeader    = ResourceController.GetTranslation("SidebarSettings/Text");
                fontIconSource.Glyph = "\xE713";
            }
            else if (currentPathForTabIcon == null && text == ResourceController.GetTranslation("NewTab"))
            {
                tabLocationHeader    = ResourceController.GetTranslation("NewTab");
                fontIconSource.Glyph = "\xE737";
            }
            else if (currentPathForTabIcon.Equals(App.AppSettings.DesktopPath, StringComparison.OrdinalIgnoreCase))
            {
                tabLocationHeader    = ResourceController.GetTranslation("SidebarDesktop");
                fontIconSource.Glyph = "\xE8FC";
            }
            else if (currentPathForTabIcon.Equals(App.AppSettings.DownloadsPath, StringComparison.OrdinalIgnoreCase))
            {
                tabLocationHeader    = ResourceController.GetTranslation("SidebarDownloads");
                fontIconSource.Glyph = "\xE896";
            }
            else if (currentPathForTabIcon.Equals(App.AppSettings.DocumentsPath, StringComparison.OrdinalIgnoreCase))
            {
                tabLocationHeader    = ResourceController.GetTranslation("SidebarDocuments");
                fontIconSource.Glyph = "\xE8A5";
            }
            else if (currentPathForTabIcon.Equals(App.AppSettings.PicturesPath, StringComparison.OrdinalIgnoreCase))
            {
                tabLocationHeader    = ResourceController.GetTranslation("SidebarPictures");
                fontIconSource.Glyph = "\xEB9F";
            }
            else if (currentPathForTabIcon.Equals(App.AppSettings.MusicPath, StringComparison.OrdinalIgnoreCase))
            {
                tabLocationHeader    = ResourceController.GetTranslation("SidebarMusic");
                fontIconSource.Glyph = "\xEC4F";
            }
            else if (currentPathForTabIcon.Equals(App.AppSettings.VideosPath, StringComparison.OrdinalIgnoreCase))
            {
                tabLocationHeader    = ResourceController.GetTranslation("SidebarVideos");
                fontIconSource.Glyph = "\xE8B2";
            }
            else if (currentPathForTabIcon.Equals(App.AppSettings.RecycleBinPath, StringComparison.OrdinalIgnoreCase))
            {
                var localSettings = ApplicationData.Current.LocalSettings;
                tabLocationHeader         = localSettings.Values.Get("RecycleBin_Title", "Recycle Bin");
                fontIconSource.FontFamily = Application.Current.Resources["RecycleBinIcons"] as FontFamily;
                fontIconSource.Glyph      = "\xEF87";
            }
            else if (App.AppSettings.OneDrivePath != null && currentPathForTabIcon.Equals(App.AppSettings.OneDrivePath, StringComparison.OrdinalIgnoreCase))
            {
                tabLocationHeader    = "OneDrive";
                fontIconSource.Glyph = "\xE753";
            }
            else
            {
                // If path is a drive's root
                if (NormalizePath(Path.GetPathRoot(currentPathForTabIcon)) == NormalizePath(currentPathForTabIcon))
                {
                    if (NormalizePath(currentPathForTabIcon) != NormalizePath("A:") && NormalizePath(currentPathForTabIcon) != NormalizePath("B:"))
                    {
                        var remDriveNames     = (await KnownFolders.RemovableDevices.GetFoldersAsync()).Select(x => x.DisplayName);
                        var matchingDriveName = remDriveNames.FirstOrDefault(x => NormalizePath(currentPathForTabIcon).Contains(x.ToUpperInvariant()));

                        if (matchingDriveName == null)
                        {
                            fontIconSource.Glyph = "\xEDA2";
                            tabLocationHeader    = NormalizePath(currentPathForTabIcon);
                        }
                        else
                        {
                            fontIconSource.Glyph = "\xE88E";
                            tabLocationHeader    = matchingDriveName;
                        }
                    }
                    else
                    {
                        fontIconSource.Glyph = "\xE74E";
                        tabLocationHeader    = NormalizePath(currentPathForTabIcon);
                    }
                }
                else
                {
                    fontIconSource.Glyph = "\xE8B7";
                    tabLocationHeader    = currentPathForTabIcon.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar).Split('\\', StringSplitOptions.RemoveEmptyEntries).Last();
                }
            }
            tabIcon = fontIconSource;
            (tabView.SelectedItem as TabViewItem).Header     = tabLocationHeader;
            (tabView.SelectedItem as TabViewItem).IconSource = tabIcon;
        }
Esempio n. 16
0
        public async void AddNewTab(Type t, string path)
        {
            Frame  frame             = new Frame();
            string tabLocationHeader = null;

            Microsoft.UI.Xaml.Controls.FontIconSource fontIconSource = new Microsoft.UI.Xaml.Controls.FontIconSource();
            Microsoft.UI.Xaml.Controls.IconSource     tabIcon;

            if (path != null)
            {
                if (path == "Settings")
                {
                    tabLocationHeader    = ResourceController.GetTranslation("SidebarSettings/Text");
                    fontIconSource.Glyph = "\xE713";
                    foreach (TabViewItem item in tabView.TabItems)
                    {
                        if (item.Header.ToString() == ResourceController.GetTranslation("SidebarSettings/Text"))
                        {
                            tabView.SelectedItem = item;
                            return;
                        }
                    }
                }
                else if (path.Equals(App.AppSettings.DesktopPath, StringComparison.OrdinalIgnoreCase))
                {
                    tabLocationHeader    = ResourceController.GetTranslation("SidebarDesktop");
                    fontIconSource.Glyph = "\xE8FC";
                }
                else if (path.Equals(App.AppSettings.DownloadsPath, StringComparison.OrdinalIgnoreCase))
                {
                    tabLocationHeader    = ResourceController.GetTranslation("SidebarDownloads");
                    fontIconSource.Glyph = "\xE896";
                }
                else if (path.Equals(App.AppSettings.DocumentsPath, StringComparison.OrdinalIgnoreCase))
                {
                    tabLocationHeader    = ResourceController.GetTranslation("SidebarDocuments");
                    fontIconSource.Glyph = "\xE8A5";
                }
                else if (path.Equals(App.AppSettings.PicturesPath, StringComparison.OrdinalIgnoreCase))
                {
                    tabLocationHeader    = ResourceController.GetTranslation("SidebarPictures");
                    fontIconSource.Glyph = "\xEB9F";
                }
                else if (path.Equals(App.AppSettings.MusicPath, StringComparison.OrdinalIgnoreCase))
                {
                    tabLocationHeader    = ResourceController.GetTranslation("SidebarMusic");
                    fontIconSource.Glyph = "\xEC4F";
                }
                else if (path.Equals(App.AppSettings.VideosPath, StringComparison.OrdinalIgnoreCase))
                {
                    tabLocationHeader    = ResourceController.GetTranslation("SidebarVideos");
                    fontIconSource.Glyph = "\xE8B2";
                }
                else if (path.Equals(App.AppSettings.RecycleBinPath, StringComparison.OrdinalIgnoreCase))
                {
                    var localSettings = ApplicationData.Current.LocalSettings;
                    tabLocationHeader    = localSettings.Values.Get("RecycleBin_Title", "Recycle Bin");
                    fontIconSource.Glyph = "\xE74D";
                }
                else if (App.AppSettings.OneDrivePath != null && path.Equals(App.AppSettings.OneDrivePath, StringComparison.OrdinalIgnoreCase))
                {
                    tabLocationHeader    = "OneDrive";
                    fontIconSource.Glyph = "\xE753";
                }
                else if (path == ResourceController.GetTranslation("NewTab"))
                {
                    tabLocationHeader    = ResourceController.GetTranslation("NewTab");
                    fontIconSource.Glyph = "\xE737";
                }
                else
                {
                    var isRoot = Path.GetPathRoot(path) == path;

                    if (Path.IsPathRooted(path) || isRoot) // Or is a directory or a root (drive)
                    {
                        var normalizedPath = NormalizePath(path);

                        var dirName = Path.GetDirectoryName(normalizedPath);
                        if (dirName != null)
                        {
                            tabLocationHeader    = dirName;
                            fontIconSource.Glyph = "\xE8B7";
                        }
                        else
                        {
                            // Pick the best icon for this tab
                            var remDriveNames = (await KnownFolders.RemovableDevices.GetFoldersAsync()).Select(x => x.DisplayName);

                            if (!remDriveNames.Contains(normalizedPath))
                            {
                                if (path != "A:" && path != "B:")    // Check if it's using (generally) floppy-reserved letters.
                                {
                                    fontIconSource.Glyph = "\xE74E"; // Floppy Disk icon
                                }
                                else
                                {
                                    fontIconSource.Glyph = "\xEDA2"; // Hard Disk icon
                                }
                                tabLocationHeader = normalizedPath;
                            }
                            else
                            {
                                fontIconSource.Glyph = "\xE88E";
                                tabLocationHeader    = (await KnownFolders.RemovableDevices.GetFolderAsync(path)).DisplayName;
                            }
                        }
                    }
                    else
                    {
                        // Invalid path, open new tab instead (explorer opens Documents when it fails)
                        Debug.WriteLine($"Invalid path \"{path}\" in InstanceTabsView.xaml.cs\\AddNewTab");

                        path = ResourceController.GetTranslation("NewTab");
                        tabLocationHeader    = ResourceController.GetTranslation("NewTab");
                        fontIconSource.Glyph = "\xE737";
                    }
                }
            }

            tabIcon = fontIconSource;
            Grid gr = new Grid();

            gr.Children.Add(frame);
            gr.HorizontalAlignment = HorizontalAlignment.Stretch;
            gr.VerticalAlignment   = VerticalAlignment.Stretch;
            TabViewItem tvi = new TabViewItem()
            {
                Header             = tabLocationHeader,
                Content            = gr,
                Width              = 200,
                IconSource         = tabIcon,
                Transitions        = null,
                Style              = rootGrid.Resources["TabItemStyle"] as Style,
                ContentTransitions = null
            };

            tabView.TabItems.Add(tvi);
            TabStrip.SelectedIndex = TabStrip.TabItems.Count - 1;

            var tabViewItemFrame = (tvi.Content as Grid).Children[0] as Frame;

            tabViewItemFrame.Loaded += delegate
            {
                if (tabViewItemFrame.CurrentSourcePageType != typeof(ModernShellPage))
                {
                    tabViewItemFrame.Navigate(t, path);
                }
            };
        }
Esempio n. 17
0
        public async void SetSelectedTabInfo(string text, string currentPathForTabIcon = null)
        {
            string tabLocationHeader;

            Microsoft.UI.Xaml.Controls.FontIconSource fontIconSource = new Microsoft.UI.Xaml.Controls.FontIconSource();
            Microsoft.UI.Xaml.Controls.IconSource     tabIcon;

            if (currentPathForTabIcon == null && text == ResourceController.GetTranslation("SidebarSettings/Text"))
            {
                tabLocationHeader    = ResourceController.GetTranslation("SidebarSettings/Text");
                fontIconSource.Glyph = "\xE713";
            }
            else if (currentPathForTabIcon == null && text == "New tab")
            {
                tabLocationHeader    = "New tab";
                fontIconSource.Glyph = "\xE737";
            }
            else if (currentPathForTabIcon.StartsWith(App.AppSettings.DesktopPath, StringComparison.OrdinalIgnoreCase))
            {
                tabLocationHeader    = ResourceController.GetTranslation("SidebarDesktop");
                fontIconSource.Glyph = "\xE8FC";
            }
            else if (currentPathForTabIcon.StartsWith(App.AppSettings.DownloadsPath, StringComparison.OrdinalIgnoreCase))
            {
                tabLocationHeader    = ResourceController.GetTranslation("SidebarDownloads");
                fontIconSource.Glyph = "\xE896";
            }
            else if (currentPathForTabIcon.StartsWith(App.AppSettings.DocumentsPath, StringComparison.OrdinalIgnoreCase))
            {
                tabLocationHeader    = ResourceController.GetTranslation("SidebarDocuments");
                fontIconSource.Glyph = "\xE8A5";
            }
            else if (currentPathForTabIcon.StartsWith(App.AppSettings.PicturesPath, StringComparison.OrdinalIgnoreCase))
            {
                tabLocationHeader    = ResourceController.GetTranslation("SidebarPictures");
                fontIconSource.Glyph = "\xEB9F";
            }
            else if (currentPathForTabIcon.StartsWith(App.AppSettings.MusicPath, StringComparison.OrdinalIgnoreCase))
            {
                tabLocationHeader    = ResourceController.GetTranslation("SidebarMusic");
                fontIconSource.Glyph = "\xEC4F";
            }
            else if (currentPathForTabIcon.StartsWith(App.AppSettings.VideosPath, StringComparison.OrdinalIgnoreCase))
            {
                tabLocationHeader    = ResourceController.GetTranslation("SidebarVideos");
                fontIconSource.Glyph = "\xE8B2";
            }
            else if (App.AppSettings.OneDrivePath != null && currentPathForTabIcon.StartsWith(App.AppSettings.OneDrivePath, StringComparison.OrdinalIgnoreCase))
            {
                tabLocationHeader    = "OneDrive";
                fontIconSource.Glyph = "\xE753";
            }
            else
            {
                // If path is a drive's root
                if (NormalizePath(Path.GetPathRoot(currentPathForTabIcon)) == NormalizePath(currentPathForTabIcon))
                {
                    if (NormalizePath(currentPathForTabIcon) != NormalizePath("A:") && NormalizePath(currentPathForTabIcon) != NormalizePath("B:"))
                    {
                        var remDriveNames = (await KnownFolders.RemovableDevices.GetFoldersAsync()).Select(x => x.DisplayName);

                        if (!remDriveNames.Contains(NormalizePath(currentPathForTabIcon)))
                        {
                            fontIconSource.Glyph = "\xEDA2";
                            tabLocationHeader    = NormalizePath(currentPathForTabIcon);
                        }
                        else
                        {
                            fontIconSource.Glyph = "\xE88E";
                            tabLocationHeader    = (await KnownFolders.RemovableDevices.GetFolderAsync(currentPathForTabIcon)).DisplayName;
                        }
                    }
                    else
                    {
                        fontIconSource.Glyph = "\xE74E";
                        tabLocationHeader    = NormalizePath(currentPathForTabIcon);
                    }
                }
                else
                {
                    fontIconSource.Glyph = "\xE8B7";
                    tabLocationHeader    = currentPathForTabIcon.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar).Split('\\', StringSplitOptions.RemoveEmptyEntries).Last();
                }
            }
            tabIcon = fontIconSource;
            (tabView.SelectedItem as TabViewItem).Header     = tabLocationHeader;
            (tabView.SelectedItem as TabViewItem).IconSource = tabIcon;
        }
Esempio n. 18
0
        public void AddNewTab(Type t, string path)
        {
            Frame frame = new Frame();
            //frame.Navigate(t, path);
            string tabLocationHeader = null;

            Microsoft.UI.Xaml.Controls.FontIconSource fontIconSource = new Microsoft.UI.Xaml.Controls.FontIconSource();
            Microsoft.UI.Xaml.Controls.IconSource     tabIcon;

            if (path != null)
            {
                if (path == "Settings")
                {
                    tabLocationHeader    = ResourceController.GetTranslation("SidebarSettings/Text");
                    fontIconSource.Glyph = "\xE713";
                    foreach (TabViewItem item in tabView.TabItems)
                    {
                        if (item.Header.ToString() == ResourceController.GetTranslation("SidebarSettings/Text"))
                        {
                            tabView.SelectedItem = item;
                            return;
                        }
                    }
                }
                else if (path.StartsWith(App.AppSettings.DesktopPath, StringComparison.OrdinalIgnoreCase))
                {
                    tabLocationHeader    = ResourceController.GetTranslation("SidebarDesktop");
                    fontIconSource.Glyph = "\xE8FC";
                }
                else if (path.StartsWith(App.AppSettings.DownloadsPath, StringComparison.OrdinalIgnoreCase))
                {
                    tabLocationHeader    = ResourceController.GetTranslation("SidebarDownloads");
                    fontIconSource.Glyph = "\xE896";
                }
                else if (path.StartsWith(App.AppSettings.DocumentsPath, StringComparison.OrdinalIgnoreCase))
                {
                    tabLocationHeader    = ResourceController.GetTranslation("SidebarDocuments");
                    fontIconSource.Glyph = "\xE8A5";
                }
                else if (path.StartsWith(App.AppSettings.PicturesPath, StringComparison.OrdinalIgnoreCase))
                {
                    tabLocationHeader    = ResourceController.GetTranslation("SidebarPictures");
                    fontIconSource.Glyph = "\xEB9F";
                }
                else if (path.StartsWith(App.AppSettings.MusicPath, StringComparison.OrdinalIgnoreCase))
                {
                    tabLocationHeader    = ResourceController.GetTranslation("SidebarMusic");
                    fontIconSource.Glyph = "\xEC4F";
                }
                else if (path.StartsWith(App.AppSettings.VideosPath, StringComparison.OrdinalIgnoreCase))
                {
                    tabLocationHeader    = ResourceController.GetTranslation("SidebarVideos");
                    fontIconSource.Glyph = "\xE8B2";
                }
                else if (App.AppSettings.OneDrivePath != null && path.StartsWith(App.AppSettings.OneDrivePath, StringComparison.OrdinalIgnoreCase))
                {
                    tabLocationHeader    = "OneDrive";
                    fontIconSource.Glyph = "\xE753";
                }
                else if (path == "New tab")
                {
                    tabLocationHeader    = "New tab";
                    fontIconSource.Glyph = "\xE737";
                }
                else
                {
                    tabLocationHeader    = Path.GetDirectoryName(path);
                    fontIconSource.Glyph = "\xE8B7";
                }
            }

            tabIcon = fontIconSource;
            Grid gr = new Grid();

            gr.Children.Add(frame);
            gr.HorizontalAlignment = HorizontalAlignment.Stretch;
            gr.VerticalAlignment   = VerticalAlignment.Stretch;
            TabViewItem tvi = new TabViewItem()
            {
                Header     = tabLocationHeader,
                Content    = gr,
                Width      = 200,
                IconSource = tabIcon
            };

            tabView.TabItems.Add(tvi);
            TabStrip.SelectedItem = TabStrip.TabItems[TabStrip.TabItems.Count - 1];
            if (tabView.SelectedItem == tvi)
            {
                (((tabView.SelectedItem as TabViewItem).Content as Grid).Children[0] as Frame).Navigate(t, path);
            }
        }
        public void AddNewTab(Type t, string path)
        {
            Frame frame = new Frame();

            frame.Navigate(t, path);
            string tabLocationHeader;

            Microsoft.UI.Xaml.Controls.FontIconSource fontIconSource = new Microsoft.UI.Xaml.Controls.FontIconSource();
            Microsoft.UI.Xaml.Controls.IconSource     tabIcon;
            if (path != null)
            {
                if (path == "Settings")
                {
                    tabLocationHeader    = "Settings";
                    fontIconSource.Glyph = "\xE713";
                }
                else if (path == ProHome.DesktopPath)
                {
                    tabLocationHeader    = "Desktop";
                    fontIconSource.Glyph = "\xE8FC";
                }
                else if (path == ProHome.DownloadsPath)
                {
                    tabLocationHeader    = "Downloads";
                    fontIconSource.Glyph = "\xE896";
                }
                else if (path == ProHome.DocumentsPath)
                {
                    tabLocationHeader    = "Documents";
                    fontIconSource.Glyph = "\xE8A5";
                }
                else if (path == ProHome.PicturesPath)
                {
                    tabLocationHeader    = "Pictures";
                    fontIconSource.Glyph = "\xEB9F";
                }
                else if (path == ProHome.MusicPath)
                {
                    tabLocationHeader    = "Music";
                    fontIconSource.Glyph = "\xEC4F";
                }
                else if (path == ProHome.VideosPath)
                {
                    tabLocationHeader    = "Videos";
                    fontIconSource.Glyph = "\xE8B2";
                }
                else if (path == ProHome.OneDrivePath)
                {
                    tabLocationHeader    = "OneDrive";
                    fontIconSource.Glyph = "\xE753";
                }
                else
                {
                    tabLocationHeader    = Path.GetDirectoryName(path);
                    fontIconSource.Glyph = "\xE8B7";
                }
            }
            else
            {
                tabLocationHeader    = "Favorites";
                fontIconSource.Glyph = "\xE728";
            }
            tabIcon = fontIconSource;
            Grid gr = new Grid();

            gr.Children.Add(frame);
            gr.HorizontalAlignment = HorizontalAlignment.Stretch;
            gr.VerticalAlignment   = VerticalAlignment.Stretch;
            TabViewItem tvi = new TabViewItem()
            {
                Header     = tabLocationHeader,
                Content    = gr,
                Width      = 200,
                IconSource = tabIcon
            };

            tabView.TabItems.Add(tvi);
            TabStrip.SelectedItem = TabStrip.TabItems[TabStrip.TabItems.Count - 1];
        }
Esempio n. 20
0
        public async void SetSelectedTabInfo(string text, string currentPathForTabIcon = null)
        {
            string tabLocationHeader;

            Microsoft.UI.Xaml.Controls.FontIconSource fontIconSource = new Microsoft.UI.Xaml.Controls.FontIconSource();
            Microsoft.UI.Xaml.Controls.IconSource     tabIcon;

            if (currentPathForTabIcon == null && text == "Settings")
            {
                tabLocationHeader    = "Settings";
                fontIconSource.Glyph = "\xE713";
            }
            else if (currentPathForTabIcon == null && text == "New tab")
            {
                tabLocationHeader    = "New tab";
                fontIconSource.Glyph = "\xE737";
            }
            else if (currentPathForTabIcon == null && text == "Start")
            {
                tabLocationHeader    = "Start";
                fontIconSource.Glyph = "\xE737";
            }
            else if (currentPathForTabIcon == ProHome.DesktopPath)
            {
                tabLocationHeader    = "Desktop";
                fontIconSource.Glyph = "\xE8FC";
            }
            else if (currentPathForTabIcon == ProHome.DownloadsPath)
            {
                tabLocationHeader    = "Downloads";
                fontIconSource.Glyph = "\xE896";
            }
            else if (currentPathForTabIcon == ProHome.DocumentsPath)
            {
                tabLocationHeader    = "Documents";
                fontIconSource.Glyph = "\xE8A5";
            }
            else if (currentPathForTabIcon == ProHome.PicturesPath)
            {
                tabLocationHeader    = "Pictures";
                fontIconSource.Glyph = "\xEB9F";
            }
            else if (currentPathForTabIcon == ProHome.MusicPath)
            {
                tabLocationHeader    = "Music";
                fontIconSource.Glyph = "\xEC4F";
            }
            else if (currentPathForTabIcon == ProHome.VideosPath)
            {
                tabLocationHeader    = "Videos";
                fontIconSource.Glyph = "\xE8B2";
            }
            else if (currentPathForTabIcon == ProHome.OneDrivePath)
            {
                tabLocationHeader    = "OneDrive";
                fontIconSource.Glyph = "\xE753";
            }
            else
            {
                // If path is a drive's root
                if (NormalizePath(Path.GetPathRoot(currentPathForTabIcon)) == NormalizePath(currentPathForTabIcon))
                {
                    if (NormalizePath(currentPathForTabIcon) != NormalizePath("A:") && NormalizePath(currentPathForTabIcon) != NormalizePath("B:"))
                    {
                        var remDriveNames = (await KnownFolders.RemovableDevices.GetFoldersAsync()).Select(x => x.DisplayName);

                        if (!remDriveNames.Contains(NormalizePath(currentPathForTabIcon)))
                        {
                            fontIconSource.Glyph = "\xEDA2";
                            tabLocationHeader    = "Local Disk (" + NormalizePath(currentPathForTabIcon) + ")";
                        }
                        else
                        {
                            fontIconSource.Glyph = "\xE88E";
                            tabLocationHeader    = (await KnownFolders.RemovableDevices.GetFolderAsync(currentPathForTabIcon)).DisplayName;
                        }
                    }
                    else
                    {
                        fontIconSource.Glyph = "\xE74E";
                        tabLocationHeader    = "Floppy Disk (" + NormalizePath(currentPathForTabIcon) + ")";
                    }
                }
                else
                {
                    fontIconSource.Glyph = "\xE8B7";
                    tabLocationHeader    = currentPathForTabIcon.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar).Split('\\', StringSplitOptions.RemoveEmptyEntries).Last();
                }
            }
            tabIcon = fontIconSource;
            (tabView.SelectedItem as TabViewItem).Header     = tabLocationHeader;
            (tabView.SelectedItem as TabViewItem).IconSource = tabIcon;
        }
Esempio n. 21
0
        public async Task SetSelectedTabInfo(string text, string currentPathForTabIcon)
        {
            var selectedTabItem = MainPage.AppInstances[App.InteractionViewModel.TabStripSelectedIndex];

            selectedTabItem.AllowStorageItemDrop = App.CurrentInstance.InstanceViewModel.IsPageTypeNotHome;

            MainPage.AppInstances[App.InteractionViewModel.TabStripSelectedIndex].Path = currentPathForTabIcon;

            string tabLocationHeader;

            Microsoft.UI.Xaml.Controls.FontIconSource fontIconSource = new Microsoft.UI.Xaml.Controls.FontIconSource();
            Microsoft.UI.Xaml.Controls.IconSource     tabIcon;
            fontIconSource.FontFamily = App.Current.Resources["FluentUIGlyphs"] as FontFamily;

            if (currentPathForTabIcon == null && text == "SidebarSettings/Text".GetLocalized())
            {
                tabLocationHeader    = "SidebarSettings/Text".GetLocalized();
                fontIconSource.Glyph = "\xeb5d";
            }
            else if (currentPathForTabIcon == null && text == "NewTab".GetLocalized())
            {
                tabLocationHeader    = "NewTab".GetLocalized();
                fontIconSource.Glyph = "\xe90c";
            }
            else if (currentPathForTabIcon.Equals(App.AppSettings.DesktopPath, StringComparison.OrdinalIgnoreCase))
            {
                tabLocationHeader    = "SidebarDesktop".GetLocalized();
                fontIconSource.Glyph = "\xe9f1";
            }
            else if (currentPathForTabIcon.Equals(App.AppSettings.DownloadsPath, StringComparison.OrdinalIgnoreCase))
            {
                tabLocationHeader    = "SidebarDownloads".GetLocalized();
                fontIconSource.Glyph = "\xe91c";
            }
            else if (currentPathForTabIcon.Equals(App.AppSettings.DocumentsPath, StringComparison.OrdinalIgnoreCase))
            {
                tabLocationHeader    = "SidebarDocuments".GetLocalized();
                fontIconSource.Glyph = "\xEA11";
            }
            else if (currentPathForTabIcon.Equals(App.AppSettings.PicturesPath, StringComparison.OrdinalIgnoreCase))
            {
                tabLocationHeader    = "SidebarPictures".GetLocalized();
                fontIconSource.Glyph = "\xEA83";
            }
            else if (currentPathForTabIcon.Equals(App.AppSettings.MusicPath, StringComparison.OrdinalIgnoreCase))
            {
                tabLocationHeader    = "SidebarMusic".GetLocalized();
                fontIconSource.Glyph = "\xead4";
            }
            else if (currentPathForTabIcon.Equals(App.AppSettings.VideosPath, StringComparison.OrdinalIgnoreCase))
            {
                tabLocationHeader    = "SidebarVideos".GetLocalized();
                fontIconSource.Glyph = "\xec0d";
            }
            else if (currentPathForTabIcon.Equals(App.AppSettings.RecycleBinPath, StringComparison.OrdinalIgnoreCase))
            {
                var localSettings = ApplicationData.Current.LocalSettings;
                tabLocationHeader         = localSettings.Values.Get("RecycleBin_Title", "Recycle Bin");
                fontIconSource.FontFamily = Application.Current.Resources["RecycleBinIcons"] as FontFamily;
                fontIconSource.Glyph      = "\xEF87";
            }
            else if (App.AppSettings.OneDrivePath != null && currentPathForTabIcon.Equals(App.AppSettings.OneDrivePath, StringComparison.OrdinalIgnoreCase))
            {
                tabLocationHeader    = "OneDrive";
                fontIconSource.Glyph = "\xe9b7";
            }
            else
            {
                // If path is a drive's root
                if (NormalizePath(Path.GetPathRoot(currentPathForTabIcon)) == NormalizePath(currentPathForTabIcon))
                {
                    if (NormalizePath(currentPathForTabIcon) != NormalizePath("A:") && NormalizePath(currentPathForTabIcon) != NormalizePath("B:"))
                    {
                        var remDriveNames     = (await KnownFolders.RemovableDevices.GetFoldersAsync()).Select(x => x.DisplayName);
                        var matchingDriveName = remDriveNames.FirstOrDefault(x => NormalizePath(currentPathForTabIcon).Contains(x.ToUpperInvariant()));

                        if (matchingDriveName == null)
                        {
                            fontIconSource.Glyph = "\xeb8b";
                            tabLocationHeader    = NormalizePath(currentPathForTabIcon);
                        }
                        else
                        {
                            fontIconSource.Glyph = "\xec0a";
                            tabLocationHeader    = matchingDriveName;
                        }
                    }
                    else
                    {
                        fontIconSource.Glyph = "\xeb4a";
                        tabLocationHeader    = NormalizePath(currentPathForTabIcon);
                    }
                }
                else
                {
                    fontIconSource.Glyph = "\xea55";
                    tabLocationHeader    = currentPathForTabIcon.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar).Split('\\', StringSplitOptions.RemoveEmptyEntries).Last();
                }
            }
            tabIcon = fontIconSource;
            selectedTabItem.Header     = tabLocationHeader;
            selectedTabItem.IconSource = tabIcon;
        }
Esempio n. 22
0
        public async void SetSelectedTabInfo(string text, string currentPathForTabIcon = null)
        {
            string tabLocationHeader;

            Microsoft.UI.Xaml.Controls.FontIconSource fontIconSource = new Microsoft.UI.Xaml.Controls.FontIconSource();
            Microsoft.UI.Xaml.Controls.IconSource     tabIcon;

            if (currentPathForTabIcon == null && text == "Settings")
            {
                tabLocationHeader    = "Settings";
                fontIconSource.Glyph = "\xE713";
            }
            else if (currentPathForTabIcon == null && text == "New tab")
            {
                tabLocationHeader    = "New tab";
                fontIconSource.Glyph = "\xE737";
            }
            else if (currentPathForTabIcon == null && text == "Start")
            {
                tabLocationHeader    = "Start";
                fontIconSource.Glyph = "\xE737";
            }
            else if (currentPathForTabIcon == ProHome.DesktopPath)
            {
                tabLocationHeader    = "Desktop";
                fontIconSource.Glyph = "\xE8FC";
            }
            else if (currentPathForTabIcon == ProHome.DownloadsPath)
            {
                tabLocationHeader    = "Downloads";
                fontIconSource.Glyph = "\xE896";
            }
            else if (currentPathForTabIcon == ProHome.DocumentsPath)
            {
                tabLocationHeader    = "Documents";
                fontIconSource.Glyph = "\xE8A5";
            }
            else if (currentPathForTabIcon == ProHome.PicturesPath)
            {
                tabLocationHeader    = "Pictures";
                fontIconSource.Glyph = "\xEB9F";
            }
            else if (currentPathForTabIcon == ProHome.MusicPath)
            {
                tabLocationHeader    = "Music";
                fontIconSource.Glyph = "\xEC4F";
            }
            else if (currentPathForTabIcon == ProHome.VideosPath)
            {
                tabLocationHeader    = "Videos";
                fontIconSource.Glyph = "\xE8B2";
            }
            else if (currentPathForTabIcon == ProHome.OneDrivePath)
            {
                tabLocationHeader    = "OneDrive";
                fontIconSource.Glyph = "\xE753";
            }
            else
            {
                // If path is a drive's root
                if (Path.GetPathRoot(currentPathForTabIcon) == currentPathForTabIcon && currentPathForTabIcon == @"C:\")
                {
                    tabLocationHeader    = @"Local Disk (C:\)";
                    fontIconSource.Glyph = "\xEDA2";
                }
                else if (Path.GetPathRoot(currentPathForTabIcon) == currentPathForTabIcon && currentPathForTabIcon != @"C:\")
                {
                    tabLocationHeader = currentPathForTabIcon;
                    if (await KnownFolders.RemovableDevices.TryGetItemAsync(currentPathForTabIcon) == null)
                    {
                        fontIconSource.Glyph = "\xEDA2";
                    }
                    else
                    {
                        fontIconSource.Glyph = "\xE88E";
                    }
                }
                else
                {
                    tabLocationHeader    = currentPathForTabIcon.Split("\\", StringSplitOptions.RemoveEmptyEntries)[currentPathForTabIcon.Split("\\", StringSplitOptions.RemoveEmptyEntries).Length - 1];
                    fontIconSource.Glyph = "\xE8B7";
                }
            }
            tabIcon = fontIconSource;
            (tabView.SelectedItem as TabViewItem).Header     = tabLocationHeader;
            (tabView.SelectedItem as TabViewItem).IconSource = tabIcon;
        }