Fixing an issue with output parameters that are of type IntPtr
[castle.git] / MonoRail / Castle.MonoRail.Framework / Helpers / WizardHelper.cs
blob2e6457025b0ff9978e64dbee72e5c43d11e88e1e
1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle.MonoRail.Framework.Helpers
17 using System;
18 using System.Collections;
20 using Castle.MonoRail.Framework.Internal;
22 /// <summary>
23 /// Provide useful helpers to be used in a layout view
24 /// or in the wizards steps views.
25 /// </summary>
26 public class WizardHelper : HtmlHelper
28 #region Constructors
30 /// <summary>
31 /// Initializes a new instance of the <see cref="WizardHelper"/> class.
32 /// </summary>
33 public WizardHelper() { }
35 /// <summary>
36 /// Initializes a new instance of the <see cref="WizardHelper"/> class.
37 /// setting the Controller, Context and ControllerContext.
38 /// </summary>
39 /// <param name="engineContext">The engine context.</param>
40 public WizardHelper(IEngineContext engineContext) : base(engineContext) { }
42 #endregion
44 /// <summary>
45 /// Returns <c>true</c> if the current wizard
46 /// flow has a next step.
47 /// </summary>
48 /// <returns></returns>
49 public bool HasNextStep()
51 return WizardUtils.HasNextStep(Context, Controller, ControllerContext);
54 /// <summary>
55 /// Returns <c>true</c> if the current wizard
56 /// flow has an accessible previous step.
57 /// </summary>
58 /// <remarks>
59 /// This will only return <c>true</c> if not
60 /// the first step
61 /// </remarks>
62 /// <returns></returns>
63 public bool HasPreviousStep()
65 return WizardUtils.HasPreviousStep(Context, Controller, ControllerContext);
68 /// <summary>
69 /// Gets the name of the current step.
70 /// </summary>
71 /// <value>The name of the current step.</value>
72 public int CurrentStepIndex
74 get { return WizardUtils.GetCurrentStepIndex(Context, Controller, ControllerContext); }
77 /// <summary>
78 /// Returns the name of the previous step
79 /// </summary>
80 public String PreviousStepName
82 get { return WizardUtils.GetPreviousStepName(Context, Controller, ControllerContext); }
85 /// <summary>
86 /// Gets the name of the current step.
87 /// </summary>
88 /// <value>The name of the current step.</value>
89 public string CurrentStepName
91 get { return WizardUtils.GetCurrentStepName(Context, Controller, ControllerContext); }
94 /// <summary>
95 /// Returns the name of the next step
96 /// </summary>
97 public String NextStepName
99 get { return WizardUtils.GetNextStepName(Context, Controller, ControllerContext); }
102 /// <summary>
103 /// Gets a wizard step name by index.
104 /// </summary>
105 /// <param name="stepindex">The stepindex.</param>
106 /// <returns></returns>
107 public String GetStepName(int stepindex)
109 return WizardUtils.GetStepName(stepindex, Context, Controller, ControllerContext);
112 #region LinkToStep
114 /// <overloads>This method has three overloads.</overloads>
115 /// <summary>
116 /// Creates an anchor tag (link) to the specified step.
117 /// <code>
118 /// &lt;a href=&quot;/page2.rails&quot;&gt;linkText&lt;/a&gt;
119 /// </code>
120 /// </summary>
121 /// <param name="linkText">The label for the step</param>
122 /// <param name="step">The WizardStepPage to link to</param>
123 /// <returns></returns>
124 public String LinkToStep(String linkText, IWizardStepPage step)
126 return LinkTo(linkText, step.WizardControllerContext.Name, step.ActionName);
129 /// <summary>
130 /// Creates an anchor tag (link) to the specified step.
131 /// <code>
132 /// &lt;a href=&quot;/page2.rails&quot;&gt;linkText&lt;/a&gt;
133 /// </code>
134 /// </summary>
135 /// <param name="linkText">The label for the step</param>
136 /// <param name="step">The WizardStepPage to link to</param>
137 /// <param name="id">Object to use for the action ID argument.</param>
138 /// <returns></returns>
139 public String LinkToStep(String linkText, IWizardStepPage step, object id)
141 return LinkTo(linkText, step.WizardControllerContext.Name, step.ActionName, id);
144 /// <summary>
145 /// Creates an anchor tag (link) to the specified step.
146 /// <code>
147 /// &lt;a href=&quot;/page2.rails&quot;&gt;linkText&lt;/a&gt;
148 /// </code>
149 /// </summary>
150 /// <param name="linkText">The label for the step</param>
151 /// <param name="step">The WizardStepPage to link to</param>
152 /// <param name="id">Object to use for the action ID argument.</param>
153 /// <param name="attributes">Additional attributes for the <b>a</b> tag.</param>
154 /// <returns></returns>
155 public String LinkToStep(String linkText, IWizardStepPage step, object id, IDictionary attributes)
157 return LinkToAttributed(linkText, step.WizardControllerContext.Name, step.ActionName, id, attributes);
160 #endregion
162 #region LinkToNext and LinkToPrevious
164 /// <overloads>This method has four overloads.</overloads>
165 /// <summary>
166 /// Creates an anchor tag (link) to the next step.
167 /// <code>
168 /// &lt;a href=&quot;/page2.rails&quot;&gt;linkText&lt;/a&gt;
169 /// </code>
170 /// </summary>
171 /// <remarks>
172 /// This helper assumes there is a next step. It's advised
173 /// that you use <see cref="HasNextStep"/> before calling this
174 /// </remarks>
175 /// <param name="linkText">The label for the link</param>
176 /// <returns></returns>
177 public String LinkToNext(String linkText)
179 return LinkTo( linkText, ControllerContext.Name, NextStepName );
182 /// <summary>
183 /// Creates an anchor tag (link) to the next step.
184 /// <code>
185 /// &lt;a href=&quot;/page2.rails&quot;&gt;linkText&lt;/a&gt;
186 /// </code>
187 /// </summary>
188 /// <remarks>
189 /// This helper assumes there is a next step. It's advised
190 /// that you use <see cref="HasNextStep"/> before calling this
191 /// </remarks>
192 /// <param name="linkText">The label for the link</param>
193 /// <param name="attributes">Additional attributes for the <b>a</b> tag.</param>
194 /// <returns></returns>
195 public String LinkToNext(String linkText, IDictionary attributes)
197 return LinkToAttributed(linkText, ControllerContext.Name, NextStepName, attributes);
200 /// <summary>
201 /// Creates an anchor tag (link) with an id attribute to the next step.
202 /// <code>
203 /// &lt;a href=&quot;/page2.rails?Id=id&quot;&gt;linkText&lt;/a&gt;
204 /// </code>
205 /// </summary>
206 /// <remarks>
207 /// This helper assumes there is a next step. It's advised
208 /// that you use <see cref="HasNextStep"/> before calling this
209 /// </remarks>
210 /// <param name="linkText">The label for the link</param>
211 /// <param name="id">Object to use for the action ID argument.</param>
212 /// <returns></returns>
213 public String LinkToNext(String linkText, object id)
215 return LinkTo(linkText, ControllerContext.Name, NextStepName, id);
218 /// <summary>
219 /// Creates an anchor tag (link) with an id attribute to the next step.
220 /// <code>
221 /// &lt;a href=&quot;/page2.rails?Id=id&quot;&gt;linkText&lt;/a&gt;
222 /// </code>
223 /// </summary>
224 /// <remarks>
225 /// This helper assumes there is a previous step. It's advised
226 /// that you use <see cref="HasNextStep"/> before calling this
227 /// </remarks>
228 /// <param name="linkText">The label for the link</param>
229 /// <param name="id">Object to use for the action ID argument.</param>
230 /// <param name="attributes">Additional attributes for the <b>a</b> tag.</param>
231 /// <returns></returns>
232 public String LinkToNext(String linkText, object id, IDictionary attributes)
234 return LinkToAttributed(linkText, ControllerContext.Name, NextStepName, id, attributes);
237 /// <overloads>This method has four overloads.</overloads>
238 /// <summary>
239 /// Creates an anchor tag (link) to the previous step.
240 /// <code>
241 /// &lt;a href=&quot;/page2.rails&quot;&gt;linkText&lt;/a&gt;
242 /// </code>
243 /// </summary>
244 /// <remarks>
245 /// This helper assumes there is a previous step. It's advised
246 /// that you use <see cref="HasPreviousStep"/> before calling this
247 /// </remarks>
248 /// <param name="linkText">The label for the link</param>
249 /// <returns></returns>
250 public String LinkToPrevious(String linkText)
252 return LinkTo(linkText, ControllerContext.Name, PreviousStepName);
255 /// <summary>
256 /// Creates an anchor tag (link) to the previous step.
257 /// <code>
258 /// &lt;a href=&quot;/page2.rails&quot;&gt;linkText&lt;/a&gt;
259 /// </code>
260 /// </summary>
261 /// <remarks>
262 /// This helper assumes there is a previous step. It's advised
263 /// that you use <see cref="HasPreviousStep"/> before calling this
264 /// </remarks>
265 /// <param name="linkText">The label for the link</param>
266 /// <param name="attributes">Additional attributes for the <b>a</b> tag.</param>
267 /// <returns></returns>
268 public String LinkToPrevious(String linkText, IDictionary attributes)
270 return LinkToAttributed(linkText, ControllerContext.Name, PreviousStepName, attributes);
273 /// <summary>
274 /// Creates an anchor tag (link) with an id attribute to the previous step.
275 /// <code>
276 /// &lt;a href=&quot;/page2.rails?Id=id&quot;&gt;linkText&lt;/a&gt;
277 /// </code>
278 /// </summary>
279 /// <remarks>
280 /// This helper assumes there is a previous step. It's advised
281 /// that you use <see cref="HasPreviousStep"/> before calling this
282 /// </remarks>
283 /// <param name="linkText">The label for the link</param>
284 /// <param name="id">Object to use for the action ID argument.</param>
285 /// <returns></returns>
286 public String LinkToPrevious(String linkText, object id)
288 return LinkTo(linkText, ControllerContext.Name, PreviousStepName, id);
291 /// <summary>
292 /// Creates an anchor tag (link) with an id attribute to the previous step.
293 /// <code>
294 /// &lt;a href=&quot;/page2.rails?Id=id&quot;&gt;linkText&lt;/a&gt;
295 /// </code>
296 /// </summary>
297 /// <remarks>
298 /// This helper assumes there is a previous step. It's advised
299 /// that you use <see cref="HasPreviousStep"/> before calling this
300 /// </remarks>
301 /// <param name="linkText">The label for the link</param>
302 /// <param name="id">Object to use for the action ID argument.</param>
303 /// <param name="attributes">Additional attributes for the <b>a</b> tag.</param>
304 /// <returns></returns>
305 public String LinkToPrevious(String linkText, object id, IDictionary attributes)
307 return LinkToAttributed(linkText, ControllerContext.Name, PreviousStepName, id, attributes);
310 #endregion