www.pudn.com > SharpDownload(FTP¼°WEBÏÂÔØ).zip > DownloadStatus.cs
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
namespace SharpDownload
{
///
/// Summary description for PartDownloadStatus.
///
public class DownloadStatus : System.Windows.Forms.UserControl
{
private System.Windows.Forms.Label labelPartNumber;
private System.Windows.Forms.Label labelCurrentStatus;
private System.Windows.Forms.ProgressBar progressPartDownload;
private System.Windows.Forms.Label labelBytesDownloaded;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
private int partNumber = 0;
private string status = string.Empty;
private int percentDownloaded = 0;
private long partSize = 0;
private long bytesDownloaded = 0;
///
/// Public default constructor
///
public DownloadStatus()
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
// Initialization
this.progressPartDownload.Minimum=0;
this.progressPartDownload.Maximum=100;
this.progressPartDownload.Value=0;
}
///
/// Display the download status
///
public void UpdateDisplay()
{
this.labelPartNumber.Text = this.partNumber.ToString();
this.labelCurrentStatus.Text = this.status;
this.progressPartDownload.Value = this.percentDownloaded;
this.labelBytesDownloaded.Text = this.bytesDownloaded.ToString() + " of " + this.partSize.ToString();
}
///
/// Public part number property
///
public int PartNumber
{
get
{
return partNumber;
}
set
{
partNumber=value;
}
}
public string Status
{
get
{
return status;
}
set
{
status=value;
}
}
public int Percent
{
get
{
return percentDownloaded;
}
}
public long PartSize
{
get
{
return partSize;
}
set
{
partSize=value;
}
}
public long BytesDownloaded
{
get
{
return bytesDownloaded;
}
set
{
bytesDownloaded=value;
// Set percent downloaded
if (partSize!=0)
{
percentDownloaded = (int)(((decimal)bytesDownloaded/(decimal)partSize)*100);
}
else
{
percentDownloaded = 0;
}
}
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Component Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.labelPartNumber = new System.Windows.Forms.Label();
this.labelCurrentStatus = new System.Windows.Forms.Label();
this.progressPartDownload = new System.Windows.Forms.ProgressBar();
this.labelBytesDownloaded = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// labelPartNumber
//
this.labelPartNumber.Location = new System.Drawing.Point(8, 0);
this.labelPartNumber.Name = "labelPartNumber";
this.labelPartNumber.Size = new System.Drawing.Size(24, 16);
this.labelPartNumber.TabIndex = 0;
this.labelPartNumber.Text = "#";
//
// labelCurrentStatus
//
this.labelCurrentStatus.Location = new System.Drawing.Point(40, 0);
this.labelCurrentStatus.Name = "labelCurrentStatus";
this.labelCurrentStatus.Size = new System.Drawing.Size(136, 16);
this.labelCurrentStatus.TabIndex = 1;
this.labelCurrentStatus.Text = "status";
//
// progressPartDownload
//
this.progressPartDownload.Location = new System.Drawing.Point(176, 0);
this.progressPartDownload.Name = "progressPartDownload";
this.progressPartDownload.Size = new System.Drawing.Size(184, 16);
this.progressPartDownload.TabIndex = 2;
//
// labelBytesDownloaded
//
this.labelBytesDownloaded.Location = new System.Drawing.Point(368, 0);
this.labelBytesDownloaded.Name = "labelBytesDownloaded";
this.labelBytesDownloaded.Size = new System.Drawing.Size(176, 16);
this.labelBytesDownloaded.TabIndex = 3;
this.labelBytesDownloaded.Text = "bytes downloaded";
//
// PartDownloadStatus
//
this.Controls.Add(this.labelBytesDownloaded);
this.Controls.Add(this.progressPartDownload);
this.Controls.Add(this.labelCurrentStatus);
this.Controls.Add(this.labelPartNumber);
this.Name = "PartDownloadStatus";
this.Size = new System.Drawing.Size(552, 16);
this.ResumeLayout(false);
}
#endregion
}
}