Commit of changes to core files, on behalf of the team
[mono.git] / mcs / class / System.Web / System.Web.UI.WebControls / Wizard.cs
1 //
2 // System.Web.UI.WebControls.Wizard
3 //
4 // Authors:
5 //  Lluis Sanchez Gual (lluis@novell.com)
6 //
7 // (C) 2005 Novell, Inc. (http://www.novell.com)
8 //
9
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30
31 #if NET_2_0
32
33 using System;
34 using System.Collections;
35 using System.ComponentModel;
36
37 namespace System.Web.UI.WebControls
38 {
39         [DefaultEventAttribute ("FinishButtonClick")]\r
40         [BindableAttribute (false)]\r
41         [DesignerAttribute ("System.Web.UI.Design.WebControls.WizardDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
42         [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>")]
43         public class Wizard: CompositeControl
44         {
45                 public static readonly string CancelCommandName = "Cancel";\r
46                 public static readonly string MoveCompleteCommandName = "MoveComplete";\r
47                 public static readonly string MoveNextCommandName = "MoveNext";\r
48                 public static readonly string MovePreviousCommandName = "MovePrevious";\r
49                 public static readonly string MoveToCommandName = "Move";
50                 
51                 protected static readonly string CancelButtonID = "CancelButton";
52                 protected static readonly string CustomFinishButtonID = "CustomFinishButton";
53                 protected static readonly string CustomNextButtonID = "CustomNextButton";
54                 protected static readonly string CustomPreviousButtonID = "CustomPreviousButton";
55                 protected static readonly string DataListID = "SideBarList";
56                 protected static readonly string FinishButtonID = "FinishButton";
57                 protected static readonly string FinishPreviousButtonID = "FinishPreviousButton";
58                 protected static readonly string SideBarButtonID = "SideBarButton";
59                 protected static readonly string StartNextButtonID = "StartNextButton";
60                 protected static readonly string StepNextButtonID = "StepNextButton";
61                 protected static readonly string StepPreviousButtonID = "StepPreviousButton";
62                 
63                 WizardStepCollection steps;
64                 
65                 // View state
66                 
67                 TableItemStyle stepStyle;
68                 TableItemStyle sideBarStyle;
69                 TableItemStyle headerStyle;
70                 TableItemStyle navigationStyle;
71                 Style sideBarButtonStyle;
72                 
73                 Style cancelButtonStyle;
74                 Style finishCompleteButtonStyle;
75                 Style finishPreviousButtonStyle;
76                 Style startNextButtonStyle;
77                 Style stepNextButtonStyle;
78                 Style stepPreviousButtonStyle;
79                 Style navigationButtonStyle;
80                 
81                 ITemplate finishNavigationTemplate;
82                 ITemplate startNavigationTemplate;
83                 ITemplate stepNavigationTemplate;
84                 ITemplate headerTemplate;
85                 ITemplate sideBarTemplate;
86                 
87                 // Control state
88                 
89                 int activeStepIndex;
90                 ArrayList history;
91
92                 Table wizardTable;
93                 MultiView multiView;
94                 DataList stepDatalist;
95                 ArrayList styles = new ArrayList ();
96                 SideBarButtonTemplate sideBarItemTemplate;
97                 
98                 private static readonly object ActiveStepChangedEvent = new object();
99                 private static readonly object CancelButtonClickEvent = new object();
100                 private static readonly object FinishButtonClickEvent = new object();
101                 private static readonly object NextButtonClickEvent = new object();
102                 private static readonly object PreviousButtonClickEvent = new object();
103                 private static readonly object SideBarButtonClickEvent = new object();
104                 
105                 public Wizard ()
106                 {
107                         sideBarItemTemplate = new SideBarButtonTemplate (this);
108                 }
109                 
110                 public event EventHandler ActiveStepChanged {
111                         add { Events.AddHandler (ActiveStepChangedEvent, value); }
112                         remove { Events.RemoveHandler (ActiveStepChangedEvent, value); }
113                 }
114                 
115                 public event EventHandler CancelButtonClick {
116                         add { Events.AddHandler (CancelButtonClickEvent, value); }
117                         remove { Events.RemoveHandler (CancelButtonClickEvent, value); }
118                 }
119                 
120                 public event WizardNavigationEventHandler FinishButtonClick {
121                         add { Events.AddHandler (FinishButtonClickEvent, value); }
122                         remove { Events.RemoveHandler (FinishButtonClickEvent, value); }
123                 }
124                 
125                 public event WizardNavigationEventHandler NextButtonClick {
126                         add { Events.AddHandler (NextButtonClickEvent, value); }
127                         remove { Events.RemoveHandler (NextButtonClickEvent, value); }
128                 }
129                 
130                 public event WizardNavigationEventHandler PreviousButtonClick {
131                         add { Events.AddHandler (PreviousButtonClickEvent, value); }
132                         remove { Events.RemoveHandler (PreviousButtonClickEvent, value); }
133                 }
134                 
135                 public event WizardNavigationEventHandler SideBarButtonClick {
136                         add { Events.AddHandler (SideBarButtonClickEvent, value); }
137                         remove { Events.RemoveHandler (SideBarButtonClickEvent, value); }
138                 }
139                 
140                 protected virtual void OnActiveStepChanged (object source, EventArgs e)
141                 {
142                         if (Events != null) {
143                                 EventHandler eh = (EventHandler) Events [ActiveStepChangedEvent];
144                                 if (eh != null) eh (source, e);
145                         }
146                 }
147                 
148                 protected virtual void OnCancelButtonClick (EventArgs e)
149                 {
150                         if (Events != null) {
151                                 EventHandler eh = (EventHandler) Events [CancelButtonClickEvent];
152                                 if (eh != null) eh (this, e);
153                         }
154                 }
155                 
156                 protected virtual void OnFinishButtonClick (WizardNavigationEventArgs e)
157                 {
158                         if (Events != null) {
159                                 WizardNavigationEventHandler eh = (WizardNavigationEventHandler) Events [FinishButtonClickEvent];
160                                 if (eh != null) eh (this, e);
161                         }
162                 }
163                 
164                 protected virtual void OnNextButtonClick (WizardNavigationEventArgs e)
165                 {
166                         if (Events != null) {
167                                 WizardNavigationEventHandler eh = (WizardNavigationEventHandler) Events [NextButtonClickEvent];
168                                 if (eh != null) eh (this, e);
169                         }
170                 }
171                 
172                 protected virtual void OnPreviousButtonClick (WizardNavigationEventArgs e)
173                 {
174                         if (Events != null) {
175                                 WizardNavigationEventHandler eh = (WizardNavigationEventHandler) Events [PreviousButtonClickEvent];
176                                 if (eh != null) eh (this, e);
177                         }
178                 }
179                 
180                 protected virtual void OnSideBarButtonClick (WizardNavigationEventArgs e)
181                 {
182                         if (Events != null) {
183                                 WizardNavigationEventHandler eh = (WizardNavigationEventHandler) Events [SideBarButtonClickEvent];
184                                 if (eh != null) eh (this, e);
185                         }
186                 }
187                 
188             [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]\r
189             [BrowsableAttribute (false)]\r
190                 public WizardStepBase ActiveStep {
191                         get {
192                                 if (activeStepIndex < -1 || activeStepIndex >= steps.Count)
193                                         throw new InvalidOperationException ("ActiveStepIndex has an invalid value.");
194                                 if (activeStepIndex == -1) return null;
195                                 return steps [activeStepIndex];
196                         }
197                 }
198                 
199             [DefaultValueAttribute (-1)]\r
200             [ThemeableAttribute (false)]\r
201                 public virtual int ActiveStepIndex {
202                         get {
203                                 return activeStepIndex;
204                         }
205                         set {
206                                 if (!AllowNavigationToStep (value))
207                                         return;
208                                 if (activeStepIndex != value) {
209                                         if (history == null) history = new ArrayList ();
210                                         history.Insert (0, activeStepIndex);
211                                 }
212                                 activeStepIndex = value;
213                                 UpdateControls ();
214                                 OnActiveStepChanged (this, EventArgs.Empty);
215                         }
216                 }
217                 
218             [UrlPropertyAttribute]\r
219             [DefaultValueAttribute ("")]\r
220             [EditorAttribute ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]\r
221                 public virtual string CancelButtonImageUrl {
222                         get {
223                                 object v = ViewState ["CancelButtonImageUrl"];
224                                 return v != null ? (string)v : string.Empty;
225                         }
226                         set {
227                                 ViewState ["CancelButtonImageUrl"] = value;
228                                 UpdateControls ();
229                         }
230                 }
231                 
232             [DefaultValueAttribute (null)]\r
233             [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]\r
234             [NotifyParentPropertyAttribute (true)]\r
235             [PersistenceModeAttribute (PersistenceMode.InnerProperty)]\r
236                 public Style CancelButtonStyle {
237                         get {
238                                 if (cancelButtonStyle == null) {
239                                         cancelButtonStyle = new Style ();
240                                         if (IsTrackingViewState)
241                                                 ((IStateManager)cancelButtonStyle).TrackViewState ();
242                                 }
243                                 return cancelButtonStyle;
244                         }
245                 }
246                 
247             [LocalizableAttribute (true)]\r
248                 public virtual string CancelButtonText {
249                         get {
250                                 object v = ViewState ["CancelButtonText"];
251                                 return v != null ? (string)v : "Cancel";
252                         }
253                         set {
254                                 ViewState ["CancelButtonText"] = value;
255                                 UpdateControls ();
256                         }
257                 }
258                 
259             [DefaultValueAttribute (ButtonType.Button)]\r
260                 public virtual ButtonType CancelButtonType {
261                         get {
262                                 object v = ViewState ["CancelButtonType"];
263                                 return v != null ? (ButtonType)v : ButtonType.Button;
264                         }
265                         set {
266                                 ViewState ["CancelButtonType"] = value;
267                                 UpdateControls ();
268                         }
269                 }
270                 
271             [UrlPropertyAttribute]\r
272             [EditorAttribute ("System.Web.UI.Design.UrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
273             [DefaultValueAttribute ("")]\r
274                 public virtual string CancelDestinationPageUrl {
275                         get {
276                                 object v = ViewState ["CancelDestinationPageUrl"];
277                                 return v != null ? (string)v : string.Empty;
278                         }
279                         set {
280                                 ViewState ["CancelDestinationPageUrl"] = value;
281                         }
282                 }
283             \r
284             [DefaultValueAttribute (0)]\r
285                 public virtual int CellPadding {
286                         get {
287                                 object v = ViewState ["CellPadding"];
288                                 return v != null ? (int)v : 0;
289                         }
290                         set {
291                                 ViewState ["CellPadding"] = value;
292                                 UpdateControls ();
293                         }
294                 }
295                 
296             [DefaultValueAttribute (0)]\r
297                 public virtual int CellSpacing {
298                         get {
299                                 object v = ViewState ["CellSpacing"];
300                                 return v != null ? (int)v : 0;
301                         }
302                         set {
303                                 ViewState ["CellSpacing"] = value;
304                                 UpdateControls ();
305                         }
306                 }
307                 
308             [DefaultValueAttribute (false)]\r
309             [ThemeableAttribute (false)]\r
310                 public virtual bool DisplayCancelButton {
311                         get {
312                                 object v = ViewState ["DisplayCancelButton"];
313                                 return v != null ? (bool) v : false;
314                         }
315                         set {
316                                 ViewState ["DisplayCancelButton"] = value;
317                                 UpdateControls ();
318                         }
319                 }
320                 
321             [DefaultValueAttribute (true)]\r
322             [ThemeableAttribute (false)]\r
323                 public virtual bool DisplaySideBar {
324                         get {
325                                 object v = ViewState ["DisplaySideBar"];
326                                 return v != null ? (bool) v : true;
327                         }
328                         set {
329                                 ViewState ["DisplaySideBar"] = value;
330                                 UpdateControls ();
331                         }
332                 }
333                 
334             [UrlPropertyAttribute]\r
335             [DefaultValueAttribute ("")]\r
336             [EditorAttribute ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]\r
337                 public virtual string FinishCompleteButtonImageUrl {
338                         get {
339                                 object v = ViewState ["FinishCompleteButtonImageUrl"];
340                                 return v != null ? (string)v : string.Empty;
341                         }
342                         set {
343                                 ViewState ["FinishCompleteButtonImageUrl"] = value;
344                                 UpdateControls ();
345                         }
346                 }
347                 
348             [DefaultValueAttribute (null)]\r
349             [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]\r
350             [NotifyParentPropertyAttribute (true)]\r
351             [PersistenceModeAttribute (PersistenceMode.InnerProperty)]\r
352                 public Style FinishCompleteButtonStyle {
353                         get {
354                                 if (finishCompleteButtonStyle == null) {
355                                         finishCompleteButtonStyle = new Style ();
356                                         if (IsTrackingViewState)
357                                                 ((IStateManager)finishCompleteButtonStyle).TrackViewState ();
358                                 }
359                                 return finishCompleteButtonStyle;
360                         }
361                 }
362                 
363             [LocalizableAttribute (true)]\r
364                 public virtual string FinishCompleteButtonText {
365                         get {
366                                 object v = ViewState ["FinishCompleteButtonText"];
367                                 return v != null ? (string)v : "Finish";
368                         }
369                         set {
370                                 ViewState ["FinishCompleteButtonText"] = value;
371                                 UpdateControls ();
372                         }
373                 }
374                 
375             [DefaultValueAttribute (ButtonType.Button)]\r
376                 public virtual ButtonType FinishCompleteButtonType {
377                         get {
378                                 object v = ViewState ["FinishCompleteButtonType"];
379                                 return v != null ? (ButtonType)v : ButtonType.Button;
380                         }
381                         set {
382                                 ViewState ["FinishCompleteButtonType"] = value;
383                                 UpdateControls ();
384                         }
385                 }
386                 
387             [UrlPropertyAttribute]\r
388             [EditorAttribute ("System.Web.UI.Design.UrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
389             [DefaultValueAttribute ("")]\r
390                 public virtual string FinishDestinationPageUrl {
391                         get {
392                                 object v = ViewState ["FinishDestinationPageUrl"];
393                                 return v != null ? (string)v : string.Empty;
394                         }
395                         set {
396                                 ViewState ["FinishDestinationPageUrl"] = value;
397                         }
398                 }
399             \r
400                 [DefaultValue (null)]
401                 [TemplateContainer (typeof(Wizard), BindingDirection.OneWay)]
402                 [PersistenceMode (PersistenceMode.InnerProperty)]
403             [Browsable (false)]
404                 public virtual ITemplate FinishNavigationTemplate {
405                         get { return finishNavigationTemplate; }
406                         set { finishNavigationTemplate = value; UpdateControls (); }
407                 }
408                 
409             [UrlPropertyAttribute]\r
410             [DefaultValueAttribute ("")]\r
411             [EditorAttribute ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]\r
412                 public virtual string FinishPreviousButtonImageUrl {
413                         get {
414                                 object v = ViewState ["FinishPreviousButtonImageUrl"];
415                                 return v != null ? (string)v : string.Empty;
416                         }
417                         set {
418                                 ViewState ["FinishPreviousButtonImageUrl"] = value;
419                                 UpdateControls ();
420                         }
421                 }
422                 
423             [DefaultValueAttribute (null)]\r
424             [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]\r
425             [NotifyParentPropertyAttribute (true)]\r
426             [PersistenceModeAttribute (PersistenceMode.InnerProperty)]\r
427                 public Style FinishPreviousButtonStyle {
428                         get {
429                                 if (finishPreviousButtonStyle == null) {
430                                         finishPreviousButtonStyle = new Style ();
431                                         if (IsTrackingViewState)
432                                                 ((IStateManager)finishPreviousButtonStyle).TrackViewState ();
433                                 }
434                                 return finishPreviousButtonStyle;
435                         }
436                 }
437                 
438             [LocalizableAttribute (true)]\r
439                 public virtual string FinishPreviousButtonText {
440                         get {
441                                 object v = ViewState ["FinishPreviousButtonText"];
442                                 return v != null ? (string)v : "Previous";
443                         }
444                         set {
445                                 ViewState ["FinishPreviousButtonText"] = value;
446                                 UpdateControls ();
447                         }
448                 }
449                 
450             [DefaultValueAttribute (ButtonType.Button)]\r
451                 public virtual ButtonType FinishPreviousButtonType {
452                         get {
453                                 object v = ViewState ["FinishPreviousButtonType"];
454                                 return v != null ? (ButtonType)v : ButtonType.Button;
455                         }
456                         set {
457                                 ViewState ["FinishPreviousButtonType"] = value;
458                                 UpdateControls ();
459                         }
460                 }
461                 
462             [DefaultValueAttribute (null)]\r
463             [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]\r
464             [NotifyParentPropertyAttribute (true)]\r
465             [PersistenceModeAttribute (PersistenceMode.InnerProperty)]\r
466                 public TableItemStyle HeaderStyle {
467                         get {
468                                 if (headerStyle == null) {
469                                         headerStyle = new TableItemStyle ();
470                                         if (IsTrackingViewState)
471                                                 ((IStateManager)headerStyle).TrackViewState ();
472                                 }
473                                 return headerStyle;
474                         }
475                 }
476                 
477                 [DefaultValue (null)]
478                 [TemplateContainer (typeof(Wizard), BindingDirection.OneWay)]
479                 [PersistenceMode (PersistenceMode.InnerProperty)]
480             [Browsable (false)]
481                 public virtual ITemplate HeaderTemplate {
482                         get { return headerTemplate; }
483                         set { headerTemplate = value; UpdateControls (); }
484                 }
485                 
486             [DefaultValueAttribute ("")]\r
487             [LocalizableAttribute (true)]\r
488                 public virtual string HeaderText {
489                         get {
490                                 object v = ViewState ["HeaderText"];
491                                 return v != null ? (string)v : string.Empty;
492                         }
493                         set {
494                                 ViewState ["HeaderText"] = value;
495                                 UpdateControls ();
496                         }
497                 }
498                 
499             [DefaultValueAttribute (null)]\r
500             [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]\r
501             [NotifyParentPropertyAttribute (true)]\r
502             [PersistenceModeAttribute (PersistenceMode.InnerProperty)]\r
503                 public Style NavigationButtonStyle {
504                         get {
505                                 if (navigationButtonStyle == null) {
506                                         navigationButtonStyle = new Style ();
507                                         if (IsTrackingViewState)
508                                                 ((IStateManager)navigationButtonStyle).TrackViewState ();
509                                 }
510                                 return navigationButtonStyle;
511                         }
512                 }
513                 
514             [DefaultValueAttribute (null)]\r
515             [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]\r
516             [NotifyParentPropertyAttribute (true)]\r
517             [PersistenceModeAttribute (PersistenceMode.InnerProperty)]\r
518                 public TableItemStyle NavigationStyle {
519                         get {
520                                 if (navigationStyle == null) {
521                                         navigationStyle = new TableItemStyle ();
522                                         if (IsTrackingViewState)
523                                                 ((IStateManager)navigationStyle).TrackViewState ();
524                                 }
525                                 return navigationStyle;
526                         }
527                 }
528                 
529             [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]\r
530             [PersistenceModeAttribute (PersistenceMode.InnerProperty)]\r
531             [DefaultValueAttribute (null)]\r
532             [NotifyParentPropertyAttribute (true)]\r
533                 public TableItemStyle SideBarStyle {
534                         get {
535                                 if (sideBarStyle == null) {
536                                         sideBarStyle = new TableItemStyle ();
537                                         if (IsTrackingViewState)
538                                                 ((IStateManager)sideBarStyle).TrackViewState ();
539                                 }
540                                 return sideBarStyle;
541                         }
542                 }
543                 
544             [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]\r
545             [PersistenceModeAttribute (PersistenceMode.InnerProperty)]\r
546             [DefaultValueAttribute (null)]\r
547             [NotifyParentPropertyAttribute (true)]\r
548                 public Style SideBarButtonStyle {
549                         get {
550                                 if (sideBarButtonStyle == null) {
551                                         sideBarButtonStyle = new Style ();
552                                         if (IsTrackingViewState)
553                                                 ((IStateManager)sideBarButtonStyle).TrackViewState ();
554                                 }
555                                 return sideBarButtonStyle;
556                         }
557                 }
558                 
559                 [DefaultValue (null)]
560                 [TemplateContainer (typeof(Wizard), BindingDirection.OneWay)]
561                 [PersistenceMode (PersistenceMode.InnerProperty)]
562             [Browsable (false)]
563                 public virtual ITemplate SideBarTemplate {
564                         get { return sideBarTemplate; }
565                         set { sideBarTemplate = value; UpdateControls (); }
566                 }
567
568                 [Localizable (true)]
569                 [MonoTODO]
570                 public virtual string SkipLinkText 
571                 {
572                         get {
573                                 throw new NotImplementedException ();
574                         }
575                         set {
576                                 throw new NotImplementedException ();
577                         }
578                 }
579                 
580                 [DefaultValue (null)]
581                 [TemplateContainer (typeof(Wizard), BindingDirection.OneWay)]
582                 [PersistenceMode (PersistenceMode.InnerProperty)]
583             [Browsable (false)]
584                 public virtual ITemplate StartNavigationTemplate {
585                         get { return startNavigationTemplate; }
586                         set { startNavigationTemplate = value; UpdateControls (); }
587                 }
588                 
589             [UrlPropertyAttribute]\r
590             [DefaultValueAttribute ("")]\r
591             [EditorAttribute ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]\r
592                 public virtual string StartNextButtonImageUrl {
593                         get {
594                                 object v = ViewState ["StartNextButtonImageUrl"];
595                                 return v != null ? (string)v : string.Empty;
596                         }
597                         set {
598                                 ViewState ["StartNextButtonImageUrl"] = value;
599                                 UpdateControls ();
600                         }
601                 }
602                 
603             [DefaultValueAttribute (null)]\r
604             [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]\r
605             [NotifyParentPropertyAttribute (true)]\r
606             [PersistenceModeAttribute (PersistenceMode.InnerProperty)]\r
607                 public Style StartNextButtonStyle {
608                         get {
609                                 if (startNextButtonStyle == null) {
610                                         startNextButtonStyle = new Style ();
611                                         if (IsTrackingViewState)
612                                                 ((IStateManager)startNextButtonStyle).TrackViewState ();
613                                 }
614                                 return startNextButtonStyle;
615                         }
616                 }
617                 
618             [LocalizableAttribute (true)]\r
619                 public virtual string StartNextButtonText {
620                         get {
621                                 object v = ViewState ["StartNextButtonText"];
622                                 return v != null ? (string)v : "Next";
623                         }
624                         set {
625                                 ViewState ["StartNextButtonText"] = value;
626                                 UpdateControls ();
627                         }
628                 }
629                 
630             [DefaultValueAttribute (ButtonType.Button)]\r
631                 public virtual ButtonType StartNextButtonType {
632                         get {
633                                 object v = ViewState ["StartNextButtonType"];
634                                 return v != null ? (ButtonType)v : ButtonType.Button;
635                         }
636                         set {
637                                 ViewState ["StartNextButtonType"] = value;
638                                 UpdateControls ();
639                         }
640                 }
641                 
642                 [DefaultValue (null)]
643                 [TemplateContainer (typeof(Wizard), BindingDirection.OneWay)]
644                 [PersistenceMode (PersistenceMode.InnerProperty)]
645             [Browsable (false)]
646                 public virtual ITemplate StepNavigationTemplate {
647                         get { return stepNavigationTemplate; }
648                         set { stepNavigationTemplate = value; UpdateControls (); }
649                 }
650                 
651             [UrlPropertyAttribute]\r
652             [DefaultValueAttribute ("")]\r
653             [EditorAttribute ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]\r
654                 public virtual string StepNextButtonImageUrl {
655                         get {
656                                 object v = ViewState ["StepNextButtonImageUrl"];
657                                 return v != null ? (string)v : string.Empty;
658                         }
659                         set {
660                                 ViewState ["StepNextButtonImageUrl"] = value;
661                                 UpdateControls ();
662                         }
663                 }
664                 
665             [DefaultValueAttribute (null)]\r
666             [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]\r
667             [NotifyParentPropertyAttribute (true)]\r
668             [PersistenceModeAttribute (PersistenceMode.InnerProperty)]\r
669                 public Style StepNextButtonStyle {
670                         get {
671                                 if (stepNextButtonStyle == null) {
672                                         stepNextButtonStyle = new Style ();
673                                         if (IsTrackingViewState)
674                                                 ((IStateManager)stepNextButtonStyle).TrackViewState ();
675                                 }
676                                 return stepNextButtonStyle;
677                         }
678                 }
679                 
680             [LocalizableAttribute (true)]\r
681                 public virtual string StepNextButtonText {
682                         get {
683                                 object v = ViewState ["StepNextButtonText"];
684                                 return v != null ? (string)v : "Next";
685                         }
686                         set {
687                                 ViewState ["StepNextButtonText"] = value;
688                                 UpdateControls ();
689                         }
690                 }
691                 
692             [DefaultValueAttribute (ButtonType.Button)]\r
693                 public virtual ButtonType StepNextButtonType {
694                         get {
695                                 object v = ViewState ["StepNextButtonType"];
696                                 return v != null ? (ButtonType)v : ButtonType.Button;
697                         }
698                         set {
699                                 ViewState ["StepNextButtonType"] = value;
700                                 UpdateControls ();
701                         }
702                 }
703                 
704             [UrlPropertyAttribute]\r
705             [DefaultValueAttribute ("")]\r
706             [EditorAttribute ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]\r
707                 public virtual string StepPreviousButtonImageUrl {
708                         get {
709                                 object v = ViewState ["StepPreviousButtonImageUrl"];
710                                 return v != null ? (string)v : string.Empty;
711                         }
712                         set {
713                                 ViewState ["StepPreviousButtonImageUrl"] = value;
714                                 UpdateControls ();
715                         }
716                 }
717                 
718             [DefaultValueAttribute (null)]\r
719             [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]\r
720             [NotifyParentPropertyAttribute (true)]\r
721             [PersistenceModeAttribute (PersistenceMode.InnerProperty)]\r
722                 public Style StepPreviousButtonStyle {
723                         get {
724                                 if (stepPreviousButtonStyle == null) {
725                                         stepPreviousButtonStyle = new Style ();
726                                         if (IsTrackingViewState)
727                                                 ((IStateManager)stepPreviousButtonStyle).TrackViewState ();
728                                 }
729                                 return stepPreviousButtonStyle;
730                         }
731                 }
732                 
733             [LocalizableAttribute (true)]\r
734                 public virtual string StepPreviousButtonText {
735                         get {
736                                 object v = ViewState ["StepPreviousButtonText"];
737                                 return v != null ? (string)v : "Previous";
738                         }
739                         set {
740                                 ViewState ["StepPreviousButtonText"] = value;
741                                 UpdateControls ();
742                         }
743                 }
744                 
745             [DefaultValueAttribute (ButtonType.Button)]\r
746                 public virtual ButtonType StepPreviousButtonType {
747                         get {
748                                 object v = ViewState ["StepPreviousButtonType"];
749                                 return v != null ? (ButtonType)v : ButtonType.Button;
750                         }
751                         set {
752                                 ViewState ["StepPreviousButtonType"] = value;
753                                 UpdateControls ();
754                         }
755                 }
756                 
757             [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]\r
758             [PersistenceModeAttribute (PersistenceMode.InnerProperty)]\r
759             [DefaultValueAttribute (null)]\r
760             [NotifyParentPropertyAttribute (true)]\r
761                 public TableItemStyle StepStyle {
762                         get {
763                                 if (stepStyle == null) {
764                                         stepStyle = new TableItemStyle ();
765                                         if (IsTrackingViewState)
766                                                 ((IStateManager)stepStyle).TrackViewState ();
767                                 }
768                                 return stepStyle;
769                         }
770                 }
771                 
772             [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]\r
773             [EditorAttribute ("System.Web.UI.Design.WebControls.WizardStepCollectionEditor," + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
774             [PersistenceModeAttribute (PersistenceMode.InnerProperty)]\r
775             [ThemeableAttribute (false)]\r
776                 public virtual WizardStepCollection WizardSteps {
777                         get {
778                                 if (steps == null)
779                                         steps = new WizardStepCollection (this);
780                                 return steps;
781                         }
782                 }
783
784                 [MonoTODO]
785                 protected virtual new HtmlTextWriterTag TagKey
786                 {
787                         get {
788                                 throw new NotImplementedException ();
789                         }
790                 }
791                 
792                 public ICollection GetHistory ()
793                 {
794                         if (history == null) history = new ArrayList ();
795                         return history;
796                 }
797                 
798                 public void MoveTo (WizardStepBase wizardStep)
799                 {
800                         if (wizardStep == null) throw new ArgumentNullException ("wizardStep");
801                         
802                         int i = WizardSteps.IndexOf (wizardStep);
803                         if (i == -1) throw new ArgumentException ("The provided wizard step does not belong to this wizard.");
804                         
805                         ActiveStepIndex = i;
806                 }
807                 
808                 public WizardStepType GetStepType (WizardStepBase wizardStep, int index)
809                 {
810                         if (wizardStep.StepType == WizardStepType.Auto) {
811                                 if (index == 0)
812                                         return WizardStepType.Start;
813                                 else if (index == WizardSteps.Count - 1)
814                                         return WizardStepType.Finish;
815                                 else
816                                         return WizardStepType.Step;
817                         } else
818                                 return wizardStep.StepType;
819                          
820                 }
821                 
822                 protected virtual bool AllowNavigationToStep (int index)
823                 {
824                         if (index < 0 || index >= WizardSteps.Count) return false;
825                         if (history == null) return true;
826                         if (!history.Contains (index)) return true;
827                         return WizardSteps [index].AllowReturn;
828                 } 
829                 
830                 protected internal override void OnInit (EventArgs e)
831                 {
832                         Page.RegisterRequiresControlState (this);
833                         base.OnInit (e);
834                 }
835                 
836                 protected override ControlCollection CreateControlCollection ()
837                 {
838                         ControlCollection col = new ControlCollection (this);
839                         col.SetReadonly (true);
840                         return col;
841                 }
842                 
843                 protected internal override void CreateChildControls ()
844                 {
845                         CreateControlHierarchy ();
846                 }
847                 
848                 protected virtual void CreateControlHierarchy ()
849                 {
850                         styles.Clear ();
851
852                         wizardTable = new Table ();
853                         wizardTable.CellPadding = CellPadding; 
854                         wizardTable.CellSpacing = CellSpacing; 
855                         
856                         AddHeaderRow (wizardTable);
857                         
858                         TableRow viewRow = new TableRow ();
859                         TableCell viewCell = new TableCell ();
860                         
861                         if (multiView == null) {
862                                 multiView = new MultiView ();
863                                 foreach (View v in WizardSteps)
864                                         multiView.Views.Add (v);
865                         }
866                         
867                         multiView.ActiveViewIndex = activeStepIndex;
868                         
869                         RegisterApplyStyle (viewCell, StepStyle);
870                         viewCell.Controls.Add (multiView);
871                         
872                         viewCell.Height = new Unit ("100%");
873                         viewRow.Cells.Add (viewCell);
874                         wizardTable.Rows.Add (viewRow);
875                         
876                         TableRow buttonRow = new TableRow ();
877                         TableCell buttonCell = new TableCell ();
878                         CreateButtonBar (buttonCell);
879                         buttonRow.Cells.Add (buttonCell);
880                         wizardTable.Rows.Add (buttonRow);
881                         
882                         if (DisplaySideBar && ActiveStep.StepType != WizardStepType.Complete) {
883                                 Table contentTable = wizardTable;
884                                 contentTable.Height = new Unit ("100%");
885                                 
886                                 wizardTable = new Table ();
887                                 wizardTable.CellPadding = CellPadding; 
888                                 wizardTable.CellSpacing = CellSpacing;
889                                 TableRow row = new TableRow ();
890                                 
891                                 TableCell sideBarCell = new TableCell ();
892                                 CreateSideBar (sideBarCell);
893                                 row.Cells.Add (sideBarCell);
894                                 
895                                 TableCell contentCell = new TableCell ();
896                                 contentCell.Controls.Add (contentTable);
897                                 row.Cells.Add (contentCell);
898                                 
899                                 wizardTable.Rows.Add (row);
900                         }
901                         
902                         Controls.SetReadonly (false);
903                         Controls.Add (wizardTable);
904                         Controls.SetReadonly (true);
905                 }
906                 
907                 void CreateButtonBar (TableCell buttonBarCell)
908                 {
909                         Table t = new Table ();
910                         TableRow row = new TableRow ();
911                         RegisterApplyStyle (buttonBarCell, NavigationStyle);
912                         
913                         WizardStepType stepType = GetStepType (ActiveStep, ActiveStepIndex);
914                         switch (stepType) {
915                                 case WizardStepType.Start:
916                                         if (startNavigationTemplate != null) {
917                                                 AddTemplateCell (row, startNavigationTemplate, StartNextButtonID, CancelButtonID);
918                                         } else {
919                                                 if (DisplayCancelButton)
920                                                         AddButtonCell (row, CreateButton (CancelButtonID, CancelCommandName, CancelButtonType, CancelButtonText, CancelButtonImageUrl, CancelButtonStyle));
921                                                 if (AllowNavigationToStep (ActiveStepIndex + 1))
922                                                         AddButtonCell (row, CreateButton (StartNextButtonID, MoveNextCommandName, StartNextButtonType, StartNextButtonText, StartNextButtonImageUrl, StartNextButtonStyle));
923                                         }
924                                         break;
925                                 case WizardStepType.Step:
926                                         if (stepNavigationTemplate != null) {
927                                                 AddTemplateCell (row, stepNavigationTemplate, StepPreviousButtonID, StepNextButtonID, CancelButtonID);
928                                         } else {
929                                                 if (DisplayCancelButton)
930                                                         AddButtonCell (row, CreateButton (CancelButtonID, CancelCommandName, CancelButtonType, CancelButtonText, CancelButtonImageUrl, CancelButtonStyle));
931                                                 if (AllowNavigationToStep (ActiveStepIndex - 1))
932                                                         AddButtonCell (row, CreateButton (StepPreviousButtonID, MovePreviousCommandName, StepPreviousButtonType, StepPreviousButtonText, StepPreviousButtonImageUrl, StepPreviousButtonStyle));
933                                                 if (AllowNavigationToStep (ActiveStepIndex + 1))
934                                                         AddButtonCell (row, CreateButton (StepNextButtonID, MoveNextCommandName, StepNextButtonType, StepNextButtonText, StepNextButtonImageUrl, StepNextButtonStyle));
935                                         }
936                                         break;
937                                 case WizardStepType.Finish:
938                                         if (finishNavigationTemplate != null) {
939                                                 AddTemplateCell (row, finishNavigationTemplate, FinishPreviousButtonID, FinishButtonID, CancelButtonID);
940                                         } else {
941                                                 if (DisplayCancelButton)
942                                                         AddButtonCell (row, CreateButton (CancelButtonID, CancelCommandName, CancelButtonType, CancelButtonText, CancelButtonImageUrl, CancelButtonStyle));
943                                                 if (AllowNavigationToStep (ActiveStepIndex - 1))
944                                                         AddButtonCell (row, CreateButton (FinishPreviousButtonID, MovePreviousCommandName, FinishPreviousButtonType, FinishPreviousButtonText, FinishPreviousButtonImageUrl, FinishPreviousButtonStyle));
945                                                 AddButtonCell (row, CreateButton (FinishButtonID, MoveCompleteCommandName, FinishCompleteButtonType, FinishCompleteButtonText, FinishCompleteButtonImageUrl, FinishCompleteButtonStyle));
946                                         }
947                                         break;
948                         }
949                         t.Rows.Add (row);
950                         buttonBarCell.Controls.Add (t);
951                 }
952                 
953                 Control CreateButton (string id, string command, ButtonType type, string text, string image, Style style)
954                 {
955                         DataControlButton b = new DataControlButton (this, text, image, command, "", false);
956                         b.ID = id;
957                         b.ButtonType = type;
958                         RegisterApplyStyle (b, NavigationButtonStyle);
959                         RegisterApplyStyle (b, style);
960                         return b;
961                 }
962                 
963                 void AddTemplateCell (TableRow row, ITemplate template, params string[] buttonIds)
964                 {
965                         TableCell cell = new TableCell ();
966                         template.InstantiateIn (cell);
967                         
968                         foreach (string id in buttonIds) {
969                                 IButtonControl b = cell.FindControl (id) as IButtonControl;
970                                 if (b != null) RegisterCommandEvents (b);
971                         }
972                         
973                         row.Cells.Add (cell);
974                 }
975                 
976                 void AddButtonCell (TableRow row, Control control)
977                 {
978                         TableCell cell = new TableCell ();
979                         cell.Controls.Add (control);
980                         row.Cells.Add (cell);
981                 }
982                 
983                 void CreateSideBar (TableCell sideBarCell)
984                 {
985                         RegisterApplyStyle (sideBarCell, SideBarStyle);
986                         
987                         if (sideBarTemplate != null) {
988                                 sideBarTemplate.InstantiateIn (sideBarCell);
989                                 stepDatalist = sideBarCell.FindControl (DataListID) as DataList;
990                                 if (stepDatalist == null)
991                                         throw new InvalidOperationException ("The side bar template must contain a DataList control with id '" + DataListID + "'.");
992                         } else {
993                                 stepDatalist = new DataList ();
994                                 stepDatalist.ID = DataListID;
995                                 sideBarCell.Controls.Add (stepDatalist);
996                         }
997
998                         stepDatalist.DataSource = WizardSteps;
999                         stepDatalist.ItemTemplate = sideBarItemTemplate;
1000                         stepDatalist.DataBind ();
1001                 }
1002                 
1003                 void AddHeaderRow (Table table)
1004                 {
1005                         if (HeaderText.Length != 0 || headerTemplate != null) {
1006                                 TableRow row = new TableRow ();
1007                                 TableCell cell = new TableCell ();
1008                                 RegisterApplyStyle (cell, HeaderStyle);
1009                                 if (headerTemplate != null)
1010                                         headerTemplate.InstantiateIn (cell);
1011                                 else
1012                                         cell.Text = HeaderText;
1013                                 row.Cells.Add (cell);
1014                                 table.Rows.Add (row);
1015                         }
1016                 }
1017                 
1018                 internal void RegisterApplyStyle (WebControl control, Style style)
1019                 {
1020                         styles.Add (new object[] { control, style });
1021                 }
1022                 
1023                 protected override Style CreateControlStyle ()
1024                 {
1025                         return new TableStyle ();
1026                 }
1027
1028                 [MonoTODO]
1029                 protected override IDictionary GetDesignModeState ()
1030                 {
1031                         throw new NotImplementedException ();
1032                 }
1033                 
1034                 protected internal override void LoadControlState (object ob)
1035                 {
1036                         if (ob == null) return;
1037                         object[] state = (object[]) ob;
1038                         base.LoadControlState (state[0]);
1039                         activeStepIndex = (int) state[1];
1040                         history = (ArrayList) state[2];
1041                 }
1042                 
1043                 protected internal override object SaveControlState ()
1044                 {
1045                         object bstate = base.SaveControlState ();
1046                         return new object[] {
1047                                 bstate, activeStepIndex, history
1048                         };
1049                 }
1050                 
1051                 protected override void LoadViewState (object savedState)
1052                 {
1053                         if (savedState == null) {
1054                                 base.LoadViewState (null);
1055                                 return;
1056                         }
1057                         
1058                         object[] states = (object[]) savedState;
1059                         base.LoadViewState (states [0]);
1060                         
1061                         if (states[1] != null) ((IStateManager)StepStyle).LoadViewState (states[1]);
1062                         if (states[2] != null) ((IStateManager)SideBarStyle).LoadViewState (states[2]);
1063                         if (states[3] != null) ((IStateManager)HeaderStyle).LoadViewState (states[3]);
1064                         if (states[4] != null) ((IStateManager)NavigationStyle).LoadViewState (states[4]);
1065                         if (states[5] != null) ((IStateManager)SideBarButtonStyle).LoadViewState (states[5]);
1066                         if (states[6] != null) ((IStateManager)CancelButtonStyle).LoadViewState (states[6]);
1067                         if (states[7] != null) ((IStateManager)FinishCompleteButtonStyle).LoadViewState (states[7]);
1068                         if (states[8] != null) ((IStateManager)FinishPreviousButtonStyle).LoadViewState (states[8]);
1069                         if (states[9] != null) ((IStateManager)StartNextButtonStyle).LoadViewState (states[9]);
1070                         if (states[10] != null) ((IStateManager)StepNextButtonStyle).LoadViewState (states[10]);
1071                         if (states[11] != null) ((IStateManager)StepPreviousButtonStyle).LoadViewState (states[11]);
1072                         if (states[12] != null) ((IStateManager)NavigationButtonStyle).LoadViewState (states[12]);
1073                 }
1074                 
1075                 protected override object SaveViewState ()
1076                 {
1077                         object[] state = new object [13];
1078                         state [0] = base.SaveViewState ();
1079                         
1080                         if (stepStyle != null) state [1] = ((IStateManager)stepStyle).SaveViewState ();
1081                         if (sideBarStyle != null) state [2] = ((IStateManager)sideBarStyle).SaveViewState ();
1082                         if (headerStyle != null) state [3] = ((IStateManager)headerStyle).SaveViewState ();
1083                         if (navigationStyle != null) state [4] = ((IStateManager)navigationStyle).SaveViewState ();
1084                         if (sideBarButtonStyle != null) state [5] = ((IStateManager)sideBarButtonStyle).SaveViewState ();
1085                         if (cancelButtonStyle != null) state [6] = ((IStateManager)cancelButtonStyle).SaveViewState ();
1086                         if (finishCompleteButtonStyle != null) state [7] = ((IStateManager)finishCompleteButtonStyle).SaveViewState ();
1087                         if (finishPreviousButtonStyle != null) state [8] = ((IStateManager)finishPreviousButtonStyle).SaveViewState ();
1088                         if (startNextButtonStyle != null) state [9] = ((IStateManager)startNextButtonStyle).SaveViewState ();
1089                         if (stepNextButtonStyle != null) state [10] = ((IStateManager)stepNextButtonStyle).SaveViewState ();
1090                         if (stepPreviousButtonStyle != null) state [11] = ((IStateManager)stepPreviousButtonStyle).SaveViewState ();
1091                         if (navigationButtonStyle != null) state [12] = ((IStateManager)navigationButtonStyle).SaveViewState ();
1092                         
1093                         for (int n=0; n<state.Length; n++)
1094                                 if (state [n] != null) return state;
1095                         return null;
1096                 }
1097                 
1098                 protected override void TrackViewState ()
1099                 {
1100                         base.TrackViewState();
1101                         if (stepStyle != null) ((IStateManager)stepStyle).TrackViewState();
1102                         if (sideBarStyle != null) ((IStateManager)sideBarStyle).TrackViewState();
1103                         if (headerStyle != null) ((IStateManager)headerStyle).TrackViewState();
1104                         if (navigationStyle != null) ((IStateManager)navigationStyle).TrackViewState();
1105                         if (sideBarButtonStyle != null) ((IStateManager)sideBarButtonStyle).TrackViewState();
1106                         if (cancelButtonStyle != null) ((IStateManager)cancelButtonStyle).TrackViewState();
1107                         if (finishCompleteButtonStyle != null) ((IStateManager)finishCompleteButtonStyle).TrackViewState();
1108                         if (finishPreviousButtonStyle != null) ((IStateManager)finishPreviousButtonStyle).TrackViewState();
1109                         if (startNextButtonStyle != null) ((IStateManager)startNextButtonStyle).TrackViewState();
1110                         if (stepNextButtonStyle != null) ((IStateManager)stepNextButtonStyle).TrackViewState();
1111                         if (stepPreviousButtonStyle != null) ((IStateManager)stepPreviousButtonStyle).TrackViewState();
1112                         if (navigationButtonStyle != null) ((IStateManager)navigationButtonStyle).TrackViewState();
1113                 }
1114                 
1115                 protected internal void RegisterCommandEvents (IButtonControl button)
1116                 {
1117                         button.Command += ProcessCommand;
1118                 }
1119                 
1120                 void ProcessCommand (object sender, CommandEventArgs args)
1121                 {
1122                         Control c = sender as Control;
1123                         if (c != null) {
1124                                 switch (c.ID) {
1125                                         case "CancelButton":
1126                                                 ProcessEvent ("Cancel", null);
1127                                                 return;
1128                                         case "FinishButton":
1129                                                 ProcessEvent ("MoveComplete", null);
1130                                                 return;
1131                                         case "StepPreviousButton":
1132                                         case "FinishPreviousButton":
1133                                                 ProcessEvent ("MovePrevious", null);
1134                                                 return;
1135                                         case "StartNextButton":
1136                                         case "StepNextButton":
1137                                                 ProcessEvent ("MoveNext", null);
1138                                                 return;
1139                                 }
1140                         }
1141                         ProcessEvent (args.CommandName, args.CommandArgument as string);
1142                 }
1143
1144                 protected override bool OnBubbleEvent (object source, EventArgs e)
1145                 {
1146                         CommandEventArgs args = e as CommandEventArgs;
1147                         if (args != null) {
1148                                 ProcessEvent (args.CommandName, args.CommandArgument as string);
1149                         }
1150                         return base.OnBubbleEvent (source, e);
1151                 }
1152                 
1153                 void ProcessEvent (string commandName, string commandArg)
1154                 {
1155                         switch (commandName) {
1156                                 case "Cancel":
1157                                         if (CancelDestinationPageUrl.Length > 0)
1158                                                 Context.Response.Redirect (CancelDestinationPageUrl);
1159                                         else
1160                                                 OnCancelButtonClick (EventArgs.Empty);
1161                                         break;
1162 \r
1163                                 case "MoveComplete":
1164                                         if (FinishDestinationPageUrl.Length > 0) {
1165                                                 Context.Response.Redirect (FinishDestinationPageUrl);
1166                                                 return;
1167                                         }
1168                                 
1169                                         int next = -1;
1170                                         for (int n=0; n<WizardSteps.Count; n++) {
1171                                                 if (WizardSteps [n].StepType == WizardStepType.Complete) {
1172                                                         next = n;
1173                                                         break;
1174                                                 }
1175                                         }
1176                                         if (next != -1) {
1177                                                 WizardNavigationEventArgs args = new WizardNavigationEventArgs (ActiveStepIndex, next);
1178                                                 OnFinishButtonClick (args);
1179                                                 if (!args.Cancel)
1180                                                         ActiveStepIndex = next;
1181                                         }
1182                                         break;
1183                                         \r
1184                                 case "MoveNext":
1185                                         if (ActiveStepIndex < WizardSteps.Count - 1) {\r
1186                                                 WizardNavigationEventArgs args = new WizardNavigationEventArgs (ActiveStepIndex, ActiveStepIndex + 1);
1187                                                 OnNextButtonClick (args);
1188                                                 if (!args.Cancel)
1189                                                         ActiveStepIndex++;
1190                                         }
1191                                         break;
1192                                                         
1193                                 case "MovePrevious":\r
1194                                         if (ActiveStepIndex > 0) {\r
1195                                                 WizardNavigationEventArgs args = new WizardNavigationEventArgs (ActiveStepIndex, ActiveStepIndex - 1);
1196                                                 OnPreviousButtonClick (args);
1197                                                 if (!args.Cancel)
1198                                                         ActiveStepIndex--;
1199                                         }
1200                                         break;
1201                                         
1202                                 case "Move":
1203                                         int newb = int.Parse (commandArg);
1204                                         ActiveStepIndex = newb;
1205                                         break;
1206                         }
1207                 }
1208                 
1209                 void UpdateControls ()
1210                 {
1211                         ChildControlsCreated = false;
1212                 }
1213                 
1214                 internal void UpdateViews ()
1215                 {
1216                         multiView = null;
1217                         UpdateControls ();
1218                 }
1219                 
1220                 protected internal override void Render (HtmlTextWriter writer)
1221                 {
1222                         wizardTable.ApplyStyle (ControlStyle);
1223
1224                         foreach (object[] styleDef in styles)
1225                                 ((WebControl)styleDef[0]).ApplyStyle ((Style)styleDef[1]);
1226                         
1227                         wizardTable.Render (writer);
1228                 }
1229                 
1230                 class SideBarButtonTemplate: ITemplate
1231                 {
1232                         Wizard wizard;
1233                         
1234                         public SideBarButtonTemplate (Wizard wizard)
1235                         {
1236                                 this.wizard = wizard;
1237                         }
1238                         
1239                         public void InstantiateIn (Control control)
1240                         {
1241                                 LinkButton b = new LinkButton ();
1242                                 wizard.RegisterApplyStyle (b, wizard.SideBarButtonStyle);
1243                                 control.Controls.Add (b);
1244                                 control.DataBinding += Bound;
1245                         }
1246                         
1247                         void Bound (object s, EventArgs args)
1248                         {
1249                                 WizardStepBase step = DataBinder.GetDataItem (s) as WizardStepBase;
1250                                 if (step != null) {
1251                                         Control c = (Control)s;
1252                                         LinkButton b = (LinkButton) c.Controls[0];
1253                                         b.ID = SideBarButtonID;
1254                                         b.CommandName = Wizard.MoveToCommandName;
1255                                         b.CommandArgument = wizard.WizardSteps.IndexOf (step).ToString ();
1256                                         b.Text = step.Title;
1257                                         if (step.StepType == WizardStepType.Complete)
1258                                                 b.Enabled = false;
1259                                         if (step == wizard.ActiveStep)
1260                                                 b.Font.Bold = true;
1261                                         wizard.RegisterCommandEvents (b);
1262                                 }
1263                         }
1264                 }
1265         }
1266 }
1267
1268 #endif