示例#1
0
        /// <summary>
        /// Load the files.
        /// </summary>
        /// <param name="files">Files selected.</param>
        private void LoadFiles(string[] files)
        {
            // Set flag
            IsLoading = true;

            if (files.Length > 0)
            {
                // Create the file playback based off the selected file
                // Try to optimize and first load the file into the Binary only codec
                // If this does not work, then try all the codecs
                FilePlayback fp = new FilePlayback();
                fp.FindRtbEnsembles(files);

                // Wait for ensembles to be added
                int timeout = 10;
                while (fp.TotalEnsembles < 0 && timeout >= 0)
                {
                    System.Threading.Thread.Sleep(250);
                    timeout--;
                }

                // Check if any ensembles were found
                if (fp.TotalEnsembles > 0)
                {
                    // Add the ensembles to the project
                    // Create a project if new, or load if old
                    var project = CreateProject(files[0], fp.GetAllEnsembles());

                    // Set the selected playback to the pulsemanager
                    _pm.SelectedProject = project;
                    //_pm.SelectedPlayback = fp;
                }
                else
                {
                    // Find the ensembles using all the codecs
                    fp.FindEnsembles(files);

                    var project = CreateProject(files[0], fp.GetAllEnsembles());

                    // Set the selected playback to the pulsemanager
                    _pm.SelectedProject = project;
                }
            }

            // Reset flag
            IsLoading = false;
        }
        /// <summary>
        /// Load the files.
        /// </summary>
        /// <param name="files">Files selected.</param>
        public Project LoadFiles(string[] files)
        {
            // Set flag
            //IsLoading = true;

            Project project = null;

            if (files.Length > 0)
            {
                // Create the file playback based off the selected file
                // Try to optimize and first load the file into the Binary only codec
                // If this does not work, then try all the codecs
                FilePlayback fp = new FilePlayback();
                fp.ProcessFileEvent += Fp_ProcessFileEvent;
                fp.FindRtbEnsembles(files);

                // Wait for ensembles to be added
                int timeout = 10;
                while (fp.TotalEnsembles < 0 && timeout >= 0)
                {
                    System.Threading.Thread.Sleep(250);
                    timeout--;
                }

                // Check if any ensembles were found
                if (fp.TotalEnsembles > 0)
                {
                    // Add the ensembles to the project
                    // Create a project if new, or load if old
                    project = CreateProject(files[0], fp.GetAllEnsembles());

                    // Publish event of found ensembles
                    _eventAggregator.PublishOnUIThread(new PlaybackTotalEnsemblesEvent(fp.TotalEnsembles));
                }
                else
                {
                    // Find the ensembles using all the codecs
                    fp.FindEnsembles(files);
                    project = CreateProject(files[0], fp.GetAllEnsembles());

                    // Publish event of found ensembles
                    _eventAggregator.PublishOnUIThread(new PlaybackTotalEnsemblesEvent(fp.TotalEnsembles));
                }

                fp.ProcessFileEvent -= Fp_ProcessFileEvent;
                fp.Dispose();
            }

            // Reset flag
            //IsLoading = false;

            // Pass the data to all Screen layers
            foreach (var vm in IoC.GetAllInstances(typeof(IProjectLayer)))
            {
                ((IProjectLayer)vm).LoadProject(project);
            }

            project.Dispose();

            return(project);
        }