File: PhotoInfo.cs

package info (click to toggle)
libflickrnet 25277-6
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 628 kB
  • ctags: 1,355
  • sloc: cs: 7,136; makefile: 24; sh: 13; ansic: 6
file content (506 lines) | stat: -rw-r--r-- 14,565 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
using System;
using System.Xml.Serialization;
using System.Xml.Schema;

namespace FlickrNet
{
	/// <summary>
    /// Detailed information returned by <see cref="Flickr.PhotosGetInfo(string)"/> or <see cref="Flickr.PhotosGetInfo(string, string)"/> methods.
	/// </summary>
	[System.Serializable]
	public class PhotoInfo
	{
		private string _photoId;
		private string _secret;
		private string _server;
		private string _farm;
		private string _originalFormat;
		private string _originalSecret;
		private int _views;
		private int _comments;
		private string _title;
		private string _description;
		private PhotoInfoTags _tags = new PhotoInfoTags();

		/// <summary>
		/// The id of the photo.
		/// </summary>
		[XmlAttribute("id", Form=XmlSchemaForm.Unqualified)]
		public string PhotoId { get { return _photoId; } set { _photoId = value; } }

		/// <summary>
		/// The secret of the photo. Used to calculate the URL (amongst other things).
		/// </summary>
		[XmlAttribute("secret", Form=XmlSchemaForm.Unqualified)]
		public string Secret { get { return _secret; } set { _secret = value; } }

		/// <summary>
		/// The server on which the photo resides.
		/// </summary>
		[XmlAttribute("server", Form=XmlSchemaForm.Unqualified)]
		public string Server { get { return _server; } set { _server = value; } }

		/// <summary>
		/// The server farm on which the photo resides.
		/// </summary>
		[XmlAttribute("farm", Form=XmlSchemaForm.Unqualified)]
		public string Farm { get { return _farm; } set { _farm = value; } }

		/// <summary>
		/// The original format of the image (e.g. jpg, png etc).
		/// </summary>
		[XmlAttribute("originalformat", Form=XmlSchemaForm.Unqualified)]
		public string OriginalFormat { get { return _originalFormat; } set { _originalFormat = value; } }

		/// <summary>
		/// Optional extra field containing the original 'secret' of the 
		/// photo used for forming the Url.
		/// </summary>
		[XmlAttribute("originalsecret", Form=XmlSchemaForm.Unqualified)]
		public string OriginalSecret { get { return _originalSecret; } set { _originalSecret = value; } }

		/// <summary>
		/// The date the photo was uploaded (or 'posted').
		/// </summary>
		[XmlIgnore()]
		public DateTime DateUploaded
		{
			get { return Utils.UnixTimestampToDate(dateuploaded_raw); }
		}

		/// <summary>
		/// The raw value for when the photo was uploaded.
		/// </summary>
		[XmlAttribute("dateuploaded", Form=XmlSchemaForm.Unqualified)]
		public string dateuploaded_raw;

		/// <summary>
		/// Is the photo a favourite of the current authorised user. 
		/// Will be 0 if the user is not authorised.
		/// </summary>
		[XmlAttribute("isfavorite", Form=XmlSchemaForm.Unqualified)]
		public int IsFavourite;

		/// <summary>
		/// The license of the photo.
		/// </summary>
		[XmlAttribute("license", Form=XmlSchemaForm.Unqualified)]
		public int License;

		/// <summary>
		/// The owner of the photo.
		/// </summary>
		/// <remarks>
		/// See <see cref="PhotoInfoOwner"/> for more details.
		/// </remarks>
		[XmlElement("owner", Form=XmlSchemaForm.Unqualified)]
		public PhotoInfoOwner Owner;

		/// <summary>
		/// The title of the photo.
		/// </summary>
		[XmlElement("title", Form=XmlSchemaForm.Unqualified)]
		public string Title { get { return _title; } set { _title = value; } }

		/// <summary>
		/// The description of the photo.
		/// </summary>
		[XmlElement("description", Form=XmlSchemaForm.Unqualified)]
		public string Description { get { return _description; } set { _description = value; } }

		/// <summary>
		/// The visibility of the photo.
		/// </summary>
		/// <remarks>
		/// See <see cref="PhotoInfoVisibility"/> for more details.
		/// </remarks>
		[XmlElement("visibility", Form=XmlSchemaForm.Unqualified)]
		public PhotoInfoVisibility Visibility;

		/// <summary>
		/// The permissions of the photo.
		/// </summary>
		/// <remarks>
		/// See <see cref="PhotoInfoPermissions"/> for more details.
		/// </remarks>
		[XmlElement("permissions", Form=XmlSchemaForm.Unqualified)]
		public PhotoInfoPermissions Permissions;

		/// <summary>
		/// The editability of the photo.
		/// </summary>
		/// <remarks>
		/// See <see cref="PhotoInfoEditability"/> for more details.
		/// </remarks>
		[XmlElement("editability", Form=XmlSchemaForm.Unqualified)]
		public PhotoInfoEditability Editability;

		/// <summary>
		/// The number of comments the photo has.
		/// </summary>
		[XmlElement("comments", Form=XmlSchemaForm.Unqualified)]
		public int CommentsCount
		{
			get { return _comments; } set { _comments = value; }
		}

		/// <summary>
		/// The number of views the photo has.
		/// </summary>
		[XmlAttribute("views", Form=XmlSchemaForm.Unqualified)]
		public int ViewCount
		{
			get { return _views; } set { _views = value; }
		}

		/// <summary>
		/// The notes for the photo.
		/// </summary>
		[XmlElement("notes", Form=XmlSchemaForm.Unqualified)]
		public PhotoInfoNotes Notes;

		/// <summary>
		/// The tags for the photo.
		/// </summary>
		[XmlElement("tags", Form=XmlSchemaForm.Unqualified)]
		public PhotoInfoTags Tags
		{
			get { return _tags; }
			set { _tags = (value==null?new PhotoInfoTags():value); }
		}
	
		/// <summary>
		/// The EXIF tags for the photo.
		/// </summary>
		[XmlElement("exif", Form=XmlSchemaForm.Unqualified)]
		public ExifTag[] ExifTagCollection;

		/// <summary>
		/// The dates (uploaded and taken dates) for the photo.
		/// </summary>
		[XmlElement("dates", Form=XmlSchemaForm.Unqualified)]
		public PhotoDates Dates;

		/// <summary>
		/// The location information of this photo, if available.
		/// </summary>
		/// <remarks>
		/// Will be null if the photo has no location information stored on Flickr.
		/// </remarks>
		[XmlElement("location", Form=XmlSchemaForm.Unqualified)]
		public PhotoLocation Location;

		/// <summary>
		/// The Web url for flickr web page for this photo.
		/// </summary>
		[XmlIgnore()]
		public string WebUrl
		{
			get { return string.Format("http://www.flickr.com/photos/{0}/{1}/", Owner.UserId, PhotoId); }
		}

		/// <summary>
		/// The URL for the square thumbnail for the photo.
		/// </summary>
		[XmlIgnore()]
		public string SquareThumbnailUrl
		{
			get { return Utils.UrlFormat(this, "_s", "jpg"); }
		}

		/// <summary>
		/// The URL for the thumbnail for the photo.
		/// </summary>
		[XmlIgnore()]
		public string ThumbnailUrl
		{
			get { return Utils.UrlFormat(this, "_t", "jpg"); }
		}

		/// <summary>
		/// The URL for the small version of this photo.
		/// </summary>
		[XmlIgnore()]
		public string SmallUrl
		{
			get { return Utils.UrlFormat(this, "_m", "jpg"); }
		}

		/// <summary>
		/// The URL for the medium version of this photo.
		/// </summary>
		/// <remarks>
		/// There is no guarentee that this size of the image actually exists.
		/// Use <see cref="Flickr.PhotosGetSizes"/> to get a list of existing photo URLs.
		/// </remarks>
		[XmlIgnore()]
		public string MediumUrl
		{
			get { return Utils.UrlFormat(this, "", "jpg"); }
		}

		/// <summary>
		/// The URL for the large version of this photo.
		/// </summary>
		/// <remarks>
		/// There is no guarentee that this size of the image actually exists.
		/// Use <see cref="Flickr.PhotosGetSizes"/> to get a list of existing photo URLs.
		/// </remarks>
		[XmlIgnore()]
		public string LargeUrl
		{
			get { return Utils.UrlFormat(this, "_b", "jpg"); }
		}

		/// <summary>
		/// If <see cref="OriginalFormat"/> was returned then this will contain the url of the original file.
		/// </summary>
		[XmlIgnore()]
		public string OriginalUrl
		{
			get 
			{ 
				if( OriginalFormat == null || OriginalFormat.Length == 0 )
					throw new InvalidOperationException("No original format information available.");

				return Utils.UrlFormat(this, "_o", OriginalFormat);
			}
		}
	}

	/// <summary>
	/// The information about the owner of a photo.
	/// </summary>
	[System.Serializable]
	public class PhotoInfoOwner
	{
		/// <summary>
		/// The id of the own of the photo.
		/// </summary>
		[XmlAttribute("nsid", Form=XmlSchemaForm.Unqualified)]
		public string UserId;

		/// <summary>
		/// The username of the owner of the photo.
		/// </summary>
		[XmlAttribute("username", Form=XmlSchemaForm.Unqualified)]
		public string UserName;

		/// <summary>
		/// The real name (as stored on Flickr) of the owner of the photo.
		/// </summary>
		[XmlAttribute("realname", Form=XmlSchemaForm.Unqualified)]
		public string RealName;

		/// <summary>
		/// The location (as stored on Flickr) of the owner of the photo.
		/// </summary>
		[XmlAttribute("location", Form=XmlSchemaForm.Unqualified)]
		public string Location;
	}

	/// <summary>
	/// The visibility of the photo.
	/// </summary>
	[System.Serializable]
	public class PhotoInfoVisibility
	{
		/// <summary>
		/// Is the photo visible to the public.
		/// </summary>
		[XmlAttribute("ispublic", Form=XmlSchemaForm.Unqualified)]
		public int IsPublic;

		/// <summary>
		/// Is the photo visible to contacts marked as friends.
		/// </summary>
		[XmlAttribute("isfriend", Form=XmlSchemaForm.Unqualified)]
		public int IsFriend;

		/// <summary>
		/// Is the photo visible to contacts marked as family.
		/// </summary>
		[XmlAttribute("isfamily", Form=XmlSchemaForm.Unqualified)]
		public int IsFamily;
	}

	/// <summary>
	/// Who has permissions to add information to this photo (comments, tag and notes).
	/// </summary>
	[System.Serializable]
	public class PhotoInfoPermissions
	{
		/// <summary>
		/// Who has permissions to add comments to this photo.
		/// </summary>
		[XmlAttribute("permcomment", Form=XmlSchemaForm.Unqualified)]
		public PermissionComment PermissionComment;

		/// <summary>
		/// Who has permissions to add meta data (tags and notes) to this photo.
		/// </summary>
		[XmlAttribute("permaddmeta", Form=XmlSchemaForm.Unqualified)]
		public PermissionAddMeta PermissionAddMeta;
	}

	/// <summary>
	/// Information about who can edit the details of a photo.
	/// </summary>
	[System.Serializable]
	public class PhotoInfoEditability 
	{
		/// <summary>
		/// Can the authorized user add new comments.
		/// </summary>
		/// <remarks>
		/// "1" = true, "0" = false.
		/// </remarks>
		[XmlAttribute("cancomment", Form=XmlSchemaForm.Unqualified)]
		public string CanComment;

		/// <summary>
		/// Can the authorized user add new meta data (tags and notes).
		/// </summary>
		/// <remarks>
		/// "1" = true, "0" = false.
		/// </remarks>
		[XmlAttribute("canaddmeta", Form=XmlSchemaForm.Unqualified)]
		public string CanAddMeta;
	}

	/// <summary>
	/// A class containing information about the notes for a photo.
	/// </summary>
	[System.Serializable]
	public class PhotoInfoNotes
	{
		/// <summary>
		/// A collection of notes for this photo.
		/// </summary>
		[XmlElement("note", Form=XmlSchemaForm.Unqualified)]
		public PhotoInfoNote[] NoteCollection;
	}

	/// <summary>
	/// A class containing information about a note on a photo.
	/// </summary>
	[System.Serializable]
	public class PhotoInfoNote
	{
		/// <summary>
		/// The notes unique ID.
		/// </summary>
		[XmlAttribute("id", Form=XmlSchemaForm.Unqualified)]
		public string NoteId;

		/// <summary>
		/// The User ID of the user who wrote the note.
		/// </summary>
		[XmlAttribute("author", Form=XmlSchemaForm.Unqualified)]
		public string AuthorId;

		/// <summary>
		/// The name of the user who wrote the note.
		/// </summary>
		[XmlAttribute("authorname", Form=XmlSchemaForm.Unqualified)]
		public string AuthorName;

		/// <summary>
		/// The x (left) position of the top left corner of the note.
		/// </summary>
		[XmlAttribute("x", Form=XmlSchemaForm.Unqualified)]
		public int XPosition;

		/// <summary>
		/// The y (top) position of the top left corner of the note.
		/// </summary>
		[XmlAttribute("y", Form=XmlSchemaForm.Unqualified)]
		public int YPosition;

		/// <summary>
		/// The width of the note.
		/// </summary>
		[XmlAttribute("w", Form=XmlSchemaForm.Unqualified)]
		public int Width;

		/// <summary>
		/// The height of the note.
		/// </summary>
		[XmlAttribute("h", Form=XmlSchemaForm.Unqualified)]
		public int Height;

		/// <summary>
		/// The text of the note.
		/// </summary>
		[XmlText()]
		public string NoteText;
	}

	/// <summary>
	/// A class containing a collection of tags for the photo.
	/// </summary>
	[System.Serializable]
	public class PhotoInfoTags
	{
		private PhotoInfoTag[] _tags = new PhotoInfoTag[0];

		/// <summary>
		/// A collection of tags for the photo.
		/// </summary>
		[XmlElement("tag", Form=XmlSchemaForm.Unqualified)]
		public PhotoInfoTag[] TagCollection
		{
			get { return _tags; }
			set { _tags = (value==null?new PhotoInfoTag[0]:value); }
		}
	}

	/// <summary>
	/// The details of a tag of a photo.
	/// </summary>
	[System.Serializable]
	public class PhotoInfoTag
	{
		private int _machineTag;
		private string _tagId;
		private string _authorId;
		private string _authorName;

		/// <summary>
		/// The id of the tag.
		/// </summary>
		[XmlAttribute("id", Form=XmlSchemaForm.Unqualified)]
		public string TagId { get { return _tagId; } set { _tagId = value; } }

		/// <summary>
		/// The author id of the tag.
		/// </summary>
		[XmlAttribute("author", Form=XmlSchemaForm.Unqualified)]
		public string AuthorId { get { return _authorId; } set { _authorId = value; } }

		/// <summary>
		/// Author of the tag - only available if using <see cref="Flickr.TagsGetListPhoto"/>.
		/// </summary>
		[XmlAttribute("authorname", Form=XmlSchemaForm.Unqualified)]
		public string AuthorName  { get { return _authorName; } set { _authorName = value; } }

		/// <summary>
		/// Raw copy of the tag, as the user entered it.
		/// </summary>
		[XmlAttribute("raw", Form=XmlSchemaForm.Unqualified)]
		public string Raw;

		/// <summary>
		/// Raw copy of the tag, as the user entered it.
		/// </summary>
		[XmlAttribute("machine_tag", Form=XmlSchemaForm.Unqualified)]
		public int IsMachineTag { get { return _machineTag; } set { _machineTag = value; } }

		/// <summary>
		/// The actually tag.
		/// </summary>
		[XmlText()]
		public string TagText;
	}

}