Ejemplo n.º 1
0
        private async void OnUpload(object sender, Upload upload)
        {
            if (sender != null && upload != null)
            {
                var dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher;
                await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine("FileName: " + upload.Name);
                    sb.AppendLine(string.Format("TotalBytes: {0}kb", upload.TotalBytes / 1024));
                    sb.AppendLine(string.Format("BytesSent: {0}kb", upload.BytesSent / 1024));
                    sb.AppendLine(string.Format("ElapsedTime: {0}.{1} sec", upload.ElapsedTime.Seconds.ToString("00"),
                                                upload.ElapsedTime.Milliseconds.ToString("00")));

                    sb.AppendLine("State: " + upload.State);
                    if (upload.State == UploaderState.Error)
                    {
                        sb.AppendLine("ErrorMessage: " + upload.ErrorMessage);
                    }
                    else if (upload.State == UploaderState.Uploaded)
                    {
                        sb.AppendLine("UploadedUrl: " + upload.UploadedUrl);
                    }

                    switch (upload.State)
                    {
                    case UploaderState.Error:
                        txtUpload.Foreground = new SolidColorBrush(Colors.Red);
                        break;

                    case UploaderState.Uploaded:
                        txtUpload.Foreground = new SolidColorBrush(Colors.Green);
                        break;

                    default:
                        txtUpload.Foreground = new SolidColorBrush(Colors.Cyan);
                        break;
                    }



                    txtUpload.Text = sb.ToString();
                });
            }
        }
Ejemplo n.º 2
0
 public WNUploader(Upload upload, StorageFile file)
 {
     Upload       = upload;
     FileToUpload = file;
     stopWatch.Reset();
 }
Ejemplo n.º 3
0
 public WNUploader()
 {
     Upload = new Upload();
     stopWatch.Reset();
 }