diff --git a/src/ChangeLog.txt b/src/ChangeLog.txt index f7aae6474..f4a8170dd 100644 --- a/src/ChangeLog.txt +++ b/src/ChangeLog.txt @@ -11,7 +11,7 @@ Subtitle Edit Changelog * Options to choose font color and background color (for list view/text-boxes) * Can now import VobSub subtitles embedded in Matroska (.mkv) files (thx mosu for mkv info) * Wave form position can be locked at center via new 'Center' button (thx Krystian) - * Can insert subtitle after a line in the list view via context menu + * Can insert (a whole) subtitle after a line in the list view via context menu * IMPROVED: * Main window: Video player will now automatically move up beside subtitle if waveform is displayed + some resizing of controls allowed via splitters @@ -22,10 +22,11 @@ Subtitle Edit Changelog * Moved video controls below subtitle preview (which now displays italic) * Fix common ocr errors improed (thx aMvEL, sialivi, Alberto) * FIXED: + * Wave form: Fix bug with unprecise data (only for some sample rates) * OCR Fix Engine: Lines after "..." will no longer be changed to start with uppercase letter * Missing line break in Sony Dvd Architecht w line numbers (thx Rosa) * A minor bug in initialization of waveform (thx Frederic) - * A minor bug in Visual Sync, if end scene was after video length + * A minor bug in Visual Sync, if end scene was after video length (thx tsieberg) * Fixed crash with wave form track bar (thx Christian) * Fixed several bugs regarding 'large fonts' / higher dpi (thx Radbert) diff --git a/src/Controls/VideoPlayerContainer.cs b/src/Controls/VideoPlayerContainer.cs index 38b902347..ca8ca3ed3 100644 --- a/src/Controls/VideoPlayerContainer.cs +++ b/src/Controls/VideoPlayerContainer.cs @@ -3,15 +3,39 @@ using System.Drawing; using System.Windows.Forms; using Nikse.SubtitleEdit.Logic.VideoPlayers; using System.Text; +using System.Runtime.InteropServices; namespace Nikse.SubtitleEdit.Controls { public sealed class VideoPlayerContainer : Panel { + class RichTextBoxViewOnly : System.Windows.Forms.RichTextBox + { + public RichTextBoxViewOnly() + { + base.ReadOnly = true; + base.BorderStyle = BorderStyle.None; + base.TabStop = false; + base.SetStyle(ControlStyles.Selectable, false); + base.SetStyle(ControlStyles.UserMouse, true); + base.MouseEnter += delegate(object sender, EventArgs e) { this.Cursor = Cursors.Default; }; + base.ScrollBars = RichTextBoxScrollBars.None; + base.Margin = new System.Windows.Forms.Padding(0); + base.TabStop = false; + } + + protected override void WndProc(ref Message m) + { + if (m.Msg == 0x204) return; // WM_RBUTTONDOWN + if (m.Msg == 0x205) return; // WM_RBUTTONUP + base.WndProc(ref m); + } + } + public event EventHandler OnButtonClicked; public Panel PanelPlayer { get; private set; } private Panel _panelSubtitle; - private RichTextBox _subtitleTextBox; + private RichTextBoxViewOnly _subtitleTextBox; private string _subtitleText = string.Empty; private VideoPlayer _videoPlayer; public VideoPlayer VideoPlayer @@ -104,24 +128,49 @@ namespace Nikse.SubtitleEdit.Controls _pictureBoxProgressBar.Width = 0; - PanelPlayer.MouseDown += PanelPlayer_MouseDown; + PanelPlayer.MouseDown += PanelPlayer_MouseDown; + } + + public void EnableMouseWheelStep() + { + AddMouseWheelEvent(this); + } + + private void AddMouseWheelEvent(Control control) + { + control.MouseWheel += Control_MouseWheel; + foreach (Control ctrl in control.Controls) + AddMouseWheelEvent(ctrl); + } + + void Control_MouseWheel(object sender, MouseEventArgs e) + { + int delta = e.Delta; + double newPosition = CurrentPosition - (delta / 256.0); + if (newPosition < 0) + newPosition = 0; + else if (newPosition > Duration) + newPosition = Duration; + CurrentPosition = newPosition; } private Control MakeSubtitlesPanel() { _panelSubtitle = new Panel { BackColor = _backgroundColor, Left = 0, Top = 0 }; _panelSubtitle.Height = SubtitlesHeight + 1; - _subtitleTextBox = new RichTextBox(); + _subtitleTextBox = new RichTextBoxViewOnly(); _panelSubtitle.Controls.Add(_subtitleTextBox); - _subtitleTextBox.ReadOnly = true; - _subtitleTextBox.ScrollBars = RichTextBoxScrollBars.None; - _subtitleTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None; - _subtitleTextBox.Margin = new System.Windows.Forms.Padding(0); _subtitleTextBox.BackColor = _backgroundColor; _subtitleTextBox.ForeColor = Color.White; _subtitleTextBox.Dock = DockStyle.Fill; _subtitleTextBox.Font = new Font("Tahoma", 8, FontStyle.Bold); + _subtitleTextBox.MouseClick += SubtitleTextBox_MouseClick; return _panelSubtitle; + } + + void SubtitleTextBox_MouseClick(object sender, MouseEventArgs e) + { + TooglePlayPause(); } private static string RemoveSubStationAlphaFormatting(string s) diff --git a/src/Controls/WaveForm.cs b/src/Controls/WaveForm.cs index 58e849179..324c9fba1 100644 --- a/src/Controls/WaveForm.cs +++ b/src/Controls/WaveForm.cs @@ -996,19 +996,17 @@ namespace Nikse.SubtitleEdit.Controls void WaveForm_MouseWheel(object sender, MouseEventArgs e) { int delta = e.Delta; + if (Locked) { - if (Locked) - { - OnPositionSelected.Invoke(_currentVideoPositionSeconds + (-delta / 256.0), null); - } - else - { - StartPositionSeconds -= delta / 256.0; - if (_currentVideoPositionSeconds < StartPositionSeconds || _currentVideoPositionSeconds >= EndPositionSeconds) - OnPositionSelected.Invoke(StartPositionSeconds, null); - } - Invalidate(); + OnPositionSelected.Invoke(_currentVideoPositionSeconds + (-delta / 256.0), null); } + else + { + StartPositionSeconds -= delta / 256.0; + if (_currentVideoPositionSeconds < StartPositionSeconds || _currentVideoPositionSeconds >= EndPositionSeconds) + OnPositionSelected.Invoke(StartPositionSeconds, null); + } + Invalidate(); } } diff --git a/src/Forms/AddWareForm.cs b/src/Forms/AddWareForm.cs index e3f3c7dad..6f59ca75b 100644 --- a/src/Forms/AddWareForm.cs +++ b/src/Forms/AddWareForm.cs @@ -1,17 +1,12 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; -using System.Windows.Forms; using System.Diagnostics; using System.IO; +using System.Windows.Forms; using Nikse.SubtitleEdit.Logic; namespace Nikse.SubtitleEdit.Forms { - public partial class AddWareForm : Form + public sealed partial class AddWareForm : Form { public string SourceVideoFileName { get; private set; } private bool _cancel = false; @@ -118,7 +113,12 @@ namespace Nikse.SubtitleEdit.Forms private void ReadWaveFile(string targetFile) { WavePeakGenerator waveFile = new WavePeakGenerator(targetFile); - waveFile.GeneratePeakSamples(128); // samples per second - SampleRate + + int sampleRate = 126; + while (!(waveFile.Header.SampleRate % sampleRate == 0) && sampleRate < 1000) + sampleRate++; // old sample-rate / new sample-rate must have rest = 0 + waveFile.GeneratePeakSamples(sampleRate); // samples per second - SampleRate + WavePeak = waveFile; waveFile.Close(); } diff --git a/src/Forms/Main.cs b/src/Forms/Main.cs index 9b152d403..33a3cae2d 100644 --- a/src/Forms/Main.cs +++ b/src/Forms/Main.cs @@ -101,7 +101,7 @@ namespace Nikse.SubtitleEdit.Forms if (versionInfo.Length >= 3 && versionInfo[2] != "0") _title += "." + versionInfo[2]; } - return _title + " Beta"; + return _title + " Beta 2"; } } diff --git a/src/Forms/VideoPlayerUnDocked.cs b/src/Forms/VideoPlayerUnDocked.cs index 7d601211e..2bcc3001e 100644 --- a/src/Forms/VideoPlayerUnDocked.cs +++ b/src/Forms/VideoPlayerUnDocked.cs @@ -29,7 +29,12 @@ namespace Nikse.SubtitleEdit.Forms _mainForm = main; _positionsAndSizes = positionsAndSizes; _videoPlayerContainer = videoPlayerContainer; - Text = title; + Text = title; + } + + void VideoPlayerContainer_MouseWheel(object sender, MouseEventArgs e) + { + MessageBox.Show("Test"); } private void VideoPlayerUnDocked_FormClosing(object sender, FormClosingEventArgs e) @@ -54,36 +59,9 @@ namespace Nikse.SubtitleEdit.Forms WindowState = FormWindowState.Maximized; e.SuppressKeyPress = true; } - else if (_videoPlayerContainer.VideoPlayer != null) + else { - if (e.Modifiers == Keys.None && e.KeyCode == Keys.Space) - { - if (_videoPlayerContainer.VideoPlayer.IsPlaying) - _videoPlayerContainer.VideoPlayer.Pause(); - else - _videoPlayerContainer.VideoPlayer.Play(); - e.SuppressKeyPress = true; - } - else if (e.KeyCode == Keys.Right && e.Modifiers == Keys.Control) - { - _videoPlayerContainer.CurrentPosition += 0.10; - e.SuppressKeyPress = true; - } - else if (e.KeyCode == Keys.Left && e.Modifiers == Keys.Control) - { - _videoPlayerContainer.CurrentPosition -= 0.10; - e.SuppressKeyPress = true; - } - else if (e.KeyCode == Keys.Right && e.Modifiers == Keys.Alt) - { - _videoPlayerContainer.CurrentPosition += 0.5; - e.SuppressKeyPress = true; - } - else if (e.KeyCode == Keys.Left && e.Modifiers == Keys.Alt) - { - _videoPlayerContainer.CurrentPosition -= 0.5; - e.SuppressKeyPress = true; - } + _mainForm.Main_KeyDown(sender, e); } } } diff --git a/src/Logic/Utilities.cs b/src/Logic/Utilities.cs index c1b08f7f6..6131723b0 100644 --- a/src/Logic/Utilities.cs +++ b/src/Logic/Utilities.cs @@ -1157,6 +1157,7 @@ namespace Nikse.SubtitleEdit.Logic videoPlayerContainer.VideoPlayer.Initialize(videoPlayerContainer.PanelPlayer, fileName, onVideoLoaded, onVideoEnded); videoPlayerContainer.ShowStopButton = Configuration.Settings.General.VideoPlayerShowStopButton; videoPlayerContainer.Volume = Configuration.Settings.General.VideoPlayerDefaultVolume; + videoPlayerContainer.EnableMouseWheelStep(); } catch (Exception exception) {