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 = (App.LipSyncApp.PhonemeType)Enum.Parse(typeof(App.LipSyncApp.PhonemeType), data.Phoneme.ToString().ToUpper()); ((LipSync)effect).LyricData = data.LyricData; EffectModelCandidate modelCandidate = new 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(args.FirstMark); } if (pasted == 0) { //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible) MessageBoxForm.msgIcon = SystemIcons.Error; //this is used if you want to add a system icon to the message form. var messageBox = new MessageBoxForm("Conversion Complete and copied to Clipboard \n Paste at first Mark offset", @"Convert Text", false, false); messageBox.ShowDialog(); } SequenceModified(); } }
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>(); var layerManager = LayerManager; 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; EffectModelCandidate modelCandidate = new EffectModelCandidate(elem.EffectNode.Effect) { Duration = elem.Duration, StartTime = elem.StartTime, LayerId = layerManager.GetLayer(elem.EffectNode).Id }; result.EffectModelCandidates.Add(modelCandidate, relativeVisibleRow); if (elem.StartTime < result.EarliestStartTime) result.EarliestStartTime = elem.StartTime; if (cutElements) { RemoveEffectNodeAndElement(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); }
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.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 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(); }
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.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 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(); }