private async void DownloadTo(object sender, RoutedEventArgs e) { var item = ((sender as FrameworkElement).DataContext as YunFileAdapter).File; if (FileList.SelectedItems.Count == 0) { IStorageItem location; if (item.isdir == 0) { location = await UWPUtils.SavePathPicker(item.server_filename); } else { location = await UWPUtils.SaveFolderPicker(); } if (location == null) { return; } Globals.downloads.AddTask(item, location); } else { // Make copy because they will be deseleted soon var files = FileList.SelectedItems.Select((file) => (file as YunFileAdapter).File).ToList(); var location = await UWPUtils.SaveFolderPicker(); if (location == null) { return; } Globals.downloads.AddTasks(files, location); FileList.SelectedItems.Clear(); } }
/// <summary> /// Shows the file open dialog. /// </summary> /// <param name="onFileOpen">Event that occurs when user choose a file.</param> public void ShowFileOpenDialog(FileOpenEventHandle onFileOpen) { UnityEngine.WSA.Application.InvokeOnUIThread(async() => { var filePicker = new Windows.Storage.Pickers.FileOpenPicker(); filePicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary; filePicker.FileTypeFilter.Add("*"); var file = await filePicker.PickSingleFileAsync(); if (file != null) { _onFileOpen = onFileOpen; _pendingFile = await UWPUtils.ReadStorageFileIntoBuffer(file); _pendingFilename = file.Path; } }, false); }
private async void CreateShare(object sender, RoutedEventArgs e) { var item = (sender as FrameworkElement).DataContext as YunFileAdapter; var list = FileList.SelectedItems.Count == 0 ? new List <YunFile>() { item.File } : FileList.SelectedItems.Select(file => (file as YunFileAdapter).File).ToList(); var password = await UWPUtils.InputDialog("设置分享密码", "", "空值为无密码"); if (await BaiduYun.CreateShare(list, password)) { Share.ListRefreshed = false; FileList.SelectedItems.Clear(); } }
private async void RenameTo(object sender, RoutedEventArgs e) { var context = (sender as FrameworkElement).DataContext as YunFileAdapter; var file = context.File; var newname = await UWPUtils.InputDialog("重命名为:", file.server_filename); if (newname != null && await BaiduYun.RenameFile(file.path, newname)) { var oldpath = file.path; var newpath = oldpath.Replace(file.server_filename, newname); file.server_filename = newname; file.path = newpath; if (file.isdir == 1) { context.Children = null; } UpdateItems(current); } }
private async void ItemTapped(object sender, TappedRoutedEventArgs e) { var item = (sender as FrameworkElement).DataContext as YunFileAdapter; switch (item.Type) { case FileType.Folder: await BrowsePath(item); break; case FileType.Image: var thumbs = item.File.thumbs; var url = thumbs?.url1 ?? thumbs?.url2 ?? thumbs?.url3; if (url == null) { return; } await UWPUtils.ImageDialog(item.File.server_filename, url); FileList.SelectedItems.Clear(); break; case FileType.Audio: case FileType.Video: var media = await BaiduYun.GetFileDownloadLink(item.File); if (media == null) { return; } await UWPUtils.MediaDialog(item.File.server_filename, media); FileList.SelectedItems.Clear(); break; default: break; } }
private async void UpdateCaptcha(string codestring) { var buffer = await BaiduYun.CaptchaImage(codestring); CaptchaImage.Source = await UWPUtils.ImageFromBuffer(buffer); }