コード例 #1
0
        /// <summary>
        /// Loads a slide show file from the specified file path.
        /// </summary>
        /// <param name="sFilePath">Specifies the full path of the slide show file.</param>
        private void LoadSlideShowFile(string sFilePath)
        {
            if ((!string.IsNullOrEmpty(sFilePath)) && (File.Exists(sFilePath)))
            {
                try
                {
                    SlideShowDocument oDoc = new SlideShowDocument();
                    oDoc.Load(sFilePath);

                    m_WaitInterval = oDoc.WaitInterval;
                    m_nTransitionMode = oDoc.TransitionMode;
                    m_fFadeSpeed = oDoc.FadeSpeed;
                    m_sFilePaths = new List<string>(oDoc.GetEntries());
                }
                catch (FileFormatException e)
                {
                    MessageBox.Show("Unable to load the specified slide show file.\n\nReason: " + e.Message, "Load File Error",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (UnauthorizedAccessException e)
                {
                    MessageBox.Show("Unable to load the specified slide show file.\n\nReason: " + e.Message, "Load File Error",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (System.Security.SecurityException e)
                {
                    MessageBox.Show("Unable to load the specified slide show file.\n\nReason: " + e.Message, "Load File Error",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (IOException e)
                {
                    MessageBox.Show("Unable to load the specified slide show file.\n\nReason: " + e.Message, "Load File Error",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Import_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog oDlg = new OpenFileDialog())
            {
                oDlg.AutoUpgradeEnabled = true;
                oDlg.Filter = FILE_FILTER;
                oDlg.Title = "Import Slide Show";

                if (oDlg.ShowDialog(this) == DialogResult.OK)
                {
                    string sCaption = "Confirm Import Slide Show";
                    string sMessage = "Importing a slide show will cause any current settings to be lost. Would you like to continue?";
                    DialogResult nDlg = MessageBox.Show(sMessage, sCaption,
                        MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                    if (nDlg == DialogResult.No)
                        return;

                    if ((!string.IsNullOrEmpty(oDlg.FileName)) && (File.Exists(oDlg.FileName)))
                    {
                        try
                        {
                            DateTime Date;
                            SlideShowDocument oDoc = new SlideShowDocument();
                            oDoc.Load(oDlg.FileName);

                            if (DateTime.TryParse(oDoc.Date, out Date))
                                dtp_Created.Value = Date;

                            nud_Seconds.Value = oDoc.WaitInterval;
                            cbx_TransitionMode.SelectedIndex = (int)oDoc.TransitionMode;
                            cbx_FadeSpeed.SelectedIndex = (int)GetFadeSpeed(oDoc.FadeSpeed);
                            txtb_FileName.Text = Path.GetFileNameWithoutExtension(oDlg.FileName);

                            // Clear any previous items.
                            if (lvw_Files.Items.Count > 0)
                                lvw_Files.Items.Clear();

                            // Add the entries to the files list view control.
                            foreach (string sEntry in oDoc.GetEntries())
                                lvw_Files.Items.Add(sEntry);

                            // Update the changes.
                            ListViewItemsChanged();
                        }
                        catch (FileFormatException ex)
                        {
                            MessageBox.Show("Unable to create the specified slide show.\n\nReason: " + ex.Message, "Error Creating File",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        catch (UnauthorizedAccessException ex)
                        {
                            MessageBox.Show("Unable to create the specified slide show.\n\nReason: " + ex.Message, "Error Creating File",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        catch (System.Security.SecurityException ex)
                        {
                            MessageBox.Show("Unable to create the specified slide show.\n\nReason: " + ex.Message, "Error Creating File",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        catch (IOException ex)
                        {
                            MessageBox.Show("Unable to create the specified slide show.\n\nReason: " + ex.Message, "Error Creating File",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
        }