private void RegisterMessages() { MessengerInstance.Register <Message>(this, NAME, msg => { switch (msg.Key) { case "Activated": OnActivated(); RaisePropertyChanged("GeneralSetting"); break; case "BackPressed": msg.GetValue <BackPressedEventArgs>().Handled = true; if (SelectionMode != ListViewSelectionMode.None) { //선택 모드 변경 SelectionMode = ListViewSelectionMode.None; ButtonGroupVisible = true; } else { DateTime now = DateTime.Now; if (GeneralSetting.HardwareBackButtonAction == HardwareBackButtonAction.MoveToUpperFolder.ToString() && ExplorerFolderSource.Any(x => x.Type == FolderType.Upper) && (lastBackKeyDttm == null || now.Subtract((DateTime)lastBackKeyDttm).TotalMilliseconds > 300)) { //완벽할 수는 없으나... 입력시간을 기간 300ms 안에 들어오는것은 버림으로 UI와 ItemSource 동기화 시간을 조금이나마 번다. //상위 폴더로 이동 ToUpperFolder(msg.GetValue <BackPressedEventArgs>()); lastBackKeyDttm = now; } else { //종료 확인 MessengerInstance.Send <Message>(new Message("ConfirmTermination", null), MainViewModel.NAME); } } break; case "ShowErrorFile": if (ExplorerFileSource.Any()) { var kv = msg.GetValue <KeyValuePair <string, MediaInfo> >(); var mi = ExplorerFileSource.FirstOrDefault(f => f.Path == kv.Value.Path); if (mi != null) { mi.OccuredError = kv.Key + "\n"; } } break; } }); }
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(); } }
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", // 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); } }