| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762 |
- //
- // System.Web.UI.WebControls.Wizard
- //
- // Authors:
- // Lluis Sanchez Gual ([email protected])
- //
- // (C) 2005 Novell, Inc. (http://www.novell.com)
- //
- //
- // Permission is hereby granted, free of charge, to any person obtaining
- // a copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to
- // permit persons to whom the Software is furnished to do so, subject to
- // the following conditions:
- //
- // The above copyright notice and this permission notice shall be
- // included in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- //
- #if NET_2_0
- using System;
- using System.Collections;
- using System.ComponentModel;
- namespace System.Web.UI.WebControls
- {
- [DefaultEventAttribute ("FinishButtonClick")]
- [BindableAttribute (false)]
- [DesignerAttribute ("System.Web.UI.Design.WebControls.WizardDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
- [ToolboxData ("<{0}:Wizard runat=\"server\"> <WizardSteps> <asp:WizardStep title=\"Step 1\" runat=\"server\"></asp:WizardStep> <asp:WizardStep title=\"Step 2\" runat=\"server\"></asp:WizardStep> </WizardSteps> </{0}:Wizard>")]
- public class Wizard: CompositeControl
- {
- public static readonly string CancelCommandName = "Cancel";
- public static readonly string MoveCompleteCommandName = "MoveComplete";
- public static readonly string MoveNextCommandName = "MoveNext";
- public static readonly string MovePreviousCommandName = "MovePrevious";
- public static readonly string MoveToCommandName = "Move";
-
- protected static readonly string CancelButtonID = "CancelButton";
- protected static readonly string CustomFinishButtonID = "CustomFinishButton";
- protected static readonly string CustomNextButtonID = "CustomNextButton";
- protected static readonly string CustomPreviousButtonID = "CustomPreviousButton";
- protected static readonly string DataListID = "SideBarList";
- protected static readonly string FinishButtonID = "FinishButton";
- protected static readonly string FinishPreviousButtonID = "FinishPreviousButton";
- protected static readonly string SideBarButtonID = "SideBarButton";
- protected static readonly string StartNextButtonID = "StartNextButton";
- protected static readonly string StepNextButtonID = "StepNextButton";
- protected static readonly string StepPreviousButtonID = "StepPreviousButton";
-
- WizardStepCollection steps;
-
- // View state
-
- TableItemStyle stepStyle;
- TableItemStyle sideBarStyle;
- TableItemStyle headerStyle;
- TableItemStyle navigationStyle;
- Style sideBarButtonStyle;
-
- Style cancelButtonStyle;
- Style finishCompleteButtonStyle;
- Style finishPreviousButtonStyle;
- Style startNextButtonStyle;
- Style stepNextButtonStyle;
- Style stepPreviousButtonStyle;
- Style navigationButtonStyle;
-
- ITemplate finishNavigationTemplate;
- ITemplate startNavigationTemplate;
- ITemplate stepNavigationTemplate;
- ITemplate headerTemplate;
- ITemplate sideBarTemplate;
-
- // Control state
-
- int activeStepIndex = -1;
- bool inited = false;
- ArrayList history;
- Table wizardTable;
- WizardHeaderCell _headerCell;
- TableCell _navigationCell;
- StartNavigationContainer _startNavContainer;
- StepNavigationContainer _stepNavContainer;
- FinishNavigationContainer _finishNavContainer;
- MultiView multiView;
- DataList stepDatalist;
- ArrayList styles = new ArrayList ();
- Hashtable customNavigation;
-
- private static readonly object ActiveStepChangedEvent = new object();
- private static readonly object CancelButtonClickEvent = new object();
- private static readonly object FinishButtonClickEvent = new object();
- private static readonly object NextButtonClickEvent = new object();
- private static readonly object PreviousButtonClickEvent = new object();
- private static readonly object SideBarButtonClickEvent = new object();
-
- public event EventHandler ActiveStepChanged {
- add { Events.AddHandler (ActiveStepChangedEvent, value); }
- remove { Events.RemoveHandler (ActiveStepChangedEvent, value); }
- }
-
- public event EventHandler CancelButtonClick {
- add { Events.AddHandler (CancelButtonClickEvent, value); }
- remove { Events.RemoveHandler (CancelButtonClickEvent, value); }
- }
-
- public event WizardNavigationEventHandler FinishButtonClick {
- add { Events.AddHandler (FinishButtonClickEvent, value); }
- remove { Events.RemoveHandler (FinishButtonClickEvent, value); }
- }
-
- public event WizardNavigationEventHandler NextButtonClick {
- add { Events.AddHandler (NextButtonClickEvent, value); }
- remove { Events.RemoveHandler (NextButtonClickEvent, value); }
- }
-
- public event WizardNavigationEventHandler PreviousButtonClick {
- add { Events.AddHandler (PreviousButtonClickEvent, value); }
- remove { Events.RemoveHandler (PreviousButtonClickEvent, value); }
- }
-
- public event WizardNavigationEventHandler SideBarButtonClick {
- add { Events.AddHandler (SideBarButtonClickEvent, value); }
- remove { Events.RemoveHandler (SideBarButtonClickEvent, value); }
- }
-
- protected virtual void OnActiveStepChanged (object source, EventArgs e)
- {
- if (Events != null) {
- EventHandler eh = (EventHandler) Events [ActiveStepChangedEvent];
- if (eh != null) eh (source, e);
- }
- }
-
- protected virtual void OnCancelButtonClick (EventArgs e)
- {
- if (Events != null) {
- EventHandler eh = (EventHandler) Events [CancelButtonClickEvent];
- if (eh != null) eh (this, e);
- }
- }
-
- protected virtual void OnFinishButtonClick (WizardNavigationEventArgs e)
- {
- if (Events != null) {
- WizardNavigationEventHandler eh = (WizardNavigationEventHandler) Events [FinishButtonClickEvent];
- if (eh != null) eh (this, e);
- }
- }
-
- protected virtual void OnNextButtonClick (WizardNavigationEventArgs e)
- {
- if (Events != null) {
- WizardNavigationEventHandler eh = (WizardNavigationEventHandler) Events [NextButtonClickEvent];
- if (eh != null) eh (this, e);
- }
- }
-
- protected virtual void OnPreviousButtonClick (WizardNavigationEventArgs e)
- {
- if (Events != null) {
- WizardNavigationEventHandler eh = (WizardNavigationEventHandler) Events [PreviousButtonClickEvent];
- if (eh != null) eh (this, e);
- }
- }
-
- protected virtual void OnSideBarButtonClick (WizardNavigationEventArgs e)
- {
- if (Events != null) {
- WizardNavigationEventHandler eh = (WizardNavigationEventHandler) Events [SideBarButtonClickEvent];
- if (eh != null) eh (this, e);
- }
- }
-
- [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
- [BrowsableAttribute (false)]
- public WizardStepBase ActiveStep {
- get {
- if (ActiveStepIndex < -1 || ActiveStepIndex >= WizardSteps.Count)
- throw new InvalidOperationException ("ActiveStepIndex has an invalid value.");
- if (ActiveStepIndex == -1) return null;
- return WizardSteps [activeStepIndex];
- }
- }
-
- [DefaultValueAttribute (-1)]
- [ThemeableAttribute (false)]
- public virtual int ActiveStepIndex {
- get {
- return activeStepIndex;
- }
- set {
- if (value < -1 || (value > WizardSteps.Count && (inited || WizardSteps.Count > 0)))
- throw new ArgumentOutOfRangeException ("The ActiveStepIndex must be less than WizardSteps.Count and at least -1");
-
- if (inited && !AllowNavigationToStep (value))
- return;
-
- if(activeStepIndex != value) {
- activeStepIndex = value;
-
- if (inited) {
- multiView.ActiveViewIndex = value;
- if (stepDatalist != null) {
- stepDatalist.SelectedIndex = value;
- stepDatalist.DataBind ();
- }
- OnActiveStepChanged (this, EventArgs.Empty);
- }
- }
- }
- }
-
- [UrlPropertyAttribute]
- [DefaultValueAttribute ("")]
- [EditorAttribute ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
- public virtual string CancelButtonImageUrl {
- get {
- object v = ViewState ["CancelButtonImageUrl"];
- return v != null ? (string)v : string.Empty;
- }
- set {
- ViewState ["CancelButtonImageUrl"] = value;
- }
- }
-
- [DefaultValueAttribute (null)]
- [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]
- [NotifyParentPropertyAttribute (true)]
- [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
- public Style CancelButtonStyle {
- get {
- if (cancelButtonStyle == null) {
- cancelButtonStyle = new Style ();
- if (IsTrackingViewState)
- ((IStateManager)cancelButtonStyle).TrackViewState ();
- }
- return cancelButtonStyle;
- }
- }
-
- [LocalizableAttribute (true)]
- public virtual string CancelButtonText {
- get {
- object v = ViewState ["CancelButtonText"];
- return v != null ? (string)v : "Cancel";
- }
- set {
- ViewState ["CancelButtonText"] = value;
- }
- }
-
- [DefaultValueAttribute (ButtonType.Button)]
- public virtual ButtonType CancelButtonType {
- get {
- object v = ViewState ["CancelButtonType"];
- return v != null ? (ButtonType)v : ButtonType.Button;
- }
- set {
- ViewState ["CancelButtonType"] = value;
- }
- }
-
- [UrlPropertyAttribute]
- [EditorAttribute ("System.Web.UI.Design.UrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
- [DefaultValueAttribute ("")]
- public virtual string CancelDestinationPageUrl {
- get {
- object v = ViewState ["CancelDestinationPageUrl"];
- return v != null ? (string)v : string.Empty;
- }
- set {
- ViewState ["CancelDestinationPageUrl"] = value;
- }
- }
-
- [DefaultValueAttribute (0)]
- public virtual int CellPadding {
- get {
- if (ControlStyleCreated)
- return ((TableStyle) ControlStyle).CellPadding;
- return 0;
- }
- set {
- ((TableStyle) ControlStyle).CellPadding = value;
- }
- }
-
- [DefaultValueAttribute (0)]
- public virtual int CellSpacing {
- get {
- if (ControlStyleCreated)
- return ((TableStyle) ControlStyle).CellSpacing;
- return 0;
- }
- set {
- ((TableStyle) ControlStyle).CellSpacing = value;
- }
- }
-
- [DefaultValueAttribute (false)]
- [ThemeableAttribute (false)]
- public virtual bool DisplayCancelButton {
- get {
- object v = ViewState ["DisplayCancelButton"];
- return v != null ? (bool) v : false;
- }
- set {
- ViewState ["DisplayCancelButton"] = value;
- }
- }
-
- [DefaultValueAttribute (true)]
- [ThemeableAttribute (false)]
- public virtual bool DisplaySideBar {
- get {
- object v = ViewState ["DisplaySideBar"];
- return v != null ? (bool) v : true;
- }
- set {
- ViewState ["DisplaySideBar"] = value;
- UpdateViews ();
- }
- }
-
- [UrlPropertyAttribute]
- [DefaultValueAttribute ("")]
- [EditorAttribute ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
- public virtual string FinishCompleteButtonImageUrl {
- get {
- object v = ViewState ["FinishCompleteButtonImageUrl"];
- return v != null ? (string)v : string.Empty;
- }
- set {
- ViewState ["FinishCompleteButtonImageUrl"] = value;
- }
- }
-
- [DefaultValueAttribute (null)]
- [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]
- [NotifyParentPropertyAttribute (true)]
- [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
- public Style FinishCompleteButtonStyle {
- get {
- if (finishCompleteButtonStyle == null) {
- finishCompleteButtonStyle = new Style ();
- if (IsTrackingViewState)
- ((IStateManager)finishCompleteButtonStyle).TrackViewState ();
- }
- return finishCompleteButtonStyle;
- }
- }
-
- [LocalizableAttribute (true)]
- public virtual string FinishCompleteButtonText {
- get {
- object v = ViewState ["FinishCompleteButtonText"];
- return v != null ? (string)v : "Finish";
- }
- set {
- ViewState ["FinishCompleteButtonText"] = value;
- }
- }
-
- [DefaultValueAttribute (ButtonType.Button)]
- public virtual ButtonType FinishCompleteButtonType {
- get {
- object v = ViewState ["FinishCompleteButtonType"];
- return v != null ? (ButtonType)v : ButtonType.Button;
- }
- set {
- ViewState ["FinishCompleteButtonType"] = value;
- }
- }
-
- [UrlPropertyAttribute]
- [EditorAttribute ("System.Web.UI.Design.UrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
- [DefaultValueAttribute ("")]
- public virtual string FinishDestinationPageUrl {
- get {
- object v = ViewState ["FinishDestinationPageUrl"];
- return v != null ? (string)v : string.Empty;
- }
- set {
- ViewState ["FinishDestinationPageUrl"] = value;
- }
- }
-
- [DefaultValue (null)]
- [TemplateContainer (typeof(Wizard), BindingDirection.OneWay)]
- [PersistenceMode (PersistenceMode.InnerProperty)]
- [Browsable (false)]
- public virtual ITemplate FinishNavigationTemplate {
- get { return finishNavigationTemplate; }
- set { finishNavigationTemplate = value; UpdateViews (); }
- }
-
- [UrlPropertyAttribute]
- [DefaultValueAttribute ("")]
- [EditorAttribute ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
- public virtual string FinishPreviousButtonImageUrl {
- get {
- object v = ViewState ["FinishPreviousButtonImageUrl"];
- return v != null ? (string)v : string.Empty;
- }
- set {
- ViewState ["FinishPreviousButtonImageUrl"] = value;
- }
- }
-
- [DefaultValueAttribute (null)]
- [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]
- [NotifyParentPropertyAttribute (true)]
- [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
- public Style FinishPreviousButtonStyle {
- get {
- if (finishPreviousButtonStyle == null) {
- finishPreviousButtonStyle = new Style ();
- if (IsTrackingViewState)
- ((IStateManager)finishPreviousButtonStyle).TrackViewState ();
- }
- return finishPreviousButtonStyle;
- }
- }
-
- [LocalizableAttribute (true)]
- public virtual string FinishPreviousButtonText {
- get {
- object v = ViewState ["FinishPreviousButtonText"];
- return v != null ? (string)v : "Previous";
- }
- set {
- ViewState ["FinishPreviousButtonText"] = value;
- }
- }
-
- [DefaultValueAttribute (ButtonType.Button)]
- public virtual ButtonType FinishPreviousButtonType {
- get {
- object v = ViewState ["FinishPreviousButtonType"];
- return v != null ? (ButtonType)v : ButtonType.Button;
- }
- set {
- ViewState ["FinishPreviousButtonType"] = value;
- }
- }
-
- [DefaultValueAttribute (null)]
- [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]
- [NotifyParentPropertyAttribute (true)]
- [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
- public TableItemStyle HeaderStyle {
- get {
- if (headerStyle == null) {
- headerStyle = new TableItemStyle ();
- if (IsTrackingViewState)
- ((IStateManager)headerStyle).TrackViewState ();
- }
- return headerStyle;
- }
- }
-
- [DefaultValue (null)]
- [TemplateContainer (typeof(Wizard), BindingDirection.OneWay)]
- [PersistenceMode (PersistenceMode.InnerProperty)]
- [Browsable (false)]
- public virtual ITemplate HeaderTemplate {
- get { return headerTemplate; }
- set { headerTemplate = value; UpdateViews (); }
- }
-
- [DefaultValueAttribute ("")]
- [LocalizableAttribute (true)]
- public virtual string HeaderText {
- get {
- object v = ViewState ["HeaderText"];
- return v != null ? (string)v : string.Empty;
- }
- set {
- ViewState ["HeaderText"] = value;
- }
- }
-
- [DefaultValueAttribute (null)]
- [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]
- [NotifyParentPropertyAttribute (true)]
- [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
- public Style NavigationButtonStyle {
- get {
- if (navigationButtonStyle == null) {
- navigationButtonStyle = new Style ();
- if (IsTrackingViewState)
- ((IStateManager)navigationButtonStyle).TrackViewState ();
- }
- return navigationButtonStyle;
- }
- }
-
- [DefaultValueAttribute (null)]
- [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]
- [NotifyParentPropertyAttribute (true)]
- [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
- public TableItemStyle NavigationStyle {
- get {
- if (navigationStyle == null) {
- navigationStyle = new TableItemStyle ();
- if (IsTrackingViewState)
- ((IStateManager)navigationStyle).TrackViewState ();
- }
- return navigationStyle;
- }
- }
-
- [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]
- [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
- [DefaultValueAttribute (null)]
- [NotifyParentPropertyAttribute (true)]
- public TableItemStyle SideBarStyle {
- get {
- if (sideBarStyle == null) {
- sideBarStyle = new TableItemStyle ();
- if (IsTrackingViewState)
- ((IStateManager)sideBarStyle).TrackViewState ();
- }
- return sideBarStyle;
- }
- }
-
- [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]
- [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
- [DefaultValueAttribute (null)]
- [NotifyParentPropertyAttribute (true)]
- public Style SideBarButtonStyle {
- get {
- if (sideBarButtonStyle == null) {
- sideBarButtonStyle = new Style ();
- if (IsTrackingViewState)
- ((IStateManager)sideBarButtonStyle).TrackViewState ();
- }
- return sideBarButtonStyle;
- }
- }
-
- [DefaultValue (null)]
- [TemplateContainer (typeof(Wizard), BindingDirection.OneWay)]
- [PersistenceMode (PersistenceMode.InnerProperty)]
- [Browsable (false)]
- public virtual ITemplate SideBarTemplate {
- get { return sideBarTemplate; }
- set { sideBarTemplate = value; UpdateViews (); }
- }
- [Localizable (true)]
- public virtual string SkipLinkText
- {
- get
- {
- object v = ViewState ["SkipLinkText"];
- return v != null ? (string) v : "Skip Navigation Links.";
- }
- set
- {
- ViewState ["SkipLinkText"] = value;
- }
- }
-
- [DefaultValue (null)]
- [TemplateContainer (typeof(Wizard), BindingDirection.OneWay)]
- [PersistenceMode (PersistenceMode.InnerProperty)]
- [Browsable (false)]
- public virtual ITemplate StartNavigationTemplate {
- get { return startNavigationTemplate; }
- set { startNavigationTemplate = value; UpdateViews (); }
- }
-
- [UrlPropertyAttribute]
- [DefaultValueAttribute ("")]
- [EditorAttribute ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
- public virtual string StartNextButtonImageUrl {
- get {
- object v = ViewState ["StartNextButtonImageUrl"];
- return v != null ? (string)v : string.Empty;
- }
- set {
- ViewState ["StartNextButtonImageUrl"] = value;
- }
- }
-
- [DefaultValueAttribute (null)]
- [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]
- [NotifyParentPropertyAttribute (true)]
- [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
- public Style StartNextButtonStyle {
- get {
- if (startNextButtonStyle == null) {
- startNextButtonStyle = new Style ();
- if (IsTrackingViewState)
- ((IStateManager)startNextButtonStyle).TrackViewState ();
- }
- return startNextButtonStyle;
- }
- }
-
- [LocalizableAttribute (true)]
- public virtual string StartNextButtonText {
- get {
- object v = ViewState ["StartNextButtonText"];
- return v != null ? (string)v : "Next";
- }
- set {
- ViewState ["StartNextButtonText"] = value;
- }
- }
-
- [DefaultValueAttribute (ButtonType.Button)]
- public virtual ButtonType StartNextButtonType {
- get {
- object v = ViewState ["StartNextButtonType"];
- return v != null ? (ButtonType)v : ButtonType.Button;
- }
- set {
- ViewState ["StartNextButtonType"] = value;
- }
- }
-
- [DefaultValue (null)]
- [TemplateContainer (typeof(Wizard), BindingDirection.OneWay)]
- [PersistenceMode (PersistenceMode.InnerProperty)]
- [Browsable (false)]
- public virtual ITemplate StepNavigationTemplate {
- get { return stepNavigationTemplate; }
- set { stepNavigationTemplate = value; UpdateViews (); }
- }
-
- [UrlPropertyAttribute]
- [DefaultValueAttribute ("")]
- [EditorAttribute ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
- public virtual string StepNextButtonImageUrl {
- get {
- object v = ViewState ["StepNextButtonImageUrl"];
- return v != null ? (string)v : string.Empty;
- }
- set {
- ViewState ["StepNextButtonImageUrl"] = value;
- }
- }
-
- [DefaultValueAttribute (null)]
- [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]
- [NotifyParentPropertyAttribute (true)]
- [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
- public Style StepNextButtonStyle {
- get {
- if (stepNextButtonStyle == null) {
- stepNextButtonStyle = new Style ();
- if (IsTrackingViewState)
- ((IStateManager)stepNextButtonStyle).TrackViewState ();
- }
- return stepNextButtonStyle;
- }
- }
-
- [LocalizableAttribute (true)]
- public virtual string StepNextButtonText {
- get {
- object v = ViewState ["StepNextButtonText"];
- return v != null ? (string)v : "Next";
- }
- set {
- ViewState ["StepNextButtonText"] = value;
- }
- }
-
- [DefaultValueAttribute (ButtonType.Button)]
- public virtual ButtonType StepNextButtonType {
- get {
- object v = ViewState ["StepNextButtonType"];
- return v != null ? (ButtonType)v : ButtonType.Button;
- }
- set {
- ViewState ["StepNextButtonType"] = value;
- }
- }
-
- [UrlPropertyAttribute]
- [DefaultValueAttribute ("")]
- [EditorAttribute ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
- public virtual string StepPreviousButtonImageUrl {
- get {
- object v = ViewState ["StepPreviousButtonImageUrl"];
- return v != null ? (string)v : string.Empty;
- }
- set {
- ViewState ["StepPreviousButtonImageUrl"] = value;
- }
- }
-
- [DefaultValueAttribute (null)]
- [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]
- [NotifyParentPropertyAttribute (true)]
- [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
- public Style StepPreviousButtonStyle {
- get {
- if (stepPreviousButtonStyle == null) {
- stepPreviousButtonStyle = new Style ();
- if (IsTrackingViewState)
- ((IStateManager)stepPreviousButtonStyle).TrackViewState ();
- }
- return stepPreviousButtonStyle;
- }
- }
-
- [LocalizableAttribute (true)]
- public virtual string StepPreviousButtonText {
- get {
- object v = ViewState ["StepPreviousButtonText"];
- return v != null ? (string)v : "Previous";
- }
- set {
- ViewState ["StepPreviousButtonText"] = value;
- }
- }
-
- [DefaultValueAttribute (ButtonType.Button)]
- public virtual ButtonType StepPreviousButtonType {
- get {
- object v = ViewState ["StepPreviousButtonType"];
- return v != null ? (ButtonType)v : ButtonType.Button;
- }
- set {
- ViewState ["StepPreviousButtonType"] = value;
- }
- }
-
- [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]
- [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
- [DefaultValueAttribute (null)]
- [NotifyParentPropertyAttribute (true)]
- public TableItemStyle StepStyle {
- get {
- if (stepStyle == null) {
- stepStyle = new TableItemStyle ();
- if (IsTrackingViewState)
- ((IStateManager)stepStyle).TrackViewState ();
- }
- return stepStyle;
- }
- }
-
- [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]
- [EditorAttribute ("System.Web.UI.Design.WebControls.WizardStepCollectionEditor," + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
- [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
- [ThemeableAttribute (false)]
- public virtual WizardStepCollection WizardSteps {
- get {
- if (steps == null)
- steps = new WizardStepCollection (this);
- return steps;
- }
- }
- protected virtual new HtmlTextWriterTag TagKey
- {
- get {
- return HtmlTextWriterTag.Table;
- }
- }
- internal virtual ITemplate SideBarItemTemplate
- {
- get { return new SideBarButtonTemplate (this); }
- }
-
- public ICollection GetHistory ()
- {
- if (history == null) history = new ArrayList ();
- return history;
- }
-
- public void MoveTo (WizardStepBase wizardStep)
- {
- if (wizardStep == null) throw new ArgumentNullException ("wizardStep");
-
- int i = WizardSteps.IndexOf (wizardStep);
- if (i == -1) throw new ArgumentException ("The provided wizard step does not belong to this wizard.");
-
- ActiveStepIndex = i;
- }
-
- public WizardStepType GetStepType (WizardStepBase wizardStep, int index)
- {
- if (wizardStep.StepType == WizardStepType.Auto) {
- if ((index == WizardSteps.Count - 1) ||
- (WizardSteps.Count > 1 &&
- WizardSteps[WizardSteps.Count - 1].StepType == WizardStepType.Complete &&
- index == WizardSteps.Count - 2))
- return WizardStepType.Finish;
- else if (index == 0)
- return WizardStepType.Start;
- else
- return WizardStepType.Step;
- } else
- return wizardStep.StepType;
-
- }
-
- protected virtual bool AllowNavigationToStep (int index)
- {
- if (index < 0 || index >= WizardSteps.Count) return false;
- if (history == null) return true;
- if (!history.Contains (index)) return true;
- return WizardSteps [index].AllowReturn;
- }
-
- protected internal override void OnInit (EventArgs e)
- {
- Page.RegisterRequiresControlState (this);
- base.OnInit (e);
- if (ActiveStepIndex == -1)
- ActiveStepIndex = 0;
- EnsureChildControls ();
-
- inited = true;
- }
-
- protected override ControlCollection CreateControlCollection ()
- {
- ControlCollection col = new ControlCollection (this);
- col.SetReadonly (true);
- return col;
- }
-
- protected internal override void CreateChildControls ()
- {
- CreateControlHierarchy ();
- }
- protected virtual void CreateControlHierarchy ()
- {
- styles.Clear ();
- wizardTable = new ContainedTable (this);
- Table contentTable = wizardTable;
- if (DisplaySideBar) {
- contentTable = new Table ();
- contentTable.CellPadding = 0;
- contentTable.CellSpacing = 0;
- contentTable.Height = new Unit ("100%");
- contentTable.Width = new Unit ("100%");
- TableRow row = new TableRow ();
- TableCellNamingContainer sideBarCell = new TableCellNamingContainer ();
- sideBarCell.ID = "SideBarContainer";
- sideBarCell.ControlStyle.Height = Unit.Percentage (100);
- CreateSideBar (sideBarCell);
- row.Cells.Add (sideBarCell);
- TableCell contentCell = new TableCell ();
- contentCell.Controls.Add (contentTable);
- contentCell.Height = new Unit ("100%");
- row.Cells.Add (contentCell);
- wizardTable.Rows.Add (row);
- }
- AddHeaderRow (contentTable);
- TableRow viewRow = new TableRow ();
- TableCell viewCell = new TableCell ();
- customNavigation = null;
- multiView = new MultiView ();
- foreach (View v in WizardSteps) {
- if (v is TemplatedWizardStep)
- InstantiateTemplateStep ((TemplatedWizardStep) v);
- multiView.Views.Add (v);
- }
- multiView.ActiveViewIndex = ActiveStepIndex;
- RegisterApplyStyle (viewCell, StepStyle);
- viewCell.Controls.Add (multiView);
- viewRow.Cells.Add (viewCell);
- viewRow.Height = new Unit ("100%");
- contentTable.Rows.Add (viewRow);
- TableRow buttonRow = new TableRow ();
- _navigationCell = new TableCell ();
- _navigationCell.HorizontalAlign = HorizontalAlign.Right;
- RegisterApplyStyle (_navigationCell, NavigationStyle);
- CreateButtonBar (_navigationCell);
- buttonRow.Cells.Add (_navigationCell);
- contentTable.Rows.Add (buttonRow);
- Controls.SetReadonly (false);
- Controls.Add (wizardTable);
- Controls.SetReadonly (true);
- }
- internal virtual void InstantiateTemplateStep(TemplatedWizardStep step)
- {
- BaseWizardContainer contentTemplateContainer = new BaseWizardContainer ();
- if (step.ContentTemplate != null)
- step.ContentTemplate.InstantiateIn (contentTemplateContainer.InnerCell);
- step.ContentTemplateContainer = contentTemplateContainer;
- step.Controls.Clear ();
- step.Controls.Add (contentTemplateContainer);
- BaseWizardNavigationContainer customNavigationTemplateContainer = new BaseWizardNavigationContainer ();
- if (step.CustomNavigationTemplate != null) {
- step.CustomNavigationTemplate.InstantiateIn (customNavigationTemplateContainer);
- RegisterCustomNavigation (step, customNavigationTemplateContainer);
- }
- step.CustomNavigationTemplateContainer = customNavigationTemplateContainer;
- }
- internal void RegisterCustomNavigation (TemplatedWizardStep step, BaseWizardNavigationContainer customNavigationTemplateContainer) {
- if (customNavigation == null)
- customNavigation = new Hashtable ();
- customNavigation [step] = customNavigationTemplateContainer;
- }
-
- void CreateButtonBar (TableCell buttonBarCell)
- {
- if(customNavigation!=null && customNavigation.Values.Count>0)
- {
- int i = 0;
- foreach (Control customNavigationTemplateContainer in customNavigation.Values) {
- customNavigationTemplateContainer.ID = "CustomNavContainer" + i++;
- buttonBarCell.Controls.Add (customNavigationTemplateContainer);
- }
- }
-
- //
- // StartNavContainer
- //
- _startNavContainer = new StartNavigationContainer (this);
- _startNavContainer.ID = "StartNavContainer";
- if (startNavigationTemplate != null) {
- startNavigationTemplate.InstantiateIn (_startNavContainer);
- }
- else {
- TableRow row;
- AddNavButtonsTable (_startNavContainer, out row);
- AddButtonCell (row, CreateButtonSet (StartNextButtonID, MoveNextCommandName));
- AddButtonCell (row, CreateButtonSet (CancelButtonID, CancelCommandName, false));
- _startNavContainer.ConfirmDefaultTemplate ();
- }
- buttonBarCell.Controls.Add (_startNavContainer);
- //
- // StepNavContainer
- //
- _stepNavContainer = new StepNavigationContainer (this);
- _stepNavContainer.ID = "StepNavContainer";
- if (stepNavigationTemplate != null) {
- stepNavigationTemplate.InstantiateIn (_stepNavContainer);
- }
- else {
- TableRow row;
- AddNavButtonsTable (_stepNavContainer, out row);
- AddButtonCell (row, CreateButtonSet (StepPreviousButtonID, MovePreviousCommandName, false));
- AddButtonCell (row, CreateButtonSet (StepNextButtonID, MoveNextCommandName));
- AddButtonCell (row, CreateButtonSet (CancelButtonID, CancelCommandName, false));
- _stepNavContainer.ConfirmDefaultTemplate ();
- }
- buttonBarCell.Controls.Add (_stepNavContainer);
- //
- // StepNavContainer
- //
- _finishNavContainer = new FinishNavigationContainer (this);
- _finishNavContainer.ID = "FinishNavContainer";
- if (finishNavigationTemplate != null) {
- finishNavigationTemplate.InstantiateIn (_finishNavContainer);
- }
- else {
- TableRow row;
- AddNavButtonsTable (_finishNavContainer, out row);
- AddButtonCell (row, CreateButtonSet (FinishPreviousButtonID, MovePreviousCommandName, false));
- AddButtonCell (row, CreateButtonSet (FinishButtonID, MoveCompleteCommandName));
- AddButtonCell (row, CreateButtonSet (CancelButtonID, CancelCommandName, false));
- _finishNavContainer.ConfirmDefaultTemplate ();
- }
- buttonBarCell.Controls.Add (_finishNavContainer);
- }
- private static void AddNavButtonsTable (BaseWizardNavigationContainer container, out TableRow row)
- {
- Table t = new Table ();
- t.CellPadding = 5;
- t.CellSpacing = 5;
- row = new TableRow ();
- t.Rows.Add (row);
- container.Controls.Add (t);
- }
- Control [] CreateButtonSet (string id, string command)
- {
- return CreateButtonSet (id, command, true, null);
- }
- Control [] CreateButtonSet (string id, string command, bool causesValidation)
- {
- return CreateButtonSet (id, command, causesValidation, null);
- }
- internal Control [] CreateButtonSet (string id, string command, bool causesValidation, string validationGroup)
- {
- return new Control [] {
- CreateButton ( id + ButtonType.Button, command, ButtonType.Button, causesValidation, validationGroup),
- CreateButton ( id + ButtonType.Image, command, ButtonType.Image, causesValidation, validationGroup),
- CreateButton ( id + ButtonType.Link, command, ButtonType.Link, causesValidation, validationGroup)
- };
- }
- Control CreateButton (string id, string command, ButtonType type, bool causesValidation, string validationGroup)
- {
- WebControl b;
- switch (type) {
- case ButtonType.Button:
- b = CreateStandartButton ();
- break;
- case ButtonType.Image:
- b = CreateImageButton (null);
- break;
- case ButtonType.Link:
- b = CreateLinkButton ();
- break;
- default:
- throw new ArgumentOutOfRangeException ("type");
- }
- b.ID = id;
- b.EnableTheming = false;
- ((IButtonControl) b).CommandName = command;
- ((IButtonControl) b).CausesValidation = causesValidation;
- if(!String.IsNullOrEmpty(validationGroup))
- ((IButtonControl) b).ValidationGroup = validationGroup;
- RegisterApplyStyle (b, NavigationButtonStyle);
- return b;
- }
- WebControl CreateStandartButton () {
- Button btn = new Button ();
- return btn;
- }
- WebControl CreateImageButton (string imageUrl) {
- ImageButton img = new ImageButton ();
- img.ImageUrl = imageUrl;
- return img;
- }
- WebControl CreateLinkButton () {
- LinkButton link = new LinkButton ();
- return link;
- }
- void AddButtonCell (TableRow row, params Control[] controls)
- {
- TableCell cell = new TableCell ();
- cell.HorizontalAlign = HorizontalAlign.Right;
- for (int i = 0; i < controls.Length; i++)
- cell.Controls.Add (controls [i]);
- row.Cells.Add (cell);
- }
-
- void CreateSideBar (TableCell sideBarCell)
- {
- RegisterApplyStyle (sideBarCell, SideBarStyle);
- if (SkipLinkText != "") {
- System.Web.UI.HtmlControls.HtmlAnchor anchor = new System.Web.UI.HtmlControls.HtmlAnchor ();
- anchor.HRef = "#" + ClientID + "_SkipLink";
- Image img = new Image ();
- ClientScriptManager csm = new ClientScriptManager (null);
- img.ImageUrl = csm.GetWebResourceUrl (typeof (SiteMapPath), "transparent.gif");
- img.Attributes.Add ("height", "0");
- img.Attributes.Add ("width", "0");
- img.AlternateText = SkipLinkText;
- anchor.Controls.Add (img);
- sideBarCell.Controls.Add (anchor);
- }
- if (sideBarTemplate != null) {
- sideBarTemplate.InstantiateIn (sideBarCell);
- stepDatalist = sideBarCell.FindControl (DataListID) as DataList;
- if (stepDatalist == null)
- throw new InvalidOperationException ("The side bar template must contain a DataList control with id '" + DataListID + "'.");
- stepDatalist.ItemDataBound += new DataListItemEventHandler(StepDatalistItemDataBound);
- } else {
- stepDatalist = new DataList ();
- stepDatalist.ID = DataListID;
- stepDatalist.SelectedItemStyle.Font.Bold = true;
- stepDatalist.ItemTemplate = SideBarItemTemplate;
- sideBarCell.Controls.Add (stepDatalist);
- }
- if (SkipLinkText != "") {
- System.Web.UI.HtmlControls.HtmlAnchor anchor = new System.Web.UI.HtmlControls.HtmlAnchor ();
- anchor.ID = "SkipLink";
- sideBarCell.Controls.Add (anchor);
- }
- stepDatalist.ItemCommand += new DataListCommandEventHandler (StepDatalistItemCommand);
- stepDatalist.CellSpacing = 0;
- stepDatalist.DataSource = WizardSteps;
- stepDatalist.SelectedIndex = ActiveStepIndex;
- stepDatalist.DataBind ();
- }
- void StepDatalistItemCommand (object sender, DataListCommandEventArgs e)
- {
- WizardNavigationEventArgs arg = new WizardNavigationEventArgs (ActiveStepIndex, Convert.ToInt32 (e.CommandArgument));
- OnSideBarButtonClick (arg);
- if (!arg.Cancel)
- ActiveStepIndex = arg.NextStepIndex;
- }
- void StepDatalistItemDataBound (object sender, DataListItemEventArgs e)
- {
- if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.SelectedItem) {
- IButtonControl button = (IButtonControl) e.Item.FindControl (SideBarButtonID);
- if (button == null)
- throw new InvalidOperationException ("SideBarList control must contain an IButtonControl with ID " + SideBarButtonID + " in every item template, this maybe include ItemTemplate, EditItemTemplate, SelectedItemTemplate or AlternatingItemTemplate if they exist.");
- WizardStepBase step = (WizardStepBase) e.Item.DataItem;
- if (button is Button)
- ((Button) button).UseSubmitBehavior = false;
- button.CommandName = Wizard.MoveToCommandName;
- button.CommandArgument = WizardSteps.IndexOf (step).ToString ();
- button.Text = step.Name;
- if (step.StepType == WizardStepType.Complete && button is WebControl)
- ((WebControl) button).Enabled = false;
- }
- }
- void AddHeaderRow (Table table)
- {
- TableRow row = new TableRow ();
- _headerCell = new WizardHeaderCell ();
- _headerCell.ID = "HeaderContainer";
- RegisterApplyStyle (_headerCell, HeaderStyle);
- if (headerTemplate != null) {
- headerTemplate.InstantiateIn (_headerCell);
- _headerCell.ConfirmInitState ();
- }
- row.Cells.Add (_headerCell);
- table.Rows.Add (row);
- }
- internal void RegisterApplyStyle (WebControl control, Style style)
- {
- styles.Add (new object [] { control, style });
- }
-
- protected override Style CreateControlStyle ()
- {
- TableStyle style = new TableStyle ();
- style.CellPadding = 0;
- style.CellSpacing = 0;
- return style;
- }
- protected override IDictionary GetDesignModeState ()
- {
- throw new NotImplementedException ();
- }
-
- protected internal override void LoadControlState (object ob)
- {
- if (ob == null) return;
- object[] state = (object[]) ob;
- base.LoadControlState (state[0]);
- activeStepIndex = (int) state[1];
- history = (ArrayList) state[2];
- }
-
- protected internal override object SaveControlState ()
- {
- if (GetHistory ().Count == 0 || (int) history [0] != ActiveStepIndex)
- history.Insert (0, ActiveStepIndex);
- object bstate = base.SaveControlState ();
- return new object[] {
- bstate, activeStepIndex, history
- };
- }
-
- protected override void LoadViewState (object savedState)
- {
- if (savedState == null) {
- base.LoadViewState (null);
- return;
- }
-
- object[] states = (object[]) savedState;
- base.LoadViewState (states [0]);
-
- if (states[1] != null) ((IStateManager)StepStyle).LoadViewState (states[1]);
- if (states[2] != null) ((IStateManager)SideBarStyle).LoadViewState (states[2]);
- if (states[3] != null) ((IStateManager)HeaderStyle).LoadViewState (states[3]);
- if (states[4] != null) ((IStateManager)NavigationStyle).LoadViewState (states[4]);
- if (states[5] != null) ((IStateManager)SideBarButtonStyle).LoadViewState (states[5]);
- if (states[6] != null) ((IStateManager)CancelButtonStyle).LoadViewState (states[6]);
- if (states[7] != null) ((IStateManager)FinishCompleteButtonStyle).LoadViewState (states[7]);
- if (states[8] != null) ((IStateManager)FinishPreviousButtonStyle).LoadViewState (states[8]);
- if (states[9] != null) ((IStateManager)StartNextButtonStyle).LoadViewState (states[9]);
- if (states[10] != null) ((IStateManager)StepNextButtonStyle).LoadViewState (states[10]);
- if (states[11] != null) ((IStateManager)StepPreviousButtonStyle).LoadViewState (states[11]);
- if (states[12] != null) ((IStateManager)NavigationButtonStyle).LoadViewState (states[12]);
- if (states [13] != null)
- ControlStyle.LoadViewState (states [13]);
- }
-
- protected override object SaveViewState ()
- {
- object [] state = new object [14];
- state [0] = base.SaveViewState ();
-
- if (stepStyle != null) state [1] = ((IStateManager)stepStyle).SaveViewState ();
- if (sideBarStyle != null) state [2] = ((IStateManager)sideBarStyle).SaveViewState ();
- if (headerStyle != null) state [3] = ((IStateManager)headerStyle).SaveViewState ();
- if (navigationStyle != null) state [4] = ((IStateManager)navigationStyle).SaveViewState ();
- if (sideBarButtonStyle != null) state [5] = ((IStateManager)sideBarButtonStyle).SaveViewState ();
- if (cancelButtonStyle != null) state [6] = ((IStateManager)cancelButtonStyle).SaveViewState ();
- if (finishCompleteButtonStyle != null) state [7] = ((IStateManager)finishCompleteButtonStyle).SaveViewState ();
- if (finishPreviousButtonStyle != null) state [8] = ((IStateManager)finishPreviousButtonStyle).SaveViewState ();
- if (startNextButtonStyle != null) state [9] = ((IStateManager)startNextButtonStyle).SaveViewState ();
- if (stepNextButtonStyle != null) state [10] = ((IStateManager)stepNextButtonStyle).SaveViewState ();
- if (stepPreviousButtonStyle != null) state [11] = ((IStateManager)stepPreviousButtonStyle).SaveViewState ();
- if (navigationButtonStyle != null) state [12] = ((IStateManager)navigationButtonStyle).SaveViewState ();
- if (ControlStyleCreated)
- state [13] = ControlStyle.SaveViewState ();
-
- for (int n=0; n<state.Length; n++)
- if (state [n] != null) return state;
- return null;
- }
-
- protected override void TrackViewState ()
- {
- base.TrackViewState();
- if (stepStyle != null) ((IStateManager)stepStyle).TrackViewState();
- if (sideBarStyle != null) ((IStateManager)sideBarStyle).TrackViewState();
- if (headerStyle != null) ((IStateManager)headerStyle).TrackViewState();
- if (navigationStyle != null) ((IStateManager)navigationStyle).TrackViewState();
- if (sideBarButtonStyle != null) ((IStateManager)sideBarButtonStyle).TrackViewState();
- if (cancelButtonStyle != null) ((IStateManager)cancelButtonStyle).TrackViewState();
- if (finishCompleteButtonStyle != null) ((IStateManager)finishCompleteButtonStyle).TrackViewState();
- if (finishPreviousButtonStyle != null) ((IStateManager)finishPreviousButtonStyle).TrackViewState();
- if (startNextButtonStyle != null) ((IStateManager)startNextButtonStyle).TrackViewState();
- if (stepNextButtonStyle != null) ((IStateManager)stepNextButtonStyle).TrackViewState();
- if (stepPreviousButtonStyle != null) ((IStateManager)stepPreviousButtonStyle).TrackViewState();
- if (navigationButtonStyle != null) ((IStateManager)navigationButtonStyle).TrackViewState();
- if (ControlStyleCreated)
- ControlStyle.TrackViewState ();
- }
-
- protected internal void RegisterCommandEvents (IButtonControl button)
- {
- button.Command += ProcessCommand;
- }
-
- void ProcessCommand (object sender, CommandEventArgs args)
- {
- Control c = sender as Control;
- if (c != null) {
- switch (c.ID) {
- case "CancelButton":
- ProcessEvent ("Cancel", null);
- return;
- case "FinishButton":
- ProcessEvent ("MoveComplete", null);
- return;
- case "StepPreviousButton":
- case "FinishPreviousButton":
- ProcessEvent ("MovePrevious", null);
- return;
- case "StartNextButton":
- case "StepNextButton":
- ProcessEvent ("MoveNext", null);
- return;
- }
- }
- ProcessEvent (args.CommandName, args.CommandArgument as string);
- }
- protected override bool OnBubbleEvent (object source, EventArgs e)
- {
- CommandEventArgs args = e as CommandEventArgs;
- if (args != null) {
- ProcessEvent (args.CommandName, args.CommandArgument as string);
- return true;
- }
- return base.OnBubbleEvent (source, e);
- }
-
- void ProcessEvent (string commandName, string commandArg)
- {
- switch (commandName) {
- case "Cancel":
- if (CancelDestinationPageUrl.Length > 0)
- Context.Response.Redirect (CancelDestinationPageUrl);
- else
- OnCancelButtonClick (EventArgs.Empty);
- break;
- case "MoveComplete":
- int next = -1;
- for (int n=0; n<WizardSteps.Count; n++) {
- if (WizardSteps [n].StepType == WizardStepType.Complete) {
- next = n;
- break;
- }
- }
- if (next == -1 && ActiveStepIndex == WizardSteps.Count - 1)
- next = ActiveStepIndex;
- WizardNavigationEventArgs navArgs = new WizardNavigationEventArgs (ActiveStepIndex, next);
- OnFinishButtonClick (navArgs);
- if (FinishDestinationPageUrl.Length > 0) {
- Context.Response.Redirect (FinishDestinationPageUrl);
- return;
- }
- if (next != -1 && !navArgs.Cancel)
- ActiveStepIndex = next;
- break;
-
- case "MoveNext":
- if (ActiveStepIndex < WizardSteps.Count - 1) {
- WizardNavigationEventArgs args = new WizardNavigationEventArgs (ActiveStepIndex, ActiveStepIndex + 1);
- OnNextButtonClick (args);
- if (!args.Cancel)
- ActiveStepIndex++;
- }
- break;
-
- case "MovePrevious":
- if (ActiveStepIndex > 0) {
- WizardNavigationEventArgs args = new WizardNavigationEventArgs (ActiveStepIndex, ActiveStepIndex - 1);
- OnPreviousButtonClick (args);
- if (!args.Cancel) {
- if (history != null)
- history.Remove (ActiveStepIndex);
- ActiveStepIndex--;
- }
- }
- break;
-
- case "Move":
- int newb = int.Parse (commandArg);
- ActiveStepIndex = newb;
- break;
- }
- }
-
- internal void UpdateViews ()
- {
- ChildControlsCreated = false;
- }
-
- protected internal override void Render (HtmlTextWriter writer)
- {
- PrepareControlHierarchy ();
-
- wizardTable.Render (writer);
- }
- void PrepareControlHierarchy ()
- {
- // header
- if (!_headerCell.Initialized) {
- if (String.IsNullOrEmpty (HeaderText))
- _headerCell.Parent.Visible = false;
- else
- _headerCell.Text = HeaderText;
- }
- if (ActiveStep.StepType == WizardStepType.Complete)
- _headerCell.Parent.Visible = false;
- // sidebar
- if (stepDatalist != null) {
- stepDatalist.SelectedIndex = ActiveStepIndex;
- stepDatalist.DataBind ();
- if (ActiveStep.StepType == WizardStepType.Complete)
- stepDatalist.NamingContainer.Visible = false;
- }
- // content
- TemplatedWizardStep templateStep = ActiveStep as TemplatedWizardStep;
- if (templateStep != null) {
- BaseWizardContainer contentContainer = templateStep.ContentTemplateContainer as BaseWizardContainer;
- if (contentContainer != null)
- contentContainer.PrepareControlHierarchy ();
- }
- // navigation
- if (customNavigation != null) {
- foreach (Control c in customNavigation.Values)
- c.Visible = false;
- }
- _startNavContainer.Visible = false;
- _stepNavContainer.Visible = false;
- _finishNavContainer.Visible = false;
- BaseWizardNavigationContainer currentNavContainer = GetCurrentNavContainer ();
- if (currentNavContainer == null) {
- _navigationCell.Parent.Visible = false;
- }
- else {
- currentNavContainer.Visible = true;
- currentNavContainer.PrepareControlHierarchy ();
- if (!currentNavContainer.Visible)
- _navigationCell.Parent.Visible = false;
- }
- foreach (object [] styleDef in styles)
- ((WebControl) styleDef [0]).ApplyStyle ((Style) styleDef [1]);
- }
- private BaseWizardNavigationContainer GetCurrentNavContainer ()
- {
- if (customNavigation != null && customNavigation [ActiveStep] != null) {
- return (BaseWizardNavigationContainer) customNavigation [ActiveStep];
- }
- else {
- WizardStepType stepType = GetStepType (ActiveStep, ActiveStepIndex);
- switch (stepType) {
- case WizardStepType.Start:
- return _startNavContainer;
- case WizardStepType.Step:
- return _stepNavContainer;
- case WizardStepType.Finish:
- return _finishNavContainer;
- default:
- return null;
- }
- }
- }
- class TableCellNamingContainer : TableCell, INamingContainer
- {
- public TableCellNamingContainer ()
- {
- SetBindingContainer (false);
- }
- }
- class SideBarButtonTemplate: ITemplate
- {
- Wizard wizard;
-
- public SideBarButtonTemplate (Wizard wizard)
- {
- this.wizard = wizard;
- }
-
- public void InstantiateIn (Control control)
- {
- LinkButton b = new LinkButton ();
- wizard.RegisterApplyStyle (b, wizard.SideBarButtonStyle);
- control.Controls.Add (b);
- control.DataBinding += Bound;
- }
-
- void Bound (object s, EventArgs args)
- {
- WizardStepBase step = DataBinder.GetDataItem (s) as WizardStepBase;
- if (step != null) {
- DataListItem c = (DataListItem) s;
- LinkButton b = (LinkButton) c.Controls[0];
- b.ID = SideBarButtonID;
- b.CommandName = Wizard.MoveToCommandName;
- b.CommandArgument = wizard.WizardSteps.IndexOf (step).ToString ();
- b.Text = step.Name;
- if (step.StepType == WizardStepType.Complete)
- b.Enabled = false;
- }
- }
- }
- class WizardHeaderCell : TableCell, INamingContainer
- {
- bool _initialized;
- public bool Initialized {
- get { return _initialized; }
- }
-
- public WizardHeaderCell ()
- {
- SetBindingContainer (false);
- }
-
- public void ConfirmInitState ()
- {
- _initialized = true;
- }
- }
- internal abstract class DefaultNavigationContainer : BaseWizardNavigationContainer
- {
- bool _isDefault;
- Wizard _wizard;
- protected Wizard Wizard {
- get { return _wizard; }
- }
- protected DefaultNavigationContainer (Wizard wizard)
- {
- _wizard = wizard;
- }
- public override sealed void PrepareControlHierarchy ()
- {
- if (_isDefault)
- UpdateState ();
- }
- protected abstract void UpdateState ();
- public void ConfirmDefaultTemplate ()
- {
- _isDefault = true;
- }
- protected void UpdateNavButtonState (string id, string text, string image, Style style)
- {
- WebControl b = (WebControl) FindControl (id);
- foreach (Control c in b.Parent.Controls)
- c.Visible = b == c;
- ((IButtonControl) b).Text = text;
- ImageButton imgbtn = b as ImageButton;
- if (imgbtn != null)
- imgbtn.ImageUrl = image;
- b.ApplyStyle (style);
- }
- }
- sealed class StartNavigationContainer : DefaultNavigationContainer
- {
- public StartNavigationContainer (Wizard wizard)
- : base (wizard)
- {
- }
- protected override void UpdateState ()
- {
- bool visible = false;
-
- // next
- if (Wizard.AllowNavigationToStep (Wizard.ActiveStepIndex + 1)) {
- visible = true;
- UpdateNavButtonState (Wizard.StartNextButtonID + Wizard.StartNextButtonType, Wizard.StartNextButtonText, Wizard.StartNextButtonImageUrl, Wizard.StartNextButtonStyle);
- }
- else {
- ((Table) Controls [0]).Rows [0].Cells [0].Visible = false;
- }
- // cancel
- if (Wizard.DisplayCancelButton) {
- visible = true;
- UpdateNavButtonState (Wizard.CancelButtonID + Wizard.CancelButtonType, Wizard.CancelButtonText, Wizard.CancelButtonImageUrl, Wizard.CancelButtonStyle);
- }
- else {
- ((Table) Controls [0]).Rows [0].Cells [1].Visible = false;
- }
- Visible = visible;
- }
- }
- sealed class StepNavigationContainer : DefaultNavigationContainer
- {
- public StepNavigationContainer (Wizard wizard)
- : base (wizard)
- {
- }
- protected override void UpdateState ()
- {
- bool visible = false;
- // previous
- if (Wizard.AllowNavigationToStep (Wizard.ActiveStepIndex - 1)) {
- visible = true;
- UpdateNavButtonState (Wizard.StepPreviousButtonID + Wizard.StepPreviousButtonType, Wizard.StepPreviousButtonText, Wizard.StepPreviousButtonImageUrl, Wizard.StepPreviousButtonStyle);
- }
- else {
- ((Table) Controls [0]).Rows [0].Cells [0].Visible = false;
- }
- // next
- if (Wizard.AllowNavigationToStep (Wizard.ActiveStepIndex + 1)) {
- visible = true;
- UpdateNavButtonState (Wizard.StepNextButtonID + Wizard.StepNextButtonType, Wizard.StepNextButtonText, Wizard.StepNextButtonImageUrl, Wizard.StepNextButtonStyle);
- }
- else {
- ((Table) Controls [0]).Rows [0].Cells [1].Visible = false;
- }
- // cancel
- if (Wizard.DisplayCancelButton) {
- visible = true;
- UpdateNavButtonState (Wizard.CancelButtonID + Wizard.CancelButtonType, Wizard.CancelButtonText, Wizard.CancelButtonImageUrl, Wizard.CancelButtonStyle);
- }
- else {
- ((Table) Controls [0]).Rows [0].Cells [2].Visible = false;
- }
- Visible = visible;
- }
- }
- sealed class FinishNavigationContainer : DefaultNavigationContainer
- {
- public FinishNavigationContainer (Wizard wizard)
- : base (wizard)
- {
- }
- protected override void UpdateState ()
- {
- // previous
- if (Wizard.AllowNavigationToStep (Wizard.ActiveStepIndex - 1)) {
- UpdateNavButtonState (Wizard.FinishPreviousButtonID + Wizard.FinishPreviousButtonType, Wizard.FinishPreviousButtonText, Wizard.FinishPreviousButtonImageUrl, Wizard.FinishPreviousButtonStyle);
- }
- else {
- ((Table) Controls [0]).Rows [0].Cells [0].Visible = false;
- }
- // finish
- UpdateNavButtonState (Wizard.FinishButtonID + Wizard.FinishCompleteButtonType, Wizard.FinishCompleteButtonText, Wizard.FinishCompleteButtonImageUrl, Wizard.FinishCompleteButtonStyle);
- // cancel
- if (Wizard.DisplayCancelButton) {
- UpdateNavButtonState (Wizard.CancelButtonID + Wizard.CancelButtonType, Wizard.CancelButtonText, Wizard.CancelButtonImageUrl, Wizard.CancelButtonStyle);
- }
- else {
- ((Table) Controls [0]).Rows [0].Cells [2].Visible = false;
- }
- }
- }
- internal class BaseWizardContainer : Table, INamingContainer
- {
- public TableCell InnerCell {
- get { return Rows [0].Cells [0]; }
- }
- internal BaseWizardContainer ()
- {
- SetBindingContainer (false);
- InitTable ();
- }
- private void InitTable () {
- TableRow row = new TableRow ();
- TableCell cell = new TableCell ();
- cell.ControlStyle.Width = Unit.Percentage (100);
- cell.ControlStyle.Height = Unit.Percentage (100);
- row.Cells.Add (cell);
- this.ControlStyle.Width = Unit.Percentage (100);
- this.ControlStyle.Height = Unit.Percentage (100);
- this.CellPadding = 0;
- this.CellSpacing = 0;
- this.Rows.Add (row);
- }
- public virtual void PrepareControlHierarchy ()
- {
- }
- }
- internal class BaseWizardNavigationContainer : Control, INamingContainer
- {
- internal BaseWizardNavigationContainer ()
- {
- SetBindingContainer (false);
- }
- public virtual void PrepareControlHierarchy ()
- {
- }
- }
- internal abstract class DefaultContentContainer : BaseWizardContainer
- {
- bool _isDefault;
- Wizard _wizard;
- protected bool IsDefaultTemplate {
- get { return _isDefault; }
- }
- protected Wizard Wizard {
- get { return _wizard; }
- }
- protected DefaultContentContainer (Wizard wizard)
- {
- _wizard = wizard;
- }
- public override sealed void PrepareControlHierarchy ()
- {
- if (_isDefault)
- UpdateState ();
- }
- protected abstract void UpdateState ();
- public void ConfirmDefaultTemplate ()
- {
- _isDefault = true;
- }
- }
- }
- }
- #endif
|