Exemple #1
0
        private void timerUpdateProgress_Tick(object sender, EventArgs e)
        {
            if (_objCurrentDownloadStats != null)
            {
                this.ThreadSafe(new MethodInvoker(delegate()
                {
                    textSizeInBytes.Text    = String.Format("{0:n0} bytes", _objCurrentDownloadStats.GetFormattedSize(TransferSizeType.Byte));
                    textBytesReceived.Text  = String.Format("{0:n0} bytes", _objCurrentDownloadStats.GetFormattedBytesReceived(TransferSizeType.Byte));
                    textBytesRemaining.Text = String.Format("{0:n0} bytes", _objCurrentDownloadStats.GetFormattedBytesRemaining(TransferSizeType.Byte));

                    textDuration.Text      = _objCurrentDownloadStats.FormattedDuration;
                    textSpeed.Text         = _objCurrentDownloadStats.GetFormattedTransferRate(TransferSizeType.Kilobyte, TransferTimeType.Second);
                    textTimeRemaining.Text = _objCurrentDownloadStats.TimeRemaining;

                    int intMaximum = Convert.ToInt32(_objCurrentDownloadStats.Size);
                    int intSize    = Convert.ToInt32(_objCurrentDownloadStats.BytesReceived);
                    UpdateCurrentProgress(intMaximum, intSize);

                    if (_blnUpdatePercentages == true)
                    {
                        double dblPercentage = (Convert.ToDouble((double)intSize / (double)intMaximum) * 100);
                        if (double.IsNaN(dblPercentage) == false)
                        {
                            int intPercentage = Convert.ToInt32(dblPercentage);

                            ListViewItem objListViewItem = listViewStatus.Items[_intTaskIndex - 1];
                            if (objListViewItem != null)
                            {
                                objListViewItem.SubItems[1].Text = intPercentage.ToString() + "%";
                            }
                        }
                    }
                }));
            }
        }