Author: lluis
Date: 2005-05-13 09:53:20 -0400 (Fri, 13 May 2005)
New Revision: 44499

Added:
   
trunk/mcs/class/System.Web/System.Web.UI.WebControls/WizardStepControlBuilder.cs
Modified:
   trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
   trunk/mcs/class/System.Web/System.Web.UI.WebControls/Wizard.cs
   trunk/mcs/class/System.Web/System.Web.UI.WebControls/WizardStep.cs
   trunk/mcs/class/System.Web/System.Web.UI.WebControls/WizardStepBase.cs
Log:
2005-05-13  Lluis Sanchez Gual <[EMAIL PROTECTED]>

        * WizardStepBase.cs:
        * WizardStep.cs: Added missing attributes.
        * Wizard.cs: Implemented missing methods and properties. It can now
        be considered feature complete.



Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog      
2005-05-13 13:52:46 UTC (rev 44498)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog      
2005-05-13 13:53:20 UTC (rev 44499)
@@ -1,3 +1,10 @@
+2005-05-13  Lluis Sanchez Gual <[EMAIL PROTECTED]>
+
+       * WizardStepBase.cs:
+       * WizardStep.cs: Added missing attributes.
+       * Wizard.cs: Implemented missing methods and properties. It can now
+       be considered feature complete.
+
 2005-05-10 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
 
        * DataGrid.cs: cleanup in AutoCreateColumns. Don't throw at the end of

Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/Wizard.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/Wizard.cs      
2005-05-13 13:52:46 UTC (rev 44498)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/Wizard.cs      
2005-05-13 13:53:20 UTC (rev 44499)
@@ -36,6 +36,9 @@
 
 namespace System.Web.UI.WebControls
 {
+       [DefaultEventAttribute ("FinishButtonClick")]
+       [BindableAttribute (false)]
+       [DesignerAttribute ("System.Web.UI.Design.WebControls.WizardDesigner, 
System.Design, Version=2.0.0.0, Culture=neutral, 
PublicKeyToken=b03f5f7f11d50a3a", "System.ComponentModel.Design.IDesigner")]
        public class Wizard: CompositeControl
        {
                public static readonly string CancelCommandName = "Cancel";
@@ -63,6 +66,7 @@
                TableItemStyle stepStyle;
                TableItemStyle sideBarStyle;
                TableItemStyle headerStyle;
+               TableItemStyle navigationStyle;
                Style sideBarButtonStyle;
                
                Style cancelButtonStyle;
@@ -74,15 +78,21 @@
                Style navigationButtonStyle;
                
                ITemplate finishNavigationTemplate;
+               ITemplate startNavigationTemplate;
+               ITemplate stepNavigationTemplate;
+               ITemplate headerTemplate;
+               ITemplate sideBarTemplate;
                
                // Control state
                
                int activeStepIndex;
+               ArrayList history;
 
-
                Table wizardTable;
                MultiView multiView;
+               DataList stepDatalist;
                ArrayList styles = new ArrayList ();
+               SideBarButtonTemplate sideBarItemTemplate;
                
                private static readonly object ActiveStepChangedEvent = new 
object();
                private static readonly object CancelButtonClickEvent = new 
object();
@@ -91,6 +101,11 @@
                private static readonly object PreviousButtonClickEvent = new 
object();
                private static readonly object SideBarButtonClickEvent = new 
object();
                
+               public Wizard ()
+               {
+                       sideBarItemTemplate = new SideBarButtonTemplate (this);
+               }
+               
                public event EventHandler ActiveStepChanged {
                        add { Events.AddHandler (ActiveStepChangedEvent, 
value); }
                        remove { Events.RemoveHandler (ActiveStepChangedEvent, 
value); }
@@ -169,6 +184,8 @@
                        }
                }
                
+           [DesignerSerializationVisibilityAttribute 
(DesignerSerializationVisibility.Hidden)]
+           [BrowsableAttribute (false)]
                public WizardStepBase ActiveStep {
                        get {
                                if (activeStepIndex < -1 || activeStepIndex >= 
steps.Count)
@@ -178,12 +195,22 @@
                        }
                }
                
+           [DefaultValueAttribute (-1)]
+           [ThemeableAttribute (false)]
                public int ActiveStepIndex {
-                       get { return activeStepIndex; }
+                       get {
+                               return activeStepIndex;
+                       }
                        set {
+                               if (!AllowNavigationToStep (value))
+                                       return;
+                               if (activeStepIndex != value) {
+                                       if (history == null) history = new 
ArrayList ();
+                                       history.Insert (0, activeStepIndex);
+                               }
                                activeStepIndex = value;
                                UpdateControls ();
-                               OnActiveStepChanged (this, EventArgs.Empty); 
+                               OnActiveStepChanged (this, EventArgs.Empty);
                        }
                }
                
@@ -240,6 +267,43 @@
                        }
                }
                
+           [UrlPropertyAttribute]
+           [EditorAttribute ("System.Web.UI.Design.ImageUrlEditor, 
System.Design, Version=2.0.0.0, Culture=neutral, 
PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, 
System.Drawing, Version=2.0.0.0, Culture=neutral, 
PublicKeyToken=b03f5f7f11d50a3a")]
+           [DefaultValueAttribute ("")]
+               public string CancelDestinationPageUrl {
+                       get {
+                               object v = ViewState 
["CancelDestinationPageUrl"];
+                               return v != null ? (string)v : string.Empty;
+                       }
+                       set {
+                               ViewState ["CancelDestinationPageUrl"] = value;
+                       }
+               }
+           
+           [DefaultValueAttribute (0)]
+               public int CellPadding {
+                       get {
+                               object v = ViewState ["CellPadding"];
+                               return v != null ? (int)v : 0;
+                       }
+                       set {
+                               ViewState ["CellPadding"] = value;
+                               UpdateControls ();
+                       }
+               }
+               
+           [DefaultValueAttribute (0)]
+               public int CellSpacing {
+                       get {
+                               object v = ViewState ["CellSpacing"];
+                               return v != null ? (int)v : 0;
+                       }
+                       set {
+                               ViewState ["CellSpacing"] = value;
+                               UpdateControls ();
+                       }
+               }
+               
            [DefaultValueAttribute (false)]
            [ThemeableAttribute (false)]
                public virtual bool DisplayCancelButton {
@@ -320,7 +384,29 @@
                }
                
            [UrlPropertyAttribute]
+           [EditorAttribute ("System.Web.UI.Design.ImageUrlEditor, 
System.Design, Version=2.0.0.0, Culture=neutral, 
PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, 
System.Drawing, Version=2.0.0.0, Culture=neutral, 
PublicKeyToken=b03f5f7f11d50a3a")]
            [DefaultValueAttribute ("")]
+               public 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 ITemplate FinishNavigationTemplate {
+                       get { return finishNavigationTemplate; }
+                       set { finishNavigationTemplate = value; UpdateControls 
(); }
+               }
+               
+           [UrlPropertyAttribute]
+           [DefaultValueAttribute ("")]
            [EditorAttribute ("System.Web.UI.Design.ImageUrlEditor, 
System.Design, Version=2.0.0.0, Culture=neutral, 
PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, 
System.Drawing, Version=2.0.0.0, Culture=neutral, 
PublicKeyToken=b03f5f7f11d50a3a")]
                public string FinishPreviousButtonImageUrl {
                        get {
@@ -387,6 +473,15 @@
                        }
                }
                
+               [DefaultValue (null)]
+               [TemplateContainer (typeof(Wizard), BindingDirection.OneWay)]
+               [PersistenceMode (PersistenceMode.InnerProperty)]
+           [Browsable (false)]
+               public ITemplate HeaderTemplate {
+                       get { return headerTemplate; }
+                       set { headerTemplate = value; UpdateControls (); }
+               }
+               
            [DefaultValueAttribute ("")]
            [LocalizableAttribute (true)]
                public string HeaderText {
@@ -415,8 +510,23 @@
                        }
                }
                
+           [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 {
@@ -445,6 +555,24 @@
                        }
                }
                
+               [DefaultValue (null)]
+               [TemplateContainer (typeof(Wizard), BindingDirection.OneWay)]
+               [PersistenceMode (PersistenceMode.InnerProperty)]
+           [Browsable (false)]
+               public ITemplate SideBarTemplate {
+                       get { return sideBarTemplate; }
+                       set { sideBarTemplate = value; UpdateControls (); }
+               }
+               
+               [DefaultValue (null)]
+               [TemplateContainer (typeof(Wizard), BindingDirection.OneWay)]
+               [PersistenceMode (PersistenceMode.InnerProperty)]
+           [Browsable (false)]
+               public ITemplate StartNavigationTemplate {
+                       get { return startNavigationTemplate; }
+                       set { startNavigationTemplate = value; UpdateControls 
(); }
+               }
+               
            [UrlPropertyAttribute]
            [DefaultValueAttribute ("")]
            [EditorAttribute ("System.Web.UI.Design.ImageUrlEditor, 
System.Design, Version=2.0.0.0, Culture=neutral, 
PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, 
System.Drawing, Version=2.0.0.0, Culture=neutral, 
PublicKeyToken=b03f5f7f11d50a3a")]
@@ -498,6 +626,15 @@
                        }
                }
                
+               [DefaultValue (null)]
+               [TemplateContainer (typeof(Wizard), BindingDirection.OneWay)]
+               [PersistenceMode (PersistenceMode.InnerProperty)]
+           [Browsable (false)]
+               public ITemplate StepNavigationTemplate {
+                       get { return stepNavigationTemplate; }
+                       set { stepNavigationTemplate = value; UpdateControls 
(); }
+               }
+               
            [UrlPropertyAttribute]
            [DefaultValueAttribute ("")]
            [EditorAttribute ("System.Web.UI.Design.ImageUrlEditor, 
System.Design, Version=2.0.0.0, Culture=neutral, 
PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, 
System.Drawing, Version=2.0.0.0, Culture=neutral, 
PublicKeyToken=b03f5f7f11d50a3a")]
@@ -619,6 +756,10 @@
                        }
                }
                
+           [DesignerSerializationVisibilityAttribute 
(DesignerSerializationVisibility.Content)]
+           [EditorAttribute 
("System.Web.UI.Design.WebControls.WizardStepCollectionEditor,System.Design, 
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", 
"System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, 
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
+           [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
+           [ThemeableAttribute (false)]
                public WizardStepCollection WizardSteps {
                        get {
                                if (steps == null)
@@ -627,8 +768,14 @@
                        }
                }
                
-               public void MoveTo (WizardStep wizardStep)
+               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);
@@ -637,12 +784,41 @@
                        ActiveStepIndex = i;
                }
                
+               public WizardStepType GetStepType (WizardStepBase wizardStep, 
int index)
+               {
+                       if (wizardStep.StepType == WizardStepType.Auto) {
+                               if (index == 0)
+                                       return WizardStepType.Start;
+                               else if (index == WizardSteps.Count - 1)
+                                       return WizardStepType.Finish;
+                               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 override void OnInit (EventArgs e)
                {
                        Page.RegisterRequiresControlState (this);
                        base.OnInit (e);
                }
                
+               protected override ControlCollection CreateControlCollection ()
+               {
+                       ControlCollection col = new ControlCollection (this);
+                       col.SetReadonly (true);
+                       return col;
+               }
+               
                protected override void CreateChildControls ()
                {
                        CreateControlHierarchy ();
@@ -653,6 +829,8 @@
                        styles.Clear ();
 
                        wizardTable = new Table ();
+                       wizardTable.CellPadding = CellPadding; 
+                       wizardTable.CellSpacing = CellSpacing; 
                        
                        AddHeaderRow (wizardTable);
                        
@@ -670,6 +848,7 @@
                        RegisterApplyStyle (viewCell, StepStyle);
                        viewCell.Controls.Add (multiView);
                        
+                       viewCell.Height = new Unit ("100%");
                        viewRow.Cells.Add (viewCell);
                        wizardTable.Rows.Add (viewRow);
                        
@@ -681,9 +860,13 @@
                        
                        if (DisplaySideBar && ActiveStep.StepType != 
WizardStepType.Complete) {
                                Table contentTable = wizardTable;
+                               contentTable.Height = new Unit ("100%");
+                               
                                wizardTable = new Table ();
+                               wizardTable.CellPadding = CellPadding; 
+                               wizardTable.CellSpacing = CellSpacing;
                                TableRow row = new TableRow ();
-                       
+                               
                                TableCell sideBarCell = new TableCell ();
                                CreateSideBar (sideBarCell);
                                row.Cells.Add (sideBarCell);
@@ -695,40 +878,51 @@
                                wizardTable.Rows.Add (row);
                        }
                        
+                       Controls.SetReadonly (false);
                        Controls.Add (wizardTable);
+                       Controls.SetReadonly (true);
                }
                
                void CreateButtonBar (TableCell buttonBarCell)
                {
                        Table t = new Table ();
                        TableRow row = new TableRow ();
+                       RegisterApplyStyle (buttonBarCell, NavigationStyle);
                        
-                       if (DisplayCancelButton)
-                               AddButtonCell (row, CreateButton 
(CancelButtonID, CancelCommandName, CancelButtonType, CancelButtonText, 
CancelButtonImageUrl, CancelButtonStyle));
-
-                       WizardStepType stepType;
-                       
-                       if (ActiveStep.StepType == WizardStepType.Auto) {
-                               if (ActiveStepIndex == 0)
-                                       stepType = WizardStepType.Start;
-                               else if (ActiveStepIndex == WizardSteps.Count - 
1)
-                                       stepType = WizardStepType.Finish;
-                               else
-                                       stepType = WizardStepType.Step;
-                       } else
-                               stepType = ActiveStep.StepType;
-                        
+                       WizardStepType stepType = GetStepType (ActiveStep, 
ActiveStepIndex);
                        switch (stepType) {
                                case WizardStepType.Start:
-                                       AddButtonCell (row, CreateButton 
(StartNextButtonID, MoveNextCommandName, StartNextButtonType, 
StartNextButtonText, StartNextButtonImageUrl, StartNextButtonStyle));
+                                       if (startNavigationTemplate != null) {
+                                               AddTemplateCell (row, 
startNavigationTemplate, StartNextButtonID, CancelButtonID);
+                                       } else {
+                                               if (DisplayCancelButton)
+                                                       AddButtonCell (row, 
CreateButton (CancelButtonID, CancelCommandName, CancelButtonType, 
CancelButtonText, CancelButtonImageUrl, CancelButtonStyle));
+                                               if (AllowNavigationToStep 
(ActiveStepIndex + 1))
+                                                       AddButtonCell (row, 
CreateButton (StartNextButtonID, MoveNextCommandName, StartNextButtonType, 
StartNextButtonText, StartNextButtonImageUrl, StartNextButtonStyle));
+                                       }
                                        break;
                                case WizardStepType.Step:
-                                       AddButtonCell (row, CreateButton 
(StepPreviousButtonID, MovePreviousCommandName, StepPreviousButtonType, 
StepPreviousButtonText, StepPreviousButtonImageUrl, StepPreviousButtonStyle));
-                                       AddButtonCell (row, CreateButton 
(StepNextButtonID, MoveNextCommandName, StepNextButtonType, StepNextButtonText, 
StepNextButtonImageUrl, StepNextButtonStyle));
+                                       if (stepNavigationTemplate != null) {
+                                               AddTemplateCell (row, 
stepNavigationTemplate, StepPreviousButtonID, StepNextButtonID, CancelButtonID);
+                                       } else {
+                                               if (DisplayCancelButton)
+                                                       AddButtonCell (row, 
CreateButton (CancelButtonID, CancelCommandName, CancelButtonType, 
CancelButtonText, CancelButtonImageUrl, CancelButtonStyle));
+                                               if (AllowNavigationToStep 
(ActiveStepIndex - 1))
+                                                       AddButtonCell (row, 
CreateButton (StepPreviousButtonID, MovePreviousCommandName, 
StepPreviousButtonType, StepPreviousButtonText, StepPreviousButtonImageUrl, 
StepPreviousButtonStyle));
+                                               if (AllowNavigationToStep 
(ActiveStepIndex + 1))
+                                                       AddButtonCell (row, 
CreateButton (StepNextButtonID, MoveNextCommandName, StepNextButtonType, 
StepNextButtonText, StepNextButtonImageUrl, StepNextButtonStyle));
+                                       }
                                        break;
                                case WizardStepType.Finish:
-                                       AddButtonCell (row, CreateButton 
(FinishPreviousButtonID, MovePreviousCommandName, FinishPreviousButtonType, 
FinishPreviousButtonText, FinishPreviousButtonImageUrl, 
FinishPreviousButtonStyle));
-                                       AddButtonCell (row, CreateButton 
(FinishButtonID, MoveCompleteCommandName, FinishCompleteButtonType, 
FinishCompleteButtonText, FinishCompleteButtonImageUrl, 
FinishCompleteButtonStyle));
+                                       if (finishNavigationTemplate != null) {
+                                               AddTemplateCell (row, 
finishNavigationTemplate, FinishPreviousButtonID, FinishButtonID, 
CancelButtonID);
+                                       } else {
+                                               if (DisplayCancelButton)
+                                                       AddButtonCell (row, 
CreateButton (CancelButtonID, CancelCommandName, CancelButtonType, 
CancelButtonText, CancelButtonImageUrl, CancelButtonStyle));
+                                               if (AllowNavigationToStep 
(ActiveStepIndex - 1))
+                                                       AddButtonCell (row, 
CreateButton (FinishPreviousButtonID, MovePreviousCommandName, 
FinishPreviousButtonType, FinishPreviousButtonText, 
FinishPreviousButtonImageUrl, FinishPreviousButtonStyle));
+                                               AddButtonCell (row, 
CreateButton (FinishButtonID, MoveCompleteCommandName, 
FinishCompleteButtonType, FinishCompleteButtonText, 
FinishCompleteButtonImageUrl, FinishCompleteButtonStyle));
+                                       }
                                        break;
                        }
                        t.Rows.Add (row);
@@ -745,6 +939,19 @@
                        return b;
                }
                
+               void AddTemplateCell (TableRow row, ITemplate template, params 
string[] buttonIds)
+               {
+                       TableCell cell = new TableCell ();
+                       template.InstantiateIn (cell);
+                       
+                       foreach (string id in buttonIds) {
+                               IButtonControl b = cell.FindControl (id) as 
IButtonControl;
+                               if (b != null) RegisterCommandEvents (b);
+                       }
+                       
+                       row.Cells.Add (cell);
+               }
+               
                void AddButtonCell (TableRow row, Control control)
                {
                        TableCell cell = new TableCell ();
@@ -755,22 +962,39 @@
                void CreateSideBar (TableCell sideBarCell)
                {
                        RegisterApplyStyle (sideBarCell, SideBarStyle);
-                       sideBarCell.Text = "Side bar";
+                       
+                       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 
+ "'.");
+                       } else {
+                               stepDatalist = new DataList ();
+                               stepDatalist.ID = DataListID;
+                               sideBarCell.Controls.Add (stepDatalist);
+                       }
+
+                       stepDatalist.DataSource = WizardSteps;
+                       stepDatalist.ItemTemplate = sideBarItemTemplate;
+                       stepDatalist.DataBind ();
                }
                
                void AddHeaderRow (Table table)
                {
-                       if (HeaderText.Length != 0) {
+                       if (HeaderText.Length != 0 || headerTemplate != null) {
                                TableRow row = new TableRow ();
                                TableCell cell = new TableCell ();
                                RegisterApplyStyle (cell, HeaderStyle);
-                               cell.Text = HeaderText;
+                               if (headerTemplate != null)
+                                       headerTemplate.InstantiateIn (cell);
+                               else
+                                       cell.Text = HeaderText;
                                row.Cells.Add (cell);
                                table.Rows.Add (row);
                        }
                }
                
-               void RegisterApplyStyle (WebControl control, Style style)
+               internal void RegisterApplyStyle (WebControl control, Style 
style)
                {
                        styles.Add (new object[] { control, style });
                }
@@ -786,15 +1010,109 @@
                        object[] state = (object[]) ob;
                        base.LoadControlState (state[0]);
                        activeStepIndex = (int) state[1];
+                       history = (ArrayList) state[2];
                }
                
                protected internal override object SaveControlState ()
                {
                        object bstate = base.SaveControlState ();
                        return new object[] {
-                               bstate, activeStepIndex
+                               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]);
+               }
+               
+               protected override object SaveViewState ()
+               {
+                       object[] state = new object [13];
+                       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 ();
+                       
+                       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();
+               }
+               
+               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)
                {
@@ -809,10 +1127,18 @@
                {
                        switch (commandName) {
                                case "Cancel":
-                                       OnCancelButtonClick (EventArgs.Empty);
+                                       if (CancelDestinationPageUrl.Length > 0)
+                                               Context.Response.Redirect 
(CancelDestinationPageUrl);
+                                       else
+                                               OnCancelButtonClick 
(EventArgs.Empty);
                                        break;
 
                                case "MoveComplete":
+                                       if (FinishDestinationPageUrl.Length > 
0) {
+                                               Context.Response.Redirect 
(FinishDestinationPageUrl);
+                                               return;
+                                       }
+                               
                                        int next = -1;
                                        for (int n=0; n<WizardSteps.Count; n++) 
{
                                                if (WizardSteps [n].StepType == 
WizardStepType.Complete) {
@@ -872,7 +1198,43 @@
                                ((WebControl)styleDef[0]).ApplyStyle 
((Style)styleDef[1]);
                        
                        wizardTable.Render (writer);
-               }  
+               }
+               
+               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) {
+                                       Control c = (Control)s;
+                                       LinkButton b = (LinkButton) 
c.Controls[0];
+                                       b.ID = SideBarButtonID;
+                                       b.CommandName = 
Wizard.MoveToCommandName;
+                                       b.CommandArgument = 
wizard.WizardSteps.IndexOf (step).ToString ();
+                                       b.Text = step.Title;
+                                       if (step.StepType == 
WizardStepType.Complete)
+                                               b.Enabled = false;
+                                       if (step == wizard.ActiveStep)
+                                               b.Font.Bold = true;
+                                       wizard.RegisterCommandEvents (b);
+                               }
+                       }
+               }
        }
 }
 

Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/WizardStep.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/WizardStep.cs  
2005-05-13 13:52:46 UTC (rev 44498)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/WizardStep.cs  
2005-05-13 13:53:20 UTC (rev 44499)
@@ -35,7 +35,7 @@
 
 namespace System.Web.UI.WebControls
 {
-//     [ControlBuilderAttribute (typeof(WizardStepControlBuilder))]
+       [ControlBuilderAttribute (typeof(WizardStepControlBuilder))]
        [ToolboxItemAttribute ("")]
        [BindableAttribute (false)]
        public sealed class WizardStep: WizardStepBase 

Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/WizardStepBase.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/WizardStepBase.cs      
2005-05-13 13:52:46 UTC (rev 44498)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/WizardStepBase.cs      
2005-05-13 13:53:20 UTC (rev 44499)
@@ -35,13 +35,16 @@
 
 namespace System.Web.UI.WebControls
 {
-//     [ControlBuilderAttribute (typeof(WizardStepControlBuilder))]
+       [ControlBuilderAttribute (typeof(WizardStepControlBuilder))]
        [BindableAttribute (false)]
        [ToolboxItemAttribute ("")]
        public abstract class WizardStepBase: View
        {
                Wizard wizard;
                
+           [DefaultValueAttribute (true)]
+           [ThemeableAttribute (false)]
+           [FilterableAttribute (false)]
                public virtual bool AllowReturn {
                        get {
                                object v = ViewState ["AllowReturn"];
@@ -52,6 +55,8 @@
                        }
                }
                
+           [DesignerSerializationVisibilityAttribute 
(DesignerSerializationVisibility.Hidden)]
+           [BrowsableAttribute (false)]
                public string Name {
                        get {
                                if (Title.Length > 0) return Title;
@@ -60,6 +65,7 @@
                        }
                }
                
+           [DefaultValueAttribute (WizardStepType.Auto)]
                public virtual WizardStepType StepType {
                        get {
                                object v = ViewState ["StepType"];
@@ -70,6 +76,8 @@
                        }
                }
                
+           [DefaultValueAttribute ("")]
+           [LocalizableAttribute (true)]
                public virtual string Title {
                        get {
                                object v = ViewState ["Title"];
@@ -80,6 +88,8 @@
                        }
                }
                
+           [EditorBrowsableAttribute (EditorBrowsableState.Advanced)]
+           [BrowsableAttribute (false)]
                public Wizard Wizard {
                        get { return wizard; }
                }

Added: 
trunk/mcs/class/System.Web/System.Web.UI.WebControls/WizardStepControlBuilder.cs
===================================================================
--- 
trunk/mcs/class/System.Web/System.Web.UI.WebControls/WizardStepControlBuilder.cs
    2005-05-13 13:52:46 UTC (rev 44498)
+++ 
trunk/mcs/class/System.Web/System.Web.UI.WebControls/WizardStepControlBuilder.cs
    2005-05-13 13:53:20 UTC (rev 44499)
@@ -0,0 +1,40 @@
+//
+// System.Web.UI.WebControls.WizardStepControlBuilder
+//
+// 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
+
+namespace System.Web.UI.WebControls
+{
+       public sealed class WizardStepControlBuilder: ControlBuilder
+       {
+       } 
+}
+
+#endif

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to