This commit is contained in:
niksedk 2014-10-03 15:34:02 +02:00
commit c7f53fc6e8
8 changed files with 230 additions and 111 deletions

View File

@ -4,6 +4,7 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Windows.Forms;
@ -12,14 +13,14 @@ namespace Nikse.SubtitleEdit.Forms
public sealed partial class AddWaveform : Form
{
public string SourceVideoFileName { get; private set; }
private bool _cancel = false;
private string _wavFileName = null;
private bool _cancel;
private string _wavFileName;
private string _spectrogramDirectory;
public List<Bitmap> SpectrogramBitmaps { get; private set; }
private string _encodeParamters;
private const string RetryEncodeParameters = "acodec=s16l";
private int _audioTrackNumber = -1;
private int _delayInMilliseconds = 0;
private int _delayInMilliseconds;
public AddWaveform()
{
@ -64,7 +65,7 @@ namespace Nikse.SubtitleEdit.Forms
else // windows
{
runningOnWindows = true;
exeFilePath = Nikse.SubtitleEdit.Logic.VideoPlayers.LibVlcDynamic.GetVlcPath("vlc.exe");
exeFilePath = Logic.VideoPlayers.LibVlcDynamic.GetVlcPath("vlc.exe");
if (!File.Exists(exeFilePath))
{
if (Configuration.Settings.General.UseFFmpegForWaveExtraction && File.Exists(Configuration.Settings.General.FFmpegLocation))
@ -104,7 +105,7 @@ namespace Nikse.SubtitleEdit.Forms
}
labelPleaseWait.Visible = true;
Process process = new Process();
var process = new Process();
process.StartInfo = new ProcessStartInfo(exeFilePath, parameters);
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.Start();
@ -128,14 +129,13 @@ namespace Nikse.SubtitleEdit.Forms
labelProgress.Text = string.Format(Configuration.Settings.Language.AddWaveform.ExtractingSeconds, seconds);
else
labelProgress.Text = string.Format(Configuration.Settings.Language.AddWaveform.ExtractingMinutes, (int)(seconds / 60), (int)(seconds % 60));
this.Refresh();
Refresh();
if (_cancel)
{
process.Kill();
progressBar1.Visible = false;
labelPleaseWait.Visible = false;
buttonRipWave.Enabled = true;
targetFile = null;
buttonCancel.Visible = false;
DialogResult = DialogResult.Cancel;
return;
@ -168,6 +168,7 @@ namespace Nikse.SubtitleEdit.Forms
buttonCancel.Visible = false;
progressBar1.Visible = false;
progressBar1.Style = ProgressBarStyle.Blocks;
process.Dispose();
if (!File.Exists(targetFile))
{
@ -184,11 +185,11 @@ namespace Nikse.SubtitleEdit.Forms
labelPleaseWait.Visible = false;
labelProgress.Text = string.Empty;
buttonRipWave.Enabled = true;
buttonRipWave.Enabled = true;
return;
}
FileInfo fi = new FileInfo(targetFile);
var fi = new FileInfo(targetFile);
if (fi.Length <= 200)
{
MessageBox.Show("Sorry! VLC/FFmpeg was unable to extract audio to wave file via this command line:" + Environment.NewLine +
@ -205,8 +206,7 @@ namespace Nikse.SubtitleEdit.Forms
ReadWaveFile(targetFile, _delayInMilliseconds);
labelProgress.Text = string.Empty;
File.Delete(targetFile);
this.DialogResult = DialogResult.OK;
process.Dispose();
DialogResult = DialogResult.OK;
}
private void ReadWaveFile(string targetFile, int delayInMilliseconds)
@ -218,13 +218,13 @@ namespace Nikse.SubtitleEdit.Forms
sampleRate++; // old sample-rate / new sample-rate must have rest = 0
labelProgress.Text = Configuration.Settings.Language.AddWaveform.GeneratingPeakFile;
this.Refresh();
Refresh();
waveFile.GeneratePeakSamples(sampleRate, delayInMilliseconds); // samples per second - SampleRate
if (Configuration.Settings.VideoControls.GenerateSpectrogram)
{
labelProgress.Text = Configuration.Settings.Language.AddWaveform.GeneratingSpectrogram;
this.Refresh();
Refresh();
Directory.CreateDirectory(_spectrogramDirectory);
SpectrogramBitmaps = waveFile.GenerateFourierData(256, _spectrogramDirectory, delayInMilliseconds); // image height = nfft / 2
}
@ -246,24 +246,25 @@ namespace Nikse.SubtitleEdit.Forms
{ // Choose for number of audio tracks in matroska files
try
{
var mkv = new Matroska(labelVideoFileName.Text);
if (mkv.IsValid)
using (var mkv = new Matroska(labelVideoFileName.Text))
{
var trackInfo = mkv.GetTrackInfo();
foreach (var ti in trackInfo)
if (mkv.IsValid)
{
if (ti.IsAudio)
var trackInfo = mkv.GetTrackInfo();
foreach (var ti in trackInfo)
{
numberOfAudioTracks++;
if (ti.CodecId != null && ti.Language != null)
audioTrackNames.Add("#" + ti.TrackNumber + ": " + ti.CodecId.Replace("\0", string.Empty) + " - " + ti.Language.Replace("\0", string.Empty));
else
audioTrackNames.Add("#" + ti.TrackNumber);
mkvAudioTrackNumbers.Add(mkvAudioTrackNumbers.Count, ti.TrackNumber);
if (ti.IsAudio)
{
numberOfAudioTracks++;
if (ti.CodecId != null && ti.Language != null)
audioTrackNames.Add("#" + ti.TrackNumber + ": " + ti.CodecId.Replace("\0", string.Empty) + " - " + ti.Language.Replace("\0", string.Empty));
else
audioTrackNames.Add("#" + ti.TrackNumber);
mkvAudioTrackNumbers.Add(mkvAudioTrackNumbers.Count, ti.TrackNumber);
}
}
}
}
mkv.Dispose();
}
catch
{
@ -273,7 +274,7 @@ namespace Nikse.SubtitleEdit.Forms
{ // Choose for number of audio tracks in mp4 files
try
{
var mp4 = new Nikse.SubtitleEdit.Logic.Mp4.MP4Parser(labelVideoFileName.Text);
var mp4 = new Logic.Mp4.MP4Parser(labelVideoFileName.Text);
var tracks = mp4.GetAudioTracks();
int i = 0;
foreach (var track in tracks)
@ -284,7 +285,7 @@ namespace Nikse.SubtitleEdit.Forms
else if (track.Name != null)
audioTrackNames.Add(i + ": " + track.Name);
else
audioTrackNames.Add(i.ToString());
audioTrackNames.Add(i.ToString(CultureInfo.InvariantCulture));
}
numberOfAudioTracks = tracks.Count;
}
@ -302,17 +303,18 @@ namespace Nikse.SubtitleEdit.Forms
// Choose audio track
if (numberOfAudioTracks > 1)
{
var form = new ChooseAudioTrack(audioTrackNames, _audioTrackNumber);
if (form.ShowDialog(this) == DialogResult.OK)
using (var form = new ChooseAudioTrack(audioTrackNames, _audioTrackNumber))
{
_audioTrackNumber = form.SelectedTrack;
if (form.ShowDialog(this) == DialogResult.OK)
{
_audioTrackNumber = form.SelectedTrack;
}
else
{
DialogResult = DialogResult.Cancel;
return;
}
}
else
{
DialogResult = DialogResult.Cancel;
return;
}
form.Dispose();
}
// check for delay in matroska files
@ -320,12 +322,13 @@ namespace Nikse.SubtitleEdit.Forms
{
try
{
var mkv = new Matroska(labelVideoFileName.Text);
if (mkv.IsValid)
using (var mkv = new Matroska(labelVideoFileName.Text))
{
_delayInMilliseconds = (int)mkv.GetTrackStartTime(mkvAudioTrackNumbers[_audioTrackNumber]);
if (mkv.IsValid)
{
_delayInMilliseconds = (int) mkv.GetTrackStartTime(mkvAudioTrackNumbers[_audioTrackNumber]);
}
}
mkv.Dispose();
}
catch
{
@ -377,19 +380,20 @@ namespace Nikse.SubtitleEdit.Forms
progressBar1.Style = ProgressBarStyle.Blocks;
labelProgress.Text = Configuration.Settings.Language.AddWaveform.GeneratingPeakFile;
this.Refresh();
Refresh();
labelPleaseWait.Visible = false;
try
{
ReadWaveFile(_wavFileName, _delayInMilliseconds);
labelProgress.Text = string.Empty;
this.DialogResult = DialogResult.OK;
DialogResult = DialogResult.OK;
}
catch (Exception exception)
{
MessageBox.Show(exception.Message + Environment.NewLine + exception.StackTrace);
this.DialogResult = DialogResult.Cancel;
DialogResult = DialogResult.Cancel;
}
}
}
}

View File

@ -46,8 +46,8 @@ namespace Nikse.SubtitleEdit.Forms
private void FixLargeFonts()
{
Graphics graphics = this.CreateGraphics();
SizeF textSize = graphics.MeasureString(buttonOK.Text, this.Font);
var graphics = CreateGraphics();
var textSize = graphics.MeasureString(buttonOK.Text, Font);
if (textSize.Height > buttonOK.Height - 4)
{
int newButtonHeight = (int)(textSize.Height + 7 + 0.5);
@ -108,8 +108,8 @@ namespace Nikse.SubtitleEdit.Forms
height = height * 95 / 100;
}
Bitmap temp = new Bitmap((int)width, (int)height);
using (Graphics g = Graphics.FromImage((Image)temp))
var temp = new Bitmap((int)width, (int)height);
using (var g = Graphics.FromImage(temp))
g.DrawImage(bmp, 0, 0, (int)width, (int)height);
bmp = temp;
}
@ -191,9 +191,12 @@ namespace Nikse.SubtitleEdit.Forms
var formSubOcr = new VobSubOcr();
formSubOcr.InitializeQuick(subs, _palette, Configuration.Settings.VobSubOcr, SelectedLanguageString);
var subtitle = formSubOcr.ReadyVobSubRip();
formSubOcr.Dispose();
var exportBdnXmlPng = new ExportPngXml();
exportBdnXmlPng.InitializeFromVobSubOcr(subtitle, new Nikse.SubtitleEdit.Logic.SubtitleFormats.SubRip(), "VOBSUB", "DVD", formSubOcr, SelectedLanguageString);
exportBdnXmlPng.InitializeFromVobSubOcr(subtitle, new Logic.SubtitleFormats.SubRip(), "VOBSUB", "DVD", formSubOcr, SelectedLanguageString);
exportBdnXmlPng.ShowDialog(this);
exportBdnXmlPng.Dispose();
}
}

View File

@ -1,25 +1,25 @@
using System;
using Nikse.SubtitleEdit.Logic;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Logic;
namespace Nikse.SubtitleEdit.Forms
{
public partial class ExportCustomText : Form
{
private List<string> _templates = new List<string>();
private Subtitle _subtitle;
private Subtitle _translated;
private string _title;
private readonly List<string> _templates = new List<string>();
private readonly Subtitle _subtitle;
private readonly Subtitle _translated;
private readonly string _title;
public string LogMessage { get; set; }
public ExportCustomText(Subtitle subtitle, Subtitle original, string title)
{
InitializeComponent();
if (original == null && original.Paragraphs == null || original.Paragraphs.Count == 0)
if (original == null || original.Paragraphs == null || original.Paragraphs.Count == 0)
{
_subtitle = subtitle;
}
@ -71,6 +71,12 @@ namespace Nikse.SubtitleEdit.Forms
newToolStripMenuItem.Text = l.New;
}
public override sealed string Text
{
get { return base.Text; }
set { base.Text = value; }
}
private void ShowTemplates(List<string> templates)
{
listViewTemplates.Items.Clear();
@ -125,13 +131,15 @@ namespace Nikse.SubtitleEdit.Forms
if (listViewTemplates.SelectedItems.Count == 1)
{
int idx = listViewTemplates.SelectedItems[0].Index;
var form = new ExportCustomTextFormat(_templates[idx]);
if (form.ShowDialog(this) == DialogResult.OK)
using (var form = new ExportCustomTextFormat(_templates[idx]))
{
_templates[idx] = form.FormatOk;
ShowTemplates(_templates);
if (idx < listViewTemplates.Items.Count)
listViewTemplates.Items[idx].Selected = true;
if (form.ShowDialog(this) == DialogResult.OK)
{
_templates[idx] = form.FormatOk;
ShowTemplates(_templates);
if (idx < listViewTemplates.Items.Count)
listViewTemplates.Items[idx].Selected = true;
}
}
}
}

View File

@ -17450,9 +17450,11 @@ namespace Nikse.SubtitleEdit.Forms
private void ToolStripMenuItemExportPngXmlClick(object sender, EventArgs e)
{
var exportBdnXmlPng = new ExportPngXml();
exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "BDNXML", _fileName, _videoInfo);
exportBdnXmlPng.ShowDialog(this);
using (var exportBdnXmlPng = new ExportPngXml())
{
exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "BDNXML", _fileName, _videoInfo);
exportBdnXmlPng.ShowDialog(this);
}
}
private void TabControlSubtitleSelecting(object sender, TabControlCancelEventArgs e)
@ -17839,16 +17841,20 @@ namespace Nikse.SubtitleEdit.Forms
private void BluraySupToolStripMenuItemClick(object sender, EventArgs e)
{
var exportBdnXmlPng = new ExportPngXml();
exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "BLURAYSUP", _fileName, _videoInfo);
exportBdnXmlPng.ShowDialog(this);
using (var exportBdnXmlPng = new ExportPngXml())
{
exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "BLURAYSUP", _fileName, _videoInfo);
exportBdnXmlPng.ShowDialog(this);
}
}
private void VobSubsubidxToolStripMenuItemClick(object sender, EventArgs e)
{
var exportBdnXmlPng = new ExportPngXml();
exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "VOBSUB", _fileName, _videoInfo);
exportBdnXmlPng.ShowDialog(this);
using (var exportBdnXmlPng = new ExportPngXml())
{
exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "VOBSUB", _fileName, _videoInfo);
exportBdnXmlPng.ShowDialog(this);
}
}
private void TextBoxListViewTextAlternateKeyUp(object sender, KeyEventArgs e)
@ -18035,9 +18041,11 @@ namespace Nikse.SubtitleEdit.Forms
private void AdobeEncoreFabImageScriptToolStripMenuItemClick(object sender, EventArgs e)
{
var exportBdnXmlPng = new ExportPngXml();
exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "FAB", _fileName, _videoInfo);
exportBdnXmlPng.ShowDialog(this);
using (var exportBdnXmlPng = new ExportPngXml())
{
exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "FAB", _fileName, _videoInfo);
exportBdnXmlPng.ShowDialog(this);
}
}
private void ToolStripMenuItemMergeDialogClick(object sender, EventArgs e)
@ -18160,9 +18168,11 @@ namespace Nikse.SubtitleEdit.Forms
private void ToolStripMenuItemImagePerFrameClick(object sender, EventArgs e)
{
var exportBdnXmlPng = new ExportPngXml();
exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "IMAGE/FRAME", _fileName, _videoInfo);
exportBdnXmlPng.ShowDialog(this);
using (var exportBdnXmlPng = new ExportPngXml())
{
exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "IMAGE/FRAME", _fileName, _videoInfo);
exportBdnXmlPng.ShowDialog(this);
}
}
private void toolStripMenuItemApplyDisplayTimeLimits_Click(object sender, EventArgs e)
@ -18832,16 +18842,20 @@ namespace Nikse.SubtitleEdit.Forms
private void DvdStudioProStl_Click(object sender, EventArgs e)
{
var exportBdnXmlPng = new ExportPngXml();
exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "STL", _fileName, _videoInfo);
exportBdnXmlPng.ShowDialog(this);
using (var exportBdnXmlPng = new ExportPngXml())
{
exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "STL", _fileName, _videoInfo);
exportBdnXmlPng.ShowDialog(this);
}
}
private void toolStripMenuItemPlugins_Click(object sender, EventArgs e)
{
var form = new PluginsGet();
form.ShowDialog(this);
LoadPlugins();
using (var form = new PluginsGet())
{
form.ShowDialog(this);
LoadPlugins();
}
}
private void toolStripMenuItemUndo_Click(object sender, EventArgs e)
@ -18859,16 +18873,18 @@ namespace Nikse.SubtitleEdit.Forms
if (audioVisualizer == null)
return;
var form = new SeekSilence();
if (form.ShowDialog(this) == DialogResult.OK)
using (var form = new SeekSilence())
{
if (form.SeekForward)
if (form.ShowDialog(this) == DialogResult.OK)
{
audioVisualizer.FindDataBelowThreshold(form.VolumeBelow, form.SecondsDuration);
}
else
{
audioVisualizer.FindDataBelowThresholdBack(form.VolumeBelow, form.SecondsDuration);
if (form.SeekForward)
{
audioVisualizer.FindDataBelowThreshold(form.VolumeBelow, form.SecondsDuration);
}
else
{
audioVisualizer.FindDataBelowThresholdBack(form.VolumeBelow, form.SecondsDuration);
}
}
}
}
@ -19407,9 +19423,11 @@ namespace Nikse.SubtitleEdit.Forms
private void toolStripMenuItemExportFcpIImage_Click(object sender, EventArgs e)
{
var exportBdnXmlPng = new ExportPngXml();
exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "FCP", _fileName, _videoInfo);
exportBdnXmlPng.ShowDialog(this);
using (var exportBdnXmlPng = new ExportPngXml())
{
exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "FCP", _fileName, _videoInfo);
exportBdnXmlPng.ShowDialog(this);
}
}
private void ToolStripMenuItemNuendoPropertiesClick(object sender, EventArgs e)
@ -19426,9 +19444,11 @@ namespace Nikse.SubtitleEdit.Forms
private void toolStripMenuItemDost_Click(object sender, EventArgs e)
{
var exportBdnXmlPng = new ExportPngXml();
exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "DOST", _fileName, _videoInfo);
exportBdnXmlPng.ShowDialog(this);
using (var exportBdnXmlPng = new ExportPngXml())
{
exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "DOST", _fileName, _videoInfo);
exportBdnXmlPng.ShowDialog(this);
}
}
private void toolStripMenuItemMeasurementConverter_Click(object sender, EventArgs e)
@ -19676,9 +19696,11 @@ namespace Nikse.SubtitleEdit.Forms
private void toolStripMenuItemExportDcinemaInteropClick(object sender, EventArgs e)
{
var exportBdnXmlPng = new ExportPngXml();
exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "DCINEMA_INTEROP", _fileName, _videoInfo);
exportBdnXmlPng.ShowDialog(this);
using (var exportBdnXmlPng = new ExportPngXml())
{
exportBdnXmlPng.Initialize(_subtitle, GetCurrentSubtitleFormat(), "DCINEMA_INTEROP", _fileName, _videoInfo);
exportBdnXmlPng.ShowDialog(this);
}
}
internal Subtitle UndoFromSpellCheck(Subtitle subtitle)

View File

@ -8022,23 +8022,29 @@ namespace Nikse.SubtitleEdit.Forms
private void vobSubToolStripMenuItem_Click(object sender, EventArgs e)
{
var exportBdnXmlPng = new ExportPngXml();
exportBdnXmlPng.InitializeFromVobSubOcr(_subtitle, new SubRip(), "VOBSUB", FileName, this, _importLanguageString);
exportBdnXmlPng.ShowDialog(this);
using (var exportBdnXmlPng = new ExportPngXml())
{
exportBdnXmlPng.InitializeFromVobSubOcr(_subtitle, new SubRip(), "VOBSUB", FileName, this, _importLanguageString);
exportBdnXmlPng.ShowDialog(this);
}
}
private void bluraySupToolStripMenuItem_Click(object sender, EventArgs e)
{
var exportBdnXmlPng = new ExportPngXml();
exportBdnXmlPng.InitializeFromVobSubOcr(_subtitle, new SubRip(), "BLURAYSUP", FileName, this, _importLanguageString);
exportBdnXmlPng.ShowDialog(this);
using (var exportBdnXmlPng = new ExportPngXml())
{
exportBdnXmlPng.InitializeFromVobSubOcr(_subtitle, new SubRip(), "BLURAYSUP", FileName, this, _importLanguageString);
exportBdnXmlPng.ShowDialog(this);
}
}
private void bDNXMLToolStripMenuItem_Click(object sender, EventArgs e)
{
var exportBdnXmlPng = new ExportPngXml();
exportBdnXmlPng.InitializeFromVobSubOcr(_subtitle, new SubRip(), "BDNXML", FileName, this, _importLanguageString);
exportBdnXmlPng.ShowDialog(this);
using (var exportBdnXmlPng = new ExportPngXml())
{
exportBdnXmlPng.InitializeFromVobSubOcr(_subtitle, new SubRip(), "BDNXML", FileName, this, _importLanguageString);
exportBdnXmlPng.ShowDialog(this);
}
}
private void clearToolStripMenuItem_Click(object sender, EventArgs e)
@ -8163,9 +8169,11 @@ namespace Nikse.SubtitleEdit.Forms
private void dOSTToolStripMenuItem_Click(object sender, EventArgs e)
{
var exportBdnXmlPng = new ExportPngXml();
exportBdnXmlPng.InitializeFromVobSubOcr(_subtitle, new SubRip(), "DOST", FileName, this, _importLanguageString);
exportBdnXmlPng.ShowDialog(this);
using (var exportBdnXmlPng = new ExportPngXml())
{
exportBdnXmlPng.InitializeFromVobSubOcr(_subtitle, new SubRip(), "DOST", FileName, this, _importLanguageString);
exportBdnXmlPng.ShowDialog(this);
}
}
// TODO: Get language from ts file

View File

@ -0,0 +1,41 @@
using System;
using System.Drawing;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Nikse.SubtitleEdit.Logic.BluRaySup;
using System.IO;
namespace Test.Logic.BluRaySup
{
[TestClass]
public class BluRaySupParserTest
{
[TestMethod]
public void BluRaySupWriteAndReadTwoBitmaps()
{
var fileName = Guid.NewGuid() + ".sup";
using (var binarySubtitleFile = new FileStream(fileName, FileMode.Create))
{
var brSub = new BluRaySupPicture
{
StartTime = 0,
EndTime = 1000,
Width = 1080,
Height = 720
};
var buffer = BluRaySupPicture.CreateSupFrame(brSub, new Bitmap(100, 20), 25, 10, ContentAlignment.BottomCenter);
binarySubtitleFile.Write(buffer, 0, buffer.Length);
brSub.StartTime = 2000;
brSub.EndTime = 3000;
buffer = BluRaySupPicture.CreateSupFrame(brSub, new Bitmap(100, 20), 25, 10, ContentAlignment.BottomCenter);
binarySubtitleFile.Write(buffer, 0, buffer.Length);
}
var log = new StringBuilder();
var subtitles = BluRaySupParser.ParseBluRaySup(fileName, log);
Assert.AreEqual(2, subtitles.Count);
}
}
}

View File

@ -0,0 +1,31 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.VobSub;
using System;
using System.Drawing;
namespace Test.Logic.VobSub
{
[TestClass]
public class VobSubTest
{
[TestMethod]
public void VobSubWriteAndReadTwoBitmaps()
{
string fileName = Guid.NewGuid() + ".sub";
var writer = new VobSubWriter(fileName, 800, 600, 10, 32, Color.White, Color.Black, true, "English", "en");
var p1 = new Paragraph("Line1", 0, 1000);
var p2 = new Paragraph("Line2", 2000, 3000);
writer.WriteParagraph(p1, new Bitmap(200, 20), ContentAlignment.BottomCenter);
writer.WriteParagraph(p2, new Bitmap(200, 20), ContentAlignment.BottomCenter);
writer.Dispose();
var reader = new VobSubParser(true);
reader.Open(fileName);
var list = reader.MergeVobSubPacks();
Assert.IsTrue(list.Count == 2);
}
}
}

View File

@ -45,9 +45,11 @@
<ItemGroup>
<Compile Include="FixCommonErrorsTest.cs" />
<Compile Include="LanguageTest.cs" />
<Compile Include="Logic\BluRaySup\BluRaySupParserTest.cs" />
<Compile Include="Logic\Dictionaries\NamesListTest.cs" />
<Compile Include="Logic\HtmlUtilsTest.cs" />
<Compile Include="Logic\Dictionaries\OcrFixReplaceListTest.cs" />
<Compile Include="Logic\VobSub\VobSubTest.cs" />
<Compile Include="RemoveTextForHearImpairedTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SubtitleFormatsTest.cs" />