~ubuntu-branches/ubuntu/lucid/gnome-subtitles/lucid

« back to all changes in this revision

Viewing changes to sublib-0.7/src/SubLib/Application/SubtitleHeaders.cs

  • Committer: Bazaar Package Importer
  • Author(s): Tiago Bortoletto Vaz
  • Date: 2007-12-03 20:52:52 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20071203205252-2y6uuv4gcw9mi9n5
Tags: 0.7-1
* New upstream release;
* Add libxml-parser-perl to Build-Depends-Indep. Thanks to Lucas Nussbaum.
  (Closes: #445799);
* Fixes manpage issue with dpatch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * This file is part of SubLib.
3
 
 * Copyright (C) 2006 Pedro Castro
4
 
 *
5
 
 * SubLib is free software; you can redistribute it and/or modify
6
 
 * it under the terms of the GNU General Public License as published by
7
 
 * the Free Software Foundation; either version 2 of the License, or
8
 
 * (at your option) any later version.
9
 
 *
10
 
 * SubLib is distributed in the hope that it will be useful,
11
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
 
 * GNU General Public License for more details.
14
 
 *
15
 
 * You should have received a copy of the GNU General Public License
16
 
 * along with this program; if not, write to the Free Software
17
 
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 
 */
19
 
 
20
 
using System;
21
 
using System.IO;
22
 
using System.Text;
23
 
 
24
 
namespace SubLib {
25
 
        
26
 
/// <summary>Represents the headers of the supported subtitle formats.</summary>
27
 
public class SubtitleHeaders {
28
 
 
29
 
        private SubtitleHeadersSubViewer1 subViewer1 = null;
30
 
        private SubtitleHeadersSubViewer2 subViewer2 = null;
31
 
        private SubtitleHeadersMPSub mPSub = null;
32
 
        private SubtitleHeadersSubStationAlphaASS subStationAlphaASS = null;
33
 
        
34
 
        /* Headers are initialized only if and when they're accessed */
35
 
        
36
 
        /// <summary>The headers for the SubViewer 1.0 subtitle type.</summary>
37
 
        public SubtitleHeadersSubViewer1 SubViewer1 {
38
 
                get {
39
 
                        if (subViewer1 == null)
40
 
                                subViewer1 = new SubtitleHeadersSubViewer1();
41
 
                        
42
 
                        return subViewer1;
43
 
                }
44
 
        }
45
 
        
46
 
        /// <summary>The headers for the SubViewer 2.0 subtitle type.</summary>
47
 
        public SubtitleHeadersSubViewer2 SubViewer2 {
48
 
                get {
49
 
                        if (subViewer2 == null)
50
 
                                subViewer2 = new SubtitleHeadersSubViewer2();
51
 
                        
52
 
                        return subViewer2;
53
 
                }
54
 
        }
55
 
        
56
 
        /// <summary>The headers for the MPSub subtitle type.</summary>
57
 
        public SubtitleHeadersMPSub MPSub {
58
 
                get {
59
 
                        if (mPSub == null)
60
 
                                mPSub = new SubtitleHeadersMPSub();
61
 
                        
62
 
                        return mPSub;
63
 
                }
64
 
        }
65
 
        
66
 
        /// <summary>The headers for the Sub Station Alpha and Advanced Sub Station Alpha subtitle types.</summary>
67
 
        public SubtitleHeadersSubStationAlphaASS SubStationAlphaASS {
68
 
                get {
69
 
                        if (subStationAlphaASS == null)
70
 
                                subStationAlphaASS = new SubtitleHeadersSubStationAlphaASS();
71
 
                        
72
 
                        return subStationAlphaASS;
73
 
                }
74
 
        }
75
 
 
76
 
        public override string ToString() {
77
 
                return "\t**** SUBTITLE HEADERS ****\t\n" +
78
 
                        (subViewer1 != null ? subViewer1.ToString() : "! SubViewer 1.0 not used") + "\n" +
79
 
                        (subViewer2 != null ? subViewer2.ToString() : "! SubViewer 2.0 not used") + "\n" +
80
 
                        (mPSub != null ? mPSub.ToString() : "! MPSub not used") + "\n" +
81
 
                        (subStationAlphaASS != null ? subStationAlphaASS.ToString() : "! SubStationAlpha and ASS not used");
82
 
        }
83
 
 
84
 
}
85
 
 
86
 
/// <summary>Represents the headers of the SubViewer 1.0 subtitle format.</summary>
87
 
public class SubtitleHeadersSubViewer1 {
88
 
        private string title = String.Empty;
89
 
        private string author = String.Empty;
90
 
        private string source = String.Empty;
91
 
        private string program = String.Empty;
92
 
        private string filePath = String.Empty;
93
 
        private int delay = 0;
94
 
        private int cdTrack = 0;
95
 
 
96
 
        /// <summary>The movie's title.</summary>
97
 
        public string Title {
98
 
                get { return title; }
99
 
                set { title = value; }
100
 
        }
101
 
 
102
 
        /// <summary>The subtitles' author.</summary>
103
 
        public string Author {
104
 
                get { return author; }
105
 
                set { author = value; }
106
 
        }
107
 
 
108
 
        /// <summary>The subtitles' source.</summary>
109
 
        public string Source {
110
 
                get { return source; }
111
 
                set { source = value; }
112
 
        }
113
 
 
114
 
        /// <summary>The name of the subtitles' program.</summary>
115
 
        public string Program {
116
 
                get { return program; }
117
 
                set { program = value; }
118
 
        }
119
 
 
120
 
        /// <summary>The subtitles' file path.</summary>
121
 
        public string FilePath {
122
 
                get { return filePath; }
123
 
                set { filePath = value; }
124
 
        }
125
 
 
126
 
        /// <summary>The delay of the subtitles.</summary>
127
 
        public int Delay {
128
 
                get { return delay; }
129
 
                set { delay = value; }
130
 
        }
131
 
        
132
 
        /// <summary>The delay of the subtitles as text.</summary>
133
 
        public string DelayAsText {
134
 
                get { return delay.ToString(); }
135
 
                set { 
136
 
                        try {
137
 
                                delay = Convert.ToInt32(value);
138
 
                        }
139
 
                        catch (Exception) {
140
 
                        }
141
 
                 }
142
 
        }
143
 
                
144
 
        /// <summary>The CD track of the subtitles.</summary>
145
 
        public int CDTrack {
146
 
                get { return cdTrack; }
147
 
                set { cdTrack = value; }
148
 
        }
149
 
        
150
 
        /// <summary>The CD track of the subtitles as text.</summary>
151
 
        public string CDTrackAsText {
152
 
                get { return cdTrack.ToString(); }
153
 
                set { 
154
 
                        try {
155
 
                                cdTrack = Convert.ToInt32(value);
156
 
                        }
157
 
                        catch (Exception) {
158
 
                        }
159
 
                 }
160
 
        }
161
 
 
162
 
        public override string ToString() {
163
 
                return "\t** SubViewer 1.0 Headers **\n" +
164
 
                        "Title: " + title + ", Author: " + author + ", Source: " + source + ", Program: " + program +
165
 
                        ", FilePath: " + filePath + ", Delay: " + delay + ", CD Track: " + cdTrack;
166
 
        }
167
 
 
168
 
}
169
 
 
170
 
/// <summary>Represents the headers of the SubViewer 2.0 subtitle format.</summary>
171
 
public class SubtitleHeadersSubViewer2 : SubtitleHeadersSubViewer1 {
172
 
        private string comment = String.Empty;
173
 
        private string fontColor = "&HFFFFFF";
174
 
        private string fontStyle = "bd";
175
 
        private int fontSize = 24;
176
 
        private string fontName = "Tahoma";
177
 
 
178
 
 
179
 
        /// <summary>A comment on the subtitles.</summary>
180
 
        public string Comment {
181
 
                get { return comment; }
182
 
                set { comment = value; }
183
 
        }
184
 
 
185
 
        /// <summary>The subtitles' font color.</summary>
186
 
        public string FontColor {
187
 
                get { return fontColor; }
188
 
                set { fontColor = value; }
189
 
        }
190
 
 
191
 
        /// <summary>The subtitles' font style.</summary>
192
 
        public string FontStyle {
193
 
                get { return fontStyle; }
194
 
                set { fontStyle = value; }
195
 
        }
196
 
 
197
 
        /// <summary>The subtitles' font size.</summary>
198
 
        public int FontSize {
199
 
                get { return fontSize; }
200
 
                set { fontSize = value; }
201
 
        }
202
 
        
203
 
        /// <summary>The subtitles' font size as text.</summary>
204
 
        public string FontSizeAsText {
205
 
                get { return fontSize.ToString(); }
206
 
                set { 
207
 
                        try {
208
 
                                fontSize = Convert.ToInt32(value);
209
 
                        }
210
 
                        catch (Exception) {
211
 
                        }
212
 
                 }
213
 
        }
214
 
        
215
 
        /// <summary>The subtitles' font name.</summary>
216
 
        public string FontName {
217
 
                get { return fontName; }
218
 
                set { fontName = value; }
219
 
        }
220
 
        
221
 
        public override string ToString() {
222
 
                return "\t** SubViewer 2.0 Headers **\n" +
223
 
                        "Base " + base.ToString() + "\n" +
224
 
                        "FontColor: " + fontColor + ", FontStyle: " + fontStyle + ", FontSize: " + fontSize + ", FontName: " + fontName;
225
 
        }
226
 
}
227
 
 
228
 
/// <summary>Represents the headers of the MPSub subtitle format.</summary>
229
 
public class SubtitleHeadersMPSub {
230
 
        private string title = String.Empty;
231
 
        private string file = String.Empty;
232
 
        private string author = String.Empty;
233
 
        private string mediaType = "VIDEO";
234
 
        private string note = String.Empty;
235
 
        
236
 
        
237
 
        /// <summary>The movie's title.</summary>
238
 
        public string Title {
239
 
                get { return title; }
240
 
                set { title = value; }
241
 
        }
242
 
        
243
 
        /// <summary>The File properties, in the format 'size,md5'.</summary>
244
 
        public string File {
245
 
                get { return file; }
246
 
                set { file = value; }
247
 
        }
248
 
        
249
 
        /// <summary>The subtitles' author.</summary>
250
 
        public string Author {
251
 
                get { return author; }
252
 
                set { author = value; }
253
 
        }
254
 
        
255
 
        /// <summary>The Media Type of the subtitles, which can be 'VIDEO' or 'AUDIO'.</summary>
256
 
        /// <remarks>This property is only set if the value is 'VIDEO' or 'AUDIO'. It's case insensitive.</remarks>
257
 
        public string MediaType {
258
 
                get { return mediaType; }
259
 
                set {
260
 
                        string type = value.ToUpper();
261
 
                        if (type.Equals("VIDEO") || type.Equals("AUDIO"))
262
 
                                mediaType = type;
263
 
                }
264
 
        }
265
 
        
266
 
        /// <summary>A note on the subtitles.</summary>
267
 
        public string Note {
268
 
                get { return note; }
269
 
                set { note = value; }
270
 
        }
271
 
        
272
 
        public override string ToString() {
273
 
                return "\t** MPSub Headers **\n" +
274
 
                        "Title: " + title + ", File: " + file + ", Author: " + author + ", MediaType: " + mediaType + ", Note: " + note;
275
 
        }
276
 
 
277
 
}
278
 
 
279
 
/// <summary>Represents the headers of the Sub Station Alpha and Advanced Sub Station Alpha subtitle formats.</summary>
280
 
public class SubtitleHeadersSubStationAlphaASS {
281
 
        private string title = String.Empty;
282
 
        private string originalScript = "<unknown>";
283
 
        private string originalTranslation = String.Empty;
284
 
        private string originalEditing = String.Empty;
285
 
        private string originalTiming = String.Empty;
286
 
        private string originalScriptChecking = String.Empty;
287
 
        private string scriptUpdatedBy = String.Empty;
288
 
        private string collisions = String.Empty;
289
 
        private int playResX = 0;
290
 
        private int playResY = 0;
291
 
        private int playDepth = 0;
292
 
        private string timer = String.Empty;
293
 
 
294
 
        /// <summary>The movie's title.</summary>
295
 
        public string Title {
296
 
                get { return title; }
297
 
                set { title = value; }
298
 
        }
299
 
        
300
 
        /// <summary>The Original Script of the subtitles.</summary>
301
 
        public string OriginalScript {
302
 
                get { return originalScript; }
303
 
                set { originalScript = value; }
304
 
        }
305
 
        
306
 
        /// <summary>The Original Translation of the subtitles.</summary>
307
 
        public string OriginalTranslation {
308
 
                get { return originalTranslation; }
309
 
                set { originalTranslation = value; }
310
 
        }
311
 
        
312
 
        /// <summary>The Original Editing of the subtitles.</summary>
313
 
        public string OriginalEditing {
314
 
                get { return originalEditing; }
315
 
                set { originalEditing = value; }
316
 
        }
317
 
        
318
 
        /// <summary>The Original Timing of the subtitles.</summary>
319
 
        public string OriginalTiming {
320
 
                get { return originalTiming; }
321
 
                set { originalTiming = value; }
322
 
        }
323
 
        
324
 
        /// <summary>The Original Script Checking of the subtitles.</summary>
325
 
        public string OriginalScriptChecking {
326
 
                get { return originalScriptChecking; }
327
 
                set { originalScriptChecking = value; }
328
 
        }
329
 
        
330
 
        /// <summary>The Script Updated By of the subtitles.</summary>
331
 
        public string ScriptUpdatedBy {
332
 
                get { return scriptUpdatedBy; }
333
 
                set { scriptUpdatedBy = value; }
334
 
        }
335
 
        
336
 
        /// <summary>The Collisions of the subtitles.</summary>
337
 
        public string Collisions {
338
 
                get { return collisions; }
339
 
                set { collisions = value; }
340
 
        }
341
 
        
342
 
        /// <summary>The PlayResX of the subtitles.</summary>
343
 
        public int PlayResX {
344
 
                get { return playResX; }
345
 
                set { playResX = value; }
346
 
        }
347
 
        
348
 
        /// <summary>The PlayResX of the subtitles as text.</summary>
349
 
        public string PlayResXAsText {
350
 
                get { return playResX.ToString(); }
351
 
                set { 
352
 
                        try {
353
 
                                playResX = Convert.ToInt32(value);
354
 
                        }
355
 
                        catch (Exception) {
356
 
                        }
357
 
                 }
358
 
        }
359
 
        
360
 
        /// <summary>The PlayResY of the subtitles.</summary>
361
 
        public int PlayResY {
362
 
                get { return playResY; }
363
 
                set { playResY = value; }
364
 
        }
365
 
        
366
 
        /// <summary>The PlayResY of the subtitles as text.</summary>
367
 
        public string PlayResYAsText {
368
 
                get { return playResY.ToString(); }
369
 
                set { 
370
 
                        try {
371
 
                                playResY = Convert.ToInt32(value);
372
 
                        }
373
 
                        catch (Exception) {
374
 
                        }
375
 
                 }
376
 
        }
377
 
        
378
 
        /// <summary>The PlayDepth of the subtitles.</summary>
379
 
        public int PlayDepth {
380
 
                get { return playDepth; }
381
 
                set { playDepth = value; }
382
 
        }
383
 
        
384
 
        /// <summary>The PlayResY of the subtitles as text.</summary>
385
 
        public string PlayDepthAsText {
386
 
                get { return playDepth.ToString(); }
387
 
                set {
388
 
                        try {
389
 
                                playDepth = Convert.ToInt32(value);
390
 
                        }
391
 
                        catch (Exception) {
392
 
                        }
393
 
                 }
394
 
        }
395
 
        
396
 
        /// <summary>The Timer of the subtitles.</summary>
397
 
        public string Timer {
398
 
                get { return timer; }
399
 
                set { timer = value; }
400
 
        }
401
 
 
402
 
        public override string ToString() {
403
 
                return "\t** SubStationAlpha and Advanced SubStationAlpha Headers **\n" +
404
 
                        "Title: " + title + ", Original Script: " + originalScript + ", Original Translation: " + originalTranslation +
405
 
                        ", Original Editing: " + originalEditing + ", Original Timing: " + originalTiming +
406
 
                        ", Original Script Checking: " + originalScriptChecking + ", Script Updated By: " + scriptUpdatedBy +
407
 
                        ", Collisions: " + collisions + ", PlayResX: " + playResX + ", PlayResY: " + playResY +
408
 
                        ", PlayDepth: " + playDepth + ", Timer: " + timer;
409
 
        }
410
 
 
411
 
}
412
 
 
413
 
}