示例#1
0
        public async Task <bool> CheckDefaultSaveFolderAccess()
        {
            if (IsEmpty)
            {
                return(false);
            }
            var res = (FilesystemResult)FolderHelpers.CheckFolderAccessWithWin32(DefaultSaveFolder);

            if (!res)
            {
                var item = await FilesystemTasks.Wrap(() => DrivesManager.GetRootFromPathAsync(DefaultSaveFolder));

                res = await FilesystemTasks.Wrap(() => StorageFileExtensions.DangerousGetFolderFromPathAsync(DefaultSaveFolder, item));
            }
            return(res);
        }
示例#2
0
        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();
                }
            });
        }