示例#1
0
        ///// <summary>
        ///// Verify if a list of source files can be added to the current source files list.
        ///// Currently we cannot mix HTML and Word documents as source files, and only one
        ///// HTML document can be source file. Multiple Word documents can be defined as
        ///// source documents.
        ///// </summary>
        ///// <param name="currentSourceFiles">Current list of source files</param>
        ///// <param name="newSourceFiles">New files to add to the source files</param>
        ///// <returns>A string with the error message if the new source files cannot be
        ///// added to the source files list. null if the new source files can be added.</returns>
        //static public string CanBeAddedToSourceFiles(List<string> currentSourceFiles, List<string> newSourceFiles)
        //{
        //    bool currentListEmpty = currentSourceFiles.Count == 0;
        //    bool currentListIsHtml = false;
        //    if (!currentListEmpty)
        //        currentListIsHtml = MSWord.IsHtmlDocument((string)currentSourceFiles[0]);
        //    foreach (String file in newSourceFiles)
        //    {
        //        bool fileIsHtml = MSWord.IsHtmlDocument(file);

        //        if (currentListEmpty)
        //        {
        //            currentListEmpty = false;
        //            currentListIsHtml = fileIsHtml;
        //        }
        //        else
        //        {
        //            if ((currentListIsHtml && !fileIsHtml) || (!currentListIsHtml && fileIsHtml))
        //                return "HTML and Word documents cannot be mixed as source documents";
        //            if (fileIsHtml)
        //                return "Only one HTML document can be used as source document";
        //        }
        //    }
        //    return null;
        //}

        /// <summary>
        /// Open a xml file with a ChmProject object serialized.
        /// </summary>
        /// <param name="filePath">Path to xml file to read.</param>
        /// <returns>The ChmProject readed.</returns>
        static public ChmProject Open(string filePath)
        {
            // Load and upgrade the xml project document
            ChmProjectXml xml = new ChmProjectXml();

            xml.Load(filePath);
            xml.UpgradeXml();
            ChmProject cfg = xml.Deserialize();

            // Change relative paths to absolute:
            cfg.MakePathsAbsolute(filePath);

            return(cfg);
        }
示例#2
0
        /// <summary>
        /// Open a xml file with a ChmProject object serialized.
        /// </summary>
        /// <param name="archivo">Path to xml file to read.</param>
        /// <returns>The ChmProject readed.</returns>
        public static ChmProject Open( string filePath )
        {
            // Load and upgrade the xml project document
            ChmProjectXml xml = new ChmProjectXml();
            xml.Load(filePath);
            xml.UpgradeXml();
            ChmProject cfg = xml.Deserialize();

            // Change relative paths to absolute:
            //if (AppSettings.SaveRelativePaths) < do it always
                cfg.MakePathsAbsolute(filePath);

            return cfg;
        }