Wizard.cs 41 KB

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