Example #1
0
 public void PreRender(CommandNode commandNode, TimeSpan commandTimeSpan)
 {
     _effect.PreRender(commandNode.TargetNodes.ToArray(), commandTimeSpan, ParameterValues);
 }
        private void papagayoImportToolStripMenuItem_Click(object sender, EventArgs e)
        {
            PapagayoDoc papagayoFile = new PapagayoDoc();
            FileDialog  openDialog   = new OpenFileDialog();

            openDialog.Filter      = @"Papagayo files (*.pgo)|*.pgo|All files (*.*)|*.*";
            openDialog.FilterIndex = 1;
            if (openDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            string fileName = openDialog.FileName;

            papagayoFile.Load(fileName);
            TimelineElementsClipboardData result = new TimelineElementsClipboardData
            {
                FirstVisibleRow   = -1,
                EarliestStartTime = TimeSpan.MaxValue,
            };

            result.FirstVisibleRow = 0;
            int rownum = 0;

            foreach (string voice in papagayoFile.VoiceList)
            {
                List <PapagayoPhoneme> phonemes = papagayoFile.PhonemeList(voice);
                if (phonemes.Count > 0)
                {
                    foreach (PapagayoPhoneme phoneme in phonemes)
                    {
                        if (phoneme.DurationMS == 0.0)
                        {
                            continue;
                        }
                        IEffectModuleInstance effect =
                            ApplicationServices.Get <IEffectModuleInstance>(new LipSyncDescriptor().TypeId);
                        ((LipSync)effect).StaticPhoneme = (App.LipSyncApp.PhonemeType)Enum.Parse(typeof(App.LipSyncApp.PhonemeType), phoneme.TypeName.ToUpper());
                        ((LipSync)effect).LyricData     = phoneme.LyricData;
                        TimeSpan             startTime      = TimeSpan.FromMilliseconds(phoneme.StartMS);
                        EffectModelCandidate modelCandidate =
                            new EffectModelCandidate(effect)
                        {
                            Duration  = TimeSpan.FromMilliseconds(phoneme.DurationMS - 1),
                            StartTime = startTime
                        };
                        result.EffectModelCandidates.Add(modelCandidate, rownum);
                        if (startTime < result.EarliestStartTime)
                        {
                            result.EarliestStartTime = startTime;
                        }
                        effect.PreRender();
                    }
                    IDataObject dataObject = new DataObject(ClipboardFormatName);
                    dataObject.SetData(result);
                    Clipboard.SetDataObject(dataObject, true);
                    _TimeLineSequenceClipboardContentsChanged(EventArgs.Empty);
                    SequenceModified();
                }
                rownum++;
            }
            string displayStr = rownum + " Voices imported to clipboard as seperate rows\n\n";
            int    j          = 1;

            foreach (string voiceStr in papagayoFile.VoiceList)
            {
                displayStr += "Row #" + j + " - " + voiceStr + "\n";
                j++;
            }
            //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible)
            MessageBoxForm.msgIcon = SystemIcons.Information;             //this is used if you want to add a system icon to the message form.
            var messageBox = new MessageBoxForm(displayStr, @"Papagayo Import", false, false);

            messageBox.ShowDialog();
        }