예제 #1
0
        internal void CreateNewPresentationInBackend(string path, string title, bool createTitleSection, string id, Settings settings, bool isStubProjectForImport, int audioChannels, int audioSampleRate)
        {
            mProject = new Project();
#if false //(DEBUG)
            mProject.PrettyFormat = true;
#else
            mProject.PrettyFormat = false;
#endif
            string parentDirectory     = System.IO.Path.GetDirectoryName(path);
            Uri    obiProjectDirectory = new Uri(parentDirectory);

            //Presentation presentation = mProject.AddNewPresentation(obiProjectDirectory, System.IO.Path.GetFileName(path));
            //ObiPresentation newPres = mProject.PresentationFactory.Create(mProject, obiProjectDirectory, System.IO.Path.GetFileName(path));

            ObiPresentation newPres = mProject.PresentationFactory.Create <ObiPresentation>();
            newPres.Project = mProject;
            newPres.RootUri = obiProjectDirectory;

            //TODO: it would be good for Obi to separate Data folder based on project file name,
            //TODO: otherwise collision of Data folder may happen if several project files are in same directory.
            //newPres.DataProviderManager.SetDataFileDirectoryWithPrefix(System.IO.Path.GetFileName(path));

#if DEBUG
            newPres.WarmUpAllFactories();
#endif


            mProject.Presentations.Insert(mProject.Presentations.Count, newPres);


            PCMFormatInfo pcmFormat = new PCMFormatInfo((ushort)audioChannels, (uint)audioSampleRate, (ushort)settings.Audio_BitDepth);
            newPres.MediaDataManager.DefaultPCMFormat       = pcmFormat;
            newPres.MediaDataManager.EnforceSinglePCMFormat = true;

            newPres.ChannelsManager.GetOrCreateTextChannel();
            //m_textChannel = presentation.ChannelFactory.CreateTextChannel();
            //m_textChannel.Name = "The Text Channel";

            newPres.ChannelsManager.GetOrCreateAudioChannel();
            //m_audioChannel = presentation.ChannelFactory.CreateAudioChannel();
            //m_audioChannel.Name = "The Audio Channel";

            ObiRootNode rootNode = newPres.TreeNodeFactory.Create <ObiRootNode>();
            newPres.RootNode = rootNode;

            //sdk2
            //mProject.setDataModelFactory ( mDataModelFactory );
            //mProject.setPresentation ( mDataModelFactory.createPresentation (), 0 );

            mPath = path;
            GetLock(mPath);
            mChangesCount = 0;
            newPres.Initialize(this, title, createTitleSection, id, settings, isStubProjectForImport);

            //sdk2
            //Presentation.setRootUri ( new Uri ( path ) );

            //sdk2
            // create data directory if it is not created
            //string dataDirectory = ((urakawa.media.data.FileDataProviderManager)Presentation.getDataProviderManager ()).getDataFileDirectoryFullPath ();
            //if ( !Directory.Exists (dataDirectory ) )
            //    {
            //    Directory.CreateDirectory ( dataDirectory );
            //    }

            //if (ProjectCreated != null) ProjectCreated ( this, null );

            SetupBackupFilesForNewSession(path);
            ShouldDisableDiskSpaceCheck();
            Save(mPath);
            //ForceSave ();
        }
예제 #2
0
        public void MergeProject()
        {
            m_SectionsToMerge.Clear();
            try
            {                //1
                Uri     uri        = new Uri(m_SourceProjectPath, UriKind.Absolute);
                bool    pretty     = m_session.Presentation.Project.PrettyFormat;
                Project subproject = new Project();

                OpenXukAction action = new OpenXukAction(subproject, uri);
                action.ShortDescription = "...";
                action.LongDescription  = "...";
                action.Execute();
                subproject.PrettyFormat = pretty;

                Presentation subpresentation = subproject.Presentations.Get(0);
                // compare audio formats
                if (m_session.Presentation.MediaDataManager.DefaultPCMFormat.Data.BitDepth != subpresentation.MediaDataManager.DefaultPCMFormat.Data.BitDepth ||
                    m_session.Presentation.MediaDataManager.DefaultPCMFormat.Data.BlockAlign != subpresentation.MediaDataManager.DefaultPCMFormat.Data.BlockAlign ||
                    m_session.Presentation.MediaDataManager.DefaultPCMFormat.Data.SampleRate != subpresentation.MediaDataManager.DefaultPCMFormat.Data.SampleRate)
                {
                    throw new System.Exception("Audio format of project does not match");
                }
                TreeNode subroot      = subpresentation.RootNode;
                int      sectionCount = ((ObiRootNode)subroot).SectionChildCount;
                if (sectionCount == 0)
                {
                    return;
                }
                int progressValue = 0;

                reportProgress(progressValue, "");
                SectionNode section = ((ObiRootNode)subroot).SectionChild(0);
                while (section != null)
                {                //2
                    if (RequestCancellation)
                    {
                        return;
                    }
                    TreeNode importedLevel = section.Export(m_session.Presentation);

                    ObiRootNode parent = (ObiRootNode)m_session.Presentation.RootNode;
                    //parent.AppendChild((SectionNode) importedLevel);
                    m_SectionsToMerge.Add((SectionNode)importedLevel);
                    progressValue += 90 / sectionCount;
                    reportProgress(progressValue,
                                   string.Format(Localizer.Message("MergeProject_SectionProgress"), section.Label));
                    //System.Windows.Forms.MessageBox.Show(section.GetText().ToString());
                    section = section.NextSibling;
                }            //-2
            }                //-1
                             //catch (Exception ex)
                             //{//1
            //messageBoxAlert("PROBLEM:\n " + xukPath, null);
            //m_session.messageBoxText("MERGE PROBLEM", xukPath, ex.Message);

            //throw ex;
            //System.Windows.Forms.MessageBox.Show(ex.ToString());
            //}//-1


            finally
            {
            }
            reportProgress(100, "");
        }