Bloom.Wizard.WinForms.WizardControl.BeginInit C# (CSharp) Method

BeginInit() public method

public BeginInit ( ) : void
return void
        public void BeginInit()
        {
            _backButton = new Button { Text = "Back", Size = new Size(75, 25), Left = 0 };
            _backButton.Text = LocalizationManager.GetString("Common.BackButton", "Back", "In a wizard, this button takes you to the previous step.");
            _nextAndFinishedButton = new Button { Text = "Next", Size = new Size(75, 25), Left = 80};
            _nextAndFinishedButton.Text = LocalizationManager.GetString("Common.NextButton", "Next", "In a wizard, this button takes you to the next step.");
            _cancelButton = new Button { Text = "Cancel", Size = new Size(75, 25), Left = 160 };
            _cancelButton.Text = LocalizationManager.GetString("Common.CancelButton", "Cancel");

            _contentPanel = new Panel { Dock = DockStyle.Fill };

            _buttonPanel = new Panel { Dock = DockStyle.Bottom, Height = 35, Padding = new Padding(5) };
            var panel = new Panel { Dock = DockStyle.Right, AutoSize = true };
            panel.Controls.Add(_backButton);
            panel.Controls.Add(_nextAndFinishedButton);
            panel.Controls.Add(_cancelButton);

            _buttonPanel.Controls.Add(panel);
        }

Usage Example

        public void Setup()
        {
            InitializeControl = () =>
            {
                _winformsWizard = new WinForms.WizardControl();

                _winformsWizard.Cancelled += (sender, e) =>
                {
                    if (this.Cancelled != null)
                    {
                        this.Cancelled(sender, e);
                    }
                };

                _winformsWizard.Finished += (sender, e) =>
                {
                    if (this.Finished != null)
                    {
                        this.Finished(sender, e);
                    }
                };

                _winformsWizard.SelectedPageChanged += (sender, e) =>
                {
                    if (this.SelectedPageChanged != null)
                    {
                        this.SelectedPageChanged(sender, e);
                    }
                };
            };

            GetSelectedPage = () => new WizardAdapterPage(_winformsWizard.SelectedPage);

            GetPages = () =>
            {
                if (_pages == null)
                {
                    _pages = new List <WizardAdapterPage>();
                    foreach (var page in _winformsWizard.Pages)
                    {
                        _pages.Add(new WizardAdapterPage(page));
                    }
                }

                return(_pages);
            };

            GetTitle            = () => _winformsWizard.Title;
            SetTitle            = (value) => _winformsWizard.Title = value;
            GetNextButtonText   = () => _winformsWizard.NextButtonText;
            SetNextButtonText   = (value) => _winformsWizard.NextButtonText = value;
            GetFinishButtonText = () => _winformsWizard.FinishButtonText;
            SetFinishButtonText = (value) => _winformsWizard.FinishButtonText = value;
            GetCancelButtonText = () => _winformsWizard.CancelButtonText;
            SetCancelButtonText = (value) => _winformsWizard.CancelButtonText = value;
            GetIcon             = () => _winformsWizard.TitleIcon;
            SetIcon             = (icon) => _winformsWizard.TitleIcon = icon;

            BeginInitLogic = () => _winformsWizard.BeginInit();
            EndInitLogic   = () =>
            {
                foreach (WizardAdapterPage page in _pages)
                {
                    page.WinFormPage.AddControls(page.Controls.Cast <Control>().ToArray());

                    _winformsWizard.Pages.Add(page.WinFormPage);
                }

                this.Controls.Add(_winformsWizard);

                _winformsWizard.EndInit();
            };
            AfterInitialization = () => _winformsWizard.ShowFirstPage();
        }