} //WriteMessageRange

        private void FinishProgressWin(ProgressWin progressWin)
        {
            progressWin.SetButtonState(true);
            if (progressWin.ShouldShowHorizontalScrollBar)
            {
                progressWin.ResultOutput.HorizontalScrollbar = true;
            }

            progressWin.BringToFront();
            progressWin.SetButtonFocus();
        } //FinishProgressWin
        } //FinishProgressWin

        private bool CreateSPTemplate(Form callee, ProvisioningOptions provisioningOptions)
        {
            SourceWin callForm = callee as SourceWin;
            bool      result   = false;

            callForm.Visible = false;
            provisioningOptions.SharePointVersion = callForm.SelectedVersion;

            string spVersionTitle = EnsureVersionLoaded(provisioningOptions.SharePointVersion);

            ProgressWin progressWin = StartProgressWin(true, spVersionTitle);

            _lbOutput = progressWin.ResultOutput;

            switch (provisioningOptions.SharePointVersion)
            {
            case SharePointVersion.SharePoint_2013_On_Premises:
                result = _sp2013OnPrem.CreateProvisioningTemplate(provisioningOptions, WriteMessage, WriteMessageRange);

                break;

            case SharePointVersion.SharePoint_2016_On_Premises:
                result = _sp2016OnPrem.CreateProvisioningTemplate(provisioningOptions, WriteMessage, WriteMessageRange);

                break;

            case SharePointVersion.SharePoint_2016_OnLine:
                result = _sp2016Online.CreateProvisioningTemplate(provisioningOptions, WriteMessage, WriteMessageRange);

                break;

            default:
                break;
            }

            callForm.Visible = true;

            FinishProgressWin(progressWin);
            return(result);
        } //CreateSPTemplate
        } //EnsureVersionLoaded

        private ProgressWin StartProgressWin(bool isCreating, string sharePointVersion)
        {
            ProgressWin progressWin = new ProgressWin();

            progressWin.FormClosed += new FormClosedEventHandler(DestroyForm);
            progressWin.MdiParent   = this;
            progressWin.TopMost     = true;
            if (isCreating)
            {
                progressWin.Text = "Creating provisioning template from " + sharePointVersion;
            }
            else
            {
                progressWin.Text = "Applying provisioning template to " + sharePointVersion;
            }

            progressWin.SetStatusBarText = SetStatusBarText;
            progressWin.SetButtonState(false);
            progressWin.Show();
            Application.DoEvents();
            return(progressWin);
        } //StartProgressWin