在现实的软件中,经常可以看到一些向导(Wizard)的存在,如何给自己的应用程序实现一个向导呢?
下面给出一个使用面向对象的思想设计出来的应用程序向导框架,虽然很简单,但希望能给人帮助。
其中有三个比较关键的类,一个是向导窗体要收集的信息封装成的类Information,一个是所有向导窗体都要继承的窗体基类frmBase,还有一个就是最关键的类,向导控制类WizardController。
有了基类frmBase,设计一个子类窗体非常简单,只需从frmBase类中派生一个新窗体,设计完用户界面之后重写其UpdateInfo()方法即可。
所有代码(VS2003版)如下,通俗易懂,不再做说明:
Information类:
1
using System;
2
3
namespace Wizard
4

{
5
/**//// <summary>
6
/// Information 的摘要说明。
7
/// </summary>
8
public class Information
9
{
10
public Information()
11
{
12
//
13
// TODO: 在此处添加构造函数逻辑
14
//
15
}
16
17
//姓名
18
public string Name = "";
19
//性别
20
public bool IsMale = true;
21
//学历
22
public string EduBackground = "";
23
//编程语言
24
public string ProgrameLanguage = "";
25
}
26
}
frmBase类:
1
using System;
2
using System.Drawing;
3
using System.Collections;
4
using System.ComponentModel;
5
using System.Windows.Forms;
6
7
namespace Wizard
8

{
9
/**//// <summary>
10
/// frmBase 的摘要说明。
11
/// </summary>
12
public class frmBase : System.Windows.Forms.Form
13
{
14
private System.Windows.Forms.Panel panel1;
15
private System.Windows.Forms.Button btnGoPrev;
16
private System.Windows.Forms.Button btnGoNext;
17
private System.Windows.Forms.Button btnOver;
18
private System.Windows.Forms.Button btnCancel;
19
private System.Windows.Forms.Button btnHelp;
20
/**//// <summary>
21
/// 必需的设计器变量。
22
/// </summary>
23
private System.ComponentModel.Container components = null;
24
25
public frmBase()
26
{
27
//
28
// Windows 窗体设计器支持所必需的
29
//
30
InitializeComponent();
31
32
//
33
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
34
//
35
}
36
37
/**//// <summary>
38
/// 清理所有正在使用的资源。
39
/// </summary>
40
protected override void Dispose( bool disposing )
41
{
42
if( disposing )
43
{
44
if(components != null)
45
{
46
components.Dispose();
47
}
48
}
49
base.Dispose( disposing );
50
}
51
52
Windows 窗体设计器生成的代码#region Windows 窗体设计器生成的代码
53
/**//// <summary>
54
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
55
/// 此方法的内容。
56
/// </summary>
57
private void InitializeComponent()
58
{
59
this.panel1 = new System.Windows.Forms.Panel();
60
this.btnGoPrev = new System.Windows.Forms.Button();
61
this.btnGoNext = new System.Windows.Forms.Button();
62
this.btnOver = new System.Windows.Forms.Button();
63
this.btnCancel = new System.Windows.Forms.Button();
64
this.btnHelp = new System.Windows.Forms.Button();
65
this.panel1.SuspendLayout();
66
this.SuspendLayout();
67
//
68
// panel1
69
//
70
this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
71
| System.Windows.Forms.AnchorStyles.Right)));
72
this.panel1.Controls.Add(this.btnHelp);
73
this.panel1.Controls.Add(this.btnCancel);
74
this.panel1.Controls.Add(this.btnOver);
75
this.panel1.Controls.Add(this.btnGoNext);
76
this.panel1.Controls.Add(this.btnGoPrev);
77
this.panel1.Location = new System.Drawing.Point(0, 202);
78
this.panel1.Name = "panel1";
79
this.panel1.Size = new System.Drawing.Size(450, 40);
80
this.panel1.TabIndex = 0;
81
//
82
// btnGoPrev
83
//
84
this.btnGoPrev.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
85
this.btnGoPrev.Location = new System.Drawing.Point(25, 8);
86
this.btnGoPrev.Name = "btnGoPrev";
87
this.btnGoPrev.Size = new System.Drawing.Size(56, 23);
88
this.btnGoPrev.TabIndex = 1;
89
this.btnGoPrev.Text = "上一步";
90
this.btnGoPrev.Click += new System.EventHandler(this.btnGoPrev_Click);
91
//
92
// btnGoNext
93
//
94
this.btnGoNext.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
95
this.btnGoNext.Location = new System.Drawing.Point(105, 8);
96
this.btnGoNext.Name = "btnGoNext";
97
this.btnGoNext.Size = new System.Drawing.Size(56, 23);
98
this.btnGoNext.TabIndex = 2;
99
this.btnGoNext.Text = "下一步";
100
this.btnGoNext.Click += new System.EventHandler(this.btnGoNext_Click);
101
//
102
// btnOver
103
//
104
this.btnOver.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
105
this.btnOver.Location = new System.Drawing.Point(193, 8);
106
this.btnOver.Name = "btnOver";
107
this.btnOver.Size = new System.Drawing.Size(56, 23);
108
this.btnOver.TabIndex = 3;
109
this.btnOver.Text = "完成";
110
this.btnOver.Click += new System.EventHandler(this.btnOver_Click);
111
//
112
// btnCancel
113
//
114
this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
115
this.btnCancel.Location = new System.Drawing.Point(281, 8);
116
this.btnCancel.Name = "btnCancel";
117
this.btnCancel.Size = new System.Drawing.Size(56, 23);
118
this.btnCancel.TabIndex = 4;
119
this.btnCancel.Text = "取消";
120
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
121
//
122
// btnHelp
123
//
124
this.btnHelp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
125
this.btnHelp.Location = new System.Drawing.Point(369, 8);
126
this.btnHelp.Name = "btnHelp";
127
this.btnHelp.Size = new System.Drawing.Size(56, 23);
128
this.btnHelp.TabIndex = 5;
129
this.btnHelp.Text = "帮助";
130
//
131
// frmBase
132
//
133
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
134
this.ClientSize = new System.Drawing.Size(450, 239);
135
this.Controls.Add(this.panel1);
136
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
137
this.Name = "frmBase";
138
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
139
this.panel1.ResumeLayout(false);
140
this.ResumeLayout(false);
141
142
}
143
#endregion
144
145
public WizardController controller = null;
146
147
public void DisableButton()
148
{
149
if(this.controller == null)
150
return;
151
if(this.controller.IsFirstForm)
152
{
153
this.btnGoPrev.Enabled = false;
154
}
155
else
156
{
157
this.btnGoPrev.Enabled = true;
158
}
159
if(this.controller.IsLastForm)
160
{
161
this.btnGoNext.Enabled = false;
162
}
163
else
164
{
165
this.btnGoNext.Enabled = true;
166
}
167
}
168
protected virtual void UpdateInfo()
169
{
170
171
}
172
protected virtual void GoNext()
173
{
174
UpdateInfo();
175
controller.GoNext();
176
}
177
protected virtual void GoPrev()
178
{
179
UpdateInfo();
180
controller.GoPrev();
181
}
182
protected virtual void Finish()
183
{
184
UpdateInfo();
185
controller.FinishWizard();
186
this.Visible = false;
187
}
188
protected virtual void Cancel()
189
{
190
this.controller.info = null;
191
this.Close();
192
}
193
194
private void btnGoPrev_Click(object sender, System.EventArgs e)
195
{
196
GoPrev();
197
}
198
199
private void btnGoNext_Click(object sender, System.EventArgs e)
200
{
201
GoNext();
202
}
203
204
private void btnOver_Click(object sender, System.EventArgs e)
205
{
206
Finish();
207
}
208
209
private void btnCancel_Click(object sender, System.EventArgs e)
210
{
211
Cancel();
212
}
213
}
214
}
向导控制器WizardController类:
1
using System;
2
using System.Collections;
3
4
namespace Wizard
5

{
6
/**//// <summary>
7
/// WizardController 的摘要说明。
8
/// </summary>
9
public class WizardController
10
{
11
public WizardController()
12
{
13
//
14
// TODO: 在此处添加构造函数逻辑
15
//
16
WizardForms.Add(new frmStep1());
17
WizardForms.Add(new frmStep2());
18
foreach(frmBase frm in WizardForms)
19
{
20
frm.controller = this;
21
frm.DisableButton();
22
}
23
}
24
private ArrayList WizardForms = new ArrayList();
25
public Information info = new Information();
26
private int curIndex = 0;
27
28
public bool IsFirstForm
29
{
30
get
{ return curIndex == 0;}
31
}
32
public bool IsLastForm
33
{
34
get
{return curIndex == this.WizardForms.Count - 1;}
35
}
36
public void GoNext()
37
{
38
if(curIndex+1 < WizardForms.Count)
39
{
40
((frmBase)WizardForms[curIndex]).Visible = false;
41
curIndex++;
42
}
43
else
44
{
45
return;
46
}
47
((frmBase)WizardForms[curIndex]).Show();
48
((frmBase)WizardForms[curIndex]).DisableButton();
49
}
50
public void GoPrev()
51
{
52
if(curIndex-1 >= 0)
53
{
54
((frmBase)WizardForms[curIndex]).Visible = false;
55
curIndex--;
56
}
57
else
58
{
59
return;
60
}
61
((frmBase)WizardForms[curIndex]).Show();
62
((frmBase)WizardForms[curIndex]).DisableButton();
63
}
64
public void BeginWizard()
65
{
66
((frmBase)WizardForms[0]).Show();
67
((frmBase)WizardForms[curIndex]).DisableButton();
68
}
69
public void FinishWizard()
70
{
71
curIndex = 0;
72
Dispose();
73
}
74
75
private void Dispose()
76
{
77
foreach(frmBase frm in WizardForms)
78
{
79
frm.Close();
80
}
81
}
82
}
83
}
第一个子窗体:
1
using System;
2
using System.Collections;
3
using System.ComponentModel;
4
using System.Drawing;
5
using System.Windows.Forms;
6
7
namespace Wizard
8

{
9
public class frmStep1 : Wizard.frmBase
10
{
11
private System.Windows.Forms.TextBox txtName;
12
private System.Windows.Forms.RadioButton rdoMale;
13
private System.Windows.Forms.RadioButton radioButton1;
14
private System.Windows.Forms.Label label1;
15
private System.Windows.Forms.Label label2;
16
private System.ComponentModel.IContainer components = null;
17
18
public frmStep1()
19
{
20
// 该调用是 Windows 窗体设计器所必需的。
21
InitializeComponent();
22
23
// TODO: 在 InitializeComponent 调用后添加任何初始化
24
}
25
26
/**//// <summary>
27
/// 清理所有正在使用的资源。
28
/// </summary>
29
protected override void Dispose( bool disposing )
30
{
31
if( disposing )
32
{
33
if (components != null)
34
{
35
components.Dispose();
36
}
37
}
38
base.Dispose( disposing );
39
}
40
41
设计器生成的代码#region 设计器生成的代码
42
/**//// <summary>
43
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
44
/// 此方法的内容。
45
/// </summary>
46
private void InitializeComponent()
47
{
48
this.txtName = new System.Windows.Forms.TextBox();
49
this.rdoMale = new System.Windows.Forms.RadioButton();
50
this.radioButton1 = new System.Windows.Forms.RadioButton();
51
this.label1 = new System.Windows.Forms.Label();
52
this.label2 = new System.Windows.Forms.Label();
53
this.SuspendLayout();
54
//
55
// txtName
56
//
57
this.txtName.Location = new System.Drawing.Point(173, 61);
58
this.txtName.Name = "txtName";
59
this.txtName.Size = new System.Drawing.Size(152, 21);
60
this.txtName.TabIndex = 1;
61
this.txtName.Text = "";
62
//
63
// rdoMale
64
//
65
this.rdoMale.Checked = true;
66
this.rdoMale.Location = new System.Drawing.Point(205, 115);
67
this.rdoMale.Name = "rdoMale";
68
this.rdoMale.Size = new System.Drawing.Size(40, 24);
69
this.rdoMale.TabIndex = 2;
70
this.rdoMale.TabStop = true;
71
this.rdoMale.Text = "男";
72
//
73
// radioButton1
74
//
75
this.radioButton1.Location = new System.Drawing.Point(253, 115);
76
this.radioButton1.Name = "radioButton1";
77
this.radioButton1.Size = new System.Drawing.Size(32, 24);
78
this.radioButton1.TabIndex = 3;
79
this.radioButton1.Text = "女";
80
//
81
// label1
82
//
83
this.label1.Location = new System.Drawing.Point(125, 64);
84
this.label1.Name = "label1";
85
this.label1.Size = new System.Drawing.Size(48, 23);
86
this.label1.TabIndex = 4;
87
this.label1.Text = "姓名";
88
//
89
// label2
90
//
91
this.label2.Location = new System.Drawing.Point(0, 0);
92
this.label2.Name = "label2";
93
this.label2.TabIndex = 5;
94
//
95
// frmStep1
96
//
97
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
98
this.ClientSize = new System.Drawing.Size(450, 239);
99
this.Controls.Add(this.label1);
100
this.Controls.Add(this.radioButton1);
101
this.Controls.Add(this.rdoMale);
102
this.Controls.Add(this.txtName);
103
this.Controls.Add(this.label2);
104
this.Name = "frmStep1";
105
this.Controls.SetChildIndex(this.label2, 0);
106
this.Controls.SetChildIndex(this.txtName, 0);
107
this.Controls.SetChildIndex(this.rdoMale, 0);
108
this.Controls.SetChildIndex(this.radioButton1, 0);
109
this.Controls.SetChildIndex(this.label1, 0);
110
this.ResumeLayout(false);
111
112
}
113
#endregion
114
115
protected override void UpdateInfo()
116
{
117
this.controller.info.Name = txtName.Text.Trim();
118
this.controller.info.IsMale = rdoMale.Checked;
119
}
120
121
}
122
}
第二个子窗体:
1
using System;
2
using System.Collections;
3
using System.ComponentModel;
4
using System.Drawing;
5
using System.Windows.Forms;
6
7
namespace Wizard
8

{
9
public class frmStep2 : Wizard.frmBase
10
{
11
private System.Windows.Forms.Label label1;
12
private System.Windows.Forms.Label label2;
13
private System.Windows.Forms.ComboBox cbbEduBackground;
14
private System.Windows.Forms.CheckBox checkBox1;
15
private System.Windows.Forms.CheckBox checkBox2;
16
private System.Windows.Forms.CheckBox checkBox3;
17
private System.Windows.Forms.CheckBox checkBox4;
18
private System.ComponentModel.IContainer components = null;
19
20
public frmStep2()
21
{
22
// 该调用是 Windows 窗体设计器所必需的。
23
InitializeComponent();
24
25
// TODO: 在 InitializeComponent 调用后添加任何初始化
26
}
27
28
/**//// <summary>
29
/// 清理所有正在使用的资源。
30
/// </summary>
31
protected override void Dispose( bool disposing )
32
{
33
if( disposing )
34
{
35
if (components != null)
36
{
37
components.Dispose();
38
}
39
}
40
base.Dispose( disposing );
41
}
42
43
设计器生成的代码#region 设计器生成的代码
44
/**//// <summary>
45
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
46
/// 此方法的内容。
47
/// </summary>
48
private void InitializeComponent()
49
{
50
this.label1 = new System.Windows.Forms.Label();
51
this.label2 = new System.Windows.Forms.Label();
52
this.cbbEduBackground = new System.Windows.Forms.ComboBox();
53
this.checkBox1 = new System.Windows.Forms.CheckBox();
54
this.checkBox2 = new System.Windows.Forms.CheckBox();
55
this.checkBox3 = new System.Windows.Forms.CheckBox();
56
this.checkBox4 = new System.Windows.Forms.CheckBox();
57
this.SuspendLayout();
58
//
59
// label1
60
//
61
this.label1.Location = new System.Drawing.Point(98, 72);
62
this.label1.Name = "label1";
63
this.label1.Size = new System.Drawing.Size(40, 23);
64
this.label1.TabIndex = 3;
65
this.label1.Text = "学历";
66
//
67
// label2
68
//
69
this.label2.Location = new System.Drawing.Point(98, 128);
70
this.label2.Name = "label2";
71
this.label2.Size = new System.Drawing.Size(64, 23);
72
this.label2.TabIndex = 4;
73
this.label2.Text = "编程语言";
74
//
75
// cbbEduBackground
76
//
77
this.cbbEduBackground.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
78
this.cbbEduBackground.Items.AddRange(new object[]
{
79
"本科",
80
"硕士",
81
"博士"});
82
this.cbbEduBackground.Location = new System.Drawing.Point(170, 68);
83
this.cbbEduBackground.Name = "cbbEduBackground";
84
this.cbbEduBackground.Size = new System.Drawing.Size(152, 20);
85
this.cbbEduBackground.TabIndex = 5;
86
//
87
// checkBox1
88
//
89
this.checkBox1.Location = new System.Drawing.Point(166, 123);
90
this.checkBox1.Name = "checkBox1";
91
this.checkBox1.Size = new System.Drawing.Size(48, 24);
92
this.checkBox1.TabIndex = 6;
93
this.checkBox1.Text = "C++";
94
//
95
// checkBox2
96
//
97
this.checkBox2.Location = new System.Drawing.Point(211, 123);
98
this.checkBox2.Name = "checkBox2";
99
this.checkBox2.Size = new System.Drawing.Size(48, 24);
100
this.checkBox2.TabIndex = 7;
101
this.checkBox2.Text = "Java";
102
//
103
// checkBox3
104
//
105
this.checkBox3.Location = new System.Drawing.Point(267, 123);
106
this.checkBox3.Name = "checkBox3";
107
this.checkBox3.Size = new System.Drawing.Size(40, 24);
108
this.checkBox3.TabIndex = 8;
109
this.checkBox3.Text = "VB";
110
//
111
// checkBox4
112
//
113
this.checkBox4.Location = new System.Drawing.Point(312, 123);
114
this.checkBox4.Name = "checkBox4";
115
this.checkBox4.Size = new System.Drawing.Size(40, 24);
116
this.checkBox4.TabIndex = 9;
117
this.checkBox4.Text = "C#";
118
//
119
// frmStep2
120
//
121
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
122
this.ClientSize = new System.Drawing.Size(450, 239);
123
this.Controls.Add(this.checkBox4);
124
this.Controls.Add(this.checkBox3);
125
this.Controls.Add(this.checkBox2);
126
this.Controls.Add(this.checkBox1);
127
this.Controls.Add(this.cbbEduBackground);
128
this.Controls.Add(this.label2);
129
this.Controls.Add(this.label1);
130
this.Name = "frmStep2";
131
this.Controls.SetChildIndex(this.label1, 0);
132
this.Controls.SetChildIndex(this.label2, 0);
133
this.Controls.SetChildIndex(this.cbbEduBackground, 0);
134
this.Controls.SetChildIndex(this.checkBox1, 0);
135
this.Controls.SetChildIndex(this.checkBox2, 0);
136
this.Controls.SetChildIndex(this.checkBox3, 0);
137
this.Controls.SetChildIndex(this.checkBox4, 0);
138
this.ResumeLayout(false);
139
140
}
141
#endregion
142
143
protected override void UpdateInfo()
144
{
145
this.controller.info.EduBackground = cbbEduBackground.GetItemText(cbbEduBackground.SelectedItem);
146
string lang = "";
147
foreach(Control ctl in this.Controls)
148
{
149
if(ctl is CheckBox && ((CheckBox)ctl).Checked)
150
{
151
lang += ctl.Text + ";";
152
}
153
}
154
this.controller.info.ProgrameLanguage = lang;
155
}
156
157
}
158
}
测试Demo:
1
using System;
2
using System.Drawing;
3
using System.Collections;
4
using System.ComponentModel;
5
using System.Windows.Forms;
6
7
namespace Wizard
8

{
9
/**//// <summary>
10
/// frmTest 的摘要说明。
11
/// </summary>
12
public class frmTest : System.Windows.Forms.Form
13
{
14
/**//// <summary>
15
/// 必需的设计器变量。
16
/// </summary>
17
private System.ComponentModel.Container components = null;
18
private System.Windows.Forms.Button button1;
19
private System.Windows.Forms.Button button2;
20
private System.Windows.Forms.Label label1;
21
private System.Windows.Forms.Label label2;
22
private System.Windows.Forms.Label label3;
23
private System.Windows.Forms.Label label4;
24
private WizardController wizard;
25
26
public frmTest()
27
{
28
//
29
// Windows 窗体设计器支持所必需的
30
//
31
InitializeComponent();
32
33
//
34
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
35
//
36
}
37
38
/**//// <summary>
39
/// 清理所有正在使用的资源。
40
/// </summary>
41
protected override void Dispose( bool disposing )
42
{
43
if( disposing )
44
{
45
if(components != null)
46
{
47
components.Dispose();
48
}
49
}
50
base.Dispose( disposing );
51
}
52
53
Windows 窗体设计器生成的代码#region Windows 窗体设计器生成的代码
54
/**//// <summary>
55
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
56
/// 此方法的内容。
57
/// </summary>
58
private void InitializeComponent()
59
{
60
this.button1 = new System.Windows.Forms.Button();
61
this.button2 = new System.Windows.Forms.Button();
62
this.label1 = new System.Windows.Forms.Label();
63
this.label2 = new System.Windows.Forms.Label();
64
this.label3 = new System.Windows.Forms.Label();
65
this.label4 = new System.Windows.Forms.Label();
66
this.SuspendLayout();
67
//
68
// button1
69
//
70
this.button1.Location = new System.Drawing.Point(48, 216);
71
this.button1.Name = "button1";
72
this.button1.Size = new System.Drawing.Size(104, 23);
73
this.button1.TabIndex = 0;
74
this.button1.Text = "显示向导";
75
this.button1.Click += new System.EventHandler(this.button1_Click);
76
//
77
// button2
78
//
79
this.button2.Location = new System.Drawing.Point(192, 216);
80
this.button2.Name = "button2";
81
this.button2.Size = new System.Drawing.Size(104, 23);
82
this.button2.TabIndex = 1;
83
this.button2.Text = "显示信息";
84
this.button2.Click += new System.EventHandler(this.button2_Click);
85
//
86
// label1
87
//
88
this.label1.Location = new System.Drawing.Point(72, 32);
89
this.label1.Name = "label1";
90
this.label1.Size = new System.Drawing.Size(232, 23);
91
this.label1.TabIndex = 2;
92
//
93
// label2
94
//
95
this.label2.Location = new System.Drawing.Point(72, 80);
96
this.label2.Name = "label2";
97
this.label2.Size = new System.Drawing.Size(224, 23);
98
this.label2.TabIndex = 3;
99
//
100
// label3
101
//
102
this.label3.Location = new System.Drawing.Point(72, 120);
103
this.label3.Name = "label3";
104
this.label3.Size = new System.Drawing.Size(232, 23);
105
this.label3.TabIndex = 4;
106
//
107
// label4
108
//
109
this.label4.Location = new System.Drawing.Point(72, 160);
110
this.label4.Name = "label4";
111
this.label4.Size = new System.Drawing.Size(232, 23);
112
this.label4.TabIndex = 5;
113
//
114
// frmTest
115
//
116
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
117
this.ClientSize = new System.Drawing.Size(344, 261);
118
this.Controls.Add(this.label4);
119
this.Controls.Add(this.label3);
120
this.Controls.Add(this.label2);
121
this.Controls.Add(this.label1);
122
this.Controls.Add(this.button2);
123
this.Controls.Add(this.button1);
124
this.Name = "frmTest";
125
this.Text = "向导测试";
126
this.ResumeLayout(false);
127
128
}
129
#endregion
130
/**//// <summary>
131
/// 应用程序的主入口点。
132
/// </summary>
133
[STAThread]
134
static void Main()
135
{
136
Application.Run(new frmTest());
137
}
138
139
private void button1_Click(object sender, System.EventArgs e)
140
{
141
this.wizard = new WizardController();
142
this.wizard.BeginWizard();
143
}
144
145
private void button2_Click(object sender, System.EventArgs e)
146
{
147
if(this.wizard != null && this.wizard.info != null)
148
{
149
this.label1.Text = this.wizard.info.Name;
150
if(this.wizard.info.IsMale)
151
this.label2.Text = "男";
152
else
153
this.label2.Text = "女";
154
this.label3.Text = this.wizard.info.EduBackground;
155
this.label4.Text = this.wizard.info.ProgrameLanguage;
156
}
157
else
158
{
159
MessageBox.Show("NULL");
160
}
161
}
162
}
163
}