private void toolStripMenuItemPointSync_Click(object sender, EventArgs e) { using (var pointSync = new SyncPointsSync()) { pointSync.Initialize(_subtitle, _fileName, _videoFileName, _videoAudioTrackNumber); mediaPlayer.Pause(); if (pointSync.ShowDialog(this) == DialogResult.OK) { _subtitleListViewIndex = -1; MakeHistoryForUndo(_language.BeforePointSynchronization); _subtitle.Paragraphs.Clear(); foreach (var p in pointSync.FixedSubtitle.Paragraphs) _subtitle.Paragraphs.Add(p); _subtitle.CalculateFrameNumbersFromTimeCodesNoCheck(CurrentFrameRate); ShowStatus(_language.PointSynchronizationDone); ShowSource(); SubtitleListview1.Fill(_subtitle, _subtitleAlternate); } Activate(); _videoFileName = pointSync.VideoFileName; } }
private void pointSyncViaOtherSubtitleToolStripMenuItem_Click(object sender, EventArgs e) { using (var pointSync = new SyncPointsSync()) { openFileDialog1.Title = _language.OpenOtherSubtitle; openFileDialog1.FileName = string.Empty; openFileDialog1.Filter = Utilities.GetOpenDialogFilter(); if (openFileDialog1.ShowDialog() == DialogResult.OK && File.Exists(openFileDialog1.FileName)) { var sub = new Subtitle(); var file = new FileInfo(openFileDialog1.FileName); var fileName = file.FullName; var extension = file.Extension.ToLowerInvariant(); // TODO: Check for mkv etc if (extension == ".sub") { if (IsVobSubFile(fileName, false)) { MessageBox.Show(_language.NoSupportHereVobSub); return; } } if (extension == ".sup") { if (FileUtil.IsBluRaySup(fileName)) { MessageBox.Show(_language.NoSupportHereBluRaySup); return; } else if (FileUtil.IsSpDvdSup(fileName)) { MessageBox.Show(_language.NoSupportHereDvdSup); return; } } if (extension == ".mkv" || extension == ".mks") { using (var matroska = new MatroskaFile(fileName)) { if (matroska.IsValid) { var subtitleList = matroska.GetTracks(true); if (subtitleList.Count > 1) { using (var subtitleChooser = new MatroskaSubtitleChooser()) { subtitleChooser.Initialize(subtitleList); if (_loading) { subtitleChooser.Icon = (Icon)this.Icon.Clone(); subtitleChooser.ShowInTaskbar = true; subtitleChooser.ShowIcon = true; } if (subtitleChooser.ShowDialog(this) == DialogResult.OK) { sub = LoadMatroskaSubtitleForSync(subtitleList[subtitleChooser.SelectedIndex], matroska); } } } else if (subtitleList.Count > 0) { sub = LoadMatroskaSubtitleForSync(subtitleList[0], matroska); } else { MessageBox.Show(_language.NoSubtitlesFound); return; } } } } if (extension == ".divx" || extension == ".avi") { MessageBox.Show(_language.NoSupportHereDivx); return; } if ((extension == ".mp4" || extension == ".m4v" || extension == ".3gp") && file.Length > 10000) { var mp4Parser = new MP4Parser(fileName); var mp4SubtitleTracks = mp4Parser.GetSubtitleTracks(); if (mp4SubtitleTracks.Count == 0) { MessageBox.Show(_language.NoSubtitlesFound); return; } else if (mp4SubtitleTracks.Count == 1) { sub = LoadMp4SubtitleForSync(mp4SubtitleTracks[0]); } else { using (var subtitleChooser = new MatroskaSubtitleChooser()) { subtitleChooser.Initialize(mp4SubtitleTracks); if (subtitleChooser.ShowDialog(this) == DialogResult.OK) { sub = LoadMp4SubtitleForSync(mp4SubtitleTracks[0]); } } } } if (file.Length > 1024 * 1024 * 10 && sub.Paragraphs.Count == 0) // max 10 mb { var text = string.Format(_language.FileXIsLargerThan10MB + Environment.NewLine + Environment.NewLine + _language.ContinueAnyway, fileName); if (MessageBox.Show(this, text, Title, MessageBoxButtons.YesNoCancel) != DialogResult.Yes) return; } sub.Renumber(); if (sub.Paragraphs.Count == 0) { Encoding enc; SubtitleFormat f = sub.LoadSubtitle(fileName, out enc, null); if (f == null) { ShowUnknownSubtitle(); return; } } pointSync.Initialize(_subtitle, _fileName, _videoFileName, _videoAudioTrackNumber, fileName, sub); mediaPlayer.Pause(); if (pointSync.ShowDialog(this) == DialogResult.OK) { _subtitleListViewIndex = -1; MakeHistoryForUndo(_language.BeforePointSynchronization); _subtitle.Paragraphs.Clear(); foreach (var p in pointSync.FixedSubtitle.Paragraphs) _subtitle.Paragraphs.Add(p); _subtitle.CalculateFrameNumbersFromTimeCodesNoCheck(CurrentFrameRate); ShowStatus(_language.PointSynchronizationDone); ShowSource(); SubtitleListview1.Fill(_subtitle, _subtitleAlternate); } _videoFileName = pointSync.VideoFileName; } } }
private void pointSyncViaOtherSubtitleToolStripMenuItem_Click(object sender, EventArgs e) { SyncPointsSync pointSync = new SyncPointsSync(); openFileDialog1.Title = _language.OpenOtherSubtitle; openFileDialog1.FileName = string.Empty; openFileDialog1.Filter = Utilities.GetOpenDialogFilter(); if (openFileDialog1.ShowDialog() == DialogResult.OK && File.Exists(openFileDialog1.FileName)) { Subtitle sub = new Subtitle(); Encoding enc; string fileName = openFileDialog1.FileName; //TODO: Check for mkv etc if (Path.GetExtension(fileName).ToLower() == ".sub" && IsVobSubFile(fileName, false)) { MessageBox.Show("VobSub files not supported here"); return; } if (Path.GetExtension(fileName).ToLower() == ".sup") { if (IsBluRaySupFile(fileName)) { MessageBox.Show("Bluray sup files not supported here"); return; } else if (IsSpDvdSupFile(fileName)) { MessageBox.Show("Dvd sup files not supported here"); return; } } if (Path.GetExtension(fileName).ToLower() == ".mkv" || Path.GetExtension(fileName).ToLower() == ".mks") { Matroska mkv = new Matroska(); bool isValid = false; bool hasConstantFrameRate = false; double frameRate = 0; int width = 0; int height = 0; double milliseconds = 0; string videoCodec = string.Empty; mkv.GetMatroskaInfo(fileName, ref isValid, ref hasConstantFrameRate, ref frameRate, ref width, ref height, ref milliseconds, ref videoCodec); if (isValid) { var subtitleList = mkv.GetMatroskaSubtitleTracks(fileName, out isValid); if (isValid) { if (subtitleList.Count == 0) { MessageBox.Show(_language.NoSubtitlesFound); return; } else { if (subtitleList.Count > 1) { MatroskaSubtitleChooser subtitleChooser = new MatroskaSubtitleChooser(); subtitleChooser.Initialize(subtitleList); if (_loading) { subtitleChooser.Icon = (Icon)this.Icon.Clone(); subtitleChooser.ShowInTaskbar = true; subtitleChooser.ShowIcon = true; } if (subtitleChooser.ShowDialog(this) == DialogResult.OK) { sub = LoadMatroskaSubtitleForSync(subtitleList[subtitleChooser.SelectedIndex], fileName); } } else { sub = LoadMatroskaSubtitleForSync(subtitleList[0], fileName); } } } } } if (Path.GetExtension(fileName).ToLower() == ".divx" || Path.GetExtension(fileName).ToLower() == ".avi") { MessageBox.Show("Divx files not supported here"); return; } var fi = new FileInfo(fileName); if ((Path.GetExtension(fileName).ToLower() == ".mp4" || Path.GetExtension(fileName).ToLower() == ".m4v" || Path.GetExtension(fileName).ToLower() == ".3gp") && fi.Length > 10000) { var mp4Parser = new Logic.Mp4.Mp4Parser(fileName); var mp4SubtitleTracks = mp4Parser.GetSubtitleTracks(); if (mp4SubtitleTracks.Count == 0) { MessageBox.Show(_language.NoSubtitlesFound); return; } else if (mp4SubtitleTracks.Count == 1) { sub = LoadMp4SubtitleForSync(fileName, mp4SubtitleTracks[0]); } else { var subtitleChooser = new MatroskaSubtitleChooser(); subtitleChooser.Initialize(mp4SubtitleTracks); if (subtitleChooser.ShowDialog(this) == DialogResult.OK) { sub = LoadMp4SubtitleForSync(fileName, mp4SubtitleTracks[0]); } } } if (fi.Length > 1024 * 1024 * 10 && sub.Paragraphs.Count == 0) // max 10 mb { if (MessageBox.Show(this, string.Format(_language.FileXIsLargerThan10Mb + Environment.NewLine + Environment.NewLine + _language.ContinueAnyway, fileName), Title, MessageBoxButtons.YesNoCancel) != DialogResult.Yes) return; } sub.Renumber(1); if (sub.Paragraphs.Count == 0) { SubtitleFormat f = sub.LoadSubtitle(fileName, out enc, null); if (f == null) { ShowUnknownSubtitle(); return; } } pointSync.Initialize(_subtitle, _fileName, _videoFileName, _videoAudioTrackNumber, fileName, sub); mediaPlayer.Pause(); if (pointSync.ShowDialog(this) == DialogResult.OK) { _subtitleListViewIndex = -1; MakeHistoryForUndo(_language.BeforePointSynchronization); _subtitle.Paragraphs.Clear(); foreach (Paragraph p in pointSync.FixedSubtitle.Paragraphs) _subtitle.Paragraphs.Add(p); _subtitle.CalculateFrameNumbersFromTimeCodesNoCheck(CurrentFrameRate); ShowStatus(_language.PointSynchronizationDone); ShowSource(); SubtitleListview1.Fill(_subtitle, _subtitleAlternate); } _videoFileName = pointSync.VideoFileName; } }