using System; using System.Collections; using System.Text; using System.IO; using System.Globalization; using System.Diagnostics; using System.ComponentModel; using HtmlHelp.ChmDecoding; // using HtmlHelp.Storage; namespace HtmlHelp { /// /// The class ChmFileInfo only extracts system information from a CHM file. /// It doesn't build the index and table of contents. /// public class ChmFileInfo { /// /// Internal member storing the full filename /// private string _chmFileName = ""; /// /// Internal member storing the associated chmfile object /// private CHMFile _associatedFile = null; /// /// Constructor for extrating the file information of the provided file. /// The constructor opens the chm-file and reads its system data. /// /// full file name which information should be extracted public ChmFileInfo(string chmFile) { if(!File.Exists(chmFile)) throw new ArgumentException("Chm file must exist on disk !", "chmFileName"); if( ! chmFile.ToLower().EndsWith(".chm") ) throw new ArgumentException("HtmlHelp file must have the extension .chm !", "chmFile"); _chmFileName = chmFile; _associatedFile = new CHMFile(null, chmFile, true); // only load system data of chm } /// /// Internal constructor used in the class CHMFile. /// /// associated chm file internal ChmFileInfo(CHMFile associatedFile) { _associatedFile = associatedFile; if( _associatedFile == null) throw new ArgumentException("Associated CHMFile instance must not be null !", "associatedFile"); } #region default info properties /// /// Gets the full filename of the chm file /// public string ChmFileName { get { return _associatedFile.ChmFilePath; } } /// /// Gets a FileInfo instance for the chm file. /// public FileInfo FileInfo { get { return new FileInfo(_associatedFile.ChmFilePath); } } #endregion #region #SYSTEM properties /// /// Gets the file version of the chm file. /// 2 for Compatibility=1.0, 3 for Compatibility=1.1 /// public int FileVersion { get { if(_associatedFile != null) return _associatedFile.FileVersion; return 0; } } /// /// Gets the contents file name /// public string ContentsFile { get { if(_associatedFile != null) return _associatedFile.ContentsFile; return ""; } } /// /// Gets the index file name /// public string IndexFile { get { if(_associatedFile != null) return _associatedFile.IndexFile; return ""; } } /// /// Gets the default help topic /// public string DefaultTopic { get { if(_associatedFile != null) return _associatedFile.DefaultTopic; return ""; } } /// /// Gets the title of the help window /// public string HelpWindowTitle { get { if(_associatedFile != null) return _associatedFile.HelpWindowTitle; return ""; } } /// /// Gets the flag if DBCS is in use /// public bool DBCS { get { if(_associatedFile != null) return _associatedFile.DBCS; return false; } } /// /// Gets the flag if full-text-search is available /// public bool FullTextSearch { get { if(_associatedFile != null) return _associatedFile.FullTextSearch; return false; } } /// /// Gets the flag if the file has ALinks /// public bool HasALinks { get { if(_associatedFile != null) return _associatedFile.HasALinks; return false; } } /// /// Gets the flag if the file has KLinks /// public bool HasKLinks { get { if(_associatedFile != null) return _associatedFile.HasKLinks; return false; } } /// /// Gets the default window name /// public string DefaultWindow { get { if(_associatedFile != null) return _associatedFile.DefaultWindow; return ""; } } /// /// Gets the file name of the compile file /// public string CompileFile { get { if(_associatedFile != null) return _associatedFile.CompileFile; return ""; } } /// /// Gets the flag if the chm has a binary index file /// public bool BinaryIndex { get { if(_associatedFile != null) return _associatedFile.BinaryIndex; return false; } } /// /// Gets the flag if the chm has a binary index file /// public string CompilerVersion { get { if(_associatedFile != null) return _associatedFile.CompilerVersion; return ""; } } /// /// Gets the flag if the chm has a binary toc file /// public bool BinaryTOC { get { if(_associatedFile != null) return _associatedFile.BinaryTOC; return false; } } /// /// Gets the font face of the read font property. /// Empty string for default font. /// public string FontFace { get { if(_associatedFile != null) return _associatedFile.FontFace; return ""; } } /// /// Gets the font size of the read font property. /// 0 for default font size /// public double FontSize { get { if(_associatedFile != null) return _associatedFile.FontSize; return 0.0; } } /// /// Gets the character set of the read font property /// 1 for default /// public int CharacterSet { get { if(_associatedFile != null) return _associatedFile.CharacterSet; return 1; } } /// /// Gets the codepage depending on the read font property /// public int CodePage { get { if(_associatedFile != null) return _associatedFile.CodePage; return 0; } } /// /// Gets the assiciated culture info /// public CultureInfo Culture { get { if(_associatedFile != null) return _associatedFile.Culture; return CultureInfo.CurrentCulture; } } #endregion #region #IDXHDR properties /// /// Gets the number of topic nodes including the contents and index files /// public int NumberOfTopicNodes { get { if(_associatedFile != null) return _associatedFile.NumberOfTopicNodes; return 0; } } /// /// Gets the ImageList string specyfied in the #IDXHDR file. /// /// This property uses the #STRINGS file to extract the string at a given offset. public string ImageList { get { if(_associatedFile != null) return _associatedFile.ImageList; return ""; } } /// /// Gets the background setting /// public int Background { get { if(_associatedFile != null) return _associatedFile.Background; return 0; } } /// /// Gets the foreground setting /// public int Foreground { get { if(_associatedFile != null) return _associatedFile.Foreground; return 0; } } /// /// Gets the FrameName string specyfied in the #IDXHDR file. /// /// This property uses the #STRINGS file to extract the string at a given offset. public string FrameName { get { if(_associatedFile != null) return _associatedFile.FrameName; return ""; } } /// /// Gets the WindowName string specyfied in the #IDXHDR file. /// /// This property uses the #STRINGS file to extract the string at a given offset. public string WindowName { get { if(_associatedFile != null) return _associatedFile.WindowName; return ""; } } /// /// Gets a string array containing the merged file names /// public string[] MergedFiles { get { if(_associatedFile != null) return _associatedFile.MergedFiles; return new string[0]; } } #endregion } }