private void btnFinish_Click(object sender, EventArgs e) { if (!DesignMode) { if (WizardFinished != null) { PageChangedEventArgs args = new PageChangedEventArgs(false); WizardFinished(this, args); if (args.Cancel) { return; } } //yep Finish was pressed if (DesignMode == false && closeOnFinish) { this.btnFinish.DialogResult = System.Windows.Forms.DialogResult.OK; this.ParentForm.DialogResult = DialogResult.OK; this.ParentForm.Close(); } } }
protected internal void ActivatePage(WizardPage page, bool backButtonPressed) { if (BeforePageChanged != null) { PageChangedEventArgs barg = new PageChangedEventArgs(backButtonPressed); BeforePageChanged(this, barg); if (barg.Cancel) { return; } } // Update the background colors of the tabs Color nonSelectedColor = Color.FromArgb((int)(page.BackColor.R * 0.95f), (int)(page.BackColor.G * 0.95f), (int)(page.BackColor.B * 0.95f)); foreach (WizardPage wizPage in vPages) { if (wizPage == page) { wizPage.PageTabControl.TabPanel.PanelColor = page.BackColor; wizPage.PageTabControl.Padding = new Padding(0, 0, 0, 3); wizPage.PageTabControl.TabPanel.Selected = true; } else { wizPage.PageTabControl.TabPanel.PanelColor = nonSelectedColor; wizPage.PageTabControl.Padding = new Padding(5, 0, 0, 3); wizPage.PageTabControl.TabPanel.Selected = false; } } //Deactivate the current if (vActivePage != null) { vActivePage.Visible = false; } //Activate the new page vActivePage = page; if (vActivePage != null) { //Ensure that this panel displays inside the wizard vActivePage.Parent = this; if (this.Contains(vActivePage) == false) { this.Container.Add(vActivePage); } //Make it fill the space vActivePage.Dock = DockStyle.Fill; vActivePage.Visible = true; vActivePage.BringToFront(); } //What should the back button say if (this.PageIndex > 0) { btnBack.Enabled = true; } else { btnBack.Enabled = false; } //What should the Next button say if (vPages.IndexOf(vActivePage) < vPages.Count-1 && vActivePage.IsFinishPage == false) { btnNext.Enabled = true; pnlNext.Visible = true; //Don't close the wizard :) btnNext.DialogResult = DialogResult.None; if (alwaysShowFinishButton) pnlFinish.Visible = true; else pnlFinish.Visible = false; } else { pnlFinish.Visible = true; if (alwaysShowFinishButton) { btnNext.Enabled = false; } else { pnlNext.Visible = false; } //btnNext.Text = "Fi&nish"; //Dont allow a finish in designer /*if (DesignMode == true && vPages.IndexOf(vActivePage) == vPages.Count-1) { btnNext.Enabled = false; }*/ //else //{ //btnNext.Enabled = true; //If Not in design mode then allow a close btnNext.DialogResult = DialogResult.OK; //} } //Cause a refresh if (vActivePage != null) vActivePage.Invalidate(); else this.Invalidate(); if (PageChanged != null) PageChanged(this, EventArgs.Empty); }
protected internal void ActivatePage(WizardPage page, bool backButtonPressed) { if (BeforePageChanged != null) { PageChangedEventArgs barg = new PageChangedEventArgs(backButtonPressed); BeforePageChanged(this, barg); if (barg.Cancel) { return; } } // Update the background colors of the tabs Color nonSelectedColor = Color.FromArgb((int)(page.BackColor.R * 0.95f), (int)(page.BackColor.G * 0.95f), (int)(page.BackColor.B * 0.95f)); foreach (WizardPage wizPage in vPages) { if (wizPage == page) { wizPage.PageTabControl.TabPanel.PanelColor = page.BackColor; wizPage.PageTabControl.Padding = new Padding(0, 0, 0, 3); wizPage.PageTabControl.TabPanel.Selected = true; } else { wizPage.PageTabControl.TabPanel.PanelColor = nonSelectedColor; wizPage.PageTabControl.Padding = new Padding(5, 0, 0, 3); wizPage.PageTabControl.TabPanel.Selected = false; } } //Deactivate the current if (vActivePage != null) { vActivePage.Visible = false; } //Activate the new page vActivePage = page; if (vActivePage != null) { //Ensure that this panel displays inside the wizard vActivePage.Parent = this; if (this.Contains(vActivePage) == false) { this.Container.Add(vActivePage); } //Make it fill the space vActivePage.Dock = DockStyle.Fill; vActivePage.Visible = true; vActivePage.BringToFront(); } //What should the back button say if (this.PageIndex > 0) { btnBack.Enabled = true; } else { btnBack.Enabled = false; } //What should the Next button say if (vPages.IndexOf(vActivePage) < vPages.Count - 1 && vActivePage.IsFinishPage == false) { btnNext.Enabled = true; pnlNext.Visible = true; //Don't close the wizard :) btnNext.DialogResult = DialogResult.None; if (alwaysShowFinishButton) { pnlFinish.Visible = true; } else { pnlFinish.Visible = false; } } else { pnlFinish.Visible = true; if (alwaysShowFinishButton) { btnNext.Enabled = false; } else { pnlNext.Visible = false; } //btnNext.Text = "Fi&nish"; //Dont allow a finish in designer /*if (DesignMode == true * && vPages.IndexOf(vActivePage) == vPages.Count-1) * { * btnNext.Enabled = false; * }*/ //else //{ //btnNext.Enabled = true; //If Not in design mode then allow a close btnNext.DialogResult = DialogResult.OK; //} } //Cause a refresh if (vActivePage != null) { vActivePage.Invalidate(); } else { this.Invalidate(); } if (PageChanged != null) { PageChanged(this, EventArgs.Empty); } }