📄 samplewizard.cs
字号:
this.textBox1.Text = "You must select \'I Agree\' before the \'Next\' button will enable itself. This custo" +
"m action is not part of the WizardControl, see the sample code which is trivial." +
"";
//
// wizardWarn
//
this.wizardWarn.CaptionTitle = "Warning, about to install";
this.wizardWarn.Controls.AddRange(new System.Windows.Forms.Control[] {
this.label6,
this.label5});
this.wizardWarn.Dock = System.Windows.Forms.DockStyle.Fill;
this.wizardWarn.FullPage = false;
this.wizardWarn.Name = "wizardWarn";
this.wizardWarn.Selected = false;
this.wizardWarn.Size = new System.Drawing.Size(410, 269);
this.wizardWarn.SubTitle = "This warns user that installation is about to begin";
this.wizardWarn.TabIndex = 6;
this.wizardWarn.Title = "Warn";
//
// label6
//
this.label6.Location = new System.Drawing.Point(40, 56);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(360, 64);
this.label6.TabIndex = 1;
this.label6.Text = "Warn user that pressing \'Next\' will begin installation process.";
//
// label5
//
this.label5.Location = new System.Drawing.Point(40, 16);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(280, 24);
this.label5.TabIndex = 0;
this.label5.Text = "Last page before installation.";
//
// wizardInstall
//
this.wizardInstall.CaptionTitle = "Installing";
this.wizardInstall.Controls.AddRange(new System.Windows.Forms.Control[] {
this.label7,
this.progressBar1});
this.wizardInstall.Dock = System.Windows.Forms.DockStyle.Fill;
this.wizardInstall.FullPage = false;
this.wizardInstall.Name = "wizardInstall";
this.wizardInstall.Selected = false;
this.wizardInstall.Size = new System.Drawing.Size(410, 269);
this.wizardInstall.SubTitle = "Perform some fake installation process";
this.wizardInstall.TabIndex = 7;
this.wizardInstall.Title = "Install";
//
// label7
//
this.label7.Location = new System.Drawing.Point(40, 16);
this.label7.Name = "label7";
this.label7.TabIndex = 1;
this.label7.Text = "Fake Installation";
//
// progressBar1
//
this.progressBar1.Location = new System.Drawing.Point(40, 48);
this.progressBar1.Name = "progressBar1";
this.progressBar1.Size = new System.Drawing.Size(328, 24);
this.progressBar1.TabIndex = 0;
//
// wizardFinish
//
this.wizardFinish.CaptionTitle = "Intall Complete";
this.wizardFinish.Controls.AddRange(new System.Windows.Forms.Control[] {
this.label10});
this.wizardFinish.Dock = System.Windows.Forms.DockStyle.Fill;
this.wizardFinish.FullPage = false;
this.wizardFinish.Name = "wizardFinish";
this.wizardFinish.Selected = false;
this.wizardFinish.Size = new System.Drawing.Size(410, 269);
this.wizardFinish.SubTitle = "This page gives the success or failure of attempting the previous install process" +
"";
this.wizardFinish.TabIndex = 8;
this.wizardFinish.Title = "Finished";
//
// label10
//
this.label10.Location = new System.Drawing.Point(32, 16);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(304, 104);
this.label10.TabIndex = 0;
this.label10.Text = "Installation has completed with success.";
//
// wizardInfo2
//
this.wizardInfo2.CaptionTitle = "Gather Info 2";
this.wizardInfo2.Controls.AddRange(new System.Windows.Forms.Control[] {
this.label9,
this.textBox3,
this.label8,
this.textBox2});
this.wizardInfo2.Dock = System.Windows.Forms.DockStyle.Fill;
this.wizardInfo2.FullPage = false;
this.wizardInfo2.Name = "wizardInfo2";
this.wizardInfo2.Selected = false;
this.wizardInfo2.Size = new System.Drawing.Size(410, 269);
this.wizardInfo2.SubTitle = "This is the second of two pages for gathering input";
this.wizardInfo2.TabIndex = 9;
this.wizardInfo2.Title = "Info2";
//
// label9
//
this.label9.Location = new System.Drawing.Point(48, 80);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(136, 23);
this.label9.TabIndex = 3;
this.label9.Text = "Enter Company Name";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(48, 104);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(160, 21);
this.textBox3.TabIndex = 2;
this.textBox3.Text = "ACNE Corp.";
//
// label8
//
this.label8.Location = new System.Drawing.Point(48, 16);
this.label8.Name = "label8";
this.label8.TabIndex = 1;
this.label8.Text = "Enter Username";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(48, 40);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(160, 21);
this.textBox2.TabIndex = 0;
this.textBox2.Text = "Anon";
//
// SampleWizard
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(410, 343);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.wizardControl});
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Name = "SampleWizard";
this.TitleMode = Crownwood.Magic.Forms.WizardDialog.TitleModes.Steps;
this.wizardStartPage.ResumeLayout(false);
this.wizardInfo1.ResumeLayout(false);
this.groupBox1.ResumeLayout(false);
this.wizardLegal.ResumeLayout(false);
this.wizardWarn.ResumeLayout(false);
this.wizardInstall.ResumeLayout(false);
this.wizardFinish.ResumeLayout(false);
this.wizardInfo2.ResumeLayout(false);
this.ResumeLayout(false);
} #endregion
private void radioButton4_CheckedChanged(object sender, System.EventArgs e)
{
if (this.radioButton4.Checked)
{
this.wizardControl.EnableNextButton = WizardControl.Status.Default;
radioButton5.Checked = false;
}
else
{
this.wizardControl.EnableNextButton = WizardControl.Status.No;
radioButton5.Checked = true;
}
}
private void radioButton5_CheckedChanged(object sender, System.EventArgs e)
{
if (this.radioButton5.Checked)
{
this.wizardControl.EnableNextButton = WizardControl.Status.No;
radioButton4.Checked = false;
}
else
{
this.wizardControl.EnableNextButton = WizardControl.Status.Default;
radioButton4.Checked = true;
}
}
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new SampleWizard());
}
protected override void OnWizardPageEnter(Crownwood.Magic.Controls.WizardPage wp,
Crownwood.Magic.Controls.WizardControl wc)
{
// Asking for licence terms by entering page?
if (wp.Name == "wizardLegal")
{
if (this.radioButton4.Checked)
wc.EnableNextButton = WizardControl.Status.Default;
else
wc.EnableNextButton = WizardControl.Status.No;
}
// Started the installation process by entering page 5?
if (wp.Name == "wizardInstall")
{
// Kick off a timer to represent progress
installCount = 0;
installTimer = new Timer();
installTimer.Interval = 250;
installTimer.Tick += new EventHandler(OnProgressTick);
installTimer.Start();
}
}
protected override void OnWizardPageLeave(Crownwood.Magic.Controls.WizardPage wp,
Crownwood.Magic.Controls.WizardControl wc)
{
// Leaving page means we have to restore default status of next button
if (wp.Name == "wizardLegal")
{
// Default the next button to disable
wc.EnableNextButton = WizardControl.Status.Default;
}
}
protected override void OnCancelClick(object sender, System.EventArgs e)
{
// Suspend any installation process if happening
if (installTimer != null)
installTimer.Stop();
if (MessageBox.Show(this, "Sure you want to exit?", "Cancel Pressed", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
{
// Let base class close the form
base.OnCancelClick(sender, e);
}
else
{
// Resume any installation process if happening
if (installTimer != null)
installTimer.Start();
}
}
private void OnProgressTick(object sender, EventArgs e)
{
installCount++;
// Finished yet?
if (installCount >= 20)
{
// No longer need to simulate actions
installTimer.Stop();
// Move to last page
base.wizardControl.SelectedIndex = base.wizardControl.WizardPages.Count - 1;
}
else
{
// Update percentage completed
progressBar1.Value = 100 / 20 * installCount;
}
}
private void button1_Click(object sender, System.EventArgs e)
{
this.wizardControl.WizardPages.Add(new WizardPage());
}
}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -