Пример #1
0
        private void BtnBuild_Click(object sender, RoutedEventArgs e)
        {
            BuildOptions options = new BuildOptions();

            options.CleanOutputDirectory = cbCleanOutputDirectory.IsChecked.Value;
            options.BuildSettings        = buildSettings;
            options.Type            = cbBuildEntireProject.IsChecked.Value ? BuildOptions.BuildType.EntireManualAllVersions : BuildOptions.BuildType.EntireManualSpecificVersions;
            options.VersionsToBuild = new List <Models.Version>();
            if (cbBuildSpecificPages.IsChecked.Value)
            {
                foreach (ListBoxItem item in lsbVersions.SelectedItems)
                {
                    options.VersionsToBuild.Add(item.Tag as Models.Version);
                }
            }
            else
            {
                options.VersionsToBuild.AddRange(project.Versions);
            }

            if (!options.VersionsToBuild.Any())
            {
                return;
            }

            if (cbCleanOutputDirectory.IsChecked.Value)
            {
                if (!builder.CleanOutputDirectory(project))
                {
                    return;
                }
            }
            btnBuild.IsEnabled             = false;
            btnCancel.IsEnabled            = false;
            btnBuildSettings.IsEnabled     = false;
            lsbVersions.IsEnabled          = false;
            cbBuildEntireProject.IsEnabled = false;
            cbBuildSpecificPages.IsEnabled = false;
            bool succes = true;

            foreach (Models.Version version in options.VersionsToBuild)
            {
                if (!builder.Build(options, project, version))
                {
                    succes = false;
                }
            }

            if (succes)
            {
                Close();
                new BuildCompleted(project.OutputFolder).ShowDialog();
            }
            else
            {
                btnBuild.IsEnabled             = true;
                btnCancel.IsEnabled            = true;
                btnBuildSettings.IsEnabled     = true;
                lsbVersions.IsEnabled          = true;
                cbBuildEntireProject.IsEnabled = true;
                cbBuildSpecificPages.IsEnabled = true;
            }
        }