Wizard.cs 41 KB

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