public Paste(ProjectView.ProjectView view, double pasteTime) : base(view) { mNode = view.SelectedNodeAs <PhraseNode>(); //AudioSelection selection = (AudioSelection)view.Selection; mMediaBefore = mNode.Audio.Copy(); mMediaAfter = mMediaBefore.Copy(); urakawa.media.data.audio.ManagedAudioMedia copy; if (view.Clipboard is AudioClipboard) { AudioClipboard clipboard = (AudioClipboard)view.Clipboard; copy = view.Presentation.MediaFactory.CreateManagedAudioMedia(); WavAudioMediaData mediaData = ((WavAudioMediaData)((PhraseNode)clipboard.Node).Audio.AudioMediaData).Copy( new Time((long)(clipboard.AudioRange.SelectionBeginTime * Time.TIME_UNIT)), new Time((long)(clipboard.AudioRange.SelectionEndTime * Time.TIME_UNIT)) ); copy.AudioMediaData = mediaData; } else { copy = ((PhraseNode)view.Clipboard.Node).Audio.Copy(); } urakawa.media.data.audio.ManagedAudioMedia after; after = mMediaAfter.Split(new Time((long)(pasteTime * Time.TIME_UNIT))); double begin = mMediaAfter.Duration.AsMilliseconds; mSelectionAfter = new AudioSelection(mNode, view.Selection.Control, new AudioRange(begin, begin + copy.Duration.AsMilliseconds)); mMediaAfter.AudioMediaData.MergeWith(copy.AudioMediaData); mMediaAfter.AudioMediaData.MergeWith(after.AudioMediaData); SetDescriptions(Localizer.Message("paste_audio")); }
// Repaint the waveform bitmap. protected override void OnPaint(PaintEventArgs pe) { if (this.bitmap != null) { pe.Graphics.DrawImage(this.bitmap, new Point(0, 0)); } AudioBlock block = Parent as AudioBlock; if (block != null) { AudioSelection selection = block.Selection as AudioSelection; if (selection != null) { int from = block.XForTime(selection.From); if (selection.IsRange) { int to = block.XForTime(selection.To); pe.Graphics.FillRectangle(block.Colors.AudioSelectionBrush, new Rectangle(from < to ? from : to, 0, from < to ? to - from : from - to, Height)); pe.Graphics.DrawLine(block.Colors.AudioSelectionPen, new Point(to, 0), new Point(to, Height - 1)); } pe.Graphics.DrawLine(block.Colors.AudioSelectionPen, new Point(from, 0), new Point(from, Height - 1)); } if (block.Playing) { int at = block.XForTime(block.PlayingTime); pe.Graphics.DrawLine(block.Colors.AudioPlaybackPen, new Point(at, 0), new Point(at, Height - 1)); } } base.OnPaint(pe); }
private IEnumerator PlayAudioSelectionProcess(AudioSelection audioSelection, AudioType audioType) { while (true) { this.Play(audioSelection.Next(), audioType); yield return(new WaitForSecondsRealtime(audioSelection._SelectedAudioClip.length + 1f)); } }
public void SelectFromXFromBelow(int x) { Track track = Parent != null && Parent.Parent is Track ? (Track)Parent.Parent : null; if (track.View != null) { Selection = new AudioSelection(track.View, this.node, TimeForX(x)); track.SelectFromBelow(this.selection); } }
public void SelectToXFromBelow(int x) { Track track = Parent != null && Parent.Parent is Track ? (Track)Parent.Parent : null; if (track.View != null) { double to = TimeForX(x); if (this.selection is AudioSelection) { double from = ((AudioSelection)this.selection).From; if (from != to) { Selection = new AudioSelection(track.View, this.node, from, to); track.SelectFromBelow(this.selection); } } } }
protected override void OnPaint(PaintEventArgs pe) { AudioBlock block = Parent as AudioBlock; if (block != null) { AudioSelection selection = block.Selection as AudioSelection; if (selection != null) { int from = block.XForTime(selection.From < selection.To ? selection.From : selection.To); int to = block.XForTime(selection.To > selection.From ? selection.To : selection.From); if (selection.IsRange) { pe.Graphics.FillRectangle(block.Colors.AudioSelectionBrush, new Rectangle(from, 0, to - from + 1, Height)); } else { pe.Graphics.FillRectangle(block.Colors.AudioSelectionBrush, new Rectangle(block.XForTime(selection.At) - Height / 2, 0, Height, Height)); } } if (block.Playing) { int at = block.XForTime(block.PlayingTime); Point[] points = new Point[3]; points[0] = new Point(at, 0); points[1] = new Point(at + Height / 2, Height / 2); points[2] = new Point(at, Height); pe.Graphics.DrawLine(block.Colors.AudioPlaybackPen, new Point(at, 0), new Point(at, Height)); pe.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; pe.Graphics.FillPolygon(block.Colors.AudioPlaybackBrush, points); } } // Calling the base class OnPaint base.OnPaint(pe); }
public void PlayAudioSelection(AudioSelection audioSelection, AudioType audioType) { this.StartCoroutine(this.PlayAudioSelectionProcess(audioSelection, audioType)); }
#pragma warning restore 0219, 414 private void OnEnable() { this._sAudioSelection = this.target as AudioSelection; }