Beispiel #1
0
        public async void ContinueFolderPicker(FolderPickerContinuationEventArgs args)
        {
            var folder = args.Folder;

            if (folder != null)
            {
                //중복된 폴더는 추가하지 않음
                if (!ExplorerFolderSource.Any(x => x.Path == folder.Path))
                {
                    //전체 비디오에 반영
                    await ThreadPool.RunAsync(async handler =>
                    {
                        var folderInfo = new FolderInfo(folder)
                        {
                            Level = 1,
                            Type  = FolderType.Root,
                            ButtonTappedCommand1 = LockFolderCommand,
                            ButtonTappedCommand2 = RemoveFolderCommand,
                            Passcode             = string.Empty
                        };

                        //선택한 폴더 DB등록
                        folderDAO.Insert(folderInfo);

                        await DispatcherHelper.RunAsync(() =>
                        {
                            //Add Folder 바로 앞에 추가
                            var addFolder         = ExplorerFolderSource.FirstOrDefault(x => x.Type == FolderType.Picker);
                            addFolder.IsHighlight = false;
                            var index             = ExplorerFolderSource.IndexOf(addFolder);
                            ExplorerFolderSource.Insert(index, folderInfo);

                            //전체 비디오에 반영
                            MessengerInstance.Send <Message>(new Message("FolderAdded", folderInfo), AllVideoViewModel.NAME);
                        });
                    });
                }
            }
            else
            {
                //간간히 화면에 렌더링이 안되는 경우가 생김. 전체 새로 고침을 통해서 다시 렌더링.
                LoadRootFolders();
            }
        }
Beispiel #2
0
        private async void LoadRootFolders()
        {
            try
            {
                //폴더 추가 버튼
                await DispatcherHelper.RunAsync(async() =>
                {
                    if (ExplorerFolderSource.Count > 0)
                    {
                        ExplorerFolderSource.Clear();
                    }

                    if (ExplorerFileSource.Count > 0)
                    {
                        ExplorerFileSource.Clear();
                    }

                    //탐색기 루트를 로드
                    folderDAO.LoadRootFolderList(ExplorerFolderSource, LockFolderCommand, RemoveFolderCommand, true);

                    ExplorerFolderSource.Add(new FolderInfo()
                    {
                        Name        = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView().GetString("AddFolder"),
                        Glyph1      = "\xE109", //&#xE109;
                        Type        = FolderType.Picker,
                        IsHighlight = ExplorerFolderSource.Count == 0,
                        Level       = 1
                    });

                    ///////////////////////////// 윈10 10549 버그 Workaround//////////////////////////////////
                    if (VersionHelper.WindowsVersion == 10 && !ExplorerFolderSource.Any(x => x.Type != FolderType.Picker))
                    {
                        List <StorageFolder> folders = new List <StorageFolder>();
                        folders.Add(KnownFolders.VideosLibrary);

                        var external = await KnownFolders.RemovableDevices.GetFoldersAsync();
                        if (external != null && external.Any())
                        {
                            folders.AddRange(external);
                        }

                        foreach (var folder in folders)
                        {
                            bool found = false;
                            //중복된 폴더는 추가하지 않음
                            foreach (var added in ExplorerFolderSource)
                            {
                                var sf = await added.GetStorageFolder(true);
                                if (sf != null && sf.FolderRelativeId == folder.FolderRelativeId)
                                {
                                    found = true;
                                    break;
                                }
                            }

                            if (!found)
                            {
                                //전체 비디오에 반영
                                var folderInfo = new FolderInfo(folder)
                                {
                                    Level = 1,
                                    Type  = FolderType.Root,
                                    ButtonTappedCommand1 = LockFolderCommand,
                                    ButtonTappedCommand2 = RemoveFolderCommand,
                                    Passcode             = string.Empty
                                };

                                //선택한 폴더 DB등록
                                folderDAO.Insert(folderInfo);

                                var addFolder         = ExplorerFolderSource.FirstOrDefault(x => x.Type == FolderType.Picker);
                                addFolder.IsHighlight = false;
                                var index             = ExplorerFolderSource.IndexOf(addFolder);
                                ExplorerFolderSource.Insert(index, folderInfo);

                                //전체 비디오에 반영
                                MessengerInstance.Send <Message>(new Message("FolderAdded", folderInfo), AllVideoViewModel.NAME);
                            }
                        }
                    }
                    //////////////////////////////////////////////////////////////////////////////////////////
                });
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.Message);
            }
        }