Example #1
0
        // Object class overrides
        public override bool Equals(object obj)
        {
            if (obj is Photograph)
            {
                Photograph p = (Photograph)obj;

                return(_fileName.ToLower().Equals(p.FileName.ToLower()));
            }

            return(false);
        }
Example #2
0
        public void MoveItemForward(int index)
        {
            if (index < 0 || index > Album.Count - 1)
            {
                throw new IndexOutOfRangeException();
            }
            // Remove photo and reinsert at subsequent pos
            Photograph photo = Album[index];

            Album.RemoveAt(index);
            Album.Insert(index + 1, photo);
        }
Example #3
0
        public void MoveItemBackward(int index)
        {
            if (index <= 0 || index >= Album.Count)
            {
                throw new IndexOutOfRangeException();
            }
            // Remove photo and reinsert at prior position
            Photograph photo = Album[index];

            Album.RemoveAt(index);
            Album.Insert(index - 1, photo);
        }
Example #4
0
        protected override void ResetSettings()
        {
            Photograph photo = _album.CurrentPhoto;

            if (photo != null)
            {
                txtPhotoFile.Text    = photo.FileName;
                txtCaption.Text      = photo.Caption;
                txtDate.Text         = photo.DateTaken.ToString();
                txtPhotographer.Text = photo.Photographer;
                this.txtNotes.Text   = photo.Notes;
            }
        }
Example #5
0
        protected override bool SaveSettings()
        {
            Photograph photo = _album.CurrentPhoto;

            if (photo != null)
            {
                photo.Caption = txtCaption.Text;
                // Ignore txtDate setting for now
                photo.Photographer = cmbxPhotographer.Text;
                photo.Notes        = txtNotes.Text;
            }

            return(true);
        }
Example #6
0
        static public Photograph ReadVersion83(StreamReader sr)
        {
            String name = sr.ReadLine();

            if (name == null)
            {
                return(null);
            }

            Photograph p = new Photograph(name);

            p.Caption = sr.ReadLine();
            return(p);
        }
Example #7
0
        static private void WritePhoto(StreamWriter sw, Photograph p)
        {
            if (p.Editing)
            {
                p.EndEdit();
            }

            sw.WriteLine(p.FileName);

            sw.WriteLine(p.Caption != null ? p.Caption : "");
            sw.WriteLine(p.DateTaken.ToString());
            sw.WriteLine(p.Photographer != null ? p.Photographer : "");
            sw.WriteLine(p.Notes != null ? p.Notes : "");
        }
Example #8
0
            public string GetDisplayText(Photograph photo)
            {
                switch (this._displayOption)
                {
                case DisplayValEnum.Caption:
                default:
                    return(photo.Caption);

                case DisplayValEnum.Date:
                    return(photo.DateTaken.ToString("g"));

                case DisplayValEnum.FileName:
                    return(Path.GetFileName(photo.FileName));
                }
            }
        static private Photograph ReadPhotoV63(StreamReader sr)
        {
            string file = sr.ReadLine();

            if (file == null || file.Length == 0)
            {
                return(null);
            }
            Photograph p = new Photograph(file);

            p.Caption      = sr.ReadLine();
            p.DateTaken    = DateTime.Parse(sr.ReadLine());
            p.Photographer = sr.ReadLine();
            p.Notes        = sr.ReadLine();

            return(p);
        }
Example #10
0
        static private Photograph ReadPhotoV63(StreamReader sr)
        {
            // Presume at the start of the photo
            string file = sr.ReadLine();

            if (file == null || file.Length == 0)
            {
                return(null);
            }

            // File not null, should find photo
            Photograph p = new Photograph(file);

            p.Caption      = sr.ReadLine();
            p.DateTaken    = DateTime.Parse(sr.ReadLine());
            p.Photographer = sr.ReadLine();
            p.Notes        = sr.ReadLine();

            return(p);
        }
Example #11
0
            public void Open(string fileName)
            {
                FileStream fs = new FileStream(fileName,
                                               FileMode.Open,
                                               FileAccess.Read);

                StreamReader sr = new StreamReader(fs);

                int version;

                try
                {
                    version = Int32.Parse(sr.ReadLine());
                }
                catch
                {
                    version = 0;
                }

                try
                {
                    // Initialize as a new album
                    Clear();
                    this._fileName = fileName;
                    ReadAlbumData(sr, version);

                    // Check for password
                    if (_password != null && _password.Length > 0)
                    {
                        using (PasswordDlg dlg = new PasswordDlg())
                        {
                            dlg.Text = String.Format("Opening album {0}", Path.GetFileName(_fileName));
                            if ((dlg.ShowDialog() == DialogResult.OK) && (dlg.Password != _password))
                            {
                                throw new ApplicationException("Invalid password provided");
                            }
                        }
                    }

                    Photograph.ReadDelegate ReadPhoto;
                    switch (version)
                    {
                    case 66:
                        ReadPhoto = new Photograph.ReadDelegate(Photograph.ReadVersion66);
                        break;

                    case 83:
                        ReadPhoto = new Photograph.ReadDelegate(Photograph.ReadVersion83);
                        break;

                    case 92:
                    case 93:
                        ReadPhoto = new Photograph.ReadDelegate(Photograph.ReadVersion92);
                        break;

                    default:
                        // Unknown version or bad file.
                        throw (new IOException
                                   ("Unrecognized album file format"));
                    }

                    // Read in each photograph in the album
                    Photograph p = ReadPhoto(sr);
                    while (p != null)
                    {
                        this.Add(p);
                        p = ReadPhoto(sr);
                    }
                }
                finally
                {
                    sr.Close();
                    fs.Close();
                }
            }
Example #12
0
 public virtual void Remove(Photograph photo)
 {
     List.Remove(photo);
 }
Example #13
0
 public virtual void Insert(int index, Photograph photo)
 {
     List.Insert(index, photo);
 }
Example #14
0
 public virtual int IndexOf(Photograph photo)
 {
     return(List.IndexOf(photo));
 }
Example #15
0
 public virtual bool Contains(Photograph photo)
 {
     return(List.Contains(photo));
 }
Example #16
0
 public virtual int Add(Photograph photo)
 {
     return(List.Add(photo));
 }