Wizard.cs 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781
  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 = -1;
  78. bool inited = false;
  79. ArrayList history;
  80. Table wizardTable;
  81. WizardHeaderCell _headerCell;
  82. TableCell _navigationCell;
  83. StartNavigationContainer _startNavContainer;
  84. StepNavigationContainer _stepNavContainer;
  85. FinishNavigationContainer _finishNavContainer;
  86. MultiView multiView;
  87. DataList stepDatalist;
  88. ArrayList styles = new ArrayList ();
  89. Hashtable customNavigation;
  90. static readonly object ActiveStepChangedEvent = new object();
  91. static readonly object CancelButtonClickEvent = new object();
  92. static readonly object FinishButtonClickEvent = new object();
  93. static readonly object NextButtonClickEvent = new object();
  94. static readonly object PreviousButtonClickEvent = new object();
  95. static readonly object SideBarButtonClickEvent = new object();
  96. public event EventHandler ActiveStepChanged {
  97. add { Events.AddHandler (ActiveStepChangedEvent, value); }
  98. remove { Events.RemoveHandler (ActiveStepChangedEvent, value); }
  99. }
  100. public event EventHandler CancelButtonClick {
  101. add { Events.AddHandler (CancelButtonClickEvent, value); }
  102. remove { Events.RemoveHandler (CancelButtonClickEvent, value); }
  103. }
  104. public event WizardNavigationEventHandler FinishButtonClick {
  105. add { Events.AddHandler (FinishButtonClickEvent, value); }
  106. remove { Events.RemoveHandler (FinishButtonClickEvent, value); }
  107. }
  108. public event WizardNavigationEventHandler NextButtonClick {
  109. add { Events.AddHandler (NextButtonClickEvent, value); }
  110. remove { Events.RemoveHandler (NextButtonClickEvent, value); }
  111. }
  112. public event WizardNavigationEventHandler PreviousButtonClick {
  113. add { Events.AddHandler (PreviousButtonClickEvent, value); }
  114. remove { Events.RemoveHandler (PreviousButtonClickEvent, value); }
  115. }
  116. public event WizardNavigationEventHandler SideBarButtonClick {
  117. add { Events.AddHandler (SideBarButtonClickEvent, value); }
  118. remove { Events.RemoveHandler (SideBarButtonClickEvent, value); }
  119. }
  120. protected virtual void OnActiveStepChanged (object source, EventArgs e)
  121. {
  122. if (Events != null) {
  123. EventHandler eh = (EventHandler) Events [ActiveStepChangedEvent];
  124. if (eh != null) eh (source, e);
  125. }
  126. }
  127. protected virtual void OnCancelButtonClick (EventArgs e)
  128. {
  129. if (Events != null) {
  130. EventHandler eh = (EventHandler) Events [CancelButtonClickEvent];
  131. if (eh != null) eh (this, e);
  132. }
  133. }
  134. protected virtual void OnFinishButtonClick (WizardNavigationEventArgs e)
  135. {
  136. if (Events != null) {
  137. WizardNavigationEventHandler eh = (WizardNavigationEventHandler) Events [FinishButtonClickEvent];
  138. if (eh != null) eh (this, e);
  139. }
  140. }
  141. protected virtual void OnNextButtonClick (WizardNavigationEventArgs e)
  142. {
  143. if (Events != null) {
  144. WizardNavigationEventHandler eh = (WizardNavigationEventHandler) Events [NextButtonClickEvent];
  145. if (eh != null) eh (this, e);
  146. }
  147. }
  148. protected virtual void OnPreviousButtonClick (WizardNavigationEventArgs e)
  149. {
  150. if (Events != null) {
  151. WizardNavigationEventHandler eh = (WizardNavigationEventHandler) Events [PreviousButtonClickEvent];
  152. if (eh != null) eh (this, e);
  153. }
  154. }
  155. protected virtual void OnSideBarButtonClick (WizardNavigationEventArgs e)
  156. {
  157. if (Events != null) {
  158. WizardNavigationEventHandler eh = (WizardNavigationEventHandler) Events [SideBarButtonClickEvent];
  159. if (eh != null) eh (this, e);
  160. }
  161. }
  162. [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
  163. [BrowsableAttribute (false)]
  164. public WizardStepBase ActiveStep {
  165. get {
  166. if (ActiveStepIndex < -1 || ActiveStepIndex >= WizardSteps.Count)
  167. throw new InvalidOperationException ("ActiveStepIndex has an invalid value.");
  168. if (ActiveStepIndex == -1) return null;
  169. return WizardSteps [activeStepIndex];
  170. }
  171. }
  172. [DefaultValueAttribute (-1)]
  173. [ThemeableAttribute (false)]
  174. public virtual int ActiveStepIndex {
  175. get {
  176. return activeStepIndex;
  177. }
  178. set {
  179. if (value < -1 || (value > WizardSteps.Count && (inited || WizardSteps.Count > 0)))
  180. throw new ArgumentOutOfRangeException ("The ActiveStepIndex must be less than WizardSteps.Count and at least -1");
  181. if (inited && !AllowNavigationToStep (value))
  182. return;
  183. if(activeStepIndex != value) {
  184. activeStepIndex = value;
  185. if (inited) {
  186. multiView.ActiveViewIndex = value;
  187. if (stepDatalist != null) {
  188. stepDatalist.SelectedIndex = value;
  189. stepDatalist.DataBind ();
  190. }
  191. OnActiveStepChanged (this, EventArgs.Empty);
  192. }
  193. }
  194. }
  195. }
  196. [UrlPropertyAttribute]
  197. [DefaultValueAttribute ("")]
  198. [EditorAttribute ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
  199. public virtual string CancelButtonImageUrl {
  200. get {
  201. object v = ViewState ["CancelButtonImageUrl"];
  202. return v != null ? (string)v : string.Empty;
  203. }
  204. set {
  205. ViewState ["CancelButtonImageUrl"] = value;
  206. }
  207. }
  208. [DefaultValueAttribute (null)]
  209. [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]
  210. [NotifyParentPropertyAttribute (true)]
  211. [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
  212. public Style CancelButtonStyle {
  213. get {
  214. if (cancelButtonStyle == null) {
  215. cancelButtonStyle = new Style ();
  216. if (IsTrackingViewState)
  217. ((IStateManager)cancelButtonStyle).TrackViewState ();
  218. }
  219. return cancelButtonStyle;
  220. }
  221. }
  222. [LocalizableAttribute (true)]
  223. public virtual string CancelButtonText {
  224. get {
  225. object v = ViewState ["CancelButtonText"];
  226. return v != null ? (string)v : "Cancel";
  227. }
  228. set {
  229. ViewState ["CancelButtonText"] = value;
  230. }
  231. }
  232. [DefaultValueAttribute (ButtonType.Button)]
  233. public virtual ButtonType CancelButtonType {
  234. get {
  235. object v = ViewState ["CancelButtonType"];
  236. return v != null ? (ButtonType)v : ButtonType.Button;
  237. }
  238. set {
  239. ViewState ["CancelButtonType"] = value;
  240. }
  241. }
  242. [UrlPropertyAttribute]
  243. [EditorAttribute ("System.Web.UI.Design.UrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
  244. [DefaultValueAttribute ("")]
  245. public virtual string CancelDestinationPageUrl {
  246. get {
  247. object v = ViewState ["CancelDestinationPageUrl"];
  248. return v != null ? (string)v : string.Empty;
  249. }
  250. set {
  251. ViewState ["CancelDestinationPageUrl"] = value;
  252. }
  253. }
  254. [DefaultValueAttribute (0)]
  255. public virtual int CellPadding {
  256. get {
  257. if (ControlStyleCreated)
  258. return ((TableStyle) ControlStyle).CellPadding;
  259. return 0;
  260. }
  261. set {
  262. ((TableStyle) ControlStyle).CellPadding = value;
  263. }
  264. }
  265. [DefaultValueAttribute (0)]
  266. public virtual int CellSpacing {
  267. get {
  268. if (ControlStyleCreated)
  269. return ((TableStyle) ControlStyle).CellSpacing;
  270. return 0;
  271. }
  272. set {
  273. ((TableStyle) ControlStyle).CellSpacing = value;
  274. }
  275. }
  276. [DefaultValueAttribute (false)]
  277. [ThemeableAttribute (false)]
  278. public virtual bool DisplayCancelButton {
  279. get {
  280. object v = ViewState ["DisplayCancelButton"];
  281. return v != null ? (bool) v : false;
  282. }
  283. set {
  284. ViewState ["DisplayCancelButton"] = value;
  285. }
  286. }
  287. [DefaultValueAttribute (true)]
  288. [ThemeableAttribute (false)]
  289. public virtual bool DisplaySideBar {
  290. get {
  291. object v = ViewState ["DisplaySideBar"];
  292. return v != null ? (bool) v : true;
  293. }
  294. set {
  295. ViewState ["DisplaySideBar"] = value;
  296. UpdateViews ();
  297. }
  298. }
  299. [UrlPropertyAttribute]
  300. [DefaultValueAttribute ("")]
  301. [EditorAttribute ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
  302. public virtual string FinishCompleteButtonImageUrl {
  303. get {
  304. object v = ViewState ["FinishCompleteButtonImageUrl"];
  305. return v != null ? (string)v : string.Empty;
  306. }
  307. set {
  308. ViewState ["FinishCompleteButtonImageUrl"] = value;
  309. }
  310. }
  311. [DefaultValueAttribute (null)]
  312. [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]
  313. [NotifyParentPropertyAttribute (true)]
  314. [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
  315. public Style FinishCompleteButtonStyle {
  316. get {
  317. if (finishCompleteButtonStyle == null) {
  318. finishCompleteButtonStyle = new Style ();
  319. if (IsTrackingViewState)
  320. ((IStateManager)finishCompleteButtonStyle).TrackViewState ();
  321. }
  322. return finishCompleteButtonStyle;
  323. }
  324. }
  325. [LocalizableAttribute (true)]
  326. public virtual string FinishCompleteButtonText {
  327. get {
  328. object v = ViewState ["FinishCompleteButtonText"];
  329. return v != null ? (string)v : "Finish";
  330. }
  331. set {
  332. ViewState ["FinishCompleteButtonText"] = value;
  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. }
  344. }
  345. [UrlPropertyAttribute]
  346. [EditorAttribute ("System.Web.UI.Design.UrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
  347. [DefaultValueAttribute ("")]
  348. public virtual string FinishDestinationPageUrl {
  349. get {
  350. object v = ViewState ["FinishDestinationPageUrl"];
  351. return v != null ? (string)v : string.Empty;
  352. }
  353. set {
  354. ViewState ["FinishDestinationPageUrl"] = value;
  355. }
  356. }
  357. [DefaultValue (null)]
  358. [TemplateContainer (typeof(Wizard), BindingDirection.OneWay)]
  359. [PersistenceMode (PersistenceMode.InnerProperty)]
  360. [Browsable (false)]
  361. public virtual ITemplate FinishNavigationTemplate {
  362. get { return finishNavigationTemplate; }
  363. set { finishNavigationTemplate = value; UpdateViews (); }
  364. }
  365. [UrlPropertyAttribute]
  366. [DefaultValueAttribute ("")]
  367. [EditorAttribute ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
  368. public virtual string FinishPreviousButtonImageUrl {
  369. get {
  370. object v = ViewState ["FinishPreviousButtonImageUrl"];
  371. return v != null ? (string)v : string.Empty;
  372. }
  373. set {
  374. ViewState ["FinishPreviousButtonImageUrl"] = value;
  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. }
  400. }
  401. [DefaultValueAttribute (ButtonType.Button)]
  402. public virtual ButtonType FinishPreviousButtonType {
  403. get {
  404. object v = ViewState ["FinishPreviousButtonType"];
  405. return v != null ? (ButtonType)v : ButtonType.Button;
  406. }
  407. set {
  408. ViewState ["FinishPreviousButtonType"] = value;
  409. }
  410. }
  411. [DefaultValueAttribute (null)]
  412. [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]
  413. [NotifyParentPropertyAttribute (true)]
  414. [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
  415. public TableItemStyle HeaderStyle {
  416. get {
  417. if (headerStyle == null) {
  418. headerStyle = new TableItemStyle ();
  419. if (IsTrackingViewState)
  420. ((IStateManager)headerStyle).TrackViewState ();
  421. }
  422. return headerStyle;
  423. }
  424. }
  425. [DefaultValue (null)]
  426. [TemplateContainer (typeof(Wizard), BindingDirection.OneWay)]
  427. [PersistenceMode (PersistenceMode.InnerProperty)]
  428. [Browsable (false)]
  429. public virtual ITemplate HeaderTemplate {
  430. get { return headerTemplate; }
  431. set { headerTemplate = value; UpdateViews (); }
  432. }
  433. [DefaultValueAttribute ("")]
  434. [LocalizableAttribute (true)]
  435. public virtual string HeaderText {
  436. get {
  437. object v = ViewState ["HeaderText"];
  438. return v != null ? (string)v : string.Empty;
  439. }
  440. set {
  441. ViewState ["HeaderText"] = value;
  442. }
  443. }
  444. [DefaultValueAttribute (null)]
  445. [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]
  446. [NotifyParentPropertyAttribute (true)]
  447. [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
  448. public Style NavigationButtonStyle {
  449. get {
  450. if (navigationButtonStyle == null) {
  451. navigationButtonStyle = new Style ();
  452. if (IsTrackingViewState)
  453. ((IStateManager)navigationButtonStyle).TrackViewState ();
  454. }
  455. return navigationButtonStyle;
  456. }
  457. }
  458. [DefaultValueAttribute (null)]
  459. [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]
  460. [NotifyParentPropertyAttribute (true)]
  461. [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
  462. public TableItemStyle NavigationStyle {
  463. get {
  464. if (navigationStyle == null) {
  465. navigationStyle = new TableItemStyle ();
  466. if (IsTrackingViewState)
  467. ((IStateManager)navigationStyle).TrackViewState ();
  468. }
  469. return navigationStyle;
  470. }
  471. }
  472. [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]
  473. [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
  474. [DefaultValueAttribute (null)]
  475. [NotifyParentPropertyAttribute (true)]
  476. public TableItemStyle SideBarStyle {
  477. get {
  478. if (sideBarStyle == null) {
  479. sideBarStyle = new TableItemStyle ();
  480. if (IsTrackingViewState)
  481. ((IStateManager)sideBarStyle).TrackViewState ();
  482. }
  483. return sideBarStyle;
  484. }
  485. }
  486. [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]
  487. [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
  488. [DefaultValueAttribute (null)]
  489. [NotifyParentPropertyAttribute (true)]
  490. public Style SideBarButtonStyle {
  491. get {
  492. if (sideBarButtonStyle == null) {
  493. sideBarButtonStyle = new Style ();
  494. if (IsTrackingViewState)
  495. ((IStateManager)sideBarButtonStyle).TrackViewState ();
  496. }
  497. return sideBarButtonStyle;
  498. }
  499. }
  500. [DefaultValue (null)]
  501. [TemplateContainer (typeof(Wizard), BindingDirection.OneWay)]
  502. [PersistenceMode (PersistenceMode.InnerProperty)]
  503. [Browsable (false)]
  504. public virtual ITemplate SideBarTemplate {
  505. get { return sideBarTemplate; }
  506. set { sideBarTemplate = value; UpdateViews (); }
  507. }
  508. [Localizable (true)]
  509. public virtual string SkipLinkText
  510. {
  511. get
  512. {
  513. object v = ViewState ["SkipLinkText"];
  514. return v != null ? (string) v : "Skip Navigation Links.";
  515. }
  516. set
  517. {
  518. ViewState ["SkipLinkText"] = value;
  519. }
  520. }
  521. [DefaultValue (null)]
  522. [TemplateContainer (typeof(Wizard), BindingDirection.OneWay)]
  523. [PersistenceMode (PersistenceMode.InnerProperty)]
  524. [Browsable (false)]
  525. public virtual ITemplate StartNavigationTemplate {
  526. get { return startNavigationTemplate; }
  527. set { startNavigationTemplate = value; UpdateViews (); }
  528. }
  529. [UrlPropertyAttribute]
  530. [DefaultValueAttribute ("")]
  531. [EditorAttribute ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
  532. public virtual string StartNextButtonImageUrl {
  533. get {
  534. object v = ViewState ["StartNextButtonImageUrl"];
  535. return v != null ? (string)v : string.Empty;
  536. }
  537. set {
  538. ViewState ["StartNextButtonImageUrl"] = value;
  539. }
  540. }
  541. [DefaultValueAttribute (null)]
  542. [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]
  543. [NotifyParentPropertyAttribute (true)]
  544. [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
  545. public Style StartNextButtonStyle {
  546. get {
  547. if (startNextButtonStyle == null) {
  548. startNextButtonStyle = new Style ();
  549. if (IsTrackingViewState)
  550. ((IStateManager)startNextButtonStyle).TrackViewState ();
  551. }
  552. return startNextButtonStyle;
  553. }
  554. }
  555. [LocalizableAttribute (true)]
  556. public virtual string StartNextButtonText {
  557. get {
  558. object v = ViewState ["StartNextButtonText"];
  559. return v != null ? (string)v : "Next";
  560. }
  561. set {
  562. ViewState ["StartNextButtonText"] = value;
  563. }
  564. }
  565. [DefaultValueAttribute (ButtonType.Button)]
  566. public virtual ButtonType StartNextButtonType {
  567. get {
  568. object v = ViewState ["StartNextButtonType"];
  569. return v != null ? (ButtonType)v : ButtonType.Button;
  570. }
  571. set {
  572. ViewState ["StartNextButtonType"] = value;
  573. }
  574. }
  575. [DefaultValue (null)]
  576. [TemplateContainer (typeof(Wizard), BindingDirection.OneWay)]
  577. [PersistenceMode (PersistenceMode.InnerProperty)]
  578. [Browsable (false)]
  579. public virtual ITemplate StepNavigationTemplate {
  580. get { return stepNavigationTemplate; }
  581. set { stepNavigationTemplate = value; UpdateViews (); }
  582. }
  583. [UrlPropertyAttribute]
  584. [DefaultValueAttribute ("")]
  585. [EditorAttribute ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
  586. public virtual string StepNextButtonImageUrl {
  587. get {
  588. object v = ViewState ["StepNextButtonImageUrl"];
  589. return v != null ? (string)v : string.Empty;
  590. }
  591. set {
  592. ViewState ["StepNextButtonImageUrl"] = value;
  593. }
  594. }
  595. [DefaultValueAttribute (null)]
  596. [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]
  597. [NotifyParentPropertyAttribute (true)]
  598. [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
  599. public Style StepNextButtonStyle {
  600. get {
  601. if (stepNextButtonStyle == null) {
  602. stepNextButtonStyle = new Style ();
  603. if (IsTrackingViewState)
  604. ((IStateManager)stepNextButtonStyle).TrackViewState ();
  605. }
  606. return stepNextButtonStyle;
  607. }
  608. }
  609. [LocalizableAttribute (true)]
  610. public virtual string StepNextButtonText {
  611. get {
  612. object v = ViewState ["StepNextButtonText"];
  613. return v != null ? (string)v : "Next";
  614. }
  615. set {
  616. ViewState ["StepNextButtonText"] = value;
  617. }
  618. }
  619. [DefaultValueAttribute (ButtonType.Button)]
  620. public virtual ButtonType StepNextButtonType {
  621. get {
  622. object v = ViewState ["StepNextButtonType"];
  623. return v != null ? (ButtonType)v : ButtonType.Button;
  624. }
  625. set {
  626. ViewState ["StepNextButtonType"] = value;
  627. }
  628. }
  629. [UrlPropertyAttribute]
  630. [DefaultValueAttribute ("")]
  631. [EditorAttribute ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
  632. public virtual string StepPreviousButtonImageUrl {
  633. get {
  634. object v = ViewState ["StepPreviousButtonImageUrl"];
  635. return v != null ? (string)v : string.Empty;
  636. }
  637. set {
  638. ViewState ["StepPreviousButtonImageUrl"] = value;
  639. }
  640. }
  641. [DefaultValueAttribute (null)]
  642. [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]
  643. [NotifyParentPropertyAttribute (true)]
  644. [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
  645. public Style StepPreviousButtonStyle {
  646. get {
  647. if (stepPreviousButtonStyle == null) {
  648. stepPreviousButtonStyle = new Style ();
  649. if (IsTrackingViewState)
  650. ((IStateManager)stepPreviousButtonStyle).TrackViewState ();
  651. }
  652. return stepPreviousButtonStyle;
  653. }
  654. }
  655. [LocalizableAttribute (true)]
  656. public virtual string StepPreviousButtonText {
  657. get {
  658. object v = ViewState ["StepPreviousButtonText"];
  659. return v != null ? (string)v : "Previous";
  660. }
  661. set {
  662. ViewState ["StepPreviousButtonText"] = value;
  663. }
  664. }
  665. [DefaultValueAttribute (ButtonType.Button)]
  666. public virtual ButtonType StepPreviousButtonType {
  667. get {
  668. object v = ViewState ["StepPreviousButtonType"];
  669. return v != null ? (ButtonType)v : ButtonType.Button;
  670. }
  671. set {
  672. ViewState ["StepPreviousButtonType"] = value;
  673. }
  674. }
  675. [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]
  676. [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
  677. [DefaultValueAttribute (null)]
  678. [NotifyParentPropertyAttribute (true)]
  679. public TableItemStyle StepStyle {
  680. get {
  681. if (stepStyle == null) {
  682. stepStyle = new TableItemStyle ();
  683. if (IsTrackingViewState)
  684. ((IStateManager)stepStyle).TrackViewState ();
  685. }
  686. return stepStyle;
  687. }
  688. }
  689. [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]
  690. [EditorAttribute ("System.Web.UI.Design.WebControls.WizardStepCollectionEditor," + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
  691. [PersistenceModeAttribute (PersistenceMode.InnerProperty)]
  692. [ThemeableAttribute (false)]
  693. public virtual WizardStepCollection WizardSteps {
  694. get {
  695. if (steps == null)
  696. steps = new WizardStepCollection (this);
  697. return steps;
  698. }
  699. }
  700. protected virtual new HtmlTextWriterTag TagKey
  701. {
  702. get {
  703. return HtmlTextWriterTag.Table;
  704. }
  705. }
  706. internal virtual ITemplate SideBarItemTemplate
  707. {
  708. get { return new SideBarButtonTemplate (this); }
  709. }
  710. public ICollection GetHistory ()
  711. {
  712. if (history == null) history = new ArrayList ();
  713. return history;
  714. }
  715. public void MoveTo (WizardStepBase wizardStep)
  716. {
  717. if (wizardStep == null) throw new ArgumentNullException ("wizardStep");
  718. int i = WizardSteps.IndexOf (wizardStep);
  719. if (i == -1) throw new ArgumentException ("The provided wizard step does not belong to this wizard.");
  720. ActiveStepIndex = i;
  721. }
  722. public WizardStepType GetStepType (WizardStepBase wizardStep, int index)
  723. {
  724. if (wizardStep.StepType == WizardStepType.Auto) {
  725. if ((index == WizardSteps.Count - 1) ||
  726. (WizardSteps.Count > 1 &&
  727. WizardSteps[WizardSteps.Count - 1].StepType == WizardStepType.Complete &&
  728. index == WizardSteps.Count - 2))
  729. return WizardStepType.Finish;
  730. else if (index == 0)
  731. return WizardStepType.Start;
  732. else
  733. return WizardStepType.Step;
  734. } else
  735. return wizardStep.StepType;
  736. }
  737. protected virtual bool AllowNavigationToStep (int index)
  738. {
  739. if (index < 0 || index >= WizardSteps.Count) return false;
  740. if (history == null) return true;
  741. if (!history.Contains (index)) return true;
  742. return WizardSteps [index].AllowReturn;
  743. }
  744. protected internal override void OnInit (EventArgs e)
  745. {
  746. Page.RegisterRequiresControlState (this);
  747. base.OnInit (e);
  748. if (ActiveStepIndex == -1)
  749. ActiveStepIndex = 0;
  750. EnsureChildControls ();
  751. inited = true;
  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 ContainedTable (this);
  767. Table contentTable = wizardTable;
  768. if (DisplaySideBar) {
  769. contentTable = new Table ();
  770. contentTable.CellPadding = 0;
  771. contentTable.CellSpacing = 0;
  772. contentTable.Height = new Unit ("100%");
  773. contentTable.Width = new Unit ("100%");
  774. TableRow row = new TableRow ();
  775. TableCellNamingContainer sideBarCell = new TableCellNamingContainer (SkipLinkText, ClientID);
  776. sideBarCell.ID = "SideBarContainer";
  777. sideBarCell.ControlStyle.Height = Unit.Percentage (100);
  778. CreateSideBar (sideBarCell);
  779. row.Cells.Add (sideBarCell);
  780. TableCell contentCell = new TableCell ();
  781. contentCell.Controls.Add (contentTable);
  782. contentCell.Height = new Unit ("100%");
  783. row.Cells.Add (contentCell);
  784. wizardTable.Rows.Add (row);
  785. }
  786. AddHeaderRow (contentTable);
  787. TableRow viewRow = new TableRow ();
  788. TableCell viewCell = new TableCell ();
  789. customNavigation = null;
  790. multiView = new MultiView ();
  791. foreach (View v in WizardSteps) {
  792. if (v is TemplatedWizardStep)
  793. InstantiateTemplateStep ((TemplatedWizardStep) v);
  794. multiView.Views.Add (v);
  795. }
  796. multiView.ActiveViewIndex = ActiveStepIndex;
  797. RegisterApplyStyle (viewCell, StepStyle);
  798. viewCell.Controls.Add (multiView);
  799. viewRow.Cells.Add (viewCell);
  800. viewRow.Height = new Unit ("100%");
  801. contentTable.Rows.Add (viewRow);
  802. TableRow buttonRow = new TableRow ();
  803. _navigationCell = new TableCell ();
  804. _navigationCell.HorizontalAlign = HorizontalAlign.Right;
  805. RegisterApplyStyle (_navigationCell, NavigationStyle);
  806. CreateButtonBar (_navigationCell);
  807. buttonRow.Cells.Add (_navigationCell);
  808. contentTable.Rows.Add (buttonRow);
  809. Controls.SetReadonly (false);
  810. Controls.Add (wizardTable);
  811. Controls.SetReadonly (true);
  812. }
  813. internal virtual void InstantiateTemplateStep(TemplatedWizardStep step)
  814. {
  815. BaseWizardContainer contentTemplateContainer = new BaseWizardContainer ();
  816. if (step.ContentTemplate != null)
  817. step.ContentTemplate.InstantiateIn (contentTemplateContainer.InnerCell);
  818. step.ContentTemplateContainer = contentTemplateContainer;
  819. step.Controls.Clear ();
  820. step.Controls.Add (contentTemplateContainer);
  821. BaseWizardNavigationContainer customNavigationTemplateContainer = new BaseWizardNavigationContainer ();
  822. if (step.CustomNavigationTemplate != null) {
  823. step.CustomNavigationTemplate.InstantiateIn (customNavigationTemplateContainer);
  824. RegisterCustomNavigation (step, customNavigationTemplateContainer);
  825. }
  826. step.CustomNavigationTemplateContainer = customNavigationTemplateContainer;
  827. }
  828. internal void RegisterCustomNavigation (TemplatedWizardStep step, BaseWizardNavigationContainer customNavigationTemplateContainer) {
  829. if (customNavigation == null)
  830. customNavigation = new Hashtable ();
  831. customNavigation [step] = customNavigationTemplateContainer;
  832. }
  833. void CreateButtonBar (TableCell buttonBarCell)
  834. {
  835. if(customNavigation!=null && customNavigation.Values.Count>0)
  836. {
  837. int i = 0;
  838. foreach (Control customNavigationTemplateContainer in customNavigation.Values) {
  839. customNavigationTemplateContainer.ID = "CustomNavContainer" + i++;
  840. buttonBarCell.Controls.Add (customNavigationTemplateContainer);
  841. }
  842. }
  843. //
  844. // StartNavContainer
  845. //
  846. _startNavContainer = new StartNavigationContainer (this);
  847. _startNavContainer.ID = "StartNavContainer";
  848. if (startNavigationTemplate != null) {
  849. startNavigationTemplate.InstantiateIn (_startNavContainer);
  850. }
  851. else {
  852. TableRow row;
  853. AddNavButtonsTable (_startNavContainer, out row);
  854. AddButtonCell (row, CreateButtonSet (StartNextButtonID, MoveNextCommandName));
  855. AddButtonCell (row, CreateButtonSet (CancelButtonID, CancelCommandName, false));
  856. _startNavContainer.ConfirmDefaultTemplate ();
  857. }
  858. buttonBarCell.Controls.Add (_startNavContainer);
  859. //
  860. // StepNavContainer
  861. //
  862. _stepNavContainer = new StepNavigationContainer (this);
  863. _stepNavContainer.ID = "StepNavContainer";
  864. if (stepNavigationTemplate != null) {
  865. stepNavigationTemplate.InstantiateIn (_stepNavContainer);
  866. }
  867. else {
  868. TableRow row;
  869. AddNavButtonsTable (_stepNavContainer, out row);
  870. AddButtonCell (row, CreateButtonSet (StepPreviousButtonID, MovePreviousCommandName, false));
  871. AddButtonCell (row, CreateButtonSet (StepNextButtonID, MoveNextCommandName));
  872. AddButtonCell (row, CreateButtonSet (CancelButtonID, CancelCommandName, false));
  873. _stepNavContainer.ConfirmDefaultTemplate ();
  874. }
  875. buttonBarCell.Controls.Add (_stepNavContainer);
  876. //
  877. // StepNavContainer
  878. //
  879. _finishNavContainer = new FinishNavigationContainer (this);
  880. _finishNavContainer.ID = "FinishNavContainer";
  881. if (finishNavigationTemplate != null) {
  882. finishNavigationTemplate.InstantiateIn (_finishNavContainer);
  883. }
  884. else {
  885. TableRow row;
  886. AddNavButtonsTable (_finishNavContainer, out row);
  887. AddButtonCell (row, CreateButtonSet (FinishPreviousButtonID, MovePreviousCommandName, false));
  888. AddButtonCell (row, CreateButtonSet (FinishButtonID, MoveCompleteCommandName));
  889. AddButtonCell (row, CreateButtonSet (CancelButtonID, CancelCommandName, false));
  890. _finishNavContainer.ConfirmDefaultTemplate ();
  891. }
  892. buttonBarCell.Controls.Add (_finishNavContainer);
  893. }
  894. static void AddNavButtonsTable (BaseWizardNavigationContainer container, out TableRow row)
  895. {
  896. Table t = new Table ();
  897. t.CellPadding = 5;
  898. t.CellSpacing = 5;
  899. row = new TableRow ();
  900. t.Rows.Add (row);
  901. container.Controls.Add (t);
  902. }
  903. Control [] CreateButtonSet (string id, string command)
  904. {
  905. return CreateButtonSet (id, command, true, null);
  906. }
  907. Control [] CreateButtonSet (string id, string command, bool causesValidation)
  908. {
  909. return CreateButtonSet (id, command, causesValidation, null);
  910. }
  911. internal Control [] CreateButtonSet (string id, string command, bool causesValidation, string validationGroup)
  912. {
  913. return new Control [] {
  914. CreateButton ( id + ButtonType.Button, command, ButtonType.Button, causesValidation, validationGroup),
  915. CreateButton ( id + ButtonType.Image, command, ButtonType.Image, causesValidation, validationGroup),
  916. CreateButton ( id + ButtonType.Link, command, ButtonType.Link, causesValidation, validationGroup)
  917. };
  918. }
  919. Control CreateButton (string id, string command, ButtonType type, bool causesValidation, string validationGroup)
  920. {
  921. WebControl b;
  922. switch (type) {
  923. case ButtonType.Button:
  924. b = CreateStandartButton ();
  925. break;
  926. case ButtonType.Image:
  927. b = CreateImageButton (null);
  928. break;
  929. case ButtonType.Link:
  930. b = CreateLinkButton ();
  931. break;
  932. default:
  933. throw new ArgumentOutOfRangeException ("type");
  934. }
  935. b.ID = id;
  936. b.EnableTheming = false;
  937. ((IButtonControl) b).CommandName = command;
  938. ((IButtonControl) b).CausesValidation = causesValidation;
  939. if(!String.IsNullOrEmpty(validationGroup))
  940. ((IButtonControl) b).ValidationGroup = validationGroup;
  941. RegisterApplyStyle (b, NavigationButtonStyle);
  942. return b;
  943. }
  944. WebControl CreateStandartButton () {
  945. Button btn = new Button ();
  946. return btn;
  947. }
  948. WebControl CreateImageButton (string imageUrl) {
  949. ImageButton img = new ImageButton ();
  950. img.ImageUrl = imageUrl;
  951. return img;
  952. }
  953. WebControl CreateLinkButton () {
  954. LinkButton link = new LinkButton ();
  955. return link;
  956. }
  957. void AddButtonCell (TableRow row, params Control[] controls)
  958. {
  959. TableCell cell = new TableCell ();
  960. cell.HorizontalAlign = HorizontalAlign.Right;
  961. for (int i = 0; i < controls.Length; i++)
  962. cell.Controls.Add (controls [i]);
  963. row.Cells.Add (cell);
  964. }
  965. void CreateSideBar (TableCell sideBarCell)
  966. {
  967. RegisterApplyStyle (sideBarCell, SideBarStyle);
  968. if (sideBarTemplate != null) {
  969. sideBarTemplate.InstantiateIn (sideBarCell);
  970. stepDatalist = sideBarCell.FindControl (DataListID) as DataList;
  971. if (stepDatalist == null)
  972. throw new InvalidOperationException ("The side bar template must contain a DataList control with id '" + DataListID + "'.");
  973. stepDatalist.ItemDataBound += new DataListItemEventHandler(StepDatalistItemDataBound);
  974. } else {
  975. stepDatalist = new DataList ();
  976. stepDatalist.ID = DataListID;
  977. stepDatalist.SelectedItemStyle.Font.Bold = true;
  978. stepDatalist.ItemTemplate = SideBarItemTemplate;
  979. sideBarCell.Controls.Add (stepDatalist);
  980. }
  981. stepDatalist.ItemCommand += new DataListCommandEventHandler (StepDatalistItemCommand);
  982. stepDatalist.CellSpacing = 0;
  983. stepDatalist.DataSource = WizardSteps;
  984. stepDatalist.SelectedIndex = ActiveStepIndex;
  985. stepDatalist.DataBind ();
  986. }
  987. void StepDatalistItemCommand (object sender, DataListCommandEventArgs e)
  988. {
  989. WizardNavigationEventArgs arg = new WizardNavigationEventArgs (ActiveStepIndex, Convert.ToInt32 (e.CommandArgument));
  990. OnSideBarButtonClick (arg);
  991. if (!arg.Cancel)
  992. ActiveStepIndex = arg.NextStepIndex;
  993. }
  994. void StepDatalistItemDataBound (object sender, DataListItemEventArgs e)
  995. {
  996. if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.SelectedItem) {
  997. IButtonControl button = (IButtonControl) e.Item.FindControl (SideBarButtonID);
  998. if (button == null)
  999. throw new InvalidOperationException ("SideBarList control must contain an IButtonControl with ID " + SideBarButtonID + " in every item template, this maybe include ItemTemplate, EditItemTemplate, SelectedItemTemplate or AlternatingItemTemplate if they exist.");
  1000. WizardStepBase step = (WizardStepBase) e.Item.DataItem;
  1001. if (button is Button)
  1002. ((Button) button).UseSubmitBehavior = false;
  1003. button.CommandName = Wizard.MoveToCommandName;
  1004. button.CommandArgument = WizardSteps.IndexOf (step).ToString ();
  1005. button.Text = step.Name;
  1006. if (step.StepType == WizardStepType.Complete && button is WebControl)
  1007. ((WebControl) button).Enabled = false;
  1008. }
  1009. }
  1010. void AddHeaderRow (Table table)
  1011. {
  1012. TableRow row = new TableRow ();
  1013. _headerCell = new WizardHeaderCell ();
  1014. _headerCell.ID = "HeaderContainer";
  1015. RegisterApplyStyle (_headerCell, HeaderStyle);
  1016. if (headerTemplate != null) {
  1017. headerTemplate.InstantiateIn (_headerCell);
  1018. _headerCell.ConfirmInitState ();
  1019. }
  1020. row.Cells.Add (_headerCell);
  1021. table.Rows.Add (row);
  1022. }
  1023. internal void RegisterApplyStyle (WebControl control, Style style)
  1024. {
  1025. styles.Add (new object [] { control, style });
  1026. }
  1027. protected override Style CreateControlStyle ()
  1028. {
  1029. TableStyle style = new TableStyle ();
  1030. style.CellPadding = 0;
  1031. style.CellSpacing = 0;
  1032. return style;
  1033. }
  1034. protected override IDictionary GetDesignModeState ()
  1035. {
  1036. throw new NotImplementedException ();
  1037. }
  1038. protected internal override void LoadControlState (object ob)
  1039. {
  1040. if (ob == null) return;
  1041. object[] state = (object[]) ob;
  1042. base.LoadControlState (state[0]);
  1043. activeStepIndex = (int) state[1];
  1044. history = (ArrayList) state[2];
  1045. }
  1046. protected internal override object SaveControlState ()
  1047. {
  1048. if (GetHistory ().Count == 0 || (int) history [0] != ActiveStepIndex)
  1049. history.Insert (0, ActiveStepIndex);
  1050. object bstate = base.SaveControlState ();
  1051. return new object[] {
  1052. bstate, activeStepIndex, history
  1053. };
  1054. }
  1055. protected override void LoadViewState (object savedState)
  1056. {
  1057. if (savedState == null) {
  1058. base.LoadViewState (null);
  1059. return;
  1060. }
  1061. object[] states = (object[]) savedState;
  1062. base.LoadViewState (states [0]);
  1063. if (states[1] != null) ((IStateManager)StepStyle).LoadViewState (states[1]);
  1064. if (states[2] != null) ((IStateManager)SideBarStyle).LoadViewState (states[2]);
  1065. if (states[3] != null) ((IStateManager)HeaderStyle).LoadViewState (states[3]);
  1066. if (states[4] != null) ((IStateManager)NavigationStyle).LoadViewState (states[4]);
  1067. if (states[5] != null) ((IStateManager)SideBarButtonStyle).LoadViewState (states[5]);
  1068. if (states[6] != null) ((IStateManager)CancelButtonStyle).LoadViewState (states[6]);
  1069. if (states[7] != null) ((IStateManager)FinishCompleteButtonStyle).LoadViewState (states[7]);
  1070. if (states[8] != null) ((IStateManager)FinishPreviousButtonStyle).LoadViewState (states[8]);
  1071. if (states[9] != null) ((IStateManager)StartNextButtonStyle).LoadViewState (states[9]);
  1072. if (states[10] != null) ((IStateManager)StepNextButtonStyle).LoadViewState (states[10]);
  1073. if (states[11] != null) ((IStateManager)StepPreviousButtonStyle).LoadViewState (states[11]);
  1074. if (states[12] != null) ((IStateManager)NavigationButtonStyle).LoadViewState (states[12]);
  1075. if (states [13] != null)
  1076. ControlStyle.LoadViewState (states [13]);
  1077. }
  1078. protected override object SaveViewState ()
  1079. {
  1080. object [] state = new object [14];
  1081. state [0] = base.SaveViewState ();
  1082. if (stepStyle != null) state [1] = ((IStateManager)stepStyle).SaveViewState ();
  1083. if (sideBarStyle != null) state [2] = ((IStateManager)sideBarStyle).SaveViewState ();
  1084. if (headerStyle != null) state [3] = ((IStateManager)headerStyle).SaveViewState ();
  1085. if (navigationStyle != null) state [4] = ((IStateManager)navigationStyle).SaveViewState ();
  1086. if (sideBarButtonStyle != null) state [5] = ((IStateManager)sideBarButtonStyle).SaveViewState ();
  1087. if (cancelButtonStyle != null) state [6] = ((IStateManager)cancelButtonStyle).SaveViewState ();
  1088. if (finishCompleteButtonStyle != null) state [7] = ((IStateManager)finishCompleteButtonStyle).SaveViewState ();
  1089. if (finishPreviousButtonStyle != null) state [8] = ((IStateManager)finishPreviousButtonStyle).SaveViewState ();
  1090. if (startNextButtonStyle != null) state [9] = ((IStateManager)startNextButtonStyle).SaveViewState ();
  1091. if (stepNextButtonStyle != null) state [10] = ((IStateManager)stepNextButtonStyle).SaveViewState ();
  1092. if (stepPreviousButtonStyle != null) state [11] = ((IStateManager)stepPreviousButtonStyle).SaveViewState ();
  1093. if (navigationButtonStyle != null) state [12] = ((IStateManager)navigationButtonStyle).SaveViewState ();
  1094. if (ControlStyleCreated)
  1095. state [13] = ControlStyle.SaveViewState ();
  1096. for (int n=0; n<state.Length; n++)
  1097. if (state [n] != null) return state;
  1098. return null;
  1099. }
  1100. protected override void TrackViewState ()
  1101. {
  1102. base.TrackViewState();
  1103. if (stepStyle != null) ((IStateManager)stepStyle).TrackViewState();
  1104. if (sideBarStyle != null) ((IStateManager)sideBarStyle).TrackViewState();
  1105. if (headerStyle != null) ((IStateManager)headerStyle).TrackViewState();
  1106. if (navigationStyle != null) ((IStateManager)navigationStyle).TrackViewState();
  1107. if (sideBarButtonStyle != null) ((IStateManager)sideBarButtonStyle).TrackViewState();
  1108. if (cancelButtonStyle != null) ((IStateManager)cancelButtonStyle).TrackViewState();
  1109. if (finishCompleteButtonStyle != null) ((IStateManager)finishCompleteButtonStyle).TrackViewState();
  1110. if (finishPreviousButtonStyle != null) ((IStateManager)finishPreviousButtonStyle).TrackViewState();
  1111. if (startNextButtonStyle != null) ((IStateManager)startNextButtonStyle).TrackViewState();
  1112. if (stepNextButtonStyle != null) ((IStateManager)stepNextButtonStyle).TrackViewState();
  1113. if (stepPreviousButtonStyle != null) ((IStateManager)stepPreviousButtonStyle).TrackViewState();
  1114. if (navigationButtonStyle != null) ((IStateManager)navigationButtonStyle).TrackViewState();
  1115. if (ControlStyleCreated)
  1116. ControlStyle.TrackViewState ();
  1117. }
  1118. protected internal void RegisterCommandEvents (IButtonControl button)
  1119. {
  1120. button.Command += ProcessCommand;
  1121. }
  1122. void ProcessCommand (object sender, CommandEventArgs args)
  1123. {
  1124. Control c = sender as Control;
  1125. if (c != null) {
  1126. switch (c.ID) {
  1127. case "CancelButton":
  1128. ProcessEvent ("Cancel", null);
  1129. return;
  1130. case "FinishButton":
  1131. ProcessEvent ("MoveComplete", null);
  1132. return;
  1133. case "StepPreviousButton":
  1134. case "FinishPreviousButton":
  1135. ProcessEvent ("MovePrevious", null);
  1136. return;
  1137. case "StartNextButton":
  1138. case "StepNextButton":
  1139. ProcessEvent ("MoveNext", null);
  1140. return;
  1141. }
  1142. }
  1143. ProcessEvent (args.CommandName, args.CommandArgument as string);
  1144. }
  1145. protected override bool OnBubbleEvent (object source, EventArgs e)
  1146. {
  1147. CommandEventArgs args = e as CommandEventArgs;
  1148. if (args != null) {
  1149. ProcessEvent (args.CommandName, args.CommandArgument as string);
  1150. return true;
  1151. }
  1152. return base.OnBubbleEvent (source, e);
  1153. }
  1154. void ProcessEvent (string commandName, string commandArg)
  1155. {
  1156. switch (commandName) {
  1157. case "Cancel":
  1158. if (CancelDestinationPageUrl.Length > 0)
  1159. Context.Response.Redirect (CancelDestinationPageUrl);
  1160. else
  1161. OnCancelButtonClick (EventArgs.Empty);
  1162. break;
  1163. case "MoveComplete":
  1164. int next = -1;
  1165. for (int n=0; n<WizardSteps.Count; n++) {
  1166. if (WizardSteps [n].StepType == WizardStepType.Complete) {
  1167. next = n;
  1168. break;
  1169. }
  1170. }
  1171. if (next == -1 && ActiveStepIndex == WizardSteps.Count - 1)
  1172. next = ActiveStepIndex;
  1173. WizardNavigationEventArgs navArgs = new WizardNavigationEventArgs (ActiveStepIndex, next);
  1174. OnFinishButtonClick (navArgs);
  1175. if (FinishDestinationPageUrl.Length > 0) {
  1176. Context.Response.Redirect (FinishDestinationPageUrl);
  1177. return;
  1178. }
  1179. if (next != -1 && !navArgs.Cancel)
  1180. ActiveStepIndex = next;
  1181. break;
  1182. case "MoveNext":
  1183. if (ActiveStepIndex < WizardSteps.Count - 1) {
  1184. WizardNavigationEventArgs args = new WizardNavigationEventArgs (ActiveStepIndex, ActiveStepIndex + 1);
  1185. int curStep = ActiveStepIndex;
  1186. OnNextButtonClick (args);
  1187. if (!args.Cancel && curStep == activeStepIndex)
  1188. ActiveStepIndex++;
  1189. }
  1190. break;
  1191. case "MovePrevious":
  1192. if (ActiveStepIndex > 0) {
  1193. WizardNavigationEventArgs args = new WizardNavigationEventArgs (ActiveStepIndex, ActiveStepIndex - 1);
  1194. int curStep = ActiveStepIndex;
  1195. OnPreviousButtonClick (args);
  1196. if (!args.Cancel) {
  1197. if (curStep == activeStepIndex)
  1198. ActiveStepIndex--;
  1199. if (history != null && activeStepIndex < curStep)
  1200. history.Remove (curStep);
  1201. }
  1202. }
  1203. break;
  1204. case "Move":
  1205. int newb = int.Parse (commandArg);
  1206. ActiveStepIndex = newb;
  1207. break;
  1208. }
  1209. }
  1210. internal void UpdateViews ()
  1211. {
  1212. ChildControlsCreated = false;
  1213. }
  1214. protected internal override void Render (HtmlTextWriter writer)
  1215. {
  1216. PrepareControlHierarchy ();
  1217. wizardTable.Render (writer);
  1218. }
  1219. void PrepareControlHierarchy ()
  1220. {
  1221. // header
  1222. if (!_headerCell.Initialized) {
  1223. if (String.IsNullOrEmpty (HeaderText))
  1224. _headerCell.Parent.Visible = false;
  1225. else
  1226. _headerCell.Text = HeaderText;
  1227. }
  1228. if (ActiveStep.StepType == WizardStepType.Complete)
  1229. _headerCell.Parent.Visible = false;
  1230. // sidebar
  1231. if (stepDatalist != null) {
  1232. stepDatalist.SelectedIndex = ActiveStepIndex;
  1233. stepDatalist.DataBind ();
  1234. if (ActiveStep.StepType == WizardStepType.Complete)
  1235. stepDatalist.NamingContainer.Visible = false;
  1236. }
  1237. // content
  1238. TemplatedWizardStep templateStep = ActiveStep as TemplatedWizardStep;
  1239. if (templateStep != null) {
  1240. BaseWizardContainer contentContainer = templateStep.ContentTemplateContainer as BaseWizardContainer;
  1241. if (contentContainer != null)
  1242. contentContainer.PrepareControlHierarchy ();
  1243. }
  1244. // navigation
  1245. if (customNavigation != null) {
  1246. foreach (Control c in customNavigation.Values)
  1247. c.Visible = false;
  1248. }
  1249. _startNavContainer.Visible = false;
  1250. _stepNavContainer.Visible = false;
  1251. _finishNavContainer.Visible = false;
  1252. BaseWizardNavigationContainer currentNavContainer = GetCurrentNavContainer ();
  1253. if (currentNavContainer == null) {
  1254. _navigationCell.Parent.Visible = false;
  1255. }
  1256. else {
  1257. currentNavContainer.Visible = true;
  1258. currentNavContainer.PrepareControlHierarchy ();
  1259. if (!currentNavContainer.Visible)
  1260. _navigationCell.Parent.Visible = false;
  1261. }
  1262. foreach (object [] styleDef in styles)
  1263. ((WebControl) styleDef [0]).ApplyStyle ((Style) styleDef [1]);
  1264. }
  1265. BaseWizardNavigationContainer GetCurrentNavContainer ()
  1266. {
  1267. if (customNavigation != null && customNavigation [ActiveStep] != null) {
  1268. return (BaseWizardNavigationContainer) customNavigation [ActiveStep];
  1269. }
  1270. else {
  1271. WizardStepType stepType = GetStepType (ActiveStep, ActiveStepIndex);
  1272. switch (stepType) {
  1273. case WizardStepType.Start:
  1274. return _startNavContainer;
  1275. case WizardStepType.Step:
  1276. return _stepNavContainer;
  1277. case WizardStepType.Finish:
  1278. return _finishNavContainer;
  1279. default:
  1280. return null;
  1281. }
  1282. }
  1283. }
  1284. sealed class TableCellNamingContainer : TableCell, INamingContainer, INonBindingContainer
  1285. {
  1286. string skipLinkText;
  1287. string clientId;
  1288. bool haveSkipLink;
  1289. protected internal override void RenderChildren (HtmlTextWriter writer)
  1290. {
  1291. if (haveSkipLink) {
  1292. // <a href="#ID_SkipLink">
  1293. writer.AddAttribute (HtmlTextWriterAttribute.Href, "#" + clientId + "_SkipLink");
  1294. writer.RenderBeginTag (HtmlTextWriterTag.A);
  1295. // <img alt="" height="0" width="0" src="" style="border-width:0px;"/>
  1296. writer.AddAttribute (HtmlTextWriterAttribute.Alt, skipLinkText);
  1297. writer.AddAttribute (HtmlTextWriterAttribute.Height, "0");
  1298. writer.AddAttribute (HtmlTextWriterAttribute.Width, "0");
  1299. Page page = Page;
  1300. ClientScriptManager csm;
  1301. if (page != null)
  1302. csm = page.ClientScript;
  1303. else
  1304. csm = new ClientScriptManager (null);
  1305. writer.AddAttribute (HtmlTextWriterAttribute.Src, csm.GetWebResourceUrl (typeof (SiteMapPath), "transparent.gif"));
  1306. writer.AddStyleAttribute (HtmlTextWriterStyle.BorderWidth, "0px");
  1307. writer.RenderBeginTag (HtmlTextWriterTag.Img);
  1308. writer.RenderEndTag ();
  1309. writer.RenderEndTag (); // </a>
  1310. }
  1311. base.RenderChildren (writer);
  1312. if (haveSkipLink) {
  1313. writer.AddAttribute (HtmlTextWriterAttribute.Id, "SkipLink");
  1314. writer.RenderBeginTag (HtmlTextWriterTag.A);
  1315. writer.RenderEndTag ();
  1316. }
  1317. }
  1318. public TableCellNamingContainer (string skipLinkText, string clientId)
  1319. {
  1320. this.skipLinkText = skipLinkText;
  1321. this.clientId = clientId;
  1322. this.haveSkipLink = !String.IsNullOrEmpty (skipLinkText);
  1323. }
  1324. }
  1325. sealed class SideBarButtonTemplate: ITemplate
  1326. {
  1327. Wizard wizard;
  1328. public SideBarButtonTemplate (Wizard wizard)
  1329. {
  1330. this.wizard = wizard;
  1331. }
  1332. public void InstantiateIn (Control control)
  1333. {
  1334. LinkButton b = new LinkButton ();
  1335. wizard.RegisterApplyStyle (b, wizard.SideBarButtonStyle);
  1336. control.Controls.Add (b);
  1337. control.DataBinding += Bound;
  1338. }
  1339. void Bound (object s, EventArgs args)
  1340. {
  1341. WizardStepBase step = DataBinder.GetDataItem (s) as WizardStepBase;
  1342. if (step != null) {
  1343. DataListItem c = (DataListItem) s;
  1344. LinkButton b = (LinkButton) c.Controls[0];
  1345. b.ID = SideBarButtonID;
  1346. b.CommandName = Wizard.MoveToCommandName;
  1347. b.CommandArgument = wizard.WizardSteps.IndexOf (step).ToString ();
  1348. b.Text = step.Name;
  1349. if (step.StepType == WizardStepType.Complete)
  1350. b.Enabled = false;
  1351. }
  1352. }
  1353. }
  1354. class WizardHeaderCell : TableCell, INamingContainer, INonBindingContainer
  1355. {
  1356. bool _initialized;
  1357. public bool Initialized {
  1358. get { return _initialized; }
  1359. }
  1360. public WizardHeaderCell ()
  1361. {
  1362. }
  1363. public void ConfirmInitState ()
  1364. {
  1365. _initialized = true;
  1366. }
  1367. }
  1368. internal abstract class DefaultNavigationContainer : BaseWizardNavigationContainer
  1369. {
  1370. bool _isDefault;
  1371. Wizard _wizard;
  1372. protected Wizard Wizard {
  1373. get { return _wizard; }
  1374. }
  1375. protected DefaultNavigationContainer (Wizard wizard)
  1376. {
  1377. _wizard = wizard;
  1378. }
  1379. public override sealed void PrepareControlHierarchy ()
  1380. {
  1381. if (_isDefault)
  1382. UpdateState ();
  1383. }
  1384. protected abstract void UpdateState ();
  1385. public void ConfirmDefaultTemplate ()
  1386. {
  1387. _isDefault = true;
  1388. }
  1389. protected void UpdateNavButtonState (string id, string text, string image, Style style)
  1390. {
  1391. WebControl b = (WebControl) FindControl (id);
  1392. foreach (Control c in b.Parent.Controls)
  1393. c.Visible = b == c;
  1394. ((IButtonControl) b).Text = text;
  1395. ImageButton imgbtn = b as ImageButton;
  1396. if (imgbtn != null)
  1397. imgbtn.ImageUrl = image;
  1398. b.ApplyStyle (style);
  1399. }
  1400. }
  1401. sealed class StartNavigationContainer : DefaultNavigationContainer
  1402. {
  1403. public StartNavigationContainer (Wizard wizard)
  1404. : base (wizard)
  1405. {
  1406. }
  1407. protected override void UpdateState ()
  1408. {
  1409. bool visible = false;
  1410. // next
  1411. if (Wizard.AllowNavigationToStep (Wizard.ActiveStepIndex + 1)) {
  1412. visible = true;
  1413. UpdateNavButtonState (Wizard.StartNextButtonID + Wizard.StartNextButtonType, Wizard.StartNextButtonText, Wizard.StartNextButtonImageUrl, Wizard.StartNextButtonStyle);
  1414. }
  1415. else {
  1416. ((Table) Controls [0]).Rows [0].Cells [0].Visible = false;
  1417. }
  1418. // cancel
  1419. if (Wizard.DisplayCancelButton) {
  1420. visible = true;
  1421. UpdateNavButtonState (Wizard.CancelButtonID + Wizard.CancelButtonType, Wizard.CancelButtonText, Wizard.CancelButtonImageUrl, Wizard.CancelButtonStyle);
  1422. }
  1423. else {
  1424. ((Table) Controls [0]).Rows [0].Cells [1].Visible = false;
  1425. }
  1426. Visible = visible;
  1427. }
  1428. }
  1429. sealed class StepNavigationContainer : DefaultNavigationContainer
  1430. {
  1431. public StepNavigationContainer (Wizard wizard)
  1432. : base (wizard)
  1433. {
  1434. }
  1435. protected override void UpdateState ()
  1436. {
  1437. bool visible = false;
  1438. // previous
  1439. if (Wizard.AllowNavigationToStep (Wizard.ActiveStepIndex - 1)) {
  1440. visible = true;
  1441. UpdateNavButtonState (Wizard.StepPreviousButtonID + Wizard.StepPreviousButtonType, Wizard.StepPreviousButtonText, Wizard.StepPreviousButtonImageUrl, Wizard.StepPreviousButtonStyle);
  1442. }
  1443. else {
  1444. ((Table) Controls [0]).Rows [0].Cells [0].Visible = false;
  1445. }
  1446. // next
  1447. if (Wizard.AllowNavigationToStep (Wizard.ActiveStepIndex + 1)) {
  1448. visible = true;
  1449. UpdateNavButtonState (Wizard.StepNextButtonID + Wizard.StepNextButtonType, Wizard.StepNextButtonText, Wizard.StepNextButtonImageUrl, Wizard.StepNextButtonStyle);
  1450. }
  1451. else {
  1452. ((Table) Controls [0]).Rows [0].Cells [1].Visible = false;
  1453. }
  1454. // cancel
  1455. if (Wizard.DisplayCancelButton) {
  1456. visible = true;
  1457. UpdateNavButtonState (Wizard.CancelButtonID + Wizard.CancelButtonType, Wizard.CancelButtonText, Wizard.CancelButtonImageUrl, Wizard.CancelButtonStyle);
  1458. }
  1459. else {
  1460. ((Table) Controls [0]).Rows [0].Cells [2].Visible = false;
  1461. }
  1462. Visible = visible;
  1463. }
  1464. }
  1465. sealed class FinishNavigationContainer : DefaultNavigationContainer
  1466. {
  1467. public FinishNavigationContainer (Wizard wizard)
  1468. : base (wizard)
  1469. {
  1470. }
  1471. protected override void UpdateState ()
  1472. {
  1473. // previous
  1474. if (Wizard.AllowNavigationToStep (Wizard.ActiveStepIndex - 1)) {
  1475. UpdateNavButtonState (Wizard.FinishPreviousButtonID + Wizard.FinishPreviousButtonType, Wizard.FinishPreviousButtonText, Wizard.FinishPreviousButtonImageUrl, Wizard.FinishPreviousButtonStyle);
  1476. }
  1477. else {
  1478. ((Table) Controls [0]).Rows [0].Cells [0].Visible = false;
  1479. }
  1480. // finish
  1481. UpdateNavButtonState (Wizard.FinishButtonID + Wizard.FinishCompleteButtonType, Wizard.FinishCompleteButtonText, Wizard.FinishCompleteButtonImageUrl, Wizard.FinishCompleteButtonStyle);
  1482. // cancel
  1483. if (Wizard.DisplayCancelButton) {
  1484. UpdateNavButtonState (Wizard.CancelButtonID + Wizard.CancelButtonType, Wizard.CancelButtonText, Wizard.CancelButtonImageUrl, Wizard.CancelButtonStyle);
  1485. }
  1486. else {
  1487. ((Table) Controls [0]).Rows [0].Cells [2].Visible = false;
  1488. }
  1489. }
  1490. }
  1491. internal class BaseWizardContainer : Table, INamingContainer, INonBindingContainer
  1492. {
  1493. public TableCell InnerCell {
  1494. get { return Rows [0].Cells [0]; }
  1495. }
  1496. internal BaseWizardContainer ()
  1497. {
  1498. InitTable ();
  1499. }
  1500. void InitTable () {
  1501. TableRow row = new TableRow ();
  1502. TableCell cell = new TableCell ();
  1503. cell.ControlStyle.Width = Unit.Percentage (100);
  1504. cell.ControlStyle.Height = Unit.Percentage (100);
  1505. row.Cells.Add (cell);
  1506. this.ControlStyle.Width = Unit.Percentage (100);
  1507. this.ControlStyle.Height = Unit.Percentage (100);
  1508. this.CellPadding = 0;
  1509. this.CellSpacing = 0;
  1510. this.Rows.Add (row);
  1511. }
  1512. public virtual void PrepareControlHierarchy ()
  1513. {
  1514. }
  1515. }
  1516. internal class BaseWizardNavigationContainer : Control, INamingContainer, INonBindingContainer
  1517. {
  1518. internal BaseWizardNavigationContainer ()
  1519. {
  1520. }
  1521. public virtual void PrepareControlHierarchy ()
  1522. {
  1523. }
  1524. }
  1525. internal abstract class DefaultContentContainer : BaseWizardContainer
  1526. {
  1527. bool _isDefault;
  1528. Wizard _wizard;
  1529. protected bool IsDefaultTemplate {
  1530. get { return _isDefault; }
  1531. }
  1532. protected Wizard Wizard {
  1533. get { return _wizard; }
  1534. }
  1535. protected DefaultContentContainer (Wizard wizard)
  1536. {
  1537. _wizard = wizard;
  1538. }
  1539. public override sealed void PrepareControlHierarchy ()
  1540. {
  1541. if (_isDefault)
  1542. UpdateState ();
  1543. }
  1544. protected abstract void UpdateState ();
  1545. public void ConfirmDefaultTemplate ()
  1546. {
  1547. _isDefault = true;
  1548. }
  1549. }
  1550. }
  1551. }
  1552. #endif