private async Task CopyLink(File file) { this.IsLoading = true; try { var link = await this.client.GetPublicFileLinkAsync(file.FileId, null); var dataPackage = new DataPackage(); dataPackage.SetText(link); dataPackage.SetWebLink(new Uri(link)); Clipboard.SetContent(dataPackage); var notificationService = SimpleIoc.Default.GetInstance<NotificationService>(); notificationService.ShowToast("File(s) shared", "A link has been copied to the clipboard", "Assets/Logo.scale-100.png"); } finally { this.IsLoading = false; } }
private Windows.UI.ViewManagement.ViewSizePreference GetPreferredViewSizeForFile(File file) { if (file.Category == Category.Audio) { return Windows.UI.ViewManagement.ViewSizePreference.UseMore; } return Windows.UI.ViewManagement.ViewSizePreference.UseLess; }
private async Task OpenFile(File file, bool displayApplicationPicker = false) { StorageFile tempFile = null; using (var cts = new CancellationTokenSource()) using (this.ShowProgress(string.Format("Opening {0}", file.Name), cts)) { tempFile = await ApplicationData.Current.TemporaryFolder.CreateFileAsync(file.Name, CreationCollisionOption.GenerateUniqueName); using (var stream = await System.IO.WindowsRuntimeStorageExtensions.OpenStreamForWriteAsync(tempFile)) { if (cts.IsCancellationRequested) { return; } await client.DownloadFileAsync(file.FileId, stream, cts.Token); } } var options = new LauncherOptions { #if WINDOWS_APP DesiredRemainingView = this.GetPreferredViewSizeForFile(file), #endif DisplayApplicationPicker = displayApplicationPicker }; await Launcher.LaunchFileAsync(tempFile, options); }