コード例 #1
0
 private void Current_FileUploadProgress(object sender, FileUploadProgress e)
 {
     Device.BeginInvokeOnMainThread(() =>
     {
         ProgressBar.ProgressTo(e.Percentage / 100.0f, 100, Easing.Linear);
     });
 }
コード例 #2
0
 private void Current_FileUploadProgress(object sender, FileUploadProgress e)
 {
     Device.BeginInvokeOnMainThread(() =>
     {
         progress.Progress = e.Percentage / 100.0f;
     });
 }
コード例 #3
0
 private async void UpdateFileUploadProgressAsync(object sender, FileUploadProgress e)
 {
     foreach (var image in _vehicle.Images.Where(vi => vi.Tag == e.Tag))
     {
         await Device.InvokeOnMainThreadAsync(() => image.UploadProgress = e.Percentage / 100.0f);
     }
 }
コード例 #4
0
        // Note that this event is invoked on a background thread, so we cannot access the UI directly.
        private void UploadProgress(UploadOperation upload)
        {
            // UploadOperation.Progress is updated in real-time while the operation is ongoing. Therefore,
            // we must make a local copy so that we can have a consistent view of that ever-changing state
            // throughout this method's lifetime.
            BackgroundUploadProgress currentProgress = upload.Progress;

            double percentSent = 100;

            if (currentProgress.TotalBytesToSend > 0)
            {
                percentSent = currentProgress.BytesSent * 100 / currentProgress.TotalBytesToSend;
            }

            var fileUploadProgress = new FileUploadProgress((long)currentProgress.BytesSent, (long)currentProgress.TotalBytesToSend, upload.TransferGroup.Name);

            FileUploadProgress(this, fileUploadProgress);

            if (currentProgress.HasRestarted)
            {
                // MarshalLog(" - Upload restarted");
            }

            if (currentProgress.HasResponseChanged)
            {
                // We've received new response headers from the server.

                // If you want to stream the response data this is a good time to start.
                //upload.GetResultStreamAt(0);
            }
        }
コード例 #5
0
        public override void DidSendBodyData(NSUrlSession session, NSUrlSessionTask task, long bytesSent, long totalBytesSent, long totalBytesExpectedToSend)
        {
            var fileUploadProgress = new FileUploadProgress(totalBytesSent, totalBytesExpectedToSend);

            FileUploadProgress(this, fileUploadProgress);

            System.Diagnostics.Debug.WriteLine(string.Format("DidSendBodyData bSent: {0}, totalBSent: {1} totalExpectedToSend: {2}", bytesSent, totalBytesSent, totalBytesExpectedToSend));
        }
コード例 #6
0
        private static void UploadProgress(UploadProgressChangedEventArgs e, string fileName, int id)
        {
            decimal pp      = (decimal)e.BytesSent / (decimal)e.TotalBytesToSend;
            int     percent = (int)Math.Round(pp * 100);

            if (percent > downloadProgressNextTick)
            {
                FileTransferProgressEventArgs args = new FileTransferProgressEventArgs();
                args.PercentProgress = percent;
                args.ID = id;
                FileUploadProgress?.Invoke(null, args);
                downloadProgressNextTick = percent + downloadProgressTreshold;
            }
        }
コード例 #7
0
        public override void DidSendBodyData(NSUrlSession session, NSUrlSessionTask task, long bytesSent, long totalBytesSent, long totalBytesExpectedToSend)
        {
            string[] parts = task.TaskDescription.Split('|');

            var tag = string.Empty;

            if (parts != null && parts.Length > 0)
            {
                tag = parts[0];
            }

            var fileUploadProgress = new FileUploadProgress(totalBytesSent, totalBytesExpectedToSend, tag);

            FileUploadProgress(this, fileUploadProgress);

            System.Diagnostics.Debug.WriteLine(string.Format("DidSendBodyData bSent: {0}, totalBSent: {1} totalExpectedToSend: {2}", bytesSent, totalBytesSent, totalBytesExpectedToSend));
        }
コード例 #8
0
        public void OnProgress(string tag, long bytesWritten, long contentLength)
        {
            var fileUploadProgress = new FileUploadProgress(bytesWritten, contentLength, tag);

            FileUploadProgress(this, fileUploadProgress);
        }
コード例 #9
0
 public UploadErrorModel(FileUploadProgress progress)
 {
     Ensure.NotNull(progress, "progress");
     Progress = progress;
 }
コード例 #10
0
 public UploadImageModel(FileUploadProgress progress, ImageModel image)
 {
     Ensure.NotNull(progress, "progress");
     Progress = progress;
     Image    = image;
 }