Scale down the wallpaper to 800x600. For some reason, scaling down the image through...
[reactos.git] / irc / TechBot / CHMLibrary / CHMDecoding / UrlTableEntry.cs
1 using System;
2 using System.IO;
3
4 namespace HtmlHelp.ChmDecoding
5 {
6 /// <summary>
7 /// The class <c>UrlTableEntry</c> stores data for an URL-Table entry
8 /// </summary>
9 internal sealed class UrlTableEntry
10 {
11 /// <summary>
12 /// Internal member storing the offset of this entry
13 /// </summary>
14 private int _entryOffset = 0;
15 /// <summary>
16 /// Internal member storing a unique id
17 /// </summary>
18 private uint _uniqueID = 0;
19 /// <summary>
20 /// Internal member storing the topics index
21 /// </summary>
22 private int _topicsIndex = 0;
23 /// <summary>
24 /// Internal member storing the offset in the urlstr table
25 /// </summary>
26 private int _urlStrOffset = 0;
27 /// <summary>
28 /// Internal member storing the associated chmfile object
29 /// </summary>
30 private CHMFile _associatedFile = null;
31
32 /// <summary>
33 /// Constructor of the class
34 /// </summary>
35 /// <param name="uniqueID">unique id</param>
36 /// <param name="entryOffset">offset of the entry</param>
37 /// <param name="topicIndex">topic index</param>
38 /// <param name="urlstrOffset">urlstr offset for filename</param>
39 public UrlTableEntry(uint uniqueID, int entryOffset, int topicIndex, int urlstrOffset) : this(uniqueID, entryOffset, topicIndex, urlstrOffset, null)
40 {
41 }
42
43 /// <summary>
44 /// Constructor of the class
45 /// </summary>
46 /// <param name="uniqueID">unique id</param>
47 /// <param name="entryOffset">offset of the entry</param>
48 /// <param name="topicIndex">topic index</param>
49 /// <param name="urlstrOffset">urlstr offset for filename</param>
50 /// <param name="associatedFile">associated chm file</param>
51 internal UrlTableEntry(uint uniqueID, int entryOffset, int topicIndex, int urlstrOffset, CHMFile associatedFile)
52 {
53 _uniqueID = uniqueID;
54 _entryOffset = entryOffset;
55 _topicsIndex = topicIndex;
56 _urlStrOffset = urlstrOffset;
57 _associatedFile = associatedFile;
58 }
59
60 /// <summary>
61 /// Standard constructor
62 /// </summary>
63 internal UrlTableEntry()
64 {
65 }
66
67 #region Data dumping
68 /// <summary>
69 /// Dump the class data to a binary writer
70 /// </summary>
71 /// <param name="writer">writer to write the data</param>
72 internal void Dump(ref BinaryWriter writer)
73 {
74 writer.Write( _urlStrOffset );
75 writer.Write( _entryOffset );
76 writer.Write( _topicsIndex );
77 writer.Write( _urlStrOffset );
78 }
79
80 /// <summary>
81 /// Reads the object data from a dump store
82 /// </summary>
83 /// <param name="reader">reader to read the data</param>
84 internal void ReadDump(ref BinaryReader reader)
85 {
86 _urlStrOffset = reader.ReadInt32();
87 _entryOffset = reader.ReadInt32();
88 _topicsIndex = reader.ReadInt32();
89 _urlStrOffset = reader.ReadInt32();
90 }
91
92 /// <summary>
93 /// Sets the associated CHMFile instance
94 /// </summary>
95 /// <param name="associatedFile">instance to set</param>
96 internal void SetCHMFile(CHMFile associatedFile)
97 {
98 _associatedFile = associatedFile;
99 }
100 #endregion
101
102 /// <summary>
103 /// Gets the unique id of the entry
104 /// </summary>
105 internal uint UniqueID
106 {
107 get {return _uniqueID; }
108 }
109
110 /// <summary>
111 /// Gets the offset of the entry
112 /// </summary>
113 internal int EntryOffset
114 {
115 get {return _entryOffset; }
116 }
117
118 /// <summary>
119 /// Gets the topics index
120 /// </summary>
121 internal int TopicIndex
122 {
123 get {return _topicsIndex; }
124 }
125
126 /// <summary>
127 /// Gets the urlstr offset
128 /// </summary>
129 internal int UrlstrOffset
130 {
131 get { return _urlStrOffset; }
132 }
133
134 /// <summary>
135 /// Gets the url of the entry
136 /// </summary>
137 public string URL
138 {
139 get
140 {
141 if(_associatedFile == null)
142 return String.Empty;
143
144 if(_associatedFile.UrlstrFile == null)
145 return String.Empty;
146
147 string sTemp = (string)_associatedFile.UrlstrFile.GetURLatOffset( _urlStrOffset );
148
149 if( sTemp == null)
150 return String.Empty;
151
152 return sTemp;
153 }
154 }
155
156 /// <summary>
157 /// Gets the associated topic for this url entry
158 /// </summary>
159 internal TopicEntry Topic
160 {
161 get
162 {
163 if(_associatedFile == null)
164 return null;
165
166 if(_associatedFile.TopicsFile == null)
167 return null;
168
169 TopicEntry tentry = _associatedFile.TopicsFile[ _topicsIndex*16 ];
170
171 return tentry;
172 }
173 }
174 }
175 }