Ejemplo n.º 1
0
 private void ReportProgress(TransferProgressArgs args)
 {
     if (this.ProgressChanged != null)
     {
         this.ProgressChanged(args.PercentDone);
     }
 }
Ejemplo n.º 2
0
        private void ProgressEventCallback(object sender, TransferProgressArgs e)
        {
            double percentDone = Math.Round(((double)(e.TransferredBytes) * 100) / e.TotalBytes);

            percentDone = percentDone >= 100 ? 100 : percentDone;
            long transferredBytes = e.TransferredBytes > e.TotalBytes ? e.TotalBytes : e.TransferredBytes;

            if ((PreviousReportBytes + this.ProgressUpdateInterval) < transferredBytes || transferredBytes == e.TotalBytes)
            {
                if (transferredBytes != e.TotalBytes)
                {
                    PreviousReportBytes = transferredBytes;
                }

                UploadProgressEvent?.Invoke(this, new S3ProgressArgs
                {
                    TransferredBytes = transferredBytes,
                    TotalBytes       = e.TotalBytes,
                    PercentDone      = (int)e.PercentDone
                });
            }
        }
Ejemplo n.º 3
0
        private static void TransferProgress(object sender, TransferProgressArgs e)
        {
            var msg = string.Format("{0,3} %", e.PercentDone);

            Debug.WriteLine(msg);
        }
Ejemplo n.º 4
0
 //Progress
 private decimal GetPercent(TransferProgressArgs e)
 {
     return((((decimal)1 / (decimal)e.TotalBytes) * (decimal)e.TransferredBytes) * 100);
 }
Ejemplo n.º 5
0
        private void fTrayForm_Load(object sender, EventArgs e)
        {
            // Make sure the border doesn't appear
            Text = string.Empty;

            progressBar1 = new NewProgressBar();
            //progressBar1.Dock = DockStyle.Top;
            progressBar1.Height   = 10;
            progressBar1.Width    = 344;
            progressBar1.Margin   = new Padding(0);
            progressBar1.Location = new Point(0, 249);
            progressBar1.Visible  = false;
            this.Controls.Add(progressBar1);

            Notifications.RecentListChanged += (o, n) => Invoke(new MethodInvoker(LoadRecent));

            Program.Account.Client.TransferProgress += (o, n) =>
            {
                // Only when Downloading/Uploading.
                if (string.IsNullOrWhiteSpace(_lastStatus.AssossiatedFile))
                {
                    return;
                }
                // Update item in recent list
                Invoke(new MethodInvoker(() =>
                {
                    // Get status progress for the transfer

                    var progress = string.Format("{2} / {3} - {0,3}% - {1} ", n.Progress, n.Rate, TransferProgressArgs.ConvertSize(n.TotalTransferred), TransferProgressArgs.ConvertSize(n.Item.Item.Size));

                    _transferItem.FileStatusLabel = string.Format(_transferItem.SubTitleFormat, progress);

                    if (fRecentList.Height != 209)
                    {
                        fRecentList.Height   = 209;
                        progressBar1.Visible = true;
                    }

                    progressBar1.Value = n.Progress;

                    if (n.Progress == 100)
                    {
                        progressBar1.Visible = false;
                        fRecentList.Height   = 219;
                    }
                }));
            };
            // Set the status label and load the recent files
            SetStatusLabel(null, _lastStatus);
            LoadRecent();
        }
Ejemplo n.º 6
0
        public void SetStatusLabel(object o, TrayTextNotificationArgs e)
        {
            try
            {
                // Save latest status
                _lastStatus = e;

                if (!string.IsNullOrWhiteSpace(e.AssossiatedFile))
                {
                    var name = Common._name(e.AssossiatedFile);

                    var format = Common.Languages[e.MessageType];

                    _transferItem.FileNameLabel   = name;
                    _transferItem.SubTitleFormat  = format;
                    _transferItem.FileStatusLabel = string.Format(format, string.Empty);
                    // Add to top of recent list
                    fRecentList.Controls.Add(_transferItem);
                    fRecentList.Controls.SetChildIndex(_transferItem, 0);
                }

                switch (e.MessageType)
                {
                case MessageType.Uploading:
                case MessageType.Downloading:
                    lCurrentStatus.Text = Common.Languages[MessageType.Syncing];
                    break;

                case MessageType.Listing:
                    lCurrentStatus.Text = (Program.Account.Account.SyncMethod == SyncMethod.Automatic)
                            ? Common.Languages[MessageType.AllSynced]
                            : Common.Languages[MessageType.Listing];
                    break;

                case MessageType.Size:
                    remoteTotalSize += e.sizeValue;
                    if (remoteTotalSize < 0)
                    {
                        remoteTotalSize = 0;
                    }
                    lSize.Text = Common.Languages[MessageType.Size] + " " + TransferProgressArgs.ConvertSize(remoteTotalSize);
                    break;

                case MessageType.NullSize:
                    remoteTotalSize = 0;
                    lSize.Text      = "";
                    break;

                case MessageType.Scanning:
                    if (e.customString.Length > 40)
                    {
                        e.customString = "..." + e.customString.Substring(e.customString.Length - 40, 40);
                    }
                    lSize.Text = e.customString;
                    break;

                default:
                    lCurrentStatus.Text = Common.Languages[e.MessageType];
                    break;
                }
            }
            catch (Exception ex)
            {
                Common.LogError(ex);
            }
        }