Update Reference Sources to .NET Framework 4.6.1
[mono.git] / mcs / class / referencesource / System.Web.Entity.Design / System / Data / WebControls / Design / Util / WizardPanel.cs
1 //------------------------------------------------------------------------------
2 // <copyright file="WizardPanel.cs" company="Microsoft">
3 //     Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>
5 //
6 // @owner       [....]
7 // @backupOwner [....]
8 //------------------------------------------------------------------------------
9
10 using System;
11 using System.Collections;
12 using System.ComponentModel;
13 using System.ComponentModel.Design;
14 using System.Diagnostics;
15 using System.Drawing;
16 using System.Windows.Forms;
17
18 namespace System.Web.UI.Design.WebControls.Util
19 {
20     /// <devdoc>
21     /// Represents a single step in a wizard.
22     /// WizardPanels are contained within a single WizardForm.
23     /// </devdoc>
24     internal class WizardPanel : System.Windows.Forms.UserControl
25     {
26
27         private WizardForm _parentWizard;
28         private string _caption;
29         private WizardPanel _nextPanel;
30         private bool _needsToInvalidate;
31
32         /// <devdoc>
33         /// Creates a new WizardPanel.
34         /// </devdoc>
35         public WizardPanel()
36         {
37         }
38
39         /// <devdoc>
40         /// The caption to be shown on the WizardForm
41         /// </devdoc>
42         public string Caption
43         {
44             get
45             {
46                 if (_caption == null)
47                 {
48                     return String.Empty;
49                 }
50                 return _caption;
51             }
52             set
53             {
54                 _caption = value;
55                 if (_parentWizard != null)
56                 {
57                     _parentWizard.Invalidate();
58                 }
59                 else
60                 {
61                     _needsToInvalidate = true;
62                 }
63             }
64         }
65
66         /// <devdoc>
67         /// The panel to go to when the Next button is clicked. This can be set dynamically in
68         /// the OnNext() event to customize the order in which panels are used.
69         /// </devdoc>
70         public WizardPanel NextPanel
71         {
72             get
73             {
74                 return _nextPanel;
75             }
76             set
77             {
78                 _nextPanel = value;
79                 Debug.Assert(_parentWizard != null);
80                 if (_parentWizard != null)
81                 {
82                     _parentWizard.RegisterPanel(_nextPanel);
83                 }
84             }
85         }
86
87         /// <devdoc>
88         /// This method is called when the wizard's Finish button is clicked.
89         /// It is called once for each wizard panel on the panel stack, in the order from the first panel to the last (current) panel.
90         /// </devdoc>
91         protected internal virtual void OnComplete()
92         {
93         }
94
95         /// <devdoc>
96         /// Runs when the next button is clicked while this panel is showing.
97         /// Returns true if the wizard should proceed to the next panel.
98         /// </devdoc>
99         public virtual bool OnNext()
100         {
101             return true;
102         }
103
104         /// <devdoc>
105         /// Runs when the previous button of the parent wizard form is clicked while this panel is active
106         /// </devdoc>
107         public virtual void OnPrevious()
108         {
109         }
110
111         /// <devdoc>
112         /// </devdoc>
113         internal void SetParentWizard(WizardForm parent)
114         {
115             _parentWizard = parent;
116             if ((_parentWizard != null) && _needsToInvalidate)
117             {
118                 _parentWizard.Invalidate();
119                 _needsToInvalidate = false;
120             }
121         }
122     }
123 }