using System; using System.Windows.Forms; using System.ComponentModel; using System.ComponentModel.Design; using System.Diagnostics; namespace Gui.Wizard { /// /// /// [Designer(typeof(Gui.Wizard.WizardPageDesigner))] public class WizardPage : Panel { /// /// Event called before this page is closed when the back button is pressed. If you don't want to show pageIndex -1 then /// set page to be the new page that you wish to show /// public event PageEventHandler CloseFromBack; /// /// Event called before this page is closed when the next button is pressed. If you don't want to show pageIndex -1 then /// set page to be the new page that you wish to show /// public event PageEventHandler CloseFromNext; /// /// Event called after this page is shown when the back button is pressed. /// public event EventHandler ShowFromBack; /// /// Event called after this page is shown when the next button is pressed. /// public event EventHandler ShowFromNext; /// /// Fires the CloseFromBack Event /// /// Wizard to pass into the sender argument /// Index of Page that the event handlers would like to see next public int OnCloseFromBack(Wizard wiz) { //Event args thinks that the next pgae will be the one before this one PageEventArgs e = new PageEventArgs(wiz.PageIndex -1, wiz.Pages); //Tell anybody who listens if (CloseFromBack != null) CloseFromBack(wiz, e); //And then tell whomever called me what the prefered page is return e.PageIndex; } /// /// Fires the CloseFromNextEvent /// /// Sender public int OnCloseFromNext(Wizard wiz) { //Event args thinks that the next pgae will be the one before this one PageEventArgs e = new PageEventArgs(wiz.PageIndex +1, wiz.Pages); //Tell anybody who listens if (CloseFromNext != null) CloseFromNext(wiz, e); //And then tell whomever called me what the prefered page is return e.PageIndex; } /// /// Fires the showFromBack event /// /// sender public void OnShowFromBack(Wizard wiz) { if (ShowFromBack != null) ShowFromBack(wiz, EventArgs.Empty); } /// /// Fires the showFromNext event /// /// Sender public void OnShowFromNext(Wizard wiz) { if (ShowFromNext != null) ShowFromNext(wiz, EventArgs.Empty); } [Category("Wizard")] public bool IsFinishPage { get { return _IsFinishPage; } set { _IsFinishPage=value; } } private bool _IsFinishPage = false; /// /// Clean up any resources being used. /// /// protected override void Dispose( bool disposing ) { if( disposing ) { // //Unregister callbacks // ClearChangeNotifications(); } base.Dispose( disposing ); } /// /// Set the focus to the contained control with a lowest tabIndex /// public void FocusFirstTabIndex() { //Activate the first control in the Panel Control found = null; //find the control with the lowest foreach (Control control in this.Controls) { if (control.CanFocus && (found == null || control.TabIndex < found.TabIndex)) { found = control; } } //Have we actually found anything if (found != null) { //Focus the found control found.Focus(); } else { //Just focus the wizard Page this.Focus(); } } } }