/// <summary>
 /// Constructor setting the <see cref="TreeNodeTestDelegate"/> determining when to create new audio files
 /// and when to
 /// </summary>
 /// <param name="treeNodeTriggersNewAudioFileDelegate">
 /// The <see cref="TreeNodeTestDelegate"/> determining which <see cref="TreeNode"/>s trigger new audio files,
 /// if <c>null</c> then no <see cref="TreeNode"/>s trigger new audio files
 /// </param>
 /// <param name="treeNodeMustBeSkippedDelegate">
 /// The <see cref="TreeNodeTestDelegate"/> determining which <see cref="TreeNode"/>s should be skipped,
 /// if <c>null</c> then no <see cref="TreeNode"/>s are skipped
 /// </param>
 public PublishManagedAudioVisitor(
     TreeNodeTestDelegate treeNodeTriggersNewAudioFileDelegate,
     TreeNodeTestDelegate treeNodeMustBeSkippedDelegate)
 {
     mTreeNodeTriggersNewAudioFileDelegate = treeNodeTriggersNewAudioFileDelegate;
     mTreeNodeMustBeSkippedDelegate        = treeNodeMustBeSkippedDelegate;
 }
Пример #2
0
        public static void PublishTest(Presentation pres)
        {
            Channel sourceCh = pres.ChannelsManager.GetChannelsByName("channel.audio")[0];

            Channel destCh = pres.ChannelFactory.Create();

            destCh.Language = sourceCh.Language;
            destCh.Name     = String.Format("{0}.published", sourceCh.Name);

            Uri publishDestination = new Uri(pres.RootUri, "AudioPublishDestination/");

            if (Directory.Exists(publishDestination.LocalPath))
            {
                foreach (string file in Directory.GetFiles(publishDestination.LocalPath))
                {
                    File.Delete(file);
                }
            }
            else
            {
                Directory.CreateDirectory(publishDestination.LocalPath);
            }

            TreeNodeTestDelegate del = new TreeNodeTestDelegate(
                delegate(TreeNode node)
            {
                if (node.Parent == node.Presentation.RootNode)
                {
                    return(true);
                }
                return(false);
            });

            PublishManagedAudioVisitor publishVisitor = new PublishManagedAudioVisitor(del, null);

            publishVisitor.SourceChannel        = sourceCh;
            publishVisitor.DestinationChannel   = destCh;
            publishVisitor.DestinationDirectory = publishDestination;

            pres.RootNode.AcceptDepthFirst(publishVisitor);

            Uri xukFile = new Uri(pres.RootUri, "TreeNodeTestsSample.xuk");

            if (File.Exists(xukFile.LocalPath))
            {
                File.Delete(xukFile.LocalPath);
            }
            pres.Project.SaveXuk(xukFile);

            CheckPublishedFiles(pres.RootNode, sourceCh, destCh, null, null, null);
        }
Пример #3
0
        public void ExportToDaisy3(string exportDirectory)
        {
            //if (m_Presentation.RootNode.GetDurationOfManagedAudioMediaFlattened().TimeDeltaAsMillisecondLong == 0)
            //{
            //    System.Diagnostics.Debug.Fail("no audio found", "No audio node found in the project being exported");
            //}

            m_ID_Counter      = 0;
            m_OutputDirectory = exportDirectory;

            //TreeNodeTestDelegate triggerDelegate  = delegate(urakawa.core.TreeNode node) { return node.GetManagedAudioMedia () != null ; };
            TreeNodeTestDelegate triggerDelegate = doesTreeNodeTriggerNewSmil;
            TreeNodeTestDelegate skipDelegate    = delegate(urakawa.core.TreeNode node) { return(false); };

            PublishFlattenedManagedAudioVisitor publishVisitor = new PublishFlattenedManagedAudioVisitor(triggerDelegate, skipDelegate);

            if (!Directory.Exists(exportDirectory))
            {
                Directory.CreateDirectory(exportDirectory);
            }
            m_OutputDirectory = exportDirectory;

            publishVisitor.DestinationDirectory = new Uri(exportDirectory, UriKind.Absolute);

            publishVisitor.SourceChannel = m_Presentation.ChannelsManager.GetOrCreateAudioChannel();

            Channel publishChannel = m_Presentation.ChannelFactory.CreateAudioChannel();

            publishChannel.Name = PUBLISH_AUDIO_CHANNEL_NAME;
            publishVisitor.DestinationChannel = publishChannel;

            m_Presentation.RootNode.AcceptDepthFirst(publishVisitor);

            // The verification is not strictly necessary, but we should use it for testing all kinds of books, before stable release.
            publishVisitor.VerifyTree(m_Presentation.RootNode);

            // following functions can be called only in this order.
            CreateDTBookDocument();
            CreateNcxAndSmilDocuments();
            CreateOpfDocument();

            m_Presentation.ChannelsManager.RemoveManagedObject(publishChannel);
        }
Пример #4
0
        //private bool m_EnableExplicitGarbageCollection = true ;
        //public bool EnableExplicitGarbageCollection
        //{
        //    get
        //    {
        //        return m_EnableExplicitGarbageCollection;
        //    }
        //    set
        //    {
        //        m_EnableExplicitGarbageCollection = value;
        //    }
        //}

        public virtual void ConfigureAudioFileDelegates()
        {
            m_TriggerDelegate = doesTreeNodeTriggerNewSmil;
            m_SkipDelegate    = delegate { return(false); };
        }