Example #1
0
 private void createSlideshowToolStripMenuItem_Click(object sender, EventArgs e)
 {
     // It should only be possible to invoke the Create Slideshow menu item for a
     // folder, but we will check to make sure
     ListView.SelectedListViewItemCollection selectedItems = this.listView.SelectedItems;
     if (selectedItems.Count == 1)
     {
         if (selectedItems[0].SubItems[1].Text.Equals("Directory"))
         {
             string    currentDirectory = TreePath(treeView.SelectedNode);
             string    subDirectory     = selectedItems[0].SubItems[0].Text;
             SlideShow newShow          = SlideShow.Create(currentDirectory, subDirectory);
             if (newShow != null)
             {
                 // Note: slide show has no title - could copy code from AlbumForm
                 // addNewToolStripMenuItem_Click method
                 if (newShow.Save())
                 {
                     // Refresh display (should be a new XML file)
                     MessageBox.Show("SlideShow created", "PhotoStudio");
                     ListFolderContents(new DirectoryInfo(currentDirectory));
                 }
                 else
                 {
                     MessageBox.Show("Failed to create slideshow", "PhotoStudio");
                 }
             }
         }
     }
 }
Example #2
0
        private void addNewToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int currentItem = eventsListBox.SelectedIndex;  // Get current selected item

            if ((currentItem < 0) || (currentItem >= eventsListBox.Items.Count))
            {
                // Not a valid selection, but cater for the special case in which there
                // is an empty EventList, hence nothing to select, but we do want to allow
                // an event to be added.
                if (iEventList.Count == 0)
                {
                    currentItem = 0;
                }
                else
                {
                    // Not a valid selection - don't allow event to be added
                    return;
                }
            }

            createSlideShowDialog.SelectedPath = Path.GetDirectoryName(iEventList.Path);
            DialogResult res = createSlideShowDialog.ShowDialog(this);

            if (res == DialogResult.OK)
            {
                string    slideShowFolder  = createSlideShowDialog.SelectedPath;
                string    currentDirectory = Path.GetDirectoryName(slideShowFolder);
                string    subDirectory     = Path.GetFileName(slideShowFolder);
                SlideShow newShow          = SlideShow.Create(currentDirectory, subDirectory);
                if (newShow != null)
                {
                    // Let the user title the slide show
                    SlideShowTitleForm titleForm = new SlideShowTitleForm();
                    DialogResult       result    = titleForm.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        // Save titled slide show to XML file
                        newShow.Title = titleForm.FullTitle;
                        if (newShow.Save())
                        {
                            // Add the saved show to the Events List
                            iEventList.Insert(currentItem, titleForm.BriefTitle, newShow);
                            iEventListChanged = true;       // Remember that an edit has taken place

                            // Repopulate the listbox with the new longer event list
                            PopulateEventsListBox(true);
                        }
                        else
                        {
                            MessageBox.Show("Failed to create slideshow", "PhotoStudio");
                        }
                    }

                    titleForm.Close();
                }
            }
        }