private async Task SyncLibrarySideBarItemsUI() { await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { if (App.AppSettings.ShowLibrarySection && !SidebarControl.SideBarItems.Contains(librarySection)) { await SidebarControl.SideBarItemsSemaphore.WaitAsync(); try { librarySection = new LocationItem { Text = "SidebarLibraries".GetLocalized(), Section = SectionType.Library, SelectsOnInvoked = false, ChildItems = new ObservableCollection <INavigationControlItem>() }; SidebarControl.SideBarItems.Insert(1, librarySection); } finally { SidebarControl.SideBarItemsSemaphore.Release(); } } Libraries.BeginBulkOperation(); Libraries.Clear(); var libs = await LibraryHelper.ListUserLibraries(); if (libs != null) { libs.Sort(); Libraries.AddRange(libs); } Libraries.EndBulkOperation(); }); }
private async Task SyncSideBarItemsUI() { await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { await SidebarControl.SideBarItemsSemaphore.WaitAsync(); try { var section = SidebarControl.SideBarItems.FirstOrDefault(x => x.Text == "SidebarNetworkDrives".GetLocalized()) as LocationItem; if (UserSettingsService.AppearanceSettingsService.ShowNetworkDrivesSection && section == null) { section = new LocationItem() { Text = "SidebarNetworkDrives".GetLocalized(), Section = SectionType.Network, SelectsOnInvoked = false, Icon = await UIHelpers.GetIconResource(Constants.ImageRes.NetworkDrives), ChildItems = new BulkConcurrentObservableCollection <INavigationControlItem>() }; var index = (SidebarControl.SideBarItems.Any(item => item.Section == SectionType.Favorites) ? 1 : 0) + (SidebarControl.SideBarItems.Any(item => item.Section == SectionType.Library) ? 1 : 0) + (SidebarControl.SideBarItems.Any(item => item.Section == SectionType.Drives) ? 1 : 0) + (SidebarControl.SideBarItems.Any(item => item.Section == SectionType.CloudDrives) ? 1 : 0); // After cloud section SidebarControl.SideBarItems.BeginBulkOperation(); SidebarControl.SideBarItems.Insert(Math.Min(index, SidebarControl.SideBarItems.Count), section); SidebarControl.SideBarItems.EndBulkOperation(); } if (section != null) { foreach (var drive in Drives.ToList() .OrderByDescending(o => string.Equals(o.Text, "Network".GetLocalized(), StringComparison.OrdinalIgnoreCase)) .ThenBy(o => o.Text)) { if (!string.IsNullOrEmpty(drive.DeviceID)) { drive.IconData = await FileThumbnailHelper.LoadIconWithoutOverlayAsync(drive.DeviceID, 24); } if (drive.IconData == null) { var resource = await UIHelpers.GetIconResourceInfo(Constants.ImageRes.Folder); drive.IconData = resource?.IconDataBytes; } drive.Icon = await drive.IconData.ToBitmapAsync(); if (!section.ChildItems.Contains(drive)) { section.ChildItems.Add(drive); } } } } finally { SidebarControl.SideBarItemsSemaphore.Release(); } }); }
private async Task SyncSideBarItemsUI() { await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { await SidebarControl.SideBarItemsSemaphore.WaitAsync(); try { var section = SidebarControl.SideBarItems.FirstOrDefault(x => x.Text == "FileTags".GetLocalized()) as LocationItem; if (UserSettingsService.PreferencesSettingsService.AreFileTagsEnabled && UserSettingsService.AppearanceSettingsService.ShowFileTagsSection && section == null) { section = new LocationItem() { Text = "FileTags".GetLocalized(), Section = SectionType.FileTag, SelectsOnInvoked = false, Icon = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri("ms-appx:///Assets/FluentIcons/FileTags.png")), ChildItems = new BulkConcurrentObservableCollection <INavigationControlItem>() }; var index = (SidebarControl.SideBarItems.Any(item => item.Section == SectionType.Favorites) ? 1 : 0) + (SidebarControl.SideBarItems.Any(item => item.Section == SectionType.Library) ? 1 : 0) + (SidebarControl.SideBarItems.Any(item => item.Section == SectionType.Drives) ? 1 : 0) + (SidebarControl.SideBarItems.Any(item => item.Section == SectionType.CloudDrives) ? 1 : 0) + (SidebarControl.SideBarItems.Any(item => item.Section == SectionType.Network) ? 1 : 0) + (SidebarControl.SideBarItems.Any(item => item.Section == SectionType.WSL) ? 1 : 0); // After wsl section SidebarControl.SideBarItems.BeginBulkOperation(); SidebarControl.SideBarItems.Insert(Math.Min(index, SidebarControl.SideBarItems.Count), section); SidebarControl.SideBarItems.EndBulkOperation(); } if (section != null) { foreach (var tag in FileTagsSettingsService.FileTagList) { if (!section.ChildItems.Any(x => x.Path == $"tag:{tag.TagName}")) { section.ChildItems.Add(new FileTagItem() { Text = tag.TagName, Path = $"tag:{tag.TagName}", FileTag = tag }); } } } } catch (Exception ex) { App.Logger.Warn(ex, "Error loading tags section."); } finally { SidebarControl.SideBarItemsSemaphore.Release(); } }); }
private async Task SyncSideBarItemsUI() { await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { await SidebarControl.SideBarItemsSemaphore.WaitAsync(); try { var section = SidebarControl.SideBarItems.FirstOrDefault(x => x.Text == "SidebarNetworkDrives".GetLocalized()) as LocationItem; if (App.AppSettings.ShowNetworkDrivesSection && section == null) { section = new LocationItem() { Text = "SidebarNetworkDrives".GetLocalized(), Section = SectionType.Network, SelectsOnInvoked = false, Icon = UIHelpers.GetImageForIconOrNull(SidebarPinnedModel.IconResources?.FirstOrDefault(x => x.Index == Constants.ImageRes.NetworkDrives).Image), ChildItems = new ObservableCollection <INavigationControlItem>() }; var index = (SidebarControl.SideBarItems.Any(item => item.Section == SectionType.Favorites) ? 1 : 0) + (SidebarControl.SideBarItems.Any(item => item.Section == SectionType.Library) ? 1 : 0) + (SidebarControl.SideBarItems.Any(item => item.Section == SectionType.Drives) ? 1 : 0) + (SidebarControl.SideBarItems.Any(item => item.Section == SectionType.CloudDrives) ? 1 : 0); // After cloud section SidebarControl.SideBarItems.BeginBulkOperation(); SidebarControl.SideBarItems.Insert(Math.Min(index, SidebarControl.SideBarItems.Count), section); SidebarControl.SideBarItems.EndBulkOperation(); } if (section != null) { foreach (var drive in Drives.ToList() .OrderByDescending(o => string.Equals(o.Text, "Network".GetLocalized(), StringComparison.OrdinalIgnoreCase)) .ThenBy(o => o.Text)) { var resource = SidebarPinnedModel.IconResources?.FirstOrDefault(x => x.Index == Constants.ImageRes.Folder); drive.Icon = UIHelpers.GetImageForIconOrNull(resource?.Image); drive.IconData = resource?.IconDataBytes; if (!section.ChildItems.Contains(drive)) { section.ChildItems.Add(drive); } } } } finally { SidebarControl.SideBarItemsSemaphore.Release(); } }); }
private async Task SyncSideBarItemsUI() { await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { await SidebarControl.SideBarItemsSemaphore.WaitAsync(); try { SidebarControl.SideBarItems.BeginBulkOperation(); var section = SidebarControl.SideBarItems.FirstOrDefault(x => x.Text == "SidebarNetworkDrives".GetLocalized()) as LocationItem; if (section == null) { section = new LocationItem() { Text = "SidebarNetworkDrives".GetLocalized(), Section = SectionType.Network, SelectsOnInvoked = false, Icon = UIHelpers.GetImageForIconOrNull(SidebarPinnedModel.IconResources?.FirstOrDefault(x => x.Index == Constants.ImageRes.NetworkDrives).Image), ChildItems = new ObservableCollection <INavigationControlItem>() }; SidebarControl.SideBarItems.Add(section); } if (section != null) { foreach (var drive in Drives.ToList() .OrderByDescending(o => string.Equals(o.Text, "Network".GetLocalized(), StringComparison.OrdinalIgnoreCase)) .ThenBy(o => o.Text)) { drive.Icon = UIHelpers.GetImageForIconOrNull(SidebarPinnedModel.IconResources?.FirstOrDefault(x => x.Index == Constants.ImageRes.Folder).Image); if (!section.ChildItems.Contains(drive)) { section.ChildItems.Add(drive); } } } SidebarControl.SideBarItems.EndBulkOperation(); } finally { SidebarControl.SideBarItemsSemaphore.Release(); } }); }
private async Task SyncSideBarItemsUI() { await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { await SidebarControl.SideBarItemsSemaphore.WaitAsync(); try { SidebarControl.SideBarItems.BeginBulkOperation(); var section = SidebarControl.SideBarItems.FirstOrDefault(x => x.Text == "SidebarNetworkDrives".GetLocalized()) as LocationItem; if (section == null && this.drivesList.Any(d => d.DeviceID != "network-folder")) { section = new LocationItem() { Text = "SidebarNetworkDrives".GetLocalized(), Section = SectionType.Network, Glyph = "\uE8CE", SelectsOnInvoked = false, ChildItems = new ObservableCollection <INavigationControlItem>() }; SidebarControl.SideBarItems.Add(section); } if (section != null) { foreach (var drive in Drives.ToList() .OrderByDescending(o => string.Equals(o.Text, "Network".GetLocalized(), StringComparison.OrdinalIgnoreCase)) .ThenBy(o => o.Text)) { if (!section.ChildItems.Contains(drive)) { section.ChildItems.Add(drive); } } } SidebarControl.SideBarItems.EndBulkOperation(); } finally { SidebarControl.SideBarItemsSemaphore.Release(); } }); }
private async Task SyncSideBarItemsUI() { await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { await SidebarControl.SideBarItemsSemaphore.WaitAsync(); try { var section = SidebarControl.SideBarItems.FirstOrDefault(x => x.Text == "SidebarCloudDrives".GetLocalized()) as LocationItem; if (App.AppSettings.ShowCloudDrivesSection && section == null && Drives.Any()) { section = new LocationItem() { Text = "SidebarCloudDrives".GetLocalized(), Section = SectionType.CloudDrives, SelectsOnInvoked = false, Icon = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri("ms-appx:///Assets/FluentIcons/CloudDrive.png")), ChildItems = new ObservableCollection <INavigationControlItem>() }; var index = (SidebarControl.SideBarItems.Any(item => item.Section == SectionType.Favorites) ? 1 : 0) + (SidebarControl.SideBarItems.Any(item => item.Section == SectionType.Library) ? 1 : 0) + (SidebarControl.SideBarItems.Any(item => item.Section == SectionType.Drives) ? 1 : 0); // After drives section SidebarControl.SideBarItems.BeginBulkOperation(); SidebarControl.SideBarItems.Insert(Math.Min(index, SidebarControl.SideBarItems.Count), section); SidebarControl.SideBarItems.EndBulkOperation(); } if (section != null) { foreach (DriveItem drive in Drives.ToList()) { if (!section.ChildItems.Contains(drive)) { section.ChildItems.Add(drive); } } } } finally { SidebarControl.SideBarItemsSemaphore.Release(); } }); }
private async Task SyncLibrarySideBarItemsUI() { await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { await SidebarControl.SideBarItemsSemaphore.WaitAsync(); try { var section = SidebarControl.SideBarItems.FirstOrDefault(x => x.Text == "SidebarLibraries".GetLocalized()) as LocationItem; if (UserSettingsService.SidebarSettingsService.ShowLibrarySection && section == null) { librarySection = new LocationItem { Text = "SidebarLibraries".GetLocalized(), Section = SectionType.Library, SelectsOnInvoked = false, Icon = await UIHelpers.GetIconResource(Constants.ImageRes.Libraries), ChildItems = new ObservableCollection <INavigationControlItem>() }; var index = (SidebarControl.SideBarItems.Any(item => item.Section == SectionType.Favorites) ? 1 : 0); // After favorites section SidebarControl.SideBarItems.BeginBulkOperation(); SidebarControl.SideBarItems.Insert(Math.Min(index, SidebarControl.SideBarItems.Count), librarySection); SidebarControl.SideBarItems.EndBulkOperation(); } } finally { SidebarControl.SideBarItemsSemaphore.Release(); } Libraries.BeginBulkOperation(); Libraries.Clear(); var libs = await LibraryHelper.ListUserLibraries(); if (libs != null) { libs.Sort(); Libraries.AddRange(libs); } Libraries.EndBulkOperation(); }); }
private async Task SyncSideBarItemsUI() { await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { await SidebarControl.SideBarItemsSemaphore.WaitAsync(); try { SidebarControl.SideBarItems.BeginBulkOperation(); var section = SidebarControl.SideBarItems.FirstOrDefault(x => x.Text == "SidebarCloudDrives".GetLocalized()) as LocationItem; if (section == null) { section = new LocationItem() { Text = "SidebarCloudDrives".GetLocalized(), Section = SectionType.CloudDrives, Glyph = "\uE753", SelectsOnInvoked = false, ChildItems = new ObservableCollection <INavigationControlItem>() }; SidebarControl.SideBarItems.Add(section); } foreach (DriveItem drive in Drives.ToList()) { if (!section.ChildItems.Contains(drive)) { section.ChildItems.Add(drive); } } SidebarControl.SideBarItems.EndBulkOperation(); } finally { SidebarControl.SideBarItemsSemaphore.Release(); } }); }
private async Task SyncSideBarItemsUI() { await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { await SidebarControl.SideBarItemsSemaphore.WaitAsync(); try { SidebarControl.SideBarItems.BeginBulkOperation(); try { var distroFolder = await StorageFolder.GetFolderFromPathAsync(@"\\wsl$\"); if ((await distroFolder.GetFoldersAsync()).Count != 0) { var section = SidebarControl.SideBarItems.FirstOrDefault(x => x.Text == "WSL") as LocationItem; if (section == null) { section = new LocationItem() { Text = "WSL", Section = SectionType.WSL, SelectsOnInvoked = false, Icon = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri("ms-appx:///Assets/WSL/genericpng.png")), ChildItems = new ObservableCollection <INavigationControlItem>() }; SidebarControl.SideBarItems.Add(section); } foreach (StorageFolder folder in await distroFolder.GetFoldersAsync()) { Uri logoURI = null; if (folder.DisplayName.Contains("ubuntu", StringComparison.OrdinalIgnoreCase)) { logoURI = new Uri("ms-appx:///Assets/WSL/ubuntupng.png"); } else if (folder.DisplayName.Contains("kali", StringComparison.OrdinalIgnoreCase)) { logoURI = new Uri("ms-appx:///Assets/WSL/kalipng.png"); } else if (folder.DisplayName.Contains("debian", StringComparison.OrdinalIgnoreCase)) { logoURI = new Uri("ms-appx:///Assets/WSL/debianpng.png"); } else if (folder.DisplayName.Contains("opensuse", StringComparison.OrdinalIgnoreCase)) { logoURI = new Uri("ms-appx:///Assets/WSL/opensusepng.png"); } else if (folder.DisplayName.Contains("alpine", StringComparison.OrdinalIgnoreCase)) { logoURI = new Uri("ms-appx:///Assets/WSL/alpinepng.png"); } else { logoURI = new Uri("ms-appx:///Assets/WSL/genericpng.png"); } if (!section.ChildItems.Any(x => x.Path == folder.Path)) { section.ChildItems.Add(new WslDistroItem() { Text = folder.DisplayName, Path = folder.Path, Logo = logoURI }); } } } } catch (Exception) { // WSL Not Supported/Enabled } SidebarControl.SideBarItems.EndBulkOperation(); } finally { SidebarControl.SideBarItemsSemaphore.Release(); } }); }
private async Task SyncLibrarySideBarItemsUI() { await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { await SidebarControl.SideBarItemsSemaphore.WaitAsync(); try { SidebarControl.SideBarItems.BeginBulkOperation(); try { if (App.AppSettings.ShowLibrarySection && !SidebarControl.SideBarItems.Contains(librarySection)) { librarySection = new LocationItem() { Text = "SidebarLibraries".GetLocalized(), Section = SectionType.Library, Font = App.Current.Resources["OldFluentUIGlyphs"] as FontFamily, Glyph = "\uEC13", SelectsOnInvoked = false, ChildItems = new ObservableCollection <INavigationControlItem>() }; SidebarControl.SideBarItems.Insert(1, librarySection); libraryItems.Clear(); libraryItems.Add(AppSettings.DocumentsPath); libraryItems.Add(AppSettings.PicturesPath); libraryItems.Add(AppSettings.MusicPath); libraryItems.Add(AppSettings.VideosPath); for (int i = 0; i < libraryItems.Count(); i++) { string path = libraryItems[i]; var item = await FilesystemTasks.Wrap(() => DrivesManager.GetRootFromPathAsync(path)); var res = await FilesystemTasks.Wrap(() => StorageFileExtensions.DangerousGetFolderFromPathAsync(path, item)); if (res || (FilesystemResult)FolderHelpers.CheckFolderAccessWithWin32(path)) { var locationItem = new LocationItem { Path = path, Section = SectionType.Library, Glyph = GlyphHelper.GetItemIcon(path), Font = InteractionViewModel.FontName, IsDefaultLocation = true, Text = res.Result?.DisplayName ?? Path.GetFileName(path.TrimEnd('\\')) }; librarySection.ChildItems.Insert(i, locationItem); } } } } catch (Exception) { } SidebarControl.SideBarItems.EndBulkOperation(); } finally { SidebarControl.SideBarItemsSemaphore.Release(); } }); }
private async Task SyncSideBarItemsUI() { await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { await SidebarControl.SideBarItemsSemaphore.WaitAsync(); try { var distroFolder = await StorageFolder.GetFolderFromPathAsync(@"\\wsl$\"); if ((await distroFolder.GetFoldersAsync()).Count != 0) { var section = SidebarControl.SideBarItems.FirstOrDefault(x => x.Text == "WSL".GetLocalized()) as LocationItem; if (App.AppSettings.ShowWslSection && section == null) { section = new LocationItem() { Text = "WSL".GetLocalized(), Section = SectionType.WSL, SelectsOnInvoked = false, Icon = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri("ms-appx:///Assets/WSL/genericpng.png")), ChildItems = new ObservableCollection <INavigationControlItem>() }; var index = (SidebarControl.SideBarItems.Any(item => item.Section == SectionType.Favorites) ? 1 : 0) + (SidebarControl.SideBarItems.Any(item => item.Section == SectionType.Library) ? 1 : 0) + (SidebarControl.SideBarItems.Any(item => item.Section == SectionType.Drives) ? 1 : 0) + (SidebarControl.SideBarItems.Any(item => item.Section == SectionType.CloudDrives) ? 1 : 0) + (SidebarControl.SideBarItems.Any(item => item.Section == SectionType.Network) ? 1 : 0); // After network section SidebarControl.SideBarItems.Insert(Math.Min(index, SidebarControl.SideBarItems.Count), section); } if (section != null) { foreach (StorageFolder folder in await distroFolder.GetFoldersAsync()) { Uri logoURI = null; if (folder.DisplayName.Contains("ubuntu", StringComparison.OrdinalIgnoreCase)) { logoURI = new Uri("ms-appx:///Assets/WSL/ubuntupng.png"); } else if (folder.DisplayName.Contains("kali", StringComparison.OrdinalIgnoreCase)) { logoURI = new Uri("ms-appx:///Assets/WSL/kalipng.png"); } else if (folder.DisplayName.Contains("debian", StringComparison.OrdinalIgnoreCase)) { logoURI = new Uri("ms-appx:///Assets/WSL/debianpng.png"); } else if (folder.DisplayName.Contains("opensuse", StringComparison.OrdinalIgnoreCase)) { logoURI = new Uri("ms-appx:///Assets/WSL/opensusepng.png"); } else if (folder.DisplayName.Contains("alpine", StringComparison.OrdinalIgnoreCase)) { logoURI = new Uri("ms-appx:///Assets/WSL/alpinepng.png"); } else { logoURI = new Uri("ms-appx:///Assets/WSL/genericpng.png"); } if (!section.ChildItems.Any(x => x.Path == folder.Path)) { section.ChildItems.Add(new WslDistroItem() { Text = folder.DisplayName, Path = folder.Path, Logo = logoURI }); } } } } } catch (Exception) { // WSL Not Supported/Enabled } finally { SidebarControl.SideBarItemsSemaphore.Release(); } }); }