using System; using System.Text; using System.ComponentModel; using System.Drawing; using System.Drawing.Drawing2D; namespace DevComponents.DotNetBar { [ToolboxItem(false), Designer("DevComponents.DotNetBar.Design.WizardPageDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf")] public class WizardPage : PanelControl { #region Private Variables private eWizardButtonState m_BackButtonEnabled = eWizardButtonState.Auto; private eWizardButtonState m_BackButtonVisible = eWizardButtonState.Auto; private eWizardButtonState m_NextButtonEnabled = eWizardButtonState.Auto; private eWizardButtonState m_NextButtonVisible = eWizardButtonState.Auto; private eWizardButtonState m_FinishButtonEnabled = eWizardButtonState.Auto; private eWizardButtonState m_CancelButtonEnabled = eWizardButtonState.Auto; private eWizardButtonState m_CancelButtonVisible = eWizardButtonState.Auto; private eWizardButtonState m_HelpButtonEnabled = eWizardButtonState.Auto; private eWizardButtonState m_HelpButtonVisible = eWizardButtonState.Auto; private string m_PageTitle = ""; private string m_PageDescription = ""; private Image m_PageHeaderImage = null; private string m_FormCaption = ""; private bool m_InteriorPage = true; #endregion #region Events /// /// Occurs before page is displayed. This event can cancel the page change. You can perform any additional setup of the Wizard page in this event. /// [Description("Occurs before page is displayed")] public event WizardCancelPageChangeEventHandler BeforePageDisplayed; /// /// Occurs after page has been displayed.This event can cancel the page change. You can perform any additional setup of the Wizard page in this event. /// [Description("Occurs before page is displayed")] public event WizardPageChangeEventHandler AfterPageDisplayed; /// /// Occurs after page is hidden. You can perform any additional steps that are needed to complete wizard step in this event. /// public event WizardPageChangeEventHandler AfterPageHidden; /// /// Occurs when Back button is clicked. You can cancel any default processing performed by Wizard control by setting Cancel=true on event arguments. /// [Description("Occurs when Back button is clicked.")] public event CancelEventHandler BackButtonClick; /// /// Occurs when Next button is clicked. You can cancel any default processing performed by Wizard control by setting Cancel=true on event arguments. /// [Description("Occurs when Next button is clicked.")] public event CancelEventHandler NextButtonClick; /// /// Occurs when Finish button is clicked. You can cancel any default processing performed by Wizard control by setting Cancel=true on event arguments. /// [Description("Occurs when Finish button is clicked.")] public event CancelEventHandler FinishButtonClick; /// /// Occurs when Cancel button is clicked. You can cancel any default processing performed by Wizard control by setting Cancel=true on event arguments. /// [Description("Occurs when Cancel button is clicked.")] public event CancelEventHandler CancelButtonClick; /// /// Occurs when Help button is clicked. You can cancel any default processing performed by Wizard control by setting Cancel=true on event arguments. /// [Description("Occurs when Help button is clicked.")] public event CancelEventHandler HelpButtonClick; #endregion #region Constructor public WizardPage() : base() { this.BackColor = SystemColors.Control; } protected override void Dispose(bool disposing) { if (BarUtilities.DisposeItemImages && !this.DesignMode) { BarUtilities.DisposeImage(ref m_PageHeaderImage); } base.Dispose(disposing); } #endregion #region Public Properties /// /// Gets whether page is currently selected page in Wizard. /// [Browsable(false)] public bool IsSelected { get { Wizard w = this.Parent as Wizard; if (w != null) { return w.SelectedPage == this; } return false; } } /// /// Gets or sets whether back button is enabled when page is active. Default value is eWizardButtonState.Auto which indicates that state is /// automatically managed by control. /// [Browsable(true), DefaultValue(eWizardButtonState.Auto), Category("Page Options"), Description("Indicates whether back button is enabled when page is active.")] public eWizardButtonState BackButtonEnabled { get { return m_BackButtonEnabled; } set { m_BackButtonEnabled = value; UpdatePageState(); } } /// /// Gets or sets whether back button is visible when page is active. Default value is eWizardButtonState.Auto. /// [Browsable(true), DefaultValue(eWizardButtonState.Auto), Category("Page Options"), Description("Indicates whether back button is visible when page is active.")] public eWizardButtonState BackButtonVisible { get { return m_BackButtonVisible; } set { m_BackButtonVisible = value; UpdatePageState(); } } /// /// Gets or sets whether next button is enabled when page is active. Default value is eWizardButtonState.Auto which indicates that state is /// automatically managed by control. /// [Browsable(true), DefaultValue(eWizardButtonState.Auto), Category("Page Options"), Description("Indicates whether next button is enabled when page is active.")] public eWizardButtonState NextButtonEnabled { get { return m_NextButtonEnabled; } set { m_NextButtonEnabled = value; UpdatePageState(); } } /// /// Gets or sets whether next button is visible when page is active. Default value is eWizardButtonState.Auto. /// [Browsable(true), DefaultValue(eWizardButtonState.Auto), Category("Page Options"), Description("Indicates whether next button is visible when page is active.")] public eWizardButtonState NextButtonVisible { get { return m_NextButtonVisible; } set { m_NextButtonVisible = value; UpdatePageState(); } } /// /// Gets or sets whether finish button is enabled when page is active. Default value is eWizardButtonState.Auto which indicates that state is /// automatically managed by control. /// [Browsable(true), DefaultValue(eWizardButtonState.Auto), Category("Page Options"), Description("Indicates whether finish button is enabled when page is active.")] public eWizardButtonState FinishButtonEnabled { get { return m_FinishButtonEnabled; } set { m_FinishButtonEnabled = value; UpdatePageState(); } } /// /// Gets or sets whether cancel button is enabled when page is active. Default value is eWizardButtonState.Auto which indicates that state is /// automatically managed by control. /// [Browsable(true), DefaultValue(eWizardButtonState.Auto), Category("Page Options"), Description("Indicates whether cancel button is enabled when page is active.")] public eWizardButtonState CancelButtonEnabled { get { return m_CancelButtonEnabled; } set { m_CancelButtonEnabled = value; UpdatePageState(); } } /// /// Gets or sets whether cancel button is visible when page is active. Default value is eWizardButtonState.Auto. /// [Browsable(true), DefaultValue(eWizardButtonState.Auto), Category("Page Options"), Description("Indicates whether cancel button is visible when page is active.")] public eWizardButtonState CancelButtonVisible { get { return m_CancelButtonVisible; } set { m_CancelButtonVisible = value; UpdatePageState(); } } /// /// Gets or sets whether help button is enabled when page is active. Default value is eWizardButtonState.Auto which indicates that state is /// automatically managed by control. /// [Browsable(true), DefaultValue(eWizardButtonState.Auto), Category("Page Options"), Description("Indicates whether help button is enabled when page is active.")] public eWizardButtonState HelpButtonEnabled { get { return m_HelpButtonEnabled; } set { m_HelpButtonEnabled = value; UpdatePageState(); } } /// /// Gets or sets whether help button is visible when page is active. Default value is eWizardButtonState.Auto. /// [Browsable(true), DefaultValue(eWizardButtonState.Auto), Category("Page Options"), Description("Indicates whether help button is visible when page is active.")] public eWizardButtonState HelpButtonVisible { get { return m_HelpButtonVisible; } set { m_HelpButtonVisible = value; UpdatePageState(); } } /// /// Gets or sets the page header image when page is an interior page, InteriorPage=true. Default value is null. /// [Browsable(true), DefaultValue(null), Category("Page Options"), Description("Indicates the page header image when page is an interior page.")] public Image PageHeaderImage { get { return m_PageHeaderImage; } set { m_PageHeaderImage = value; UpdatePageState(); } } /// /// Gets or sets the text that is displayed as title in wizard header when page is active. /// [Browsable(true), Localizable(true), DefaultValue(""), Category("Page Options"), Description("Indicates text that is displayed as title in wizard header.")] public string PageTitle { get { return m_PageTitle; } set { m_PageTitle = value; UpdatePageState(); } } /// /// Gets or sets the text that is displayed as description in wizard header when page is active. /// [Browsable(true), Localizable(true), DefaultValue(""), Category("Page Options"), Description("Indicates text that is displayed as description in wizard header when page is active.")] public string PageDescription { get { return m_PageDescription; } set { m_PageDescription = value; UpdatePageState(); } } /// /// Gets or sets the text that is displayed on form caption when page is active. Default value is empty string which indicates that form caption /// is not changed when page becomes active. /// [Browsable(true), Localizable(true), DefaultValue(""), Category("Page Options"), Description("Indicates text that is displayed on form caption when page is active.")] public string FormCaption { get { return m_FormCaption; } set { m_FormCaption = value; UpdatePageState(); } } /// /// Gets or sets whether page is interior page. Interior pages use wizard header area to display page title, description and optional image. They are also padded and do not /// fill the client area of the Wizard. Default value is true. /// You can set this value to false to hide header area and make page fill the client area of the wizard. /// [Browsable(true), DefaultValue(true), Category("Page Options"), Description("Indicates whether page is inner page.")] public bool InteriorPage { get { return m_InteriorPage; } set { if (m_InteriorPage != value) { m_InteriorPage = value; OnInnerPageChanged(); } } } #endregion #region Internal Implementation [Browsable(true), EditorBrowsable(EditorBrowsableState.Always), DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] public override Color BackColor { get { return base.BackColor; } set { base.BackColor = value; } } public bool ShouldSerializeBackColor() { return (BackColor != SystemColors.Control); } /// /// Gets or sets whether page is visible. Page visibility is managed by Wizard control and it should not be set directly. /// [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public new bool Visible { get { return base.Visible; } set { base.Visible = value; } } /// /// Updates page state when one of the page appearance properties has changed. /// private void UpdatePageState() { if (this.Parent is Wizard && ((Wizard)this.Parent).SelectedPage==this) { ((Wizard)this.Parent).UpdatePageDisplay(); ((Wizard)this.Parent).SetupButtons(false); } } private void OnInnerPageChanged() { if (this.Parent is Wizard) { Wizard w=this.Parent as Wizard; w.SetupPage(this); if(w.SelectedPage==this) w.UpdatePageDisplay(); } } protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { base.OnPaint(e); if (this.DesignMode && this.InteriorPage) { Graphics g = e.Graphics; Rectangle r = this.DisplayRectangle; using (Pen pen = new Pen(Color.FromArgb(100,SystemColors.ControlDarkDark), 1)) { pen.DashStyle = DashStyle.Dot; System.Drawing.Drawing2D.SmoothingMode sm = g.SmoothingMode; g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default; // Outer guide r.Inflate(-12, 0); g.DrawLine(pen, r.X, r.Y, r.X, r.Bottom); g.DrawLine(pen, r.Right, r.Y, r.Right, r.Bottom); // Inner guide 1 r.Inflate(-22, 0); g.DrawLine(pen, r.X, r.Y, r.X, r.Bottom); g.DrawLine(pen, r.Right, r.Y, r.Right, r.Bottom); // Inner guide 2 r.Inflate(-22, 0); g.DrawLine(pen, r.X, r.Y, r.X, r.Bottom); g.DrawLine(pen, r.Right, r.Y, r.Right, r.Bottom); g.SmoothingMode = sm; } } } #endregion #region Event Implementation /// /// Fires BeforePageDisplayed event. /// /// Event arguments protected virtual void OnBeforePageDisplayed(WizardCancelPageChangeEventArgs e) { if (BeforePageDisplayed != null) BeforePageDisplayed(this, e); } /// /// Invokes the BeforePageDisplayed event. /// /// Event arguments internal void InvokeBeforePageDisplayed(WizardCancelPageChangeEventArgs e) { OnBeforePageDisplayed(e); } /// /// Fires AfterPageDisplayed event. /// /// Event arguments. protected virtual void OnAfterPageDisplayed(WizardPageChangeEventArgs e) { if (AfterPageDisplayed != null) AfterPageDisplayed(this, e); } /// /// Invokes AfterPageDisplayed event. /// /// Event arguments internal void InvokeAfterPageDisplayed(WizardPageChangeEventArgs e) { OnAfterPageDisplayed(e); } /// /// Fires BeforePageDisplayed event. /// /// Event arguments protected virtual void OnAfterPageHidden(WizardPageChangeEventArgs e) { if (AfterPageHidden != null) AfterPageHidden(this, e); } /// /// Invokes the BeforePageDisplayed event. /// /// Event arguments internal void InvokeAfterPageHidden(WizardPageChangeEventArgs e) { OnAfterPageHidden(e); } /// /// Raises BackButtonClick event. /// /// Event arguments protected virtual void OnBackButtonClick(CancelEventArgs e) { if (BackButtonClick != null) BackButtonClick(this, e); } /// /// Invokes BackButtonClick event. /// internal void InvokeBackButtonClick(CancelEventArgs e) { OnBackButtonClick(e); } /// /// Raises NextButtonClick event. /// /// Event arguments protected virtual void OnNextButtonClick(CancelEventArgs e) { if (NextButtonClick != null) NextButtonClick(this, e); } /// /// Invokes NextButtonClick event. /// internal void InvokeNextButtonClick(CancelEventArgs e) { OnNextButtonClick(e); } /// /// Raises FinishButtonClick event. /// /// Event arguments protected virtual void OnFinishButtonClick(CancelEventArgs e) { if (FinishButtonClick != null) FinishButtonClick(this, e); } /// /// Invokes FinishButtonClick event. /// internal void InvokeFinishButtonClick(CancelEventArgs e) { OnFinishButtonClick(e); } /// /// Raises CancelButtonClick event. /// /// Event arguments protected virtual void OnCancelButtonClick(CancelEventArgs e) { if (CancelButtonClick != null) CancelButtonClick(this, e); } /// /// Invokes CancelButtonClick event. /// internal void InvokeCancelButtonClick(CancelEventArgs e) { OnCancelButtonClick(e); } /// /// Raises HelpButtonClick event. /// /// Event arguments protected virtual void OnHelpButtonClick(CancelEventArgs e) { if (HelpButtonClick != null) HelpButtonClick(this, e); } /// /// Invokes HelpButtonClick event. /// internal void InvokeHelpButtonClick(CancelEventArgs e) { OnHelpButtonClick(e); } #endregion } }