Esempio n. 1
0
        protected override void ResetDialog()
        {
            Manning.PhotoAlbum.PhotoAlbum album = Manager.Album;
            txtAlbumFile.Text = Manager.FullName;
            txtTile.Text      = album.Title;
            // Assign radio button
            switch (album.PhotoDescriptor)
            {
            case Manning.PhotoAlbum.PhotoAlbum.DescriptorOption.Caption:
                rbtnCaption.Checked = true;
                break;

            case Manning.PhotoAlbum.PhotoAlbum.DescriptorOption.DateTaken:
                rbtnDateTaken.Checked = true;
                break;

            case Manning.PhotoAlbum.PhotoAlbum.DescriptorOption.FileName:
                rbtnFileName.Checked = true;
                break;
            }
            // Assign check box
            string pwd = Manager.Password;

            cbxPassword.Checked
                = (pwd != null && pwd.Length > 0);
            txtPassword.Text = pwd;
            txtConfirm.Text  = pwd;
        }
Esempio n. 2
0
 private void SaveSettings()
 {
     Manning.PhotoAlbum.PhotoAlbum album = Manager.Album;
     if (album != null)
     {
         album.Title = txtTile.Text;
         if (rbtnCaption.Checked)
         {
             album.PhotoDescriptor = Manning.PhotoAlbum.PhotoAlbum.DescriptorOption.Caption;
         }
         else if (rbtnDateTaken.Checked)
         {
             album.PhotoDescriptor = Manning.PhotoAlbum.PhotoAlbum.DescriptorOption.DateTaken;
         }
         else if (rbtnFileName.Checked)
         {
             album.PhotoDescriptor = Manning.PhotoAlbum.PhotoAlbum.DescriptorOption.FileName;
         }
         if (cbxPassword.Checked && ValidPassword())
         {
             Manager.Password = txtPassword.Text;
         }
         else
         {
             Manager.Password = null;
         }
     }
 }
Esempio n. 3
0
 public AlbumManager()
 {
     album = new PhotoAlbum();
 }
Esempio n. 4
0
        static public PhotoAlbum ReadAlbum(string path, string password)
        {
            StreamReader sr = null;

            try
            {
                string version;
                if (password == null || password.Length == 0)
                {
                    sr      = new StreamReader(path);
                    version = sr.ReadLine();
                    if (version.EndsWith("e"))
                    {
                        throw new AlbumStorageException(
                                  "A password is required to open the album");
                    }
                }
                else
                {
                    // Create CryptoReader to use as StreamReader
                    CryptoReader cr = new CryptoReader(path, password);
                    version = cr.ReadUnencryptedLine();
                    if (!version.EndsWith("e"))
                    {
                        // Decryption not required
                        cr.Close();
                        sr      = new StreamReader(path);
                        version = sr.ReadLine();
                    }
                    else
                    {
                        string checkLine = cr.ReadLine();
                        if (checkLine != password)
                        {
                            throw new AlbumStorageException(
                                      "The given password is not valid");
                        }

                        sr = cr;
                    }
                }
                PhotoAlbum album = new PhotoAlbum();
                switch (version)
                {
                case "63":
                    ReadAlbumV63(sr, album);
                    break;

                case "91":
                case "91e":
                    ReadAlbumV91(sr, album);
                    break;

                default:
                    throw new AlbumStorageException(
                              "Unrecognized album version");
                }

                album.HasChanged = false;
                return(album);
            }
            catch (System.Security.Cryptography.CryptographicException cex)
            {
                throw new AlbumStorageException(
                          "Unable to decrypt album " + path, cex);
            }
            catch (FileNotFoundException fnx)
            {
                throw new AlbumStorageException("Unable to read album " + path, fnx);
            }
            finally
            {
                if (sr != null)
                {
                    sr.Close();
                }
            }
        }
Esempio n. 5
0
 static public void WriteAlbum(PhotoAlbum album, string path)
 {
     WriteAlbum(album, path, null);
 }