4 using HtmlHelp.ChmDecoding;
9 /// The class <c>IndexTopic</c> implements an entry for the <see cref="IndexItem">IndexItem</see> topics list.
11 public sealed class IndexTopic
13 private DataMode _topicMode = DataMode.TextBased;
14 private string _title="";
15 private string _local="";
16 private string _compileFile = "";
17 private string _chmPath = "";
18 private int _topicOffset = -1;
19 private CHMFile _associatedFile = null;
22 /// Creates a new instance of the class based on an existing TopicEntry
24 /// <param name="entry"></param>
25 internal static IndexTopic FromTopicEntry(TopicEntry entry)
27 return new IndexTopic(entry.EntryOffset, entry.ChmFile);
28 //return new IndexTopic( entry.Title, entry.Locale, entry.ChmFile.CompileFile, entry.ChmFile.ChmFilePath);
32 /// Creates a new instance of the class (binary extraction mode)
34 /// <param name="topicOffset">offset of the topic entry</param>
35 /// <param name="associatedFile">associated CHMFile instance</param>
36 internal IndexTopic(int topicOffset, CHMFile associatedFile)
38 _topicMode = DataMode.Binary;
39 _topicOffset = topicOffset;
40 _associatedFile = associatedFile;
44 /// Constructor of the class
46 /// <param name="Title">topic title</param>
47 /// <param name="local">topic local (content filename)</param>
48 /// <param name="compilefile">name of the chm file (location of topic)</param>
49 /// <param name="chmpath">path of the chm file</param>
50 public IndexTopic(string Title, string local, string compilefile, string chmpath)
52 _topicMode = DataMode.TextBased;
55 _compileFile = compilefile;
61 /// Dump the class data to a binary writer
63 /// <param name="writer">writer to write the data</param>
64 internal void Dump(ref BinaryWriter writer)
66 writer.Write((int)_topicMode);
68 if(_topicMode==DataMode.TextBased)
75 writer.Write(_topicOffset);
80 /// Reads the object data from a dump store
82 /// <param name="reader">reader to read the data</param>
83 internal void ReadDump(ref BinaryReader reader)
85 _topicMode = (DataMode)reader.ReadInt32();
87 if(_topicMode==DataMode.TextBased)
89 _title = reader.ReadString();
90 _local = reader.ReadString();
94 _topicOffset = reader.ReadInt32();
100 /// Internally used to set the chm-finos when reading from dump store
102 /// <param name="compilefile"></param>
103 /// <param name="chmpath"></param>
104 internal void SetChmInfo(string compilefile, string chmpath)
106 _compileFile = compilefile;
111 /// Gets/Sets the associated CHMFile instance
113 internal CHMFile AssociatedFile
115 get { return _associatedFile; }
116 set { _associatedFile = value; }
120 /// Gets the topic title
126 if((_topicMode == DataMode.Binary )&&(_associatedFile!=null))
128 if( _topicOffset >= 0)
130 TopicEntry te = (TopicEntry) (_associatedFile.TopicsFile[_topicOffset]);
143 /// Gets the local (content filename)
149 if((_topicMode == DataMode.Binary )&&(_associatedFile!=null))
151 if( _topicOffset >= 0)
153 TopicEntry te = (TopicEntry) (_associatedFile.TopicsFile[_topicOffset]);
166 /// Gets the compile file (location)
168 public string CompileFile
172 if(_associatedFile != null)
173 return _associatedFile.CompileFile;
180 /// Gets the chm file path
182 public string ChmFilePath
186 if(_associatedFile != null)
187 return _associatedFile.ChmFilePath;
203 return "";//"about:blank";
205 if( (sL.ToLower().IndexOf("http://") >= 0) ||
206 (sL.ToLower().IndexOf("https://") >= 0) ||
207 (sL.ToLower().IndexOf("mailto:") >= 0) ||
208 (sL.ToLower().IndexOf("ftp://") >= 0) ||
209 (sL.ToLower().IndexOf("ms-its:") >= 0))
212 return HtmlHelpSystem.UrlPrefix + ChmFilePath + "::/" + sL;