예제 #1
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();
                }
            }
        }
예제 #2
0
        private void addExistingToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int currentItem = eventsListBox.SelectedIndex;

            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;
                }
            }

            openSlideShowDialog.InitialDirectory = Path.GetDirectoryName(iEventList.Path);
            DialogResult res = openSlideShowDialog.ShowDialog(this);

            if (res == DialogResult.OK)
            {
                string    slideShowPath = openSlideShowDialog.FileName;
                SlideShow newShow       = new SlideShow();
                newShow.Load(slideShowPath);

                // Let the user title the slide show: but recall the existing full title
                SlideShowTitleForm titleForm = new SlideShowTitleForm(newShow.Title);
                DialogResult       result    = titleForm.ShowDialog();
                if (result == DialogResult.OK)
                {
                    // Save titled slide show to XML file
                    newShow.Title = titleForm.FullTitle;

                    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);
                }
            }
        }