Example #1
0
 // Context menu strip click events (Rename/Delete album)
 private void lstBxAlbumsContextMenu_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
 {
     this.listboxContextMenu.Hide();
     if (e.ClickedItem.ToString().Equals("Rename")) // Display dialog albm name to rename
     {
         DialogAlbumName dialog   = new DialogAlbumName();
         dialog.getTextBox().Text = this.lstBxAlbums.SelectedItem.ToString();
         if (albumNameCheck(dialog))
         {
             // Move directory name / change xml content / refresh listbox
             Directory.Move("albums\\" + this.lstBxAlbums.SelectedItem.ToString(), "albums\\" + dialog.getTextBox().Text);
             this.photoViewer.getAlbum(this.lstBxAlbums.SelectedItem.ToString()).Name = dialog.getTextBox().Text;
             this.photoViewer.save();
             int index = this.lstBxAlbums.SelectedIndex;
             lstBxAlbums.Items.RemoveAt(index);
             lstBxAlbums.Items.Insert(index, dialog.getTextBox().Text);
             this.lstBxAlbums.SelectedIndex = index;
         }
         dialog.Dispose();
     }
     else if (e.ClickedItem.ToString().Equals("Delete"))
     {
         this.rmAlbum();
     }
 }
Example #2
0
        // Click event on button to add album. Display dialog to ask for album name
        private void buttonAddAlbum_Click(object sender, EventArgs e)
        {
            DialogAlbumName dialog = new DialogAlbumName();

            if (albumNameCheck(dialog))
            {
                this.lstBxAlbums.Items.Add(dialog.getTextBox().Text);
                Directory.CreateDirectory("albums\\" + dialog.getTextBox().Text); // Create folder for the album
                this.photoViewer.addAlbum(dialog.getTextBox().Text, DateTime.Now);
                this.photoViewer.save();
            }
            dialog.Dispose();
            this.lstBxAlbums.Focus(); // Return focus to list box album
        }