first neet add an user control "DownloadBar":

/*

  • Created by SharpDevelop.
  • User: gwang
  • Date: 2016/8/25
  • Time: 14:01
  • To change this template use Tools | Options | Coding | Edit Standard Headers.

    */

    using System;

    using System.ComponentModel;

    using System.Drawing;

    using System.Windows.Forms;

namespace testHttp

{

///



/// Description of DownloadBar.

///

public partial class DownloadBar : UserControl

{

public DownloadBar()

{

//

// The InitializeComponent() call is required for Windows Forms designer support.

//

InitializeComponent();

Anchor=AnchorStyles.Left|AnchorStyles.Right;

// Width=Parent.Width -40;

Height=65;

		//
// TODO: Add constructor code after the InitializeComponent() call.
//
} public DownloadBar(DownLoadInfo info)
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
MinimumSize= new Size(126,66);
this.info=info;
btn1.Text=""+info.title +info.uid;
btn1.Visible=false;
lb1.Visible=true ; if (info.ProgressPercentage<100){ lb1.Visible=true;
lb1.Text=info.ProgressPercentage+"%"; } t = new Timer();
t.Tick+=t_tick;
t.Start ();
} protected override void OnLoad(EventArgs e)
{ base.OnLoad(e);
//Anchor=AnchorStyles.Left|AnchorStyles.Right;
// this.Size = new System.Drawing.Size(274, 65);
this.Size = new System.Drawing.Size(Parent.Width-20, 65);
this.ResumeLayout(false); } Timer t;
DownLoadInfo info; void t_tick(object sender, EventArgs e){ if(info.ProgressPercentage>=100 || info.isCompleted )
{
//lb1.Visible=false;
t.Stop();
btn1.Visible=true ;
lb1.Visible=false;
} lb1.Text=info.ProgressPercentage+"%";
lb1.Width=(int )( Width* ((double )info.ProgressPercentage * 0.01d)); }
void Btn1Click(object sender, EventArgs e)
{
MessageBox.Show(info.title );
} }

}

---------partial class for ui InitializeComponent------------------------

/*

  • Created by SharpDevelop.

  • User: gwang

  • Date: 2016/8/25

  • Time: 14:01

  • To change this template use Tools | Options | Coding | Edit Standard Headers.

    */

    namespace testHttp

    {

    partial class DownloadBar

    {

    ///



    /// Designer variable used to keep track of non-visual components.

    ///

    private System.ComponentModel.IContainer components = null;

    private System.Windows.Forms.Label lb1;

    private System.Windows.Forms.Button btn1;

     /// <summary>
    /// Disposes resources used by the control.
    /// </summary>
    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
    protected override void Dispose(bool disposing)
    {
    if (disposing) {
    if (components != null) {
    components.Dispose();
    }
    }
    base.Dispose(disposing);
    } /// <summary>
    /// This method is required for Windows Forms designer support.
    /// Do not change the method contents inside the source code editor. The Forms designer might
    /// not be able to load this method if it was changed manually.
    /// </summary>
    private void InitializeComponent()
    {
    this.lb1 = new System.Windows.Forms.Label();
    this.btn1 = new System.Windows.Forms.Button();
    this.SuspendLayout();
    //
    // lb1
    //
    this.lb1.BackColor = System.Drawing.Color.DodgerBlue;
    this.lb1.Dock = System.Windows.Forms.DockStyle.Left;
    this.lb1.Location = new System.Drawing.Point(0, 0);
    this.lb1.Name = "lb1";
    this.lb1.Size = new System.Drawing.Size(55, 65);
    this.lb1.TabIndex = 0;
    this.lb1.Text = "10%";
    this.lb1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
    //
    // btn1
    //
    this.btn1.Dock = System.Windows.Forms.DockStyle.Fill;
    this.btn1.Location = new System.Drawing.Point(0, 0);
    this.btn1.Name = "btn1";
    this.btn1.Size = new System.Drawing.Size(274, 65);
    this.btn1.TabIndex = 1;
    this.btn1.UseVisualStyleBackColor = true;
    this.btn1.Click += new System.EventHandler(this.Btn1Click);
    //
    // DownloadBar
    //
    this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    this.BackColor = System.Drawing.Color.LightSteelBlue;
    this.Controls.Add(this.lb1);
    this.Controls.Add(this.btn1);
    this.Name = "DownloadBar";
    this.Size = new System.Drawing.Size(274, 65);
    this.ResumeLayout(false); }

    }

    }


2 main ui form code behind "FrmDownload":

/*

  • Created by SharpDevelop.
  • User: gwang
  • Date: 2016/8/25
  • Time: 14:34
  • To change this template use Tools | Options | Coding | Edit Standard Headers.

    */

    using System;

    using System.Drawing;

    using System.Windows.Forms;

namespace testHttp

{

///



/// Description of FrmDownload.

///

public partial class FrmDownload : Form

{

public FrmDownload()

{

//

// The InitializeComponent() call is required for Windows Forms designer support.

//

InitializeComponent();

		//
// TODO: Add constructor code after the InitializeComponent() call.
//
} int uid=1; void Button1Click(object sender, EventArgs e)
{
DownLoadInfo info = new DownLoadInfo();
info.url="http://sw.bos.baidu.com/sw-search-sp/av_aladdin/a997f8c5c22/rj_hb1174.exe";
info.title="test it "+ uid ;
info.uid=""+uid ;
HttpUtils.downloadFile(info);
uid++; this.flowLayoutPanel1.Controls.Add(new DownloadBar(info));
Text="there "+ this.flowLayoutPanel1.Controls.Count +" downloading.........";
} }

}

oh... first need define util class "HttpUtils"

/*

  • Created by SharpDevelop.

  • User: gwang

  • Date: 2016/8/24

  • Time: 17:23

  • To change this template use Tools | Options | Coding | Edit Standard Headers.

    */

    using System;

    using System.Net;

    using System.ComponentModel;

    using System.Collections;

    using System.Collections.Generic;

    using System.Linq;

    namespace testHttp

    {

    ///



    /// Description of HttpUtils.

    ///

    public class HttpUtils

    {

    public HttpUtils()

    {

     }
    
     public static List<DownLoadInfo> listDownloadInfo= new List<DownLoadInfo>();
    
     public static void downloadFile(DownLoadInfo info){
    
     	if(listDownloadInfo.Count (n=> n.uid==info.uid )>0)
    { return;
    } listDownloadInfo.Add(info);
    WebClient wc=new WebClient();
    wc.DownloadProgressChanged+= wc_DownloadProgressChanged;
    wc.DownloadDataCompleted+=wc_DownloadDataCompleted; //wc.DownloadStringAsync(new Uri("https://jirafnd.dev.activenetwork.com/browse/HYTEK-274",UriKind.Absolute ),info);
    wc.DownloadDataAsync(new Uri(info.url ,UriKind.Absolute ),info); } private static void wc_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e){ (e.UserState as DownLoadInfo ).ProgressPercentage= e.ProgressPercentage; } private static void wc_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e){ (e.UserState as DownLoadInfo ).isCompleted =( e.Error==null) ; }

    }

    // this for basic info class

    public class DownLoadInfo{

     public string title{get;set;}
    public string url{get;set;}
    public string uid{get;set;}
    public int ProgressPercentage{ get;set;}
    public bool isCompleted{get;set;}

    }

}

c# multi-ply download ui的更多相关文章

  1. jQuery ui autocomplete 与easyUI冲突解决办法(重命名ui的autocomplete 和menu部分)

    http://jqueryui.com/download/   UI定制只选autocomplete 会自动把依赖的menu模块也加入进来--然而easyUI也有自己的menu,于是就-- 折腾了好久 ...

  2. 25套用于 Web UI 设计的免费 PSD 网页元素模板

    Web 元素是任何网站相关项目都需要的,质量和良好设计的元素对于设计师来说就像宝贝一样.如果您正在为您的网站,博客,Web 应用程序或移动应用程序寻找完美设计的网页元素,那么下面这个列表会是你需要的. ...

  3. 免费素材:25套免费的 Web UI 设计的界面元素(转)

    Web 元素是任何网站相关项目都需要的,质量和良好设计的元素对于设计师来说就像宝贝一样.如果您正在为您的网站,博客,Web 应用程序或移动应用程序寻找完美设计的网页元素,那么下面这个列表会是你需要的. ...

  4. "多行文本"组件:<multi> —— 快应用组件库H-UI

     <import name="multi" src="../Common/ui/h-ui/text/c_text_multi"></impo ...

  5. English word

    第一部分  通过词缀认识单词 (常用前缀一) 1.a- ①加在单词(形容词)或词根前面,表示"不,无,非" acentric [ə'sentrik] a  无中心的(a+centr ...

  6. Android DownloadProvider学习 (二)

    DownloadManager.Request用来请求一个下载,DownloadManager.Query用来查询下载信息,这两个类的具体功能会在后面穿插介绍.DownloadManager的源码可见 ...

  7. JavaScript使用DeviceOne开发实战(四)仿优酷视频应用

    开发之前需要考虑系统的差异性,比如ios手机没有回退键,所以在开发时一定要考虑二级界面需要有回退键,否则ios的手机就会陷入到这个页面出不去了.安卓系统有回退键,针对这个情况需要要求用户在3秒钟之内连 ...

  8. Android 下载模块分析(DownloadManager和DownloadProvider)

    Android下载模块主要有2个部分组成:DownloadManager和DownloadProvider:其中DownloadManager提供接口供调用,具体的实现是 DownloadProvid ...

  9. Android 演示 DownloadManager——Android 下载 apk 包并安装

    本文内容 环境 项目结构 演示下载 参考资料 本文是 github 上 Trinea-Android-common 和 Trinea-Android-Demo 项目的一部分,将下载部分分离出来,看看如 ...

随机推荐

  1. Sqlserver2014 迁移数据库

    由于当初安装sqlserver 的时候选择默认安装的路径,导致现在c盘爆满,安装不了其它软件.因此想到了迁移数据库,网上搜索了一些简介,但是缺少一些步骤,导致数据库附加的时候失败.现总结如下: 1.将 ...

  2. Sublime Text 3 调用cmd运行c、java、python、batch file

    一.调用cmd运行c(首先复制MinGW到C盘根目录,并添加环境变量) Tools --> Build System --> New Build System 删除所有内容 复制如下代码进 ...

  3. Http协议浅析

    目录 Http协议浅析 http协议简介 http协议特性 http请求协议与响应协议 请求协议 响应协议 响应状态码 请求URI定位资源 HTTP方法 GET:获取资源 POST:传输实体主体 PU ...

  4. windows下PyCharm安装及使用

    一.首先安装pycharm,可以参考这篇文章:http://www.jianshu.com/p/042324342bf4 1.win10_X64,其他Win版本也可以. 2.PyCharm版本:Pro ...

  5. PHP SFTP应用(二)

    SFTP应用(二) SFTP Server SSH2 sftp操作 FTP进行文件传输需要通过端口进行.一般所需端口为: 控制链路—TCP端口21.控制器端.用于发送指令给服务器以及等待服务器响应. ...

  6. IP地址编址

    比特:一比特就是一个数字,1或者0. 字节:以字节是7比特或者8比特,取决于是否使用奇偶校验 八位组:8比特构成 网络地址:用来将数据包发送到远端网路 比如10.0.0.0 广播地址:将信息发送给网络 ...

  7. October 1st 2017 Week 40th Sunday

    It's only after we've lost everything that we're free to do anything. 只有我们失去了所有之后我们才能随心而为. After los ...

  8. notepad快捷键大全

    Notepad++ 快捷键 大全Ctrl+C 复制Ctrl+X 剪切Ctrl+V 粘贴Ctrl+Z 撤消Ctrl+Y 恢复Ctrl+A 全选Ctrl+F 键查找对话框启动Ctrl+H 查找/替换对话框 ...

  9. fun()可拆分赋值 fun()可以拆, 变成 fun 和 括号, fun 可以赋值

    2. 函数名可以赋值给其他变量   --->   就是 func()可以拆 def fun (): print("哈哈") a = fun # 拆分 fun()的    fu ...

  10. PHP设计模式系列 - 单例

    单例模式 通过提供自身共享实例的访问,单例设计模式用于限制特定对象只能被创建一次. 使用场景 例如数据库实例,一般都会走单例模式. 单例模式可以减少类的实例化 代码:来源InitPHP框架,先检测类有 ...