Example #1
0
        private void eventsListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Item selected in EventList listbox: enable/disable the Play button
            // depending upon whether it has a slide show
            if (iEventList.SetEvent(eventsListBox.SelectedIndex))
            {
                SlideShow show = iEventList.SlideShow;
                if (show == null)
                {
                    // Not a slide show
                    eventLabel.Text = iEventList.Name;

                    // Free up resources for thumbnail
                    if (albumPictureBox.Image != null)
                    {
                        albumPictureBox.Image.Dispose();
                        albumPictureBox.Image = null;
                    }

                    playButton.Enabled = false;
                    editButton.Enabled = false;
                }
                else
                {
                    eventLabel.Text = show.Title;
                    string eventFavourite = show.GetFavourite();
                    if (File.Exists(eventFavourite))
                    {
                        // Can't use the following statement, as it locks the file and
                        // causes problems if the user wants to delete it within the editor
                        //albumPictureBox.Image = System.Drawing.Bitmap.FromFile(show.GetFavourite());

                        Stream s = File.Open(show.GetFavourite(), FileMode.Open);
                        albumPictureBox.Image = Image.FromStream(s);
                        s.Close();
                    }
                    else
                    {
                        albumPictureBox.Image = null;
                    }
                    playButton.Enabled = true;
                    editButton.Enabled = true;
                }
            }

            PrepareContextMenu();
        }