Esempio n. 1
0
        // Compile() is called by a background Thread in ProgressForm so be carful

        void ICompilableHelp.Compile(IProgressReporter progressReporter) //Called by Progress form
        {
            try
            {
                HxComp hxsCompiler = new HxComp();
                hxsCompiler.Initialize();

                CompMsg compMsg = new CompMsg(progressReporter, this.logFile);
                compMsg.Log("Date: " + DateTime.Today.ToShortDateString() + ", " + DateTime.Today.ToShortTimeString());
                compMsg.Log("Log file: " + logFile);
                compMsg.Log("Project file: " + projectFile);
                compMsg.Log("");
                int cookie = hxsCompiler.AdviseCompilerMessageCallback(compMsg);

                // Compile
                //
                hxsCompiler.Compile(projectFile, hxsDir, outputFile, 0);

                hxsCompiler.UnadviseCompilerMessageCallback(cookie);   //Done - Break link with compMsg Obj
                compMsg.SaveLog();
                hxsCompiler = null;

                //Show the log file if errors
                if (compMsg.ErrorCount > 0)   //If nore Warnings
                {
                    SafeShowCompileError();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 2
0
        void ICompilable.Compile(IProgressReporter progressReporter)
        {
            HxComp hxsCompiler = new HxComp();

            hxsCompiler.Initialize();
            //MSHelpCompilerError compilerError = new MSHelpCompilerError();
            CompMsg compilerError;

            compilerError = new CompMsg(progressReporter);

            int i = hxsCompiler.AdviseCompilerMessageCallback(compilerError);


            hxsCompiler.Compile(projectFile, projectRoot, outputFile, 0);
            //if (compilerError.HxErrorType != MSHelpCompilerError.ErrorType.None)
            //{
            //    Console.WriteLine(compilerError.ShortErrorDescription);
            //}
            hxsCompiler.UnadviseCompilerMessageCallback(i);
            hxsCompiler = null;
        }
Esempio n. 3
0
        //Called by Progress form
        // Compile() is called by a background Thread in ProgressForm so be carful
        void ICompilableHelp.Compile(IProgressReporter progressReporter)
        {
            try
            {
                HxComp hxsCompiler = new HxComp();
                hxsCompiler.Initialize();

                CompMsg compMsg = new CompMsg(progressReporter, this.logFile);
                compMsg.Log("Date: " + DateTime.Today.ToShortDateString() + ", " + DateTime.Today.ToShortTimeString());
                compMsg.Log("Log file: " + logFile);
                compMsg.Log("Project file: " + projectFile);
                compMsg.Log("");
                int cookie = hxsCompiler.AdviseCompilerMessageCallback(compMsg);

                // Compile
                //
                hxsCompiler.Compile(projectFile, hxsDir, outputFile, 0);

                hxsCompiler.UnadviseCompilerMessageCallback(cookie);   //Done - Break link with compMsg Obj
                compMsg.SaveLog();
                hxsCompiler = null;

                //Show the log file if errors
                if (compMsg.ErrorCount > 0)   //If nore Warnings
                {
                    SafeShowCompileError();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 4
0
        private void exportToHxsFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (ContentDataSet.Tables["Item"].Rows.Count == 0)
                return;

            // Test if Help SDK Install - Suck it and see
            try
            {
                HxComp hxsCompiler = new HxComp();
                hxsCompiler.Initialize();
                hxsCompiler = null;
            }
            catch
            {
                MessageBox.Show(@"Please install the VS 2005\2008 SDK, which includes the MS Help 2.x SDK and compiler.",
                    "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            GenerateHxsForm exportDialog = new GenerateHxsForm();

            if (exportDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            appController.CreateHxs(exportDialog.FileTextBox.Text,
                exportDialog.TitleTextBox.Text,
                exportDialog.CopyrightComboBox.Text,
                currentLocale,
                ContentDataSet);

            ShowFileinExplorer(exportDialog.FileTextBox.Text);
        }
Esempio n. 5
0
        protected override bool OnExecute(BuildContext context)
        {
            bool processResult = false;

            if (String.IsNullOrEmpty(this.Application) &&
                String.IsNullOrEmpty(this.Arguments))
            {
                if (String.IsNullOrEmpty(_projectFile) ||
                    File.Exists(_projectFile) == false)
                {
                    return(processResult);
                }
            }

            BuildLogger logger = context.Logger;

            try
            {
                if (String.IsNullOrEmpty(_projectFile) ||
                    File.Exists(_projectFile) == false)
                {
                    processResult = this.Run(logger);
                }
                else
                {
                    HxComp hxsCompiler = new HxComp();
                    hxsCompiler.Initialize();

                    HxCompError compilerError = new HxCompError(logger, this.Verbosity);

                    compilerError.Attach(hxsCompiler);

                    hxsCompiler.Compile(_projectFile, Path.GetDirectoryName(_projectFile),
                                        null, 0);

                    compilerError.Detach(hxsCompiler);
                    hxsCompiler = null;

                    processResult = compilerError.IsSuccess;
                }

                if (!processResult)
                {
                    return(processResult);
                }
            }
            catch (ArgumentException)
            {
                // If the COM server compiler fails, run the command line version...
                processResult = this.Run(logger);

                if (!processResult)
                {
                    return(processResult);
                }
            }
            catch (Exception ex)
            {
                if (logger != null)
                {
                    logger.WriteLine(ex, BuildLoggerLevel.Error);
                }

                return(false);
            }

            // If the help is successfully compiled, then...
            // 1. Copy the compiled help files to the output folder...
            string workingDir = this.WorkingDirectory;

            if (!Directory.Exists(_helpDirectory))
            {
                Directory.CreateDirectory(_helpDirectory);
            }
            // If we need to keep the help sources, then just copy everything to
            // the output folder...
            string helpOutput = Path.Combine(_helpDirectory, _helpFolder);

            if (_keepSources)
            {
                string compiledDir = Path.Combine(workingDir, _helpFolder);
                if (!Directory.Exists(compiledDir))
                {
                    return(processResult);
                }
                if (Directory.Exists(helpOutput))
                {
                    DirectoryUtils.DeleteDirectory(helpOutput, true);
                }
                Directory.Move(compiledDir, helpOutput);

                string destHelpPath = Path.Combine(helpOutput, _helpName + ".HxS");
                context.AddOutput(BuildFormatType.HtmlHelp2, destHelpPath);
            }
            else  //...otherwise, just copy the essentials...
            {
                if (!Directory.Exists(helpOutput))
                {
                    Directory.CreateDirectory(helpOutput);
                }
                string sourceHelpPath = Path.Combine(workingDir,
                                                     String.Format(@"{0}\{1}.HxS", _helpFolder, _helpName));
                string destHelpPath = Path.Combine(helpOutput, _helpName + ".HxS");
                if (File.Exists(sourceHelpPath))
                {
                    File.Copy(sourceHelpPath, destHelpPath, true);
                    File.SetAttributes(destHelpPath, FileAttributes.Normal);
                    context.AddOutput(BuildFormatType.HtmlHelp2, destHelpPath);
                }
                // Copy the log file, if available...
                sourceHelpPath = Path.ChangeExtension(sourceHelpPath, ".log");
                if (File.Exists(sourceHelpPath))
                {
                    destHelpPath = Path.ChangeExtension(destHelpPath, ".log");
                    File.Copy(sourceHelpPath, destHelpPath, true);
                    File.SetAttributes(destHelpPath, FileAttributes.Normal);
                }
                // Copy the separated index file, if available...
                sourceHelpPath = Path.ChangeExtension(sourceHelpPath, ".HxI");
                if (File.Exists(sourceHelpPath))
                {
                    destHelpPath = Path.ChangeExtension(destHelpPath, ".HxI");
                    File.Copy(sourceHelpPath, destHelpPath, true);
                    File.SetAttributes(destHelpPath, FileAttributes.Normal);
                }
            }

            // 2. Create the help collection files for registration...
            processResult = CreateCollection(context);

            return(processResult);
        }