fix typos.
[reactos.git] / irc / TechBot / CHMLibrary / ChmFileInfo.cs
1 using System;
2 using System.Collections;
3 using System.Text;
4 using System.IO;
5 using System.Globalization;
6 using System.Diagnostics;
7 using System.ComponentModel;
8
9 using HtmlHelp.ChmDecoding;
10 // using HtmlHelp.Storage;
11
12 namespace HtmlHelp
13 {
14 /// <summary>
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.
17 /// </summary>
18 public class ChmFileInfo
19 {
20 /// <summary>
21 /// Internal member storing the full filename
22 /// </summary>
23 private string _chmFileName = "";
24 /// <summary>
25 /// Internal member storing the associated chmfile object
26 /// </summary>
27 private CHMFile _associatedFile = null;
28
29 /// <summary>
30 /// Constructor for extrating the file information of the provided file.
31 /// The constructor opens the chm-file and reads its system data.
32 /// </summary>
33 /// <param name="chmFile">full file name which information should be extracted</param>
34 public ChmFileInfo(string chmFile)
35 {
36 if(!File.Exists(chmFile))
37 throw new ArgumentException("Chm file must exist on disk !", "chmFileName");
38
39 if( ! chmFile.ToLower().EndsWith(".chm") )
40 throw new ArgumentException("HtmlHelp file must have the extension .chm !", "chmFile");
41
42 _chmFileName = chmFile;
43 _associatedFile = new CHMFile(null, chmFile, true); // only load system data of chm
44 }
45
46 /// <summary>
47 /// Internal constructor used in the class <see cref="HtmlHelp.ChmDecoding.CHMFile">CHMFile</see>.
48 /// </summary>
49 /// <param name="associatedFile">associated chm file</param>
50 internal ChmFileInfo(CHMFile associatedFile)
51 {
52 _associatedFile = associatedFile;
53
54 if( _associatedFile == null)
55 throw new ArgumentException("Associated CHMFile instance must not be null !", "associatedFile");
56 }
57
58 #region default info properties
59 /// <summary>
60 /// Gets the full filename of the chm file
61 /// </summary>
62 public string ChmFileName
63 {
64 get
65 {
66 return _associatedFile.ChmFilePath;
67 }
68 }
69
70 /// <summary>
71 /// Gets a <see cref="System.IO.FileInfo">FileInfo</see> instance for the chm file.
72 /// </summary>
73 public FileInfo FileInfo
74 {
75 get { return new FileInfo(_associatedFile.ChmFilePath); }
76 }
77 #endregion
78
79 #region #SYSTEM properties
80 /// <summary>
81 /// Gets the file version of the chm file.
82 /// 2 for Compatibility=1.0, 3 for Compatibility=1.1
83 /// </summary>
84 public int FileVersion
85 {
86 get
87 {
88 if(_associatedFile != null)
89 return _associatedFile.FileVersion;
90
91 return 0;
92 }
93 }
94
95 /// <summary>
96 /// Gets the contents file name
97 /// </summary>
98
99 public string ContentsFile
100 {
101 get
102 {
103 if(_associatedFile != null)
104 return _associatedFile.ContentsFile;
105
106 return "";
107 }
108 }
109
110 /// <summary>
111 /// Gets the index file name
112 /// </summary>
113
114 public string IndexFile
115 {
116 get
117 {
118 if(_associatedFile != null)
119 return _associatedFile.IndexFile;
120
121 return "";
122 }
123 }
124
125 /// <summary>
126 /// Gets the default help topic
127 /// </summary>
128
129 public string DefaultTopic
130 {
131 get
132 {
133 if(_associatedFile != null)
134 return _associatedFile.DefaultTopic;
135
136 return "";
137 }
138 }
139
140 /// <summary>
141 /// Gets the title of the help window
142 /// </summary>
143
144 public string HelpWindowTitle
145 {
146 get
147 {
148 if(_associatedFile != null)
149 return _associatedFile.HelpWindowTitle;
150
151 return "";
152 }
153 }
154
155 /// <summary>
156 /// Gets the flag if DBCS is in use
157 /// </summary>
158
159 public bool DBCS
160 {
161 get
162 {
163 if(_associatedFile != null)
164 return _associatedFile.DBCS;
165
166 return false;
167 }
168 }
169
170 /// <summary>
171 /// Gets the flag if full-text-search is available
172 /// </summary>
173
174 public bool FullTextSearch
175 {
176 get
177 {
178 if(_associatedFile != null)
179 return _associatedFile.FullTextSearch;
180
181 return false;
182 }
183 }
184
185 /// <summary>
186 /// Gets the flag if the file has ALinks
187 /// </summary>
188
189 public bool HasALinks
190 {
191 get
192 {
193 if(_associatedFile != null)
194 return _associatedFile.HasALinks;
195
196 return false;
197 }
198 }
199
200 /// <summary>
201 /// Gets the flag if the file has KLinks
202 /// </summary>
203
204 public bool HasKLinks
205 {
206 get
207 {
208 if(_associatedFile != null)
209 return _associatedFile.HasKLinks;
210
211 return false;
212 }
213 }
214
215 /// <summary>
216 /// Gets the default window name
217 /// </summary>
218
219 public string DefaultWindow
220 {
221 get
222 {
223 if(_associatedFile != null)
224 return _associatedFile.DefaultWindow;
225
226 return "";
227 }
228 }
229
230 /// <summary>
231 /// Gets the file name of the compile file
232 /// </summary>
233
234 public string CompileFile
235 {
236 get
237 {
238 if(_associatedFile != null)
239 return _associatedFile.CompileFile;
240
241 return "";
242 }
243 }
244
245 /// <summary>
246 /// Gets the flag if the chm has a binary index file
247 /// </summary>
248
249 public bool BinaryIndex
250 {
251 get
252 {
253 if(_associatedFile != null)
254 return _associatedFile.BinaryIndex;
255
256 return false;
257 }
258 }
259
260 /// <summary>
261 /// Gets the flag if the chm has a binary index file
262 /// </summary>
263
264 public string CompilerVersion
265 {
266 get
267 {
268 if(_associatedFile != null)
269 return _associatedFile.CompilerVersion;
270
271 return "";
272 }
273 }
274
275 /// <summary>
276 /// Gets the flag if the chm has a binary toc file
277 /// </summary>
278
279 public bool BinaryTOC
280 {
281 get
282 {
283 if(_associatedFile != null)
284 return _associatedFile.BinaryTOC;
285
286 return false;
287 }
288 }
289
290 /// <summary>
291 /// Gets the font face of the read font property.
292 /// Empty string for default font.
293 /// </summary>
294
295 public string FontFace
296 {
297 get
298 {
299 if(_associatedFile != null)
300 return _associatedFile.FontFace;
301
302 return "";
303 }
304 }
305
306 /// <summary>
307 /// Gets the font size of the read font property.
308 /// 0 for default font size
309 /// </summary>
310
311 public double FontSize
312 {
313 get
314 {
315 if(_associatedFile != null)
316 return _associatedFile.FontSize;
317
318 return 0.0;
319 }
320 }
321
322 /// <summary>
323 /// Gets the character set of the read font property
324 /// 1 for default
325 /// </summary>
326
327 public int CharacterSet
328 {
329 get
330 {
331 if(_associatedFile != null)
332 return _associatedFile.CharacterSet;
333
334 return 1;
335 }
336 }
337
338 /// <summary>
339 /// Gets the codepage depending on the read font property
340 /// </summary>
341
342 public int CodePage
343 {
344 get
345 {
346 if(_associatedFile != null)
347 return _associatedFile.CodePage;
348
349 return 0;
350 }
351 }
352
353 /// <summary>
354 /// Gets the assiciated culture info
355 /// </summary>
356 public CultureInfo Culture
357 {
358 get
359 {
360 if(_associatedFile != null)
361 return _associatedFile.Culture;
362
363 return CultureInfo.CurrentCulture;
364 }
365 }
366 #endregion
367
368 #region #IDXHDR properties
369 /// <summary>
370 /// Gets the number of topic nodes including the contents and index files
371 /// </summary>
372
373 public int NumberOfTopicNodes
374 {
375 get
376 {
377 if(_associatedFile != null)
378 return _associatedFile.NumberOfTopicNodes;
379
380 return 0;
381 }
382 }
383
384 /// <summary>
385 /// Gets the ImageList string specyfied in the #IDXHDR file.
386 /// </summary>
387 /// <remarks>This property uses the #STRINGS file to extract the string at a given offset.</remarks>
388
389 public string ImageList
390 {
391 get
392 {
393 if(_associatedFile != null)
394 return _associatedFile.ImageList;
395
396 return "";
397 }
398 }
399
400 /// <summary>
401 /// Gets the background setting
402 /// </summary>
403
404 public int Background
405 {
406 get
407 {
408 if(_associatedFile != null)
409 return _associatedFile.Background;
410
411 return 0;
412 }
413 }
414
415 /// <summary>
416 /// Gets the foreground setting
417 /// </summary>
418
419 public int Foreground
420 {
421 get
422 {
423 if(_associatedFile != null)
424 return _associatedFile.Foreground;
425
426 return 0;
427 }
428 }
429
430 /// <summary>
431 /// Gets the FrameName string specyfied in the #IDXHDR file.
432 /// </summary>
433 /// <remarks>This property uses the #STRINGS file to extract the string at a given offset.</remarks>
434
435 public string FrameName
436 {
437 get
438 {
439 if(_associatedFile != null)
440 return _associatedFile.FrameName;
441
442 return "";
443 }
444 }
445
446 /// <summary>
447 /// Gets the WindowName string specyfied in the #IDXHDR file.
448 /// </summary>
449 /// <remarks>This property uses the #STRINGS file to extract the string at a given offset.</remarks>
450
451 public string WindowName
452 {
453 get
454 {
455 if(_associatedFile != null)
456 return _associatedFile.WindowName;
457
458 return "";
459 }
460 }
461
462 /// <summary>
463 /// Gets a string array containing the merged file names
464 /// </summary>
465 public string[] MergedFiles
466 {
467 get
468 {
469 if(_associatedFile != null)
470 return _associatedFile.MergedFiles;
471
472 return new string[0];
473 }
474 }
475
476 #endregion
477 }
478 }