示例#1
0
 /// <summary>
 /// Inputs the length of the silence.
 /// </summary>
 /// <param name="mediafield">The mediafield.</param>
 /// <remarks>Documented by Dev02, 2008-03-30</remarks>
 private MediaField InputSilenceLength(MediaField mediafield)
 {
     if (mediafield != null && mediafield.Type == MediaField.TypeEnum.Silence && mediafield.SilenceDuration == 0)
     {
         SilenceLength lengthform = new SilenceLength();
         lengthform.ShowDialog();
         if (lengthform.DialogResult == DialogResult.OK)
         {
             mediafield = new MediaField(lengthform.Length);
         }
         lengthform.Close();
     }
     return(mediafield);
 }
示例#2
0
        /// <summary>
        /// Adds a media field to the playback sequence listview.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <remarks>Documented by Dev02, 2008-03-30</remarks>
        private void AddMediaField(ListViewItem item)
        {
            item = (ListViewItem)item.Clone();

            MediaField mediafield = item.Tag as MediaField;

            if (mediafield != null && mediafield.Type == MediaField.TypeEnum.Silence && mediafield.SilenceDuration == 0)
            {
                //ask the user to enter the desired duration of the silence
                mediafield = InputSilenceLength(mediafield);
                if (mediafield.SilenceDuration == 0)
                {
                    return;
                }
                else
                {
                    item.Tag  = mediafield;
                    item.Text = mediafield.ToString();
                }
            }

            listViewPlaybackSequence.Items.Add(item);
        }
示例#3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MediaFieldFile"/> class.
 /// </summary>
 /// <param name="mediafield">The mediafield.</param>
 /// <param name="file">The file.</param>
 /// <remarks>Documented by Dev02, 2008-03-30</remarks>
 public MediaFieldFile(MediaField mediafield, FileInfo file)
 {
     this.mediafield = mediafield;
     this.file = file;
 }
示例#4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MediaFieldFile"/> class.
 /// </summary>
 /// <param name="mediafield">The mediafield.</param>
 /// <remarks>Documented by Dev02, 2008-03-30</remarks>
 public MediaFieldFile(MediaField mediafield)
 {
     this.mediafield = mediafield;
 }
示例#5
0
 /// <summary>
 /// Inputs the length of the silence.
 /// </summary>
 /// <param name="mediafield">The mediafield.</param>
 /// <remarks>Documented by Dev02, 2008-03-30</remarks>
 private MediaField InputSilenceLength(MediaField mediafield)
 {
     if (mediafield != null && mediafield.Type == MediaField.TypeEnum.Silence && mediafield.SilenceDuration == 0)
     {
         SilenceLength lengthform = new SilenceLength();
         lengthform.ShowDialog();
         if (lengthform.DialogResult == DialogResult.OK)
             mediafield = new MediaField(lengthform.Length);
         lengthform.Close();
     }
     return mediafield;
 }
示例#6
0
        /// <summary>
        /// Handles the Click event of the buttonStart control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        /// <remarks>Documented by Dev02, 2008-03-17</remarks>
        private void buttonStart_Click(object sender, EventArgs e)
        {
            if (BusinessLayer.WorkingThreadActive)
            {
                BusinessLayer.AbortWorkingThread();
                return;
            }

            textBoxLog.Clear();
            tracelistener.LogMessages.Clear();

            //check if input file exists
            if (!File.Exists(textBoxLearningModule.Text))
            {
                BusinessLayer.AddLog("The specified learning module file cannot be found");
                return;
            }

            //check if any audio fields are selected
            if (listViewPlaybackSequence.Items.Count == 0)
            {
                BusinessLayer.AddLog("Please select at least one field for the playback sequence");
                return;
            }

            IDictionary dictionary = null;

            try
            {
                AudioBookOptions options = new AudioBookOptions();

                //add mono/stereo selection to options
                options.Stereo = radioButtonStereo.Checked;

                //add selected fields to the options
                foreach (ListViewItem lvi in listViewPlaybackSequence.Items)
                {
                    MediaField mediafield = lvi.Tag as MediaField;
                    if (mediafield != null)
                    {
                        options.MediaFields.Add(mediafield);
                    }
                }

                //check for valid file paths
                FileInfo dictionaryfile = null, audiobook = null;
                try
                {
                    dictionaryfile = new FileInfo(textBoxLearningModule.Text);
                    audiobook      = new FileInfo(textBoxAudiobook.Text);
                    if (string.IsNullOrEmpty(audiobook.Extension))
                    {
                        BusinessLayer.AddLog("Please enter a valid extension for the target audiobook file");
                        return;
                    }
                }
                catch
                {
                    BusinessLayer.AddLog("The specified file paths are not valid. Please check your input");
                    return;
                }

                //save file paths to settings as recent files
                Settings.Default.RecentLearningModule = dictionaryfile.FullName;
                Settings.Default.RecentAudioBook      = audiobook.FullName;
                Settings.Default.Save();

                //open learning module and start audio book generation
                try
                {
                    ConnectionStringStruct       css  = new ConnectionStringStruct(DatabaseType.MsSqlCe, dictionaryfile.FullName);
                    MLifter.DAL.Interfaces.IUser user = UserFactory.Create((GetLoginInformation)MLifter.Controls.LoginForm.OpenLoginForm, css, (DataAccessErrorDelegate) delegate { return; }, this);
                    css.LmId = User.GetIdOfLearningModule(dictionaryfile.FullName, user);
                    user.ConnectionString = css;
                    dictionary            = user.Open();
                }
                catch (System.IO.IOException)
                {
                    BusinessLayer.AddLog("The Learning Module file could not be accessed. Please make sure that it is not open within another program (e.g. MemoryLifter)");
                    return;
                }
                catch (System.Xml.XmlException)
                {
                    BusinessLayer.AddLog("The Learning Module file does not seem to be in a valid format");
                    return;
                }
                catch (ProtectedLearningModuleException)
                {
                    BusinessLayer.AddLog("The Learning Module could not be opened: It is content protected");
                    return;
                }
                catch (Exception exp)
                {
                    BusinessLayer.AddLog("The Learning Module file could not be opened:" + Environment.NewLine + exp.Message);
                    return;
                }
                buttonStart.Text = "Cancel";
                BusinessLayer.GenerateAudioBook(dictionary, audiobook, options, codecs);
            }
            catch (Exception exp)
            {
                BusinessLayer.AddLog("Audio book generation exception happened: " + Environment.NewLine + exp.ToString());
                return;
            }
            finally
            {
                if (dictionary != null)
                {
                    dictionary.Dispose();
                }
            }
        }
示例#7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MediaFieldFile"/> class.
 /// </summary>
 /// <param name="mediafield">The mediafield.</param>
 /// <param name="file">The file.</param>
 /// <remarks>Documented by Dev02, 2008-03-30</remarks>
 public MediaFieldFile(MediaField mediafield, FileInfo file)
 {
     this.mediafield = mediafield;
     this.file       = file;
 }
示例#8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MediaFieldFile"/> class.
 /// </summary>
 /// <param name="mediafield">The mediafield.</param>
 /// <remarks>Documented by Dev02, 2008-03-30</remarks>
 public MediaFieldFile(MediaField mediafield)
 {
     this.mediafield = mediafield;
 }