Exemple #1
0
        /// <summary>
        /// Cancel the current build process
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void miCancelBuild_Click(object sender, EventArgs e)
        {
            if (buildThread != null && buildThread.IsAlive)
            {
                try
                {
                    this.Cursor = Cursors.WaitCursor;
                    StatusBarTextProvider.UpdateProgress("Cancelling build...");
                    buildThread.Abort();

                    while (buildThread != null && !buildThread.Join(1000))
                    {
                        Application.DoEvents();
                    }

                    StatusBarTextProvider.ResetProgressBar();
                    System.Diagnostics.Debug.WriteLine("Thread stopped");
                }
                finally
                {
                    this.Cursor  = Cursors.Default;
                    buildThread  = null;
                    buildProcess = null;
                }
            }

            this.SetUIEnabledState(true);
        }
Exemple #2
0
        /// <summary>
        /// This is called by the build process thread to update the main
        /// window with information about its progress.
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void buildProcess_BuildProgress(object sender,
                                                BuildProgressEventArgs e)
        {
            if (this.InvokeRequired)
            {
                // Ignore it if we've already shut down
                if (!this.IsDisposed)
                {
                    this.Invoke(new EventHandler <BuildProgressEventArgs>(
                                    buildProcess_BuildProgress),
                                new object[] { sender, e });
                }
            }
            else
            {
                if (e.BuildStep < BuildStep.Completed)
                {
                    StatusBarTextProvider.UpdateProgress((int)e.BuildStep);
                }

                if (Settings.Default.VerboseLogging ||
                    e.BuildStep == BuildStep.Failed)
                {
                    txtOutput.AppendText(e.Message);
                    txtOutput.AppendText("\r\n");
                }
            }
        }
        /// <summary>
        /// Utilize the status strip label and progress bar via the status bar
        /// text provider.
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event argumnents</param>
        private void btnProgress_Click(object sender, EventArgs e)
        {
            StatusBarTextProvider.InitializeProgressBar(100);

            for (int i = 0; i < 100; i++)
            {
                StatusBarTextProvider.UpdateProgress(i + 1,
                                                     String.Format("Step #{0}", i + 1));

                System.Threading.Thread.Sleep(25);
            }

            StatusBarTextProvider.ResetProgressBar();
        }
Exemple #4
0
        /// <summary>
        /// Build the help file using the current project settings
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void miBuildProject_Click(object sender, EventArgs e)
        {
            // If it's a new project without a name, ask the
            // user to save it now.  This is required as we need
            // a base folder for any relative paths in the project.
            if (project.Filename == SandcastleProject.DefaultName)
            {
                miSaveProjectAs_Click(sender, e);

                if (project.Filename == SandcastleProject.DefaultName)
                {
                    return;
                }
            }

            this.SetUIEnabledState(false);
            lastBuiltHelpFile = null;
            txtOutput.Text    = String.Empty;

            buildProcess = new BuildProcess(project);
            buildProcess.BuildStepChanged +=
                new EventHandler <BuildProgressEventArgs>(
                    buildProcess_BuildStepChanged);
            buildProcess.BuildProgress +=
                new EventHandler <BuildProgressEventArgs>(
                    buildProcess_BuildProgress);

            StatusBarTextProvider.InitializeProgressBar(0,
                                                        (int)BuildStep.Completed, "Building help file");

            buildThread = new Thread(new ThreadStart(
                                         buildProcess.Build));
            buildThread.Name         = "Help file builder thread";
            buildThread.IsBackground = true;
            buildThread.Start();
        }
Exemple #5
0
        /// <summary>
        /// This is called by the build process thread to update the main
        /// window with the current build step.
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void buildProcess_BuildStepChanged(object sender,
                                                   BuildProgressEventArgs e)
        {
            string outputPath;

            if (this.InvokeRequired)
            {
                // Ignore it if we've already shut down or it hasn't
                // completed yet.
                if (!this.IsDisposed)
                {
                    this.Invoke(new EventHandler <BuildProgressEventArgs>(
                                    buildProcess_BuildStepChanged),
                                new object[] { sender, e });
                }
            }
            else
            {
                if (!Settings.Default.VerboseLogging)
                {
                    txtOutput.AppendText(e.BuildStep.ToString());
                    txtOutput.AppendText("\r\n");
                }

                if (e.HasCompleted)
                {
                    StatusBarTextProvider.ResetProgressBar();
                    this.SetUIEnabledState(true);

                    // Save the output log filename and help filename on
                    // completion if possible
                    outputPath = buildProcess.OutputFolder;

                    if (Directory.Exists(outputPath))
                    {
                        lastOutputLog = buildProcess.LogFilename;
                    }
                    else
                    {
                        lastOutputLog = null;
                    }

                    // Store the help file filename so that it can be viewed
                    // if it exists.
                    if (e.BuildStep == BuildStep.Completed)
                    {
                        switch (project.HelpFileFormat)
                        {
                        case HelpFileFormat.HtmlHelp1x:
                        case HelpFileFormat.Help1xAndHelp2x:
                            outputPath += project.HtmlHelpName + ".chm";
                            break;

                        case HelpFileFormat.HtmlHelp2x:
                            outputPath += project.HtmlHelpName + ".hxs";
                            break;

                        default:
                            outputPath += "Index.html";
                            break;
                        }

                        if (File.Exists(outputPath))
                        {
                            lastBuiltHelpFile = outputPath;
                        }
                    }

                    buildThread  = null;
                    buildProcess = null;
                }
            }
        }