Wizard.cs 43 KB

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