My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// E-Book Copier
// Copyright (C) 2009 Chuan-Gen Fan
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// Project: http://code.google.com/p/ebookcopier/
// Contact Author:
// website: http://chuangen.name/
// e-mail/msn: chuangen@live.cn

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace EbookCopier
{
/// <summary>
/// PDF 文档生成进度对话框。
/// </summary>
public partial class PdfProcessForm : Form
{
BackgroundWorker bw = null;
/// <summary>
/// 初始化类 <see cref="PdfProcessForm"/> 的新实例。
/// </summary>
/// <param name="bw">BackgroundWorker 实例。</param>
public PdfProcessForm(BackgroundWorker bw)
{
InitializeComponent();

this.bw = bw;
bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bw_RunWorkerCompleted);
bw.ProgressChanged += new ProgressChangedEventHandler(bw_ProgressChanged);

btnCancel.Click += new EventHandler(btnCancel_Click);
}

void btnCancel_Click(object sender, EventArgs e)
{
bw.CancelAsync();
}
/// <summary>
/// 获取或设置处理进度(百分数)。
/// </summary>
/// <value>进度(百分数)</value>
public int ProgressPercentage
{
get { return progressBar.Value; }
set
{
if(progressBar.Value == value)
return;

if(value < 0)
progressBar.Value = 0;
else if(value > 100)
progressBar.Value = 100;
else
progressBar.Value = value;

labelTitle.Text = string.Format("正在生成 PDF 文档,请稍等 ...({0} %)", progressBar.Value);
}
}

void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
this.ProgressPercentage = 100;
if (e.Cancelled)
labelTitle.Text = "操作已经取消。";
else if (e.Error != null)
labelTitle.Text = "生成过程中发生错误。";
else
labelTitle.Text = "成功创建 PDF 文档。";
}

void bw_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
this.ProgressPercentage = e.ProgressPercentage;
}
}
}

Change log

r2 by chuangen on Mar 11, 2009   Diff
ebookcopier v1.0.3357.8997

为准备将项目开源,我做了些修改,主要包括:
1. 代码书写规范;
2. 补充必要的注释;
3. 审查版权问题,对引用的别人代码做了版权说明。
Go to: 
Project members, sign in to write a code review

Older revisions

All revisions of this file

File info

Size: 3276 bytes, 96 lines
Powered by Google Project Hosting