private void AudioWaveform_OnTimeChanged(object sender, ParagraphEventArgs e) { var paragraph = e.Paragraph; var beforeParagraph = e.BeforeParagraph; if (beforeParagraph == null) { beforeParagraph = paragraph; } if (beforeParagraph.StartTime.TotalMilliseconds == paragraph.StartTime.TotalMilliseconds && beforeParagraph.EndTime.TotalMilliseconds == paragraph.EndTime.TotalMilliseconds) { this._makeHistoryPaused = true; } int selectedIndex = this.FirstSelectedIndex; int index = this._subtitle.Paragraphs.IndexOf(paragraph); if (index == this._subtitleListViewIndex) { // Make history item for rollback (change paragraph back for history + change again) this._subtitle.Paragraphs[index] = new Paragraph(beforeParagraph); this.MakeHistoryForUndoOnlyIfNotResent(string.Format(this._language.VideoControls.BeforeChangingTimeInWaveformX, "#" + paragraph.Number + " " + paragraph.Text)); this._subtitle.Paragraphs[index] = paragraph; this._makeHistoryPaused = true; Paragraph original = null; if (this._subtitleAlternate != null && this.SubtitleListview1.IsAlternateTextColumnVisible) { original = Utilities.GetOriginalParagraph(index, beforeParagraph, this._subtitleAlternate.Paragraphs); } if (Configuration.Settings.General.UseTimeFormatHHMMSSFF) { // so we don't get weird rounds we'll use whole frames when moving start time double fr = TimeCode.BaseUnit / Configuration.Settings.General.CurrentFrameRate; if (e.BeforeParagraph != null && e.BeforeParagraph.StartTime.TotalMilliseconds != e.Paragraph.StartTime.TotalMilliseconds && e.BeforeParagraph.Duration.TotalMilliseconds == e.Paragraph.Duration.TotalMilliseconds) { // move paragraph paragraph.StartTime.TotalMilliseconds = ((int)Math.Round(paragraph.StartTime.TotalMilliseconds / fr)) * fr; paragraph.EndTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds + e.BeforeParagraph.Duration.TotalMilliseconds; } else if (e.BeforeParagraph != null && e.BeforeParagraph.EndTime.TotalMilliseconds == e.Paragraph.EndTime.TotalMilliseconds) { paragraph.EndTime.TotalMilliseconds = ((int)Math.Round(paragraph.EndTime.TotalMilliseconds / fr)) * fr; int end = SubtitleFormat.MillisecondsToFrames(paragraph.EndTime.TotalMilliseconds); int dur = SubtitleFormat.MillisecondsToFrames(paragraph.Duration.TotalMilliseconds); paragraph.StartTime.TotalMilliseconds = SubtitleFormat.FramesToMilliseconds(end - dur); } } this.timeUpDownStartTime.TimeCode = paragraph.StartTime; var durationInSeconds = (decimal)paragraph.Duration.TotalSeconds; if (durationInSeconds >= this.numericUpDownDuration.Minimum && durationInSeconds <= this.numericUpDownDuration.Maximum) { this.SetDurationInSeconds((double)durationInSeconds); } this.MovePrevNext(e, beforeParagraph, index); if (original != null) { original.StartTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds; original.EndTime.TotalMilliseconds = paragraph.EndTime.TotalMilliseconds; } } else if (this._subtitleAlternate != null && this.SubtitleListview1.IsAlternateTextColumnVisible && Configuration.Settings.General.ShowOriginalAsPreviewIfAvailable) { index = this._subtitleAlternate.GetIndex(paragraph); if (index >= 0) { // Make history item for rollback (change paragraph back for history + change again) this._subtitleAlternate.Paragraphs[index] = new Paragraph(beforeParagraph); this.MakeHistoryForUndoOnlyIfNotResent(string.Format(this._language.VideoControls.BeforeChangingTimeInWaveformX, "#" + paragraph.Number + " " + paragraph.Text)); this._subtitleAlternate.Paragraphs[index] = paragraph; this._makeHistoryPaused = true; var current = Utilities.GetOriginalParagraph(index, beforeParagraph, this._subtitle.Paragraphs); if (current != null) { current.StartTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds; current.EndTime.TotalMilliseconds = paragraph.EndTime.TotalMilliseconds; index = this._subtitle.GetIndex(current); this.SubtitleListview1.SetStartTimeAndDuration(index, paragraph); if (index == selectedIndex) { this.timeUpDownStartTime.TimeCode = paragraph.StartTime; var durationInSeconds = (decimal)paragraph.Duration.TotalSeconds; if (durationInSeconds >= this.numericUpDownDuration.Minimum && durationInSeconds <= this.numericUpDownDuration.Maximum) { this.SetDurationInSeconds((double)durationInSeconds); } } } } } else if (this._subtitleAlternate != null && this.SubtitleListview1.IsAlternateTextColumnVisible) { index = this._subtitle.GetIndex(paragraph); if (index >= 0) { // Make history item for rollback (change paragraph back for history + change again) this._subtitle.Paragraphs[index] = new Paragraph(beforeParagraph); this.MakeHistoryForUndoOnlyIfNotResent(string.Format(this._language.VideoControls.BeforeChangingTimeInWaveformX, "#" + paragraph.Number + " " + paragraph.Text)); this._subtitle.Paragraphs[index] = paragraph; this._makeHistoryPaused = true; this.MovePrevNext(e, beforeParagraph, index); var original = Utilities.GetOriginalParagraph(index, beforeParagraph, this._subtitleAlternate.Paragraphs); if (original != null) { original.StartTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds; original.EndTime.TotalMilliseconds = paragraph.EndTime.TotalMilliseconds; } this.SubtitleListview1.SetStartTimeAndDuration(index, paragraph); } } else { if (index >= 0) { // Make history item for rollback (change paragraph back for history + change again) this._subtitle.Paragraphs[index] = new Paragraph(beforeParagraph); this.MakeHistoryForUndoOnlyIfNotResent(string.Format(this._language.VideoControls.BeforeChangingTimeInWaveformX, "#" + paragraph.Number + " " + paragraph.Text)); this._subtitle.Paragraphs[index] = paragraph; this._makeHistoryPaused = true; this.MovePrevNext(e, beforeParagraph, index); if (this._subtitleAlternate != null) { var original = Utilities.GetOriginalParagraph(index, beforeParagraph, this._subtitleAlternate.Paragraphs); if (original != null) { original.StartTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds; original.EndTime.TotalMilliseconds = paragraph.EndTime.TotalMilliseconds; } } } this.SubtitleListview1.SetStartTimeAndDuration(index, paragraph); } beforeParagraph.StartTime.TotalMilliseconds = paragraph.StartTime.TotalMilliseconds; beforeParagraph.EndTime.TotalMilliseconds = paragraph.EndTime.TotalMilliseconds; this._makeHistoryPaused = false; }
private void AudioWaveform_OnTimeChangedAndOffsetRest(object sender, ParagraphEventArgs e) { if (this.mediaPlayer.VideoPlayer == null) { return; } int index = this._subtitle.Paragraphs.IndexOf(e.Paragraph); if (index < 0) { if (this._subtitleAlternate != null && this.SubtitleListview1.IsAlternateTextColumnVisible && Configuration.Settings.General.ShowOriginalAsPreviewIfAvailable) { index = this._subtitleAlternate.GetIndex(e.Paragraph); if (index >= 0) { var current = Utilities.GetOriginalParagraph(index, e.Paragraph, this._subtitle.Paragraphs); if (current != null) { index = this._subtitle.Paragraphs.IndexOf(current); } } } else if (this._subtitleAlternate != null && this.SubtitleListview1.IsAlternateTextColumnVisible) { index = this._subtitle.GetIndex(e.Paragraph); } } if (index >= 0) { this.SubtitleListview1.SelectIndexAndEnsureVisible(index); this.mediaPlayer.CurrentPosition = e.Seconds; this.ButtonSetStartAndOffsetRestClick(null, null); } this.audioVisualizer.Invalidate(); }
private void AudioWaveform_OnPositionSelected(object sender, ParagraphEventArgs e) { this.mediaPlayer.CurrentPosition = e.Seconds; if (e.Paragraph != null) { this.SubtitleListview1.SelectIndexAndEnsureVisible(this._subtitle.GetIndex(e.Paragraph)); } }
private void AudioWaveform_OnSingleClick(object sender, ParagraphEventArgs e) { this.timerWaveform.Stop(); this._endSeconds = -1; if (this.mediaPlayer.VideoPlayer != null) { this.mediaPlayer.Pause(); } this.mediaPlayer.CurrentPosition = e.Seconds; int index = -1; if (this.SubtitleListview1.SelectedItems.Count > 0) { index = this.SubtitleListview1.SelectedItems[0].Index; } this.SetWaveformPosition(this.audioVisualizer.StartPositionSeconds, e.Seconds, index); this.timerWaveform.Start(); }
private void AudioWaveform_OnParagraphRightClicked(object sender, ParagraphEventArgs e) { this.SubtitleListview1.SelectIndexAndEnsureVisible(this._subtitle.GetIndex(e.Paragraph)); this.addParagraphHereToolStripMenuItem.Visible = false; this.addParagraphAndPasteToolStripMenuItem.Visible = false; this.deleteParagraphToolStripMenuItem.Visible = true; this.toolStripMenuItemFocusTextbox.Visible = true; this.splitToolStripMenuItem1.Visible = true; this.mergeWithPreviousToolStripMenuItem.Visible = true; this.mergeWithNextToolStripMenuItem.Visible = true; this.toolStripSeparator11.Visible = true; this.toolStripMenuItemWaveformPlaySelection.Visible = true; this.toolStripSeparator24.Visible = true; this._audioWaveformRightClickSeconds = e.Seconds; this.contextMenuStripWaveform.Show(MousePosition.X, MousePosition.Y); }
private void AudioWaveform_OnNonParagraphRightClicked(object sender, ParagraphEventArgs e) { this.addParagraphHereToolStripMenuItem.Visible = false; this.addParagraphAndPasteToolStripMenuItem.Visible = false; this.deleteParagraphToolStripMenuItem.Visible = false; this.toolStripMenuItemFocusTextbox.Visible = true; this.splitToolStripMenuItem1.Visible = false; this.mergeWithPreviousToolStripMenuItem.Visible = false; this.mergeWithNextToolStripMenuItem.Visible = false; this.toolStripSeparator11.Visible = false; this.toolStripMenuItemWaveformPlaySelection.Visible = false; this.toolStripSeparator24.Visible = false; this.contextMenuStripWaveform.Show(MousePosition.X, MousePosition.Y); }
private void AudioWaveform_OnNewSelectionRightClicked(object sender, ParagraphEventArgs e) { this.SubtitleListview1.SelectIndexAndEnsureVisible(this._subtitle.GetIndex(e.Paragraph)); this.addParagraphHereToolStripMenuItem.Visible = true; this.addParagraphAndPasteToolStripMenuItem.Visible = Clipboard.ContainsText(); this.deleteParagraphToolStripMenuItem.Visible = false; this.toolStripMenuItemFocusTextbox.Visible = false; this.splitToolStripMenuItem1.Visible = false; this.mergeWithPreviousToolStripMenuItem.Visible = false; this.mergeWithNextToolStripMenuItem.Visible = false; this.contextMenuStripWaveform.Show(MousePosition.X, MousePosition.Y); }
private void AudioWaveform_OnDoubleClickNonParagraph(object sender, ParagraphEventArgs e) { if (this.mediaPlayer.VideoPlayer != null) { this._endSeconds = -1; if (e.Paragraph == null) { if (Configuration.Settings.VideoControls.WaveformDoubleClickOnNonParagraphAction == "PlayPause") { this.mediaPlayer.TogglePlayPause(); } } else { this.SubtitleListview1.SelectIndexAndEnsureVisible(this._subtitle.GetIndex(e.Paragraph)); } } }
private void MovePrevNext(ParagraphEventArgs e, Paragraph beforeParagraph, int index) { if (e.MovePreviousOrNext) { if (e.MouseDownParagraphType == MouseDownParagraphType.Start) { var prev = this._subtitle.GetParagraphOrDefault(index - 1); if (prev != null) { Paragraph originalPrev = null; if (this._subtitleAlternate != null && this.SubtitleListview1.IsAlternateTextColumnVisible) { originalPrev = Utilities.GetOriginalParagraph(index - 1, prev, this._subtitleAlternate.Paragraphs); } prev.EndTime.TotalMilliseconds = prev.EndTime.TotalMilliseconds + (e.Paragraph.StartTime.TotalMilliseconds - beforeParagraph.StartTime.TotalMilliseconds); this.SubtitleListview1.SetStartTimeAndDuration(index - 1, prev); this.audioVisualizer.Invalidate(); if (originalPrev != null) { originalPrev.EndTime.TotalMilliseconds = prev.EndTime.TotalMilliseconds; } } } else if (e.MouseDownParagraphType == MouseDownParagraphType.End) { var next = this._subtitle.GetParagraphOrDefault(index + 1); if (next != null) { Paragraph originalNext = null; if (this._subtitleAlternate != null && this.SubtitleListview1.IsAlternateTextColumnVisible) { originalNext = Utilities.GetOriginalParagraph(index + 1, next, this._subtitleAlternate.Paragraphs); } next.StartTime.TotalMilliseconds = next.StartTime.TotalMilliseconds + (e.Paragraph.EndTime.TotalMilliseconds - beforeParagraph.EndTime.TotalMilliseconds); this.SubtitleListview1.SetStartTimeAndDuration(index + 1, next); this.audioVisualizer.Invalidate(); if (originalNext != null) { originalNext.StartTime.TotalMilliseconds = next.StartTime.TotalMilliseconds; } } } } }