/// <devdoc> /// Registers a panel for use in this wizard. /// </devdoc> internal void RegisterPanel(WizardPanel panel) { if (!TaskPanel.Controls.Contains(panel)) { panel.Dock = DockStyle.Fill; panel.SetParentWizard(this); panel.Hide(); TaskPanel.Controls.Add(panel); } }
/// <devdoc> /// Goes to the back panel in the wizard. /// </devdoc> 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); } }
/// <devdoc> /// Initializes a WizardForm to use an ordered array of panels. /// </devdoc> 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]; } } }
/// <devdoc> /// Goes to the next panel in the wizard. /// </devdoc> 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); } } }
/// <devdoc> /// Click event handler for the Finish button. /// </devdoc> 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(); } }
/// <devdoc> /// Shows the panel specified by the given index. /// </devdoc> 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(); }
/// <devdoc> /// </devdoc> public WizardPanelChangingEventArgs(WizardPanel currentPanel) { _currentPanel = currentPanel; }
/// <devdoc> /// </devdoc> public WizardPanelChangingEventArgs(WizardPanel currentPanel) { _currentPanel = currentPanel; }
/// <devdoc> /// Shows the panel specified by the given index. /// </devdoc> 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(); }
/// <devdoc> /// Initializes a WizardForm to use an ordered array of panels. /// </devdoc> 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]; } } }
/// <devdoc> /// Registers a panel for use in this wizard. /// </devdoc> internal void RegisterPanel(WizardPanel panel) { if (!TaskPanel.Controls.Contains(panel)) { panel.Dock = DockStyle.Fill; panel.SetParentWizard(this); panel.Hide(); TaskPanel.Controls.Add(panel); } }