Example #1
0
        private void AssignSelectDropDown()
        {
            ToolStripDropDown drop = new ToolStripDropDown();

            PhotoAlbum.PhotoAlbum a = Manager.Album;
            for (int i = 0; i < a.Count; i++)
            {
                PictureBox box = new PictureBox();
                box.SizeMode = PictureBoxSizeMode.Zoom;
                box.Image    = a[i].Image;
                box.Dock     = DockStyle.Fill;
                ToolStripControlHost host = new ToolStripControlHost(box);
                host.AutoSize = false;
                host.Size     = new Size(tssSelect.Width, tssSelect.Width);
                host.Tag      = i;
                host.Click   += delegate(object o, EventArgs e)
                {
                    int x = (int)(o as ToolStripItem).Tag;
                    Manager.Index = x;
                    drop.Close();
                    DisplayAlbum();
                };
                drop.Items.Add(host);
            }
            if (drop.Items.Count > 0)
            {
                tssSelect.DropDown    = drop;
                tssSelect.DefaultItem = drop.Items[0];
            }
        }
Example #2
0
        protected override void ResetDialog()
        {
            PhotoAlbum.PhotoAlbum album = Manager.Album;

            // Assign text boxes
            txtAlbumFile.Text = Manager.FullName;
            txtTitle.Text     = album.Title;
            // Assign radio button
            switch (album.PhotoDescriptor)
            {
            case PhotoAlbum.PhotoAlbum.DescriptorOption.Caption:
                rbtnCaption.Checked = true;
                break;

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

            case 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;
        }
Example #3
0
 private void SaveSettings()
 {
     PhotoAlbum.PhotoAlbum album = Manager.Album;
     if (album != null)
     {
         album.Title = txtTitle.Text;
         if (rbtnCaption.Checked)
         {
             album.PhotoDescriptor = PhotoAlbum.PhotoAlbum.DescriptorOption.Caption;
         }
         else if (rbtnDateTaken.Checked)
         {
             album.PhotoDescriptor = PhotoAlbum.PhotoAlbum.DescriptorOption.DateTaken;
         }
         else if (rbtnFileName.Checked)
         {
             album.PhotoDescriptor = PhotoAlbum.PhotoAlbum.DescriptorOption.FileName;
         }
         if (cbxPassword.Checked && ValidPassword())
         {
             Manager.Password = txtPassword.Text;
         }
         else
         {
             Manager.Password = null;
         }
     }
 }
Example #4
0
 public static string addItem(PhotoAlbum parent)
 {
     AddItem item = new AddItem(parent);
     if (item.ShowDialog(parent) == DialogResult.OK)
     {
         return item.result;
     }
     return null;
 }
Example #5
0
 static void Main(string[] args)
 {
     //try
     {
         Application.EnableVisualStyles();
         Application.SetCompatibleTextRenderingDefault(false);
         PhotoAlbum main = new PhotoAlbum(args);
         if (!main.exitApplication)
         {
             Application.Run(main);
         }
     }
     //catch (Exception e)
     //{
         //MessageBox.Show(e.ToString(), "An unknown or unhandled error occured");
         //Application.Exit();
     //}
 }
Example #6
0
        private void AssignSubItems(ListViewItem item, string path, AlbumManager mgr)
        {
            item.SubItems.Clear();
            item.Text = Path.GetFileNameWithoutExtension(path);
            ListViewItem.ListViewSubItem subitem;
            if (mgr == null)
            {
                item.Tag = path;
                item.SubItems.Add("");
                subitem     = item.SubItems.Add("?");
                subitem.Tag = 999;
            }
            else
            {
                PhotoAlbum.PhotoAlbum album = mgr.Album;
                int count = album.Count;

                item.Tag = mgr;
                item.SubItems.Add(album.Title);
                subitem     = item.SubItems.Add(count.ToString());
                subitem.Tag = count;
            }
        }
Example #7
0
 public AlbumManager()
 {
     album = new PhotoAlbum();
 }
Example #8
0
 static public void WriteAlbum(PhotoAlbum album, string path)
 {
     WriteAlbum(album, path, null);
 }
Example #9
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();
                }
            }
        }
Example #10
0
 public Options(PhotoAlbum parent)
 {
     InitializeComponent();
     this.parent = parent;
     initializeOptions();
 }
Example #11
0
 /// <summary>
 /// Stops the timer that performs automatic insertions.
 /// </summary>
 public void StopAutomaticInsertions()
 {
     albumForAutomaticInsertions = null;
     automaticInsertionTimer?.Stop();
     automaticInsertionTimer = null;
 }
Example #12
0
        /// <summary>
        /// Adds a photo to the album.
        /// </summary>
        public void Add(Photo photo, PhotoAlbum toAlbum)
        {
            var albumIndex = Albums.IndexOf(toAlbum);

            Albums[albumIndex].Photos.Insert(0, photo);
        }
Example #13
0
 private AddItem(PhotoAlbum parent)
 {
     InitializeComponent();
     this.parent = parent;
 }
Example #14
0
 /// <summary>
 /// Configures the cell to display the album.
 /// </summary>
 public void Configure(PhotoAlbum album)
 {
     Accessory       = UITableViewCellAccessory.DisclosureIndicator;
     TextLabel.Text  = album.Title;
     ImageView.Image = album?.Thumbnail;
 }
Example #15
0
 public AlbumManager(string name, string pwd) : this()
 {
     this.name = name;
     album     = AlbumStorage.ReadAlbum(name, pwd);
     Password  = pwd;
 }
 public void DragSessionDidEnd(UICollectionView collectionView, IUIDragSession session)
 {
     ReloadAlbumFromPhotoLibrary();
     DeleteItems(collectionView);
     albumBeforeDrag = null;
 }
 public void DragSessionWillBegin(UICollectionView collectionView, IUIDragSession session)
 {
     albumBeforeDrag = album;
 }
Example #18
0
        /// <summary>
        /// Inserts the photo at a specific index in the album.
        /// </summary>
        public void Insert(Photo photo, PhotoAlbum inAlbum, int index)
        {
            var albumIndex = Albums.IndexOf(inAlbum);

            Albums[albumIndex].Photos.Insert(index, photo);
        }
Example #19
0
 public bool Equals(PhotoAlbum p)
 {
     return(p.Identifier == Identifier);
 }
Example #20
0
 public AlbumTest(BigPhotoAlbum bigPhoto, PhotoAlbum photoAlbum, PhotoAlbum photoAlbum1)
 {
     _BigPhotoAlbum = bigPhoto;
     _photoAlbum    = photoAlbum;
     _photoAlbum1   = photoAlbum1;
 }