コード例 #1
0
        public CloudFile(ICloudFile file, IFolder folder)
            : base(Path.Combine(folder.FullPath, file.CloudId), folder)
        {
            if (file.IsNull() || folder.IsNull())
            {
                throw new ArgumentNullException();
            }
            this.CloudItem = file;
            this.Parent    = folder;

            this.Name           = file.Name;
            this.Extension      = Path.GetExtension(file.Name);
            this.LastModifyTime = file.ModificationTime;
            this.Size           = file.Size;
            this.FullPath       = Path.Combine(folder.FullPath, file.CloudId);
        }
コード例 #2
0
        public override async Task <bool> OpenFileAsync(ICloudFile fileToDownload, bool forceDownload = false, bool showOpenWith = false)
        {
            var          sourceObject = new Uri(fileToDownload.DownloadSourceLocation);
            IStorageFile file         = null;

            if (fileToDownload.IsQualifiedAsSmallDownload() && !forceDownload)
            {
                file = await StorageFile.CreateStreamedFileFromUriAsync(fileToDownload.Name,
                                                                        sourceObject,
                                                                        null);
            }
            else
            {
                //TODO: Add feature to send as attachment. :D
                //TODO: Verify the code waits till the background download is complete before launching the file.
                var downloader = new BackgroundDownloader();
                file = await DownloadManager.DownloadStorageFileAsync(fileToDownload);

                DownloadOperation operation = downloader.CreateDownload(sourceObject, file);
                var result = await operation.StartAsync();

                file = result.ResultFile;
            }

            //SAD: the following did not work somehow
            //var result = await _liveClient.BackgroundDownloadAsync(objectToDownload.DownloadSourceLocation,);
            //var options = new LauncherOptions();
            //options.DisplayApplicationPicker = true;
            //var result2 = await _liveClient.GetAsync(objectToDownload.Id);

            bool launchResult;

            //Consider LaunchUriAsync(...) for else part?
            if (showOpenWith)
            {
                var options = new LauncherOptions {
                    DisplayApplicationPicker = true
                };
                launchResult = await Launcher.LaunchFileAsync(file, options);
            }
            else
            {
                launchResult = await Launcher.LaunchFileAsync(file);
            }

            return(launchResult);
        }
コード例 #3
0
        public override async Task<bool> OpenFileAsync(ICloudFile fileToDownload, bool forceDownload = false, bool showOpenWith = false)
        {
            var sourceObject = new Uri(fileToDownload.DownloadSourceLocation);
            IStorageFile file = null;
            if (fileToDownload.IsQualifiedAsSmallDownload() && !forceDownload)
            {
                file = await StorageFile.CreateStreamedFileFromUriAsync(fileToDownload.Name,
                                                                                     sourceObject,
                                                                                     null);
            }
            else
            {
                //TODO: Add feature to send as attachment. :D
                //TODO: Verify the code waits till the background download is complete before launching the file.
                var downloader = new BackgroundDownloader();
                file = await DownloadManager.DownloadStorageFileAsync(fileToDownload);
                DownloadOperation operation = downloader.CreateDownload(sourceObject, file);
                var result = await operation.StartAsync();
                file = result.ResultFile;
            }

            //SAD: the following did not work somehow
            //var result = await _liveClient.BackgroundDownloadAsync(objectToDownload.DownloadSourceLocation,);
            //var options = new LauncherOptions();
            //options.DisplayApplicationPicker = true;
            //var result2 = await _liveClient.GetAsync(objectToDownload.Id);

            bool launchResult;
            //Consider LaunchUriAsync(...) for else part?
            if (showOpenWith)
            {
                var options = new LauncherOptions {DisplayApplicationPicker = true};
                launchResult = await Launcher.LaunchFileAsync(file, options);
            }
            else
                launchResult = await Launcher.LaunchFileAsync(file);

            return launchResult;
        }
コード例 #4
0
ファイル: CloudProvider.cs プロジェクト: haydenprock/OneDrive
 /// <summary>
 /// Method to download this ICloudObject.
 /// </summary>
 /// <returns>Running task which is downloading the ICloudObject</returns>
 public abstract Task <bool> OpenFileAsync(ICloudFile cloudFile, bool forceDownload = false, bool showOpenWith = false);
コード例 #5
0
 public static bool IsQualifiedAsSmallDownload(this ICloudFile objectToDownload)
 {
     return(objectToDownload.Size <= OneDriveSettings.MaxSmallDownloadSize);
 }
コード例 #6
0
 public Task<IStorageFile> DownloadStorageFileAsync(ICloudFile fileToDownload)
 {
     throw new NotImplementedException();
 }
コード例 #7
0
 public Task <IStorageFile> DownloadStorageFileAsync(ICloudFile fileToDownload)
 {
     throw new NotImplementedException();
 }