Wizard.cs 55 KB

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