Ejemplo n.º 1
0
 private void LoadThumbnailMetadataInFolder(IList <Item> itemList)
 {
     if (itemList.Any() && !_ThumbnailListInCurrentFolder.Any())
     {
         var thumbDirectory = itemList.Where(x => x.ParentReference != null).Select(x => x.ParentReference.Path).FirstOrDefault();
         ThumbnailDAO.LoadThumnailInFolder(thumbDirectory, _ThumbnailListInCurrentFolder);
     }
 }
Ejemplo n.º 2
0
        private async void LoadFilesAsync(StorageItemInfo fi)
        {
            if (fi != null)
            {
                string nonGroupName = ResourceLoader.GetForCurrentView().GetString("List/File/Text");
                ///파일 로딩 표시기 실행
                IsLoadingFiles = true;
                //폴더 로딩 표시기 정지
                IsLoadingFolders = false;

                await ThreadPool.RunAsync(async (handler) =>
                {
                    StorageFolder currentFolder = await fi.GetStorageFolderAsync();
                    if (currentFolder != null)
                    {
                        var queryResult = currentFolder.CreateFileQueryWithOptions(_VideoFileQueryOptions);
                        var list        = await queryResult.GetFilesAsync();
                        if (list.Any())
                        {
                            //썸네일 캐시 로드
                            ThumbnailDAO.LoadThumnailInFolder(fi.Path, _ThumbnailListInCurrentFolder);

                            //아이템을 정렬하여 화면에 표시
                            await LoadItemsAsync(list.Select(x => new StorageItemInfo(x)
                            {
                                Tapped        = FileTapped,
                                RightTapped   = FileRightTapped,
                                Holding       = FileHolding,
                                IsOrderByName = (_Sort == SortType.Name || _Sort == SortType.NameDescending)
                            }), list.Count, nonGroupName, true, 9);
                        }
                    }
                    await DispatcherHelper.RunAsync(() => { IsLoadingFiles = false; });
                });
            }
            else
            {
                IsLoadingFolders = false;
            }
        }
Ejemplo n.º 3
0
        private async void SetExtraPropertiesAsync(StorageItemInfo itemInfo)
        {
            if (itemInfo.IsFile)
            {
                //파일 용량 조회
                var file = await itemInfo.GetStorageFileAsync();

                if (file != null)
                {
                    //System.Diagnostics.Debug.WriteLine(file.DisplayName);
                    var bi = await file.GetBasicPropertiesAsync();

                    //파일 크기 설정
                    itemInfo.Size = bi.Size;
                    //썸네일 로드
                    this.LoadThumbnailAsync(itemInfo, _ThumbnailListInCurrentFolder, Settings.Thumbnail.UseUnsupportedDLNAFile);
                    //자막 목록 설정
                    if (_CurrentSubtitleFileList != null && _CurrentSubtitleFileList.Any())
                    {
                        itemInfo.SubtitleList = _CurrentSubtitleFileList.Where(x => x.Contains(System.IO.Path.GetFileNameWithoutExtension(itemInfo.Name).ToUpper())).ToList();
                    }
                }
            }
            else
            {
                var folder = await itemInfo.GetStorageFolderAsync();

                if (folder != null)
                {
                    itemInfo.DateCreated = folder.DateCreated;

                    //비디오 파일 갯수를 알아내기 위한 필터링 옵션
                    var queryResult = folder.CreateFileQueryWithOptions(_VideoFileQueryOptions);
                    itemInfo.FileCount = (int)await queryResult.GetItemCountAsync();

                    var folderCount = await folder.CreateFolderQuery().GetItemCountAsync();

                    if (itemInfo.FileCount > 0)
                    {
                        itemInfo.FileCountDescription = itemInfo.FileCount.ToString() + (folderCount > 0 ? "+" : string.Empty);
                    }
                    else
                    {
                        itemInfo.FileCountDescription = "0" + (folderCount > 0 ? "*" : string.Empty);
                    }

                    if (itemInfo.FileCount > 0)
                    {
                        var fileList = await queryResult.GetFilesAsync();

                        List <ImageSource> imageSourceList = new List <ImageSource>();

                        List <Thumbnail> thumbnailList = new List <Thumbnail>();
                        ThumbnailDAO.LoadThumnailInFolder(itemInfo.Path, thumbnailList);

                        for (int i = 0; i < fileList.Count; i++)
                        {
                            //썸네일 로드
                            var imgSrc = await GetThumbnailAsync(fileList[i], thumbnailList, Settings.Thumbnail.UseUnsupportedDLNAFolder);

                            if (imgSrc != null)
                            {
                                imageSourceList.Add(imgSrc);
                            }
                            //4장의 이미지를 채우지 못할 것으로 확신되거나, 이미 4장을 채운경우 정지
                            if (((imageSourceList.Count > 0 && imageSourceList.Count >= 4) ||
                                 (itemInfo.FileCount - (i + 1) + imageSourceList.Count < 4)) && imageSourceList.Count > 0)
                            {
                                break;
                            }
                        }

                        itemInfo.ImageItemsSource = imageSourceList;
                    }
                    else if (!_FolderStack.Any())
                    {
                        //NAS아이콘 추출
                        ImageSource imageSource = null;
                        var         thumb       = await folder.GetThumbnailAsync(ThumbnailMode.SingleItem);

                        if (thumb?.Type == ThumbnailType.Image)
                        {
                            //썸네일 설정
                            await DispatcherHelper.RunAsync(() =>
                            {
                                var bi = new Windows.UI.Xaml.Media.Imaging.BitmapImage();
                                bi.SetSource(thumb);
                                imageSource               = bi;
                                itemInfo.IsFullFitImage   = false;
                                itemInfo.ImageItemsSource = imageSource;
                            });
                        }
                    }
                }
            }
        }