} //ShowCreateForm

        private void ShowEditForm(object sender, EventArgs e)
        {
            SharePointVersion version = GetVersion("of the template to edit");

            if (version != SharePointVersion.SharePoint_Invalid)
            {
                EditWin editForm = new EditWin();

                editForm.FormClosed     += new FormClosedEventHandler(DestroyForm);
                editForm.Text            = "Edit Template - ";
                editForm.SelectedVersion = version;

                switch (version)
                {
                case SharePointVersion.SharePoint_2013_On_Premises:
                    editForm.Text += Constants.SharePoint_2013_On_Premises;
                    if (_sp2013OnPrem == null)
                    {
                        _sp2013OnPrem = Program.LoadSPLoader(version);
                    }

                    editForm.SharePointLoader = _sp2013OnPrem;

                    break;

                case SharePointVersion.SharePoint_2016_On_Premises:
                    editForm.Text += Constants.SharePoint_2016_On_Premises;
                    if (_sp2016OnPrem == null)
                    {
                        _sp2016OnPrem = Program.LoadSPLoader(version);
                    }

                    editForm.SharePointLoader = _sp2016OnPrem;

                    break;

                case SharePointVersion.SharePoint_2016_OnLine:
                    editForm.Text += Constants.SharePoint_2016_Online;
                    if (_sp2016Online == null)
                    {
                        _sp2016Online = Program.LoadSPLoader(version);
                    }

                    editForm.SharePointLoader = _sp2016Online;

                    break;

                default:
                    break;
                }

                editForm.OpenTemplate = OpenFile;

                editForm.SetStatusBarText = SetStatusBarText;

                editForm.MdiParent = this;

                editForm.Show();
            }
        } //ShowEditForm
        } //bCancel_Click

        private void SetVersionSelected(object sender, EventArgs e)
        {
            RadioButton rb = sender as RadioButton;

            if (rb.Checked)
            {
                switch (rb.Name)
                {
                case "rbSP2013OP":
                    _versionSelected = SharePointVersion.SharePoint_2013_On_Premises;

                    break;

                case "rbSP2016OP":
                    _versionSelected = SharePointVersion.SharePoint_2016_On_Premises;

                    break;

                case "rbSP2016OL":
                    _versionSelected = SharePointVersion.SharePoint_2016_OnLine;

                    break;

                default:

                    break;
                }
            }
        } //SetVersionSelected
        /// <summary>
        /// Opens the in SharePoint designer.
        /// </summary>
        /// <param name="url">The URL.</param>
        void OpenInSharePointDesigner(string url)
        {
            string path = String.Empty;

            SharePointVersion version = ProjectUtilities.WhichSharePointVersionIsProjectDeployingTo();

            if (version == SharePointVersion.SP2010)
            {
                path = Path.Combine(ProjectUtilities.GetSharePoint14DesignerInstallRoot(),
                                    "SPDesign.exe");
            }
            else if (version == SharePointVersion.SP2013)
            {
                path = Path.Combine(ProjectUtilities.GetSharePoint15DesignerInstallRoot(),
                                    "SPDesign.exe");
            }

            ProcessUtilities utils = new ProcessUtilities();

            if (!String.IsNullOrEmpty(path))
            {
                if (File.Exists(path))
                {
                    utils.StartProcess(DTEManager.ActiveSharePointProject, path, url);
                }
            }
        }
 public SPEvolutionManager(SharePointVersion sharepointVersion, Assembly asm, SPWeb web)
 {
     if (asm == null)
         throw new ArgumentNullException("Assembly file not found");
     evoAssembly = new SPEvolutionAssembly(asm);
     provider = new SPEvolutionProvider(web);
 }
        } //ShowApplyForm

        private void ShowCreateForm(object sender, EventArgs e)
        {
            SharePointVersion version = GetVersion("to create the template from");

            if (version != SharePointVersion.SharePoint_Invalid)
            {
                SourceWin createForm = new SourceWin();

                createForm.FormClosed += new FormClosedEventHandler(DestroyForm);
                createForm.Text        = "Create Template From ";

                switch (version)
                {
                case SharePointVersion.SharePoint_2013_On_Premises:
                    createForm.Text += Constants.SharePoint_2013_On_Premises;

                    break;

                case SharePointVersion.SharePoint_2016_On_Premises:
                    createForm.Text += Constants.SharePoint_2016_On_Premises;

                    break;

                case SharePointVersion.SharePoint_2016_OnLine:
                    createForm.Text += Constants.SharePoint_2016_Online;

                    break;

                default:
                    break;
                }

                createForm.CreateTemplate = CreateSPTemplate;

                createForm.SelectedVersion = version;

                createForm.SaveTemplate = SaveFile;

                createForm.SetStatusBarText = SetStatusBarText;

                createForm.MdiParent = this;

                createForm.Show();
            }
        } //ShowCreateForm
        } //GetVersion

        private void ShowApplyForm(object sender, EventArgs e)
        {
            SharePointVersion version = GetVersion("to apply the template to");

            if (version != SharePointVersion.SharePoint_Invalid)
            {
                TargetWin applyForm = new TargetWin();

                applyForm.FormClosed += new FormClosedEventHandler(DestroyForm);
                applyForm.Text        = "Apply Template To ";

                switch (version)
                {
                case SharePointVersion.SharePoint_2013_On_Premises:
                    applyForm.Text += Constants.SharePoint_2013_On_Premises;

                    break;

                case SharePointVersion.SharePoint_2016_On_Premises:
                    applyForm.Text += Constants.SharePoint_2016_On_Premises;

                    break;

                case SharePointVersion.SharePoint_2016_OnLine:
                    applyForm.Text += Constants.SharePoint_2016_Online;

                    break;

                default:
                    break;
                }

                applyForm.ApplyTemplate = ApplySPTemplate;

                applyForm.SelectedVersion = version;

                applyForm.OpenTemplate = OpenFile;

                applyForm.SetStatusBarText = SetStatusBarText;

                applyForm.MdiParent = this;

                applyForm.Show();
            }
        } //ShowApplyForm
        } //ArrangeIconsToolStripMenuItem_Click

        private SharePointVersion GetVersion(string topic)
        {
            SharePointVersion version = SharePointVersion.SharePoint_Invalid;

            SelectSharePoint dialog = new SelectSharePoint();

            dialog.FormClosed += new FormClosedEventHandler(DestroyForm);

            dialog.setTopic("Select the SharePoint version " + topic);

            dialog.SetStatusBarText = SetStatusBarText;

            DialogResult result = dialog.ShowDialog(this);

            if (result == DialogResult.OK)
            {
                version = dialog.VersionSelected;
            }

            return(version);
        } //GetVersion
        } //DestroyForm

        private string EnsureVersionLoaded(SharePointVersion version)
        {
            string spVersionTitle = string.Empty;

            switch (version)
            {
            case SharePointVersion.SharePoint_2013_On_Premises:
                spVersionTitle = Constants.SharePoint_2013_On_Premises;
                if (_sp2013OnPrem == null)
                {
                    _sp2013OnPrem = Program.LoadSPLoader(SharePointVersion.SharePoint_2013_On_Premises);
                }

                break;

            case SharePointVersion.SharePoint_2016_On_Premises:
                spVersionTitle = Constants.SharePoint_2016_On_Premises;
                if (_sp2016OnPrem == null)
                {
                    _sp2016OnPrem = Program.LoadSPLoader(SharePointVersion.SharePoint_2016_On_Premises);
                }

                break;

            case SharePointVersion.SharePoint_2016_OnLine:
                spVersionTitle = Constants.SharePoint_2016_Online;
                if (_sp2016Online == null)
                {
                    _sp2016Online = Program.LoadSPLoader(SharePointVersion.SharePoint_2016_OnLine);
                }

                break;

            default:
                break;
            }

            return(spVersionTitle);
        } //EnsureVersionLoaded
        public static SPLoader LoadSPLoader(SharePointVersion version)
        {
            SPLoader loader = null;

            switch (version)
            {
            case SharePointVersion.SharePoint_2013_On_Premises:

                AppDomainSetup setup2013OP = new AppDomainSetup()
                {
                    ApplicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
                    ApplicationName = NAME_SharePoint2013OnPrem,
                    PrivateBinPath  = $"{NAME_SharePoint2013OnPrem};",
                    DisallowApplicationBaseProbing = false,
                    DisallowBindingRedirects       = false
                };

                appDomain2013OP = AppDomain.CreateDomain(Constants.SharePoint_2013_On_Premises, null, setup2013OP);

                appDomain2013OP.Load(typeof(SPLoader).Assembly.FullName);

                loader = (SPLoader)Activator.CreateInstance(appDomain2013OP,
                                                            typeof(SPLoader).Assembly.FullName,
                                                            typeof(SPLoader).FullName,
                                                            false,
                                                            BindingFlags.Public | BindingFlags.Instance,
                                                            null, null, null, null).Unwrap();


                loader.LoadProvisioningAssembly(setup2013OP.ApplicationName);

                break;

            case SharePointVersion.SharePoint_2016_On_Premises:

                AppDomainSetup setup2016OP = new AppDomainSetup()
                {
                    ApplicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
                    ApplicationName = NAME_SharePoint2016OnPrem,
                    PrivateBinPath  = $"{NAME_SharePoint2016OnPrem};",
                    DisallowApplicationBaseProbing = false,
                    DisallowBindingRedirects       = false
                };

                appDomain2016OP = AppDomain.CreateDomain(Constants.SharePoint_2016_On_Premises, null, setup2016OP);

                appDomain2016OP.Load(typeof(SPLoader).Assembly.FullName);

                loader = (SPLoader)Activator.CreateInstance(appDomain2016OP,
                                                            typeof(SPLoader).Assembly.FullName,
                                                            typeof(SPLoader).FullName,
                                                            false,
                                                            BindingFlags.Public | BindingFlags.Instance,
                                                            null, null, null, null).Unwrap();


                loader.LoadProvisioningAssembly(setup2016OP.ApplicationName);

                break;

            case SharePointVersion.SharePoint_2016_OnLine:

                AppDomainSetup setup2016OL = new AppDomainSetup()
                {
                    ApplicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
                    ApplicationName = NAME_SharePoint2016Online,
                    PrivateBinPath  = $"{NAME_SharePoint2016Online};",
                    DisallowApplicationBaseProbing = false,
                    DisallowBindingRedirects       = false
                };

                appDomain2016OL = AppDomain.CreateDomain(Constants.SharePoint_2016_Online, null, setup2016OL);

                appDomain2016OL.Load(typeof(SPLoader).Assembly.FullName);

                loader = (SPLoader)Activator.CreateInstance(appDomain2016OL,
                                                            typeof(SPLoader).Assembly.FullName,
                                                            typeof(SPLoader).FullName,
                                                            false,
                                                            BindingFlags.Public | BindingFlags.Instance,
                                                            null, null, null, null).Unwrap();


                loader.LoadProvisioningAssembly(setup2016OL.ApplicationName);

                break;

            default:

                break;
            } //switch

            return(loader);
        } //LoadSPLoader