~ubuntu-branches/ubuntu/quantal/ipod-sharp/quantal

« back to all changes in this revision

Viewing changes to src/Photo.cs

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2006-11-13 12:36:39 UTC
  • mfrom: (1.1.4 upstream) (6.1.5 edgy)
  • Revision ID: james.westby@ubuntu.com-20061113123639-cynm2axegef1etff
* New upstream release
* debian/patches/01_fix-playcounts.patch:
  + Dropped, merged upstream
* debian/control:
  + Build depend on mono-gmcs, libmono-sharpzip2.84-cil, libmono2.0-cil,
    libglib2.0-dev and libipoddevice >= 0.5.0
  + Bumped Standards-Version to 3.7.2
  + Add ${misc:Depends} to Depends
  + Let libipodui-cil depend on libipod-cil
* debian/libipod-cil.install:
  + Add ipod-sharp-firmware.dll
* debian/patches/01_dllmap.patch:
  + Add dllmap to libgobject-2.0.so.0 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
using System;
 
2
using System.IO;
 
3
using System.Collections.Generic;
 
4
using System.Collections.ObjectModel;
 
5
 
 
6
namespace IPod {
 
7
 
 
8
    public class Photo {
 
9
 
 
10
        private ImageItemRecord item;
 
11
        private PhotoDatabase db;
 
12
        private List<Thumbnail> thumbnails = new List<Thumbnail> ();
 
13
        private string fullSizeFile;
 
14
        private bool dirty = false;
 
15
 
 
16
        internal int Id {
 
17
            get { return item.Id; }
 
18
        }
 
19
        
 
20
        internal ImageItemRecord Record {
 
21
            get { return item; }
 
22
        }
 
23
 
 
24
        public PhotoDatabase PhotoDatabase {
 
25
            get { return db; }
 
26
        }
 
27
 
 
28
        internal bool Dirty {
 
29
            get { return dirty; }
 
30
        }
 
31
 
 
32
        public DateTime OriginalDate {
 
33
            get { return item.OriginalDate; }
 
34
            set { item.OriginalDate = value; }
 
35
        }
 
36
 
 
37
        public DateTime DigitizedDate {
 
38
            get { return item.DigitizedDate; }
 
39
            set { item.DigitizedDate = value; }
 
40
        }
 
41
 
 
42
        // FIXME: use an enum or whatever
 
43
        public int Rating {
 
44
            get { return item.Rating; }
 
45
            set { item.Rating = value; }
 
46
        }
 
47
 
 
48
        public IList<Thumbnail> Thumbnails {
 
49
            get { return new ReadOnlyCollection<Thumbnail> (thumbnails); }
 
50
        }
 
51
 
 
52
        public string FullSizeFileName {
 
53
            get {
 
54
                if (dirty) {
 
55
                    return fullSizeFile;
 
56
                } else {
 
57
                    return CurrentFullSizeFileName;
 
58
                }
 
59
            } set {
 
60
                fullSizeFile = value;
 
61
                dirty = true;
 
62
            }
 
63
        }
 
64
 
 
65
        internal string CurrentFullSizeFileName {
 
66
            get {
 
67
                if (item.FullName == null || item.FullName.FileName == null)
 
68
                    return null;
 
69
 
 
70
                return db.GetFilesystemPath (item.FullName.FileName);
 
71
            }
 
72
        }
 
73
                
 
74
        
 
75
        internal Photo (ImageItemRecord item, PhotoDatabase db) {
 
76
            this.item = item;
 
77
            this.db = db;
 
78
 
 
79
            foreach (ImageNameRecord name in item.Names) {
 
80
                thumbnails.Add (new Thumbnail (this, name));
 
81
            }
 
82
        }
 
83
 
 
84
        internal void SetPodFileName () {
 
85
            if (fullSizeFile != null) {
 
86
                item.FullName.FileName = String.Format (":Full Resolution:{0}:{1}:{2}:{3}", OriginalDate.Year,
 
87
                                                        OriginalDate.Month, OriginalDate.Day,
 
88
                                                        Path.GetFileName (fullSizeFile));
 
89
            } else {
 
90
                item.FullName = null;
 
91
            }
 
92
        }
 
93
 
 
94
        public Thumbnail CreateThumbnail () {
 
95
            ImageNameRecord name = new ImageNameRecord (item.IsBE);
 
96
            item.AddName (name);
 
97
            
 
98
            Thumbnail thumbnail = new Thumbnail (this, name);
 
99
            thumbnails.Add (thumbnail);
 
100
 
 
101
            return thumbnail;
 
102
        }
 
103
 
 
104
        public void RemoveThumbnail (Thumbnail thumbnail) {
 
105
            item.RemoveName (thumbnail.Record);
 
106
            thumbnails.Remove (thumbnail);
 
107
        }
 
108
 
 
109
        public Thumbnail LookupThumbnail (ArtworkFormat format) {
 
110
            foreach (Thumbnail thumbnail in thumbnails) {
 
111
                if (thumbnail.Format == format) {
 
112
                    return thumbnail;
 
113
                }
 
114
            }
 
115
 
 
116
            return null;
 
117
        }
 
118
    }
 
119
 
 
120
}