2 using System.Collections;
5 using System.Globalization;
6 using System.Diagnostics;
7 using System.ComponentModel;
9 using HtmlHelp.ChmDecoding;
10 // using HtmlHelp.Storage;
15 /// The class <c>ChmFileInfo</c> only extracts system information from a CHM file.
16 /// It doesn't build the index and table of contents.
18 public class ChmFileInfo
21 /// Internal member storing the full filename
23 private string _chmFileName = "";
25 /// Internal member storing the associated chmfile object
27 private CHMFile _associatedFile = null;
30 /// Constructor for extrating the file information of the provided file.
31 /// The constructor opens the chm-file and reads its system data.
33 /// <param name="chmFile">full file name which information should be extracted</param>
34 public ChmFileInfo(string chmFile)
36 if(!File.Exists(chmFile))
37 throw new ArgumentException("Chm file must exist on disk !", "chmFileName");
39 if( ! chmFile.ToLower().EndsWith(".chm") )
40 throw new ArgumentException("HtmlHelp file must have the extension .chm !", "chmFile");
42 _chmFileName = chmFile;
43 _associatedFile = new CHMFile(null, chmFile, true); // only load system data of chm
47 /// Internal constructor used in the class <see cref="HtmlHelp.ChmDecoding.CHMFile">CHMFile</see>.
49 /// <param name="associatedFile">associated chm file</param>
50 internal ChmFileInfo(CHMFile associatedFile)
52 _associatedFile = associatedFile;
54 if( _associatedFile == null)
55 throw new ArgumentException("Associated CHMFile instance must not be null !", "associatedFile");
58 #region default info properties
60 /// Gets the full filename of the chm file
62 public string ChmFileName
66 return _associatedFile.ChmFilePath;
71 /// Gets a <see cref="System.IO.FileInfo">FileInfo</see> instance for the chm file.
73 public FileInfo FileInfo
75 get { return new FileInfo(_associatedFile.ChmFilePath); }
79 #region #SYSTEM properties
81 /// Gets the file version of the chm file.
82 /// 2 for Compatibility=1.0, 3 for Compatibility=1.1
84 public int FileVersion
88 if(_associatedFile != null)
89 return _associatedFile.FileVersion;
96 /// Gets the contents file name
99 public string ContentsFile
103 if(_associatedFile != null)
104 return _associatedFile.ContentsFile;
111 /// Gets the index file name
114 public string IndexFile
118 if(_associatedFile != null)
119 return _associatedFile.IndexFile;
126 /// Gets the default help topic
129 public string DefaultTopic
133 if(_associatedFile != null)
134 return _associatedFile.DefaultTopic;
141 /// Gets the title of the help window
144 public string HelpWindowTitle
148 if(_associatedFile != null)
149 return _associatedFile.HelpWindowTitle;
156 /// Gets the flag if DBCS is in use
163 if(_associatedFile != null)
164 return _associatedFile.DBCS;
171 /// Gets the flag if full-text-search is available
174 public bool FullTextSearch
178 if(_associatedFile != null)
179 return _associatedFile.FullTextSearch;
186 /// Gets the flag if the file has ALinks
189 public bool HasALinks
193 if(_associatedFile != null)
194 return _associatedFile.HasALinks;
201 /// Gets the flag if the file has KLinks
204 public bool HasKLinks
208 if(_associatedFile != null)
209 return _associatedFile.HasKLinks;
216 /// Gets the default window name
219 public string DefaultWindow
223 if(_associatedFile != null)
224 return _associatedFile.DefaultWindow;
231 /// Gets the file name of the compile file
234 public string CompileFile
238 if(_associatedFile != null)
239 return _associatedFile.CompileFile;
246 /// Gets the flag if the chm has a binary index file
249 public bool BinaryIndex
253 if(_associatedFile != null)
254 return _associatedFile.BinaryIndex;
261 /// Gets the flag if the chm has a binary index file
264 public string CompilerVersion
268 if(_associatedFile != null)
269 return _associatedFile.CompilerVersion;
276 /// Gets the flag if the chm has a binary toc file
279 public bool BinaryTOC
283 if(_associatedFile != null)
284 return _associatedFile.BinaryTOC;
291 /// Gets the font face of the read font property.
292 /// Empty string for default font.
295 public string FontFace
299 if(_associatedFile != null)
300 return _associatedFile.FontFace;
307 /// Gets the font size of the read font property.
308 /// 0 for default font size
311 public double FontSize
315 if(_associatedFile != null)
316 return _associatedFile.FontSize;
323 /// Gets the character set of the read font property
327 public int CharacterSet
331 if(_associatedFile != null)
332 return _associatedFile.CharacterSet;
339 /// Gets the codepage depending on the read font property
346 if(_associatedFile != null)
347 return _associatedFile.CodePage;
354 /// Gets the assiciated culture info
356 public CultureInfo Culture
360 if(_associatedFile != null)
361 return _associatedFile.Culture;
363 return CultureInfo.CurrentCulture;
368 #region #IDXHDR properties
370 /// Gets the number of topic nodes including the contents and index files
373 public int NumberOfTopicNodes
377 if(_associatedFile != null)
378 return _associatedFile.NumberOfTopicNodes;
385 /// Gets the ImageList string specyfied in the #IDXHDR file.
387 /// <remarks>This property uses the #STRINGS file to extract the string at a given offset.</remarks>
389 public string ImageList
393 if(_associatedFile != null)
394 return _associatedFile.ImageList;
401 /// Gets the background setting
404 public int Background
408 if(_associatedFile != null)
409 return _associatedFile.Background;
416 /// Gets the foreground setting
419 public int Foreground
423 if(_associatedFile != null)
424 return _associatedFile.Foreground;
431 /// Gets the FrameName string specyfied in the #IDXHDR file.
433 /// <remarks>This property uses the #STRINGS file to extract the string at a given offset.</remarks>
435 public string FrameName
439 if(_associatedFile != null)
440 return _associatedFile.FrameName;
447 /// Gets the WindowName string specyfied in the #IDXHDR file.
449 /// <remarks>This property uses the #STRINGS file to extract the string at a given offset.</remarks>
451 public string WindowName
455 if(_associatedFile != null)
456 return _associatedFile.WindowName;
463 /// Gets a string array containing the merged file names
465 public string[] MergedFiles
469 if(_associatedFile != null)
470 return _associatedFile.MergedFiles;
472 return new string[0];