Esempio n. 1
0
        private void papagayoImportToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string fileName;
            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;
            }
            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 = phoneme.TypeName.ToUpper();
                        ((LipSync)effect).LyricData = phoneme.LyricData;

                        TimeSpan startTime = TimeSpan.FromMilliseconds(phoneme.StartMS);
                        TimelineElementsClipboardData.EffectModelCandidate modelCandidate =
                              new TimelineElementsClipboardData.EffectModelCandidate(effect)
                              {
                                  Duration = TimeSpan.FromMilliseconds(phoneme.DurationMS - 1),
                                  StartTime = startTime,
                              };

                        result.EffectModelCandidates.Add(modelCandidate, rownum);
                        if (startTime < result.EarliestStartTime)
                            result.EarliestStartTime = startTime;

                        effect.Render();

                    }

                    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.Show(displayStr, "Papagayo Import", MessageBoxButtons.OK);
        }
Esempio n. 2
0
        private void textConverterHandler(object sender, NewTranslationEventArgs args)
        {
            TimelineElementsClipboardData result = new TimelineElementsClipboardData()
            {
                FirstVisibleRow = -1,
                EarliestStartTime = TimeSpan.MaxValue,
            };

            if (args.PhonemeData.Count > 0)
            {

                foreach (LipSyncConvertData data in args.PhonemeData)
                {
                    if (data.Duration.Ticks == 0)
                    {
                        continue;
                    }

                    IEffectModuleInstance effect =
                        ApplicationServices.Get<IEffectModuleInstance>(new LipSyncDescriptor().TypeId);

                    ((LipSync)effect).StaticPhoneme = data.Phoneme.ToString().ToUpper();
                    ((LipSync)effect).LyricData = data.LyricData;

                    TimelineElementsClipboardData.EffectModelCandidate modelCandidate =
                          new TimelineElementsClipboardData.EffectModelCandidate(effect)
                          {
                              Duration = data.Duration,
                              StartTime = data.StartOffset
                          };

                    result.EffectModelCandidates.Add(modelCandidate, 0);
                    if (data.StartOffset < result.EarliestStartTime)
                        result.EarliestStartTime = data.StartOffset;

                    effect.Render();

                }

                IDataObject dataObject = new DataObject(_clipboardFormatName);
                dataObject.SetData(result);
                Clipboard.SetDataObject(dataObject, true);
                _TimeLineSequenceClipboardContentsChanged(EventArgs.Empty);

                int pasted = 0;

                if (args.Placement == TranslatePlacement.Cursor)
                {
                    args.FirstMark += TimelineControl.grid.CursorPosition;
                }

                if (args.Placement != TranslatePlacement.Clipboard)
                {
                    pasted = ClipboardPaste((TimeSpan)args.FirstMark);
                }

                if (pasted == 0)
                {
                    MessageBox.Show("Conversion Complete and copied to Clipboard \n Paste at first Mark offset", "Convert Text", MessageBoxButtons.OK);
                }

                sequenceModified();

            }
        }
Esempio n. 3
0
        private void ClipboardAddData(bool cutElements)
        {
            if (!TimelineControl.SelectedElements.Any())
                return;

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

            int rownum = 0;
            var affectedElements = new List<Element>();
            foreach (Row row in TimelineControl.VisibleRows)
            {
                // Since removals may happen during enumeration, make a copy with ToArray().

                affectedElements.AddRange(row.SelectedElements);
                foreach (Element elem in row.SelectedElements.ToArray())
                {
                    if (result.FirstVisibleRow == -1)
                        result.FirstVisibleRow = rownum;

                    int relativeVisibleRow = rownum - result.FirstVisibleRow;

                    TimelineElementsClipboardData.EffectModelCandidate modelCandidate =
                        new TimelineElementsClipboardData.EffectModelCandidate(((TimedSequenceElement)elem).EffectNode.Effect)
                            {
                                Duration = elem.Duration,
                                StartTime = elem.StartTime
                            };
                    result.EffectModelCandidates.Add(modelCandidate, relativeVisibleRow);

                    if (elem.StartTime < result.EarliestStartTime)
                        result.EarliestStartTime = elem.StartTime;

                    if (cutElements)
                    {
                        row.RemoveElement(elem);
                        _sequence.RemoveData(((TimedSequenceElement)elem).EffectNode);
                        sequenceModified();
                    }
                }
                rownum++;
            }
            if (cutElements)
            {
                var act = new EffectsCutUndoAction(this, affectedElements.Select(x => x.EffectNode));
                _undoMgr.AddUndoAction(act);
            }

            IDataObject dataObject = new DataObject(_clipboardFormatName);
            dataObject.SetData(result);
            Clipboard.SetDataObject(dataObject, true);
            _TimeLineSequenceClipboardContentsChanged(EventArgs.Empty);
        }