public void OnClick(Window mainWindow, Instance instance)
        {
            if (instance != null)
            {
                var connectionString = ProfileManager.GetConnectionString();
                var args             = new DeleteArgs(instance, connectionString);
                args.OnCompleted += () => mainWindow.Dispatcher.Invoke(() => OnPipelineCompleted(args));
                var index = MainWindowHelper.GetListItemID(instance.ID);
                int version;
                if (int.TryParse(instance.Product.ShortVersion, out version) && version < 90)
                {
                    WizardPipelineManager.Start("delete", mainWindow, args, null, (ignore) => OnWizardCompleted(index, args.HasInstallationBeenCompleted), () => null);
                }
                else
                {
                    string uninstallPath    = string.Empty;
                    SitecoreEnvironment env = SitecoreEnvironmentHelper.GetExistingSitecoreEnvironment(instance.Name);
                    if (!string.IsNullOrEmpty(env?.UnInstallDataPath))
                    {
                        uninstallPath = env.UnInstallDataPath;
                    }
                    else
                    {
                        foreach (string installName in Directory.GetDirectories(ApplicationManager.UnInstallParamsFolder).OrderByDescending(s => s.Length))
                        {
                            if (instance.Name.StartsWith(Path.GetFileName(installName)))
                            {
                                uninstallPath = installName;
                                break;
                            }
                        }
                    }
                    if (string.IsNullOrEmpty(uninstallPath))
                    {
                        WindowHelper.ShowMessage("UnInstall files not found.");
                        return;
                    }

                    Delete9WizardArgs delete9WizardArgsargs = new Delete9WizardArgs(instance, connectionString, uninstallPath);
                    WizardPipelineManager.Start("delete9", mainWindow, null, null, (ignore) => OnWizardCompleted(index, delete9WizardArgsargs.HasInstallationBeenCompleted), () => delete9WizardArgsargs);
                }
            }
        }
        public void InitializeStep(WizardArgs wizardArgs)
        {
            var    args             = wizardArgs as ReinstallWizardArgs;
            string uninstallPath    = string.Empty;
            SitecoreEnvironment env = SitecoreEnvironmentHelper.GetExistingSitecoreEnvironment(args.Instance.Name);

            if (!string.IsNullOrEmpty(env?.UnInstallDataPath))
            {
                uninstallPath = env.UnInstallDataPath;
            }
            else
            {
                foreach (string installName in Directory.GetDirectories(ApplicationManager.UnInstallParamsFolder).OrderByDescending(s => s.Length))
                {
                    if (args.Instance.Name.StartsWith(Path.GetFileName(installName)))
                    {
                        uninstallPath = installName;
                        break;
                    }
                }
            }

            if (string.IsNullOrEmpty(uninstallPath))
            {
                WindowHelper.ShowMessage("UnInstall files not found.");
                wizardArgs.WizardWindow.Close();
            }

            Tasker       tasker    = new Tasker(uninstallPath);
            InstallParam sqlServer = tasker.GlobalParams.FirstOrDefault(p => p.Name == "SqlServer");

            if (sqlServer != null)
            {
                sqlServer.Value = args.ConnectionString.DataSource;
            }

            InstallParam sqlAdminUser = tasker.GlobalParams.FirstOrDefault(p => p.Name == "SqlAdminUser");

            if (sqlAdminUser != null)
            {
                sqlAdminUser.Value = args.ConnectionString.UserID;
            }

            InstallParam sqlAdminPass = tasker.GlobalParams.FirstOrDefault(p => p.Name == "SqlAdminPassword");

            if (sqlAdminPass != null)
            {
                sqlAdminPass.Value = args.ConnectionString.Password;
            }

            tasker.UnInstall = true;
            args.Tasker      = tasker;
            StringBuilder displayText = new StringBuilder();

            displayText.AppendLine("Reinstall:");
            foreach (var task in tasker.Tasks.Where(t => t.SupportsUninstall()))
            {
                displayText.AppendLine(string.Format(" -{0}", task.Name));
            }

            this.TextBlock.Text = displayText.ToString();
            args.InstanceName   = args.Tasker.GlobalParams.First(p => p.Name == "SqlDbPrefix").Value;
        }