using System;
using System.Data;
using System.Collections;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CMS.PortalControls;
using CMS.GlobalHelper;
using CMS.CMSHelper;
using CMS.UIControls;
using CMS.SettingsProvider;
public partial class CMSWebParts_Layouts_Wizard_WizardButtons : CMSAbstractWebPart
{
#region "Properties"
///
/// Show back button
///
public bool BackEnabled
{
get
{
return ValidationHelper.GetBoolean(this.GetValue("BackEnabled"), true);
}
set
{
this.SetValue("BackEnabled", value);
btnBack.Visible = value;
}
}
///
/// Show back as button
///
public bool BackShowAsButton
{
get
{
return ValidationHelper.GetBoolean(this.GetValue("BackShowAsButton"), btnBack.ShowAsButton);
}
set
{
this.SetValue("BackShowAsButton", value);
btnBack.ShowAsButton = value;
}
}
///
/// Back button text
///
public string BackText
{
get
{
return ValidationHelper.GetString(this.GetValue("BackText"), btnBack.LinkText);
}
set
{
this.SetValue("BackText", value);
btnBack.LinkText = value;
}
}
///
/// Back button image
///
public string BackImage
{
get
{
return ValidationHelper.GetString(this.GetValue("BackImage"), btnBack.ImageUrl);
}
set
{
this.SetValue("BackImage", value);
btnBack.ImageUrl = value;
}
}
///
/// Show next as button
///
public bool NextShowAsButton
{
get
{
return ValidationHelper.GetBoolean(this.GetValue("NextShowAsButton"), btnNext.ShowAsButton);
}
set
{
this.SetValue("NextShowAsButton", value);
btnNext.ShowAsButton = value;
}
}
///
/// Next button text
///
public string NextText
{
get
{
return ValidationHelper.GetString(this.GetValue("NextText"), btnNext.LinkText);
}
set
{
this.SetValue("NextText", value);
btnNext.LinkText = value;
}
}
///
/// Next button image
///
public string NextImage
{
get
{
return ValidationHelper.GetString(this.GetValue("NextImage"), btnNext.ImageUrl);
}
set
{
this.SetValue("NextImage", value);
btnNext.ImageUrl = value;
}
}
///
/// Use extra button for finish
///
public bool FinishExtraButton
{
get
{
return ValidationHelper.GetBoolean(this.GetValue("FinishExtraButton"), true);
}
set
{
this.SetValue("FinishExtraButton", value);
btnFinish.Visible = value;
}
}
///
/// Show finish as button
///
public bool FinishShowAsButton
{
get
{
return ValidationHelper.GetBoolean(this.GetValue("FinishShowAsButton"), btnFinish.ShowAsButton);
}
set
{
this.SetValue("FinishShowAsButton", value);
btnFinish.ShowAsButton = value;
}
}
///
/// Finish button text
///
public string FinishText
{
get
{
return ValidationHelper.GetString(this.GetValue("FinishText"), btnFinish.LinkText);
}
set
{
this.SetValue("FinishText", value);
btnFinish.LinkText = value;
}
}
///
/// Finish button image
///
public string FinishImage
{
get
{
return ValidationHelper.GetString(this.GetValue("FinishImage"), btnFinish.ImageUrl);
}
set
{
this.SetValue("FinishImage", value);
btnFinish.ImageUrl = value;
}
}
#endregion
#region "Methods"
///
/// Init event handler
///
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
// Register the events
ComponentEvents.RequestEvents.RegisterForComponentEvent(this.WebPartID, ComponentEvents.STEP_LOADED, StepLoaded);
}
///
/// Content loaded event handler
///
public override void OnContentLoaded()
{
base.OnContentLoaded();
SetupControl();
}
///
/// Initializes the control properties
///
protected void SetupControl()
{
if (this.StopProcessing)
{
// Do not process
}
else
{
// Load the buttons
LoadButton(btnBack, "Back");
btnBack.LinkEvent = ComponentEvents.BACK;
LoadButton(btnNext, "Next");
btnNext.LinkEvent = ComponentEvents.NEXT;
LoadButton(btnFinish, "Finish");
btnFinish.LinkEvent = ComponentEvents.FINISH;
}
}
///
/// Loads the properties to the given button
///
/// Property prefix
protected void LoadButton(UniButton btn, string prefix)
{
btn.ShowAsButton = ValidationHelper.GetBoolean(GetValue(prefix + "ShowAsButton"), btn.ShowAsButton);
btn.LinkText = GetStringValue(prefix + "Text", btn.LinkText);
btn.ImageUrl = GetStringValue(prefix + "Image", btn.ImageUrl);
string cssClass = GetStringValue(prefix + "CssClass", btn.CssClass);
if (!String.IsNullOrEmpty(cssClass))
{
btn.CssClass = cssClass;
}
}
///
/// Fired when the step is loaded
///
protected void StepLoaded(object sender, EventArgs e)
{
StepEventArgs args = (StepEventArgs)e;
btnBack.Visible = (this.BackEnabled && (args.CurrentStep > 1) && !args.HideBackButton);
btnFinish.Visible = (this.FinishExtraButton && (args.CurrentStep >= args.Steps) && !args.HideNextButton);
btnNext.Visible = ((args.CurrentStep < args.Steps) && !args.HideNextButton);
}
///
/// Reloads the control data
///
public override void ReloadData()
{
base.ReloadData();
SetupControl();
}
#endregion
}