Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WebForms / System / Web / UI / Design / Util / WizardForm.cs / 1 / WizardForm.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI.Design.Util { using System; using System.Collections; using System.ComponentModel; using System.ComponentModel.Design; using System.Design; using System.Diagnostics; using System.Drawing; using System.Windows.Forms; using System.Windows.Forms.Design; ////// Represents a wizard used to guide users through configuration processes. /// internal abstract class WizardForm : TaskFormBase { private System.Windows.Forms.Button _nextButton; private System.Windows.Forms.Button _previousButton; private System.Windows.Forms.Button _cancelButton; private System.Windows.Forms.Button _finishButton; private System.Windows.Forms.TableLayoutPanel _wizardButtonsTableLayoutPanel; private System.Windows.Forms.Label _dummyLabel1; private System.Windows.Forms.Label _dummyLabel2; private System.Windows.Forms.Label _dummyLabel3; System.Collections.Generic.Stack_panelHistory; private WizardPanel _initialPanel; /// /// Creates a new WizardForm with a given service provider. /// public WizardForm(IServiceProvider serviceProvider) : base(serviceProvider) { _panelHistory = new System.Collections.Generic.Stack(); InitializeComponent(); InitializeUI(); } /// /// /// Not used, according to FxCop. Commenting out per [....]'s request. /*[ Browsable(false), ] public WizardPanel InitialPanel { get { return _initialPanel; } set { _initialPanel = value; } }*/ ////// The Finish button of the wizard. /// public Button FinishButton { get { return _finishButton; } } ////// The Next button of the wizard. /// public Button NextButton { get { return _nextButton; } } ////// The Back button of the wizard. /// public Button PreviousButton { get { return _previousButton; } } #region Designer generated code ////// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this._wizardButtonsTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); this._previousButton = new System.Windows.Forms.Button(); this._nextButton = new System.Windows.Forms.Button(); this._dummyLabel2 = new System.Windows.Forms.Label(); this._finishButton = new System.Windows.Forms.Button(); this._dummyLabel3 = new System.Windows.Forms.Label(); this._cancelButton = new System.Windows.Forms.Button(); this._dummyLabel1 = new System.Windows.Forms.Label(); this._wizardButtonsTableLayoutPanel.SuspendLayout(); this.SuspendLayout(); // // _wizardButtonsTableLayoutPanel // this._wizardButtonsTableLayoutPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this._wizardButtonsTableLayoutPanel.AutoSize = true; this._wizardButtonsTableLayoutPanel.ColumnCount = 7; this._wizardButtonsTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); this._wizardButtonsTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 3F)); this._wizardButtonsTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); this._wizardButtonsTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 7F)); this._wizardButtonsTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); this._wizardButtonsTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 7F)); this._wizardButtonsTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); this._wizardButtonsTableLayoutPanel.Controls.Add(this._previousButton); this._wizardButtonsTableLayoutPanel.Controls.Add(this._dummyLabel1); this._wizardButtonsTableLayoutPanel.Controls.Add(this._nextButton); this._wizardButtonsTableLayoutPanel.Controls.Add(this._dummyLabel2); this._wizardButtonsTableLayoutPanel.Controls.Add(this._finishButton); this._wizardButtonsTableLayoutPanel.Controls.Add(this._dummyLabel3); this._wizardButtonsTableLayoutPanel.Controls.Add(this._cancelButton); this._wizardButtonsTableLayoutPanel.Location = new System.Drawing.Point(239, 384); this._wizardButtonsTableLayoutPanel.Name = "_wizardButtonsTableLayoutPanel"; this._wizardButtonsTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle()); this._wizardButtonsTableLayoutPanel.Size = new System.Drawing.Size(317, 23); this._wizardButtonsTableLayoutPanel.TabIndex = 100; // // _previousButton // this._previousButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); this._previousButton.AutoSize = true; this._previousButton.Enabled = false; this._previousButton.Location = new System.Drawing.Point(0, 0); this._previousButton.Margin = new System.Windows.Forms.Padding(0); this._previousButton.MinimumSize = new System.Drawing.Size(75, 23); this._previousButton.Name = "_previousButton"; this._previousButton.TabIndex = 10; this._previousButton.Click += new System.EventHandler(this.OnPreviousButtonClick); // // _dummyLabel1 // this._dummyLabel1.Location = new System.Drawing.Point(75, 0); this._dummyLabel1.Margin = new System.Windows.Forms.Padding(0); this._dummyLabel1.Name = "_dummyLabel1"; this._dummyLabel1.Size = new System.Drawing.Size(3, 0); this._dummyLabel1.TabIndex = 20; // // _nextButton // this._nextButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); this._nextButton.AutoSize = true; this._nextButton.Location = new System.Drawing.Point(78, 0); this._nextButton.Margin = new System.Windows.Forms.Padding(0); this._nextButton.MinimumSize = new System.Drawing.Size(75, 23); this._nextButton.Name = "_nextButton"; this._nextButton.TabIndex = 30; this._nextButton.Click += new System.EventHandler(this.OnNextButtonClick); // // _dummyLabel2 // this._dummyLabel2.Location = new System.Drawing.Point(153, 0); this._dummyLabel2.Margin = new System.Windows.Forms.Padding(0); this._dummyLabel2.Name = "_dummyLabel2"; this._dummyLabel2.Size = new System.Drawing.Size(7, 0); this._dummyLabel2.TabIndex = 40; // // _finishButton // this._finishButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); this._finishButton.AutoSize = true; this._finishButton.Enabled = false; this._finishButton.Location = new System.Drawing.Point(160, 0); this._finishButton.Margin = new System.Windows.Forms.Padding(0); this._finishButton.MinimumSize = new System.Drawing.Size(75, 23); this._finishButton.Name = "_finishButton"; this._finishButton.TabIndex = 50; this._finishButton.Click += new System.EventHandler(this.OnFinishButtonClick); // // _dummyLabel3 // this._dummyLabel3.Location = new System.Drawing.Point(235, 0); this._dummyLabel3.Margin = new System.Windows.Forms.Padding(0); this._dummyLabel3.Name = "_dummyLabel3"; this._dummyLabel3.Size = new System.Drawing.Size(7, 0); this._dummyLabel3.TabIndex = 60; // // _cancelButton // this._cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); this._cancelButton.AutoSize = true; this._cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; this._cancelButton.Location = new System.Drawing.Point(242, 0); this._cancelButton.Margin = new System.Windows.Forms.Padding(0); this._cancelButton.MinimumSize = new System.Drawing.Size(75, 23); this._cancelButton.Name = "_cancelButton"; this._cancelButton.TabIndex = 70; this._cancelButton.Click += new System.EventHandler(this.OnCancelButtonClick); // // TaskForm // this.AcceptButton = this._nextButton; this.CancelButton = this._cancelButton; this.Controls.Add(this._wizardButtonsTableLayoutPanel); this.MinimumSize = new System.Drawing.Size(580, 450); this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show; this._wizardButtonsTableLayoutPanel.ResumeLayout(false); this._wizardButtonsTableLayoutPanel.PerformLayout(); InitializeForm(); this.ResumeLayout(false); this.PerformLayout(); } #endregion ////// Called after InitializeComponent to perform additional actions that /// are not supported by the designer. /// private void InitializeUI() { _cancelButton.Text = SR.GetString(SR.Wizard_CancelButton); _nextButton.Text = SR.GetString(SR.Wizard_NextButton); _previousButton.Text = SR.GetString(SR.Wizard_PreviousButton); _finishButton.Text = SR.GetString(SR.Wizard_FinishButton); } ////// Goes to the next panel in the wizard. /// public void NextPanel() { WizardPanel currentPanel = _panelHistory.Peek(); if (currentPanel.OnNext()) { currentPanel.Hide(); WizardPanel nextPanel = currentPanel.NextPanel; if (nextPanel != null) { RegisterPanel(nextPanel); _panelHistory.Push(nextPanel); OnPanelChanging(new WizardPanelChangingEventArgs(currentPanel)); ShowPanel(nextPanel); } } } ////// Click event handler for the Cancel button. /// protected virtual void OnCancelButtonClick(object sender, System.EventArgs e) { DialogResult = DialogResult.Cancel; Close(); } ////// Raises the InitialActivated event. /// protected override void OnInitialActivated(EventArgs e) { base.OnInitialActivated(e); if (_initialPanel != null) { RegisterPanel(_initialPanel); _panelHistory.Push(_initialPanel); ShowPanel(_initialPanel); } } ////// Click event handler for the Finish button. /// protected virtual void OnFinishButtonClick(object sender, System.EventArgs e) { WizardPanel currentPanel = _panelHistory.Peek(); if (currentPanel.OnNext()) { // Call OnComplete for every panel on the stack WizardPanel[] panels = _panelHistory.ToArray(); Array.Reverse(panels); foreach (WizardPanel panel in panels) { panel.OnComplete(); } DialogResult = DialogResult.OK; Close(); } } ////// Click event handler for the Next button. /// protected virtual void OnNextButtonClick(object sender, System.EventArgs e) { NextPanel(); } ////// Called when a panel is about to change. /// protected virtual void OnPanelChanging(WizardPanelChangingEventArgs e) { } ////// Click event handler for the Previous button. /// protected virtual void OnPreviousButtonClick(object sender, System.EventArgs e) { PreviousPanel(); } ////// Goes to the back panel in the wizard. /// public void PreviousPanel() { if (_panelHistory.Count > 1) { WizardPanel currentPanel = _panelHistory.Pop(); WizardPanel backPanel = _panelHistory.Peek(); currentPanel.OnPrevious(); currentPanel.Hide(); OnPanelChanging(new WizardPanelChangingEventArgs(currentPanel)); ShowPanel(backPanel); } } ////// Registers a panel for use in this wizard. /// internal void RegisterPanel(WizardPanel panel) { if (!TaskPanel.Controls.Contains(panel)) { panel.Dock = DockStyle.Fill; panel.SetParentWizard(this); panel.Hide(); TaskPanel.Controls.Add(panel); } } ////// Initializes a WizardForm to use an ordered array of panels. /// protected void SetPanels(WizardPanel[] panels) { if ((panels != null) && (panels.Length > 0)) { RegisterPanel(panels[0]); _initialPanel = panels[0]; for (int i = 0; i < panels.Length - 1; i++) { RegisterPanel(panels[i+1]); panels[i].NextPanel = panels[i + 1]; } } } ////// Shows the panel specified by the given index. /// private void ShowPanel(WizardPanel panel) { if (_panelHistory.Count == 1) { // If we're on the first panel, disable the back button PreviousButton.Enabled = false; } else { // Otherwise, enable it PreviousButton.Enabled = true; } if (panel.NextPanel == null) { // If we're on the last panel, change the button text NextButton.Enabled = false; } else { NextButton.Enabled = true; } // Show the specified panel panel.Show(); // Set the description and caption of the task bar AccessibleDescription = panel.Caption; CaptionLabel.Text = panel.Caption; if (IsHandleCreated) { // Refresh the screen Invalidate(); } // Focus the newly shown panel panel.Focus(); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- NativeMethods.cs
- TypeReference.cs
- RequestTimeoutManager.cs
- XmlJsonReader.cs
- CommonDialog.cs
- FileChangesMonitor.cs
- WebPartHeaderCloseVerb.cs
- CustomDictionarySources.cs
- MetadataArtifactLoaderResource.cs
- ExpressionStringBuilder.cs
- MetadataArtifactLoader.cs
- OleDbPropertySetGuid.cs
- NameValueConfigurationCollection.cs
- VideoDrawing.cs
- UnlockInstanceAsyncResult.cs
- ColumnMapCopier.cs
- HttpCapabilitiesSectionHandler.cs
- XsdDuration.cs
- DiscoveryDocumentSerializer.cs
- HideDisabledControlAdapter.cs
- LiteralText.cs
- XmlReaderSettings.cs
- RsaSecurityTokenAuthenticator.cs
- UpdateManifestForBrowserApplication.cs
- DeferrableContent.cs
- PropertyGridView.cs
- ManagedCodeMarkers.cs
- HostSecurityManager.cs
- SchemaImporter.cs
- XmlDocumentFragment.cs
- StackBuilderSink.cs
- XsltContext.cs
- ProcessStartInfo.cs
- ExceptionHelpers.cs
- PageHandlerFactory.cs
- AmbientProperties.cs
- TableRowGroup.cs
- BlurBitmapEffect.cs
- CustomTokenProvider.cs
- StorageFunctionMapping.cs
- contentDescriptor.cs
- DataContract.cs
- DataList.cs
- GlyphElement.cs
- ControlHelper.cs
- AspNetHostingPermission.cs
- ModuleElement.cs
- OutputWindow.cs
- ExtendedProperty.cs
- ThousandthOfEmRealDoubles.cs
- connectionpool.cs
- SqlStream.cs
- OperandQuery.cs
- ConfigurationSchemaErrors.cs
- SerializationInfoEnumerator.cs
- SoapIgnoreAttribute.cs
- RegularExpressionValidator.cs
- ClientUrlResolverWrapper.cs
- SrgsGrammar.cs
- LoginCancelEventArgs.cs
- AssemblyResourceLoader.cs
- DataGridViewImageColumn.cs
- WebPartEditorCancelVerb.cs
- SoapDocumentServiceAttribute.cs
- DynamicEntity.cs
- UserPreferenceChangingEventArgs.cs
- BamlMapTable.cs
- SystemThemeKey.cs
- URI.cs
- FixedHighlight.cs
- HtmlTernaryTree.cs
- UnsafeNativeMethods.cs
- RTLAwareMessageBox.cs
- QueryCoreOp.cs
- ReflectTypeDescriptionProvider.cs
- FixUpCollection.cs
- KnownAssembliesSet.cs
- CaseInsensitiveHashCodeProvider.cs
- WindowsToolbar.cs
- RegexBoyerMoore.cs
- WindowsIdentity.cs
- ColorPalette.cs
- AnnotationAuthorChangedEventArgs.cs
- ServiceContractListItem.cs
- SocketConnection.cs
- MouseWheelEventArgs.cs
- CalendarDateChangedEventArgs.cs
- PeerDuplexChannel.cs
- SerializationAttributes.cs
- Function.cs
- Control.cs
- WasNotInstalledException.cs
- ObjectParameterCollection.cs
- XmlWriterDelegator.cs
- EmptyTextWriter.cs
- CacheEntry.cs
- PaperSource.cs
- MinimizableAttributeTypeConverter.cs
- BufferModesCollection.cs
- Verify.cs