Merge pull request #287 from SubtitleEdit/tools

Creation of a Core namespace
This commit is contained in:
Nikolaj Olsson 2014-10-04 17:27:25 +02:00
commit 6ef5674746
127 changed files with 376 additions and 255 deletions

View File

@ -1,6 +1,7 @@
using System;
using System.Drawing;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
namespace Nikse.SubtitleEdit.Controls

View File

@ -1,4 +1,5 @@
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using System;
using System.Globalization;
using System.Windows.Forms;

View File

@ -1,9 +1,10 @@
using System;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.VideoPlayers;
using System;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.VideoPlayers;
namespace Nikse.SubtitleEdit.Controls
{
@ -307,7 +308,7 @@ namespace Nikse.SubtitleEdit.Controls
// remove styles for display text (except italic)
string text = RemoveSubStationAlphaFormatting(_subtitleText);
text = HtmlUtils.RemoveOpenCloseTags(text, HtmlUtils.TagBold, HtmlUtils.TagUnderline);
text = HtmlUtil.RemoveOpenCloseTags(text, HtmlUtil.TagBold, HtmlUtil.TagUnderline);
// display italic
var sb = new StringBuilder();

View File

@ -1,14 +1,45 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Logic.TransportStream;
using Nikse.SubtitleEdit.Logic.VobSub;
namespace Nikse.SubtitleEdit.Logic
namespace Nikse.SubtitleEdit.Core
{
/// <summary>
/// File related utilities.
/// </summary>
internal static class FileUtils
internal static class FileUtil
{
/// <summary>
/// Opens a binary file in read/write shared mode, reads the contents of the file into a
/// byte array, and then closes the file.
/// </summary>
/// <param name="path">The file to open for reading. </param>
/// <returns>A byte array containing the contents of the file.</returns>
public static byte[] ReadAllBytesShared(string path)
{
using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
var index = 0;
var fileLength = fs.Length;
if (fileLength > Int32.MaxValue)
throw new IOException("File too long");
var count = (int)fileLength;
var bytes = new byte[count];
while (count > 0)
{
var n = fs.Read(bytes, index, count);
if (n == 0)
throw new InvalidOperationException("End of file reached before expected");
index += n;
count -= n;
}
return bytes;
}
}
/// <summary>
/// Opens an existing file for reading, and allow the user to retry if it fails.
/// </summary>
@ -85,7 +116,7 @@ namespace Nikse.SubtitleEdit.Logic
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
Debug.WriteLine(ex.Message);
return false;
}
finally
@ -101,7 +132,7 @@ namespace Nikse.SubtitleEdit.Logic
{
using (var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
var tsp = new TransportStream.TransportStreamParser();
var tsp = new TransportStreamParser();
tsp.DetectFormat(fs);
return tsp.IsM2TransportStream;
}
@ -113,8 +144,8 @@ namespace Nikse.SubtitleEdit.Logic
{
var buffer = new byte[4];
fs.Read(buffer, 0, 4);
return VobSub.VobSubParser.IsMpeg2PackHeader(buffer)
|| VobSub.VobSubParser.IsPrivateStream1(buffer, 0);
return VobSubParser.IsMpeg2PackHeader(buffer)
|| VobSubParser.IsPrivateStream1(buffer, 0);
}
}
@ -122,13 +153,13 @@ namespace Nikse.SubtitleEdit.Logic
{
using (var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
var buffer = new byte[VobSub.SpHeader.SpHeaderLength];
var buffer = new byte[SpHeader.SpHeaderLength];
if (fs.Read(buffer, 0, buffer.Length) != buffer.Length)
{
return false;
}
var header = new VobSub.SpHeader(buffer);
var header = new SpHeader(buffer);
if (header.Identifier != "SP" || header.NextBlockPosition < 5)
{
return false;
@ -140,13 +171,13 @@ namespace Nikse.SubtitleEdit.Logic
return false;
}
buffer = new byte[VobSub.SpHeader.SpHeaderLength];
buffer = new byte[SpHeader.SpHeaderLength];
if (fs.Read(buffer, 0, buffer.Length) != buffer.Length)
{
return false;
}
header = new VobSub.SpHeader(buffer);
header = new SpHeader(buffer);
return header.Identifier == "SP";
}
}

View File

@ -3,12 +3,12 @@ using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace Nikse.SubtitleEdit.Logic
namespace Nikse.SubtitleEdit.Core
{
/// <summary>
/// HTML specific string manipulations.
/// </summary>
internal static class HtmlUtils
internal static class HtmlUtil
{
public const string TagItalic = "i";
public const string TagBold = "b";

43
src/Core/RegistryUtil.cs Normal file
View File

@ -0,0 +1,43 @@
using Microsoft.Win32;
using System.Security;
namespace Nikse.SubtitleEdit.Core
{
internal static class RegistryUtil
{
/// <summary>
/// Retrieves the specified registry subkey value.
/// </summary>
/// <param name="keyName">The path of the subkey to open.</param>
/// <param name="valueName">The name of the value to retrieve.</param>
/// <returns>The value of the subkey requested, or <b>null</b> if the operation failed.</returns>
public static string GetValue(string keyName, string valueName)
{
RegistryKey key = null;
try
{
key = Registry.LocalMachine.OpenSubKey(keyName);
if (key != null)
{
var value = key.GetValue(valueName);
if (value != null)
{
return (string)value;
}
}
}
catch (SecurityException)
{
// The user does not have the permissions required to read the registry key.
}
finally
{
if (key != null)
{
key.Dispose();
}
}
return null;
}
}
}

View File

@ -1,12 +1,11 @@
using System;
using System;
using System.Text;
namespace Nikse.SubtitleEdit.Logic
namespace Nikse.SubtitleEdit.Core
{
public static class Extensions
internal static class StringExtensions
{
public static bool StartsWith(this String s, char c)
public static bool StartsWith(this string s, char c)
{
return s.Length > 0 && s[0] == c;
}
@ -16,7 +15,7 @@ namespace Nikse.SubtitleEdit.Logic
return sb.Length > 0 && sb[0] == c;
}
public static bool EndsWith(this String s, char c)
public static bool EndsWith(this string s, char c)
{
return s.Length > 0 && s[s.Length - 1] == c;
}
@ -35,6 +34,5 @@ namespace Nikse.SubtitleEdit.Logic
{
return source.IndexOf(value, comparisonType) >= 0;
}
}
}

View File

@ -1,4 +1,5 @@
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.BluRaySup;
using Nikse.SubtitleEdit.Logic.SubtitleFormats;
using Nikse.SubtitleEdit.Logic.VideoFormats;
@ -361,11 +362,11 @@ namespace Nikse.SubtitleEdit.Forms
if (format == null)
{
if (FileUtils.IsBluRaySup(fileName))
if (FileUtil.IsBluRaySup(fileName))
{
item.SubItems.Add("Blu-ray");
}
else if (FileUtils.IsVobSub(fileName))
else if (FileUtil.IsVobSub(fileName))
{
item.SubItems.Add("VobSub");
}
@ -680,12 +681,12 @@ namespace Nikse.SubtitleEdit.Forms
var bluRaySubtitles = new List<BluRaySupParser.PcsData>();
bool isVobSub = false;
bool isMatroska = false;
if (format == null && fileName.EndsWith(".sup", StringComparison.OrdinalIgnoreCase) && FileUtils.IsBluRaySup(fileName))
if (format == null && fileName.EndsWith(".sup", StringComparison.OrdinalIgnoreCase) && FileUtil.IsBluRaySup(fileName))
{
var log = new StringBuilder();
bluRaySubtitles = BluRaySupParser.ParseBluRaySup(fileName, log);
}
else if (format == null && fileName.EndsWith(".sub", StringComparison.OrdinalIgnoreCase) && FileUtils.IsVobSub(fileName))
else if (format == null && fileName.EndsWith(".sub", StringComparison.OrdinalIgnoreCase) && FileUtil.IsVobSub(fileName))
{
isVobSub = true;
}
@ -1178,11 +1179,11 @@ namespace Nikse.SubtitleEdit.Forms
if (ext != ".png" && ext != ".jpg" && ext != ".dll" && ext != ".exe" && ext != ".zip")
{
var fi = new FileInfo(fileName);
if (ext == ".sub" && FileUtils.IsVobSub(fileName))
if (ext == ".sub" && FileUtil.IsVobSub(fileName))
{
AddFromSearch(fileName, fi, "VobSub");
}
else if (ext == ".sup" && FileUtils.IsBluRaySup(fileName))
else if (ext == ".sup" && FileUtil.IsBluRaySup(fileName))
{
AddFromSearch(fileName, fi, "Blu-ray");
}

View File

@ -1,11 +1,12 @@
using System;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Text;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Logic;
namespace Nikse.SubtitleEdit.Forms
{
@ -219,7 +220,7 @@ namespace Nikse.SubtitleEdit.Forms
g = Graphics.FromImage(bmp);
var lefts = new List<float>();
foreach (var line in HtmlUtils.RemoveOpenCloseTags(text, HtmlUtils.TagItalic, HtmlUtils.TagFont).Split(Utilities.NewLineChars, StringSplitOptions.RemoveEmptyEntries))
foreach (var line in HtmlUtil.RemoveOpenCloseTags(text, HtmlUtil.TagItalic, HtmlUtil.TagFont).Split(Utilities.NewLineChars, StringSplitOptions.RemoveEmptyEntries))
{
if (subtitleAlignLeft)
lefts.Add(5);

View File

@ -1,4 +1,5 @@
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.Dictionaries;
using System;
using System.Collections.Generic;

View File

@ -1,4 +1,5 @@
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.Dictionaries;
using System;
using System.Collections.Generic;

View File

@ -1,4 +1,5 @@
using Nikse.SubtitleEdit.Controls;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.SubtitleFormats;
using System;
@ -111,7 +112,7 @@ namespace Nikse.SubtitleEdit.Forms
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
if (FileUtils.IsVobSub(openFileDialog1.FileName) || FileUtils.IsBluRaySup(openFileDialog1.FileName))
if (FileUtil.IsVobSub(openFileDialog1.FileName) || FileUtil.IsBluRaySup(openFileDialog1.FileName))
{
MessageBox.Show(Configuration.Settings.Language.CompareSubtitles.CannotCompareWithImageBasedSubtitles);
return;
@ -154,7 +155,7 @@ namespace Nikse.SubtitleEdit.Forms
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
if (FileUtils.IsVobSub(openFileDialog1.FileName) || FileUtils.IsBluRaySup(openFileDialog1.FileName))
if (FileUtil.IsVobSub(openFileDialog1.FileName) || FileUtil.IsBluRaySup(openFileDialog1.FileName))
{
MessageBox.Show(Configuration.Settings.Language.CompareSubtitles.CannotCompareWithImageBasedSubtitles);
return;
@ -873,7 +874,7 @@ namespace Nikse.SubtitleEdit.Forms
}
if (!listExt.Contains(Path.GetExtension(filePath)))
return;
if (FileUtils.IsVobSub(filePath) || FileUtils.IsBluRaySup(filePath))
if (FileUtil.IsVobSub(filePath) || FileUtil.IsBluRaySup(filePath))
{
MessageBox.Show(Configuration.Settings.Language.CompareSubtitles.CannotCompareWithImageBasedSubtitles);
return;

View File

@ -1,11 +1,12 @@
using System;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.VobSub;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Text;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.VobSub;
namespace Nikse.SubtitleEdit.Forms
{
@ -209,7 +210,7 @@ namespace Nikse.SubtitleEdit.Forms
{
long firstNavStartPTS = 0;
using (var fs = FileUtils.RetryOpenRead(vobFileName))
using (var fs = FileUtil.RetryOpenRead(vobFileName))
{
byte[] buffer = new byte[0x800];
long position = 0;

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
namespace Nikse.SubtitleEdit.Forms

View File

@ -1,4 +1,4 @@
using System.Text.RegularExpressions;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.SubtitleFormats;
using Nikse.SubtitleEdit.Logic.VobSub;
@ -11,6 +11,7 @@ using System.Drawing.Text;
using System.Globalization;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows.Forms;
using System.Xml;
@ -1793,7 +1794,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
text = text.Replace("</B>", "</b>");
// no support for underline
text = HtmlUtils.RemoveOpenCloseTags(text, HtmlUtils.TagUnderline);
text = HtmlUtil.RemoveOpenCloseTags(text, HtmlUtil.TagUnderline);
Font font = SetFont(parameter, parameter.SubtitleFontSize);
var lineHeight = parameter.LineHeight; // (textSize.Height * 0.64f);
@ -1852,7 +1853,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
{
foreach (string line in text.Split(Utilities.NewLineChars, StringSplitOptions.RemoveEmptyEntries))
{
var lineNoHtml = HtmlUtils.RemoveOpenCloseTags(line, HtmlUtils.TagItalic, HtmlUtils.TagFont);
var lineNoHtml = HtmlUtil.RemoveOpenCloseTags(line, HtmlUtil.TagItalic, HtmlUtil.TagFont);
if (parameter.AlignLeft)
lefts.Add(5);
else if (parameter.AlignRight)
@ -1863,7 +1864,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
}
else
{
foreach (var line in HtmlUtils.RemoveOpenCloseTags(text, HtmlUtils.TagItalic, HtmlUtils.TagFont).Split(Utilities.NewLineChars, StringSplitOptions.RemoveEmptyEntries))
foreach (var line in HtmlUtil.RemoveOpenCloseTags(text, HtmlUtil.TagItalic, HtmlUtil.TagFont).Split(Utilities.NewLineChars, StringSplitOptions.RemoveEmptyEntries))
{
if (parameter.AlignLeft)
lefts.Add(5);

View File

@ -1,5 +1,6 @@
using System;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using System.Collections.Generic;
using System.Drawing;

View File

@ -1,4 +1,5 @@
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.Dictionaries;
using Nikse.SubtitleEdit.Logic.Forms;
using Nikse.SubtitleEdit.Logic.Ocr;

View File

@ -6,6 +6,7 @@ using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using System.Xml;

View File

@ -4,6 +4,7 @@ using System.Drawing;
using System.IO;
using System.Text;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
namespace Nikse.SubtitleEdit.Forms

View File

@ -6,6 +6,7 @@ using System.IO;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
namespace Nikse.SubtitleEdit.Forms

View File

@ -1,4 +1,5 @@
using Nikse.SubtitleEdit.Controls;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.BluRaySup;
using Nikse.SubtitleEdit.Logic.Enums;
@ -2259,12 +2260,12 @@ namespace Nikse.SubtitleEdit.Forms
if (ext == ".sup")
{
if (FileUtils.IsBluRaySup(fileName))
if (FileUtil.IsBluRaySup(fileName))
{
ImportAndOcrBluRaySup(fileName, _loading);
return;
}
else if (FileUtils.IsSpDvdSup(fileName))
else if (FileUtil.IsSpDvdSup(fileName))
{
ImportAndOcrSpDvdSup(fileName, _loading);
return;
@ -2297,13 +2298,13 @@ namespace Nikse.SubtitleEdit.Forms
var fi = new FileInfo(fileName);
if ((ext == ".ts" || ext == ".rec" || ext == ".mpeg" || ext == ".mpg") && fi.Length > 10000 && FileUtils.IsTransportStream(fileName))
if ((ext == ".ts" || ext == ".rec" || ext == ".mpeg" || ext == ".mpg") && fi.Length > 10000 && FileUtil.IsTransportStream(fileName))
{
ImportSubtitleFromTransportStream(fileName);
return;
}
if ((ext == ".m2ts") && fi.Length > 10000 && FileUtils.IsM2TransportStream(fileName))
if ((ext == ".m2ts") && fi.Length > 10000 && FileUtil.IsM2TransportStream(fileName))
{
ImportSubtitleFromTransportStream(fileName);
return;
@ -2321,7 +2322,7 @@ namespace Nikse.SubtitleEdit.Forms
{
// retry Blu-ray sup (file with wrong extension)
if (FileUtils.IsBluRaySup(fileName))
if (FileUtil.IsBluRaySup(fileName))
{
ImportAndOcrBluRaySup(fileName, _loading);
return;
@ -2770,14 +2771,14 @@ namespace Nikse.SubtitleEdit.Forms
}
// retry Blu-ray (file with wrong extension)
if (format == null && fi.Length > 500 && FileUtils.IsBluRaySup(fileName))
if (format == null && fi.Length > 500 && FileUtil.IsBluRaySup(fileName))
{
ImportAndOcrBluRaySup(fileName, _loading);
return;
}
// retry SP DVD (file with wrong extension)
if (format == null && fi.Length > 500 && FileUtils.IsSpDvdSup(fileName))
if (format == null && fi.Length > 500 && FileUtil.IsSpDvdSup(fileName))
{
ImportAndOcrSpDvdSup(fileName, _loading);
return;
@ -2794,7 +2795,7 @@ namespace Nikse.SubtitleEdit.Forms
}
// check for .rar file
if (format == null && fi.Length > 100 && FileUtils.IsRar(fileName))
if (format == null && fi.Length > 100 && FileUtil.IsRar(fileName))
{
if (string.IsNullOrEmpty(_language.ErrorLoadRar))
MessageBox.Show("This file seems to be a compressed .rar file. Subtitle Edit cannot open compressed files.");
@ -2804,7 +2805,7 @@ namespace Nikse.SubtitleEdit.Forms
}
// check for .zip file
if (format == null && fi.Length > 100 && FileUtils.IsZip(fileName))
if (format == null && fi.Length > 100 && FileUtil.IsZip(fileName))
{
if (string.IsNullOrEmpty(_language.ErrorLoadZip))
MessageBox.Show("This file seems to be a compressed .zip file. Subtitle Edit cannot open compressed files.");
@ -5236,11 +5237,11 @@ namespace Nikse.SubtitleEdit.Forms
// do not allow blu-ray/vobsub
string extension = Path.GetExtension(fileName).ToLower();
if (extension == ".sub" && (IsVobSubFile(fileName, false) || FileUtils.IsSpDvdSup(fileName)))
if (extension == ".sub" && (IsVobSubFile(fileName, false) || FileUtil.IsSpDvdSup(fileName)))
{
format = null;
}
else if (extension == ".sup" && FileUtils.IsBluRaySup(fileName))
else if (extension == ".sup" && FileUtil.IsBluRaySup(fileName))
{
format = null;
}
@ -7131,7 +7132,7 @@ namespace Nikse.SubtitleEdit.Forms
{
if (textBoxListViewText.Text.Contains("<i>"))
{
textBoxListViewText.Text = HtmlUtils.RemoveOpenCloseTags(textBoxListViewText.Text, HtmlUtils.TagItalic);
textBoxListViewText.Text = HtmlUtil.RemoveOpenCloseTags(textBoxListViewText.Text, HtmlUtil.TagItalic);
}
else
{
@ -8089,7 +8090,7 @@ namespace Nikse.SubtitleEdit.Forms
}
if (allLinesStartAndEndsWithItalic)
{
text = HtmlUtils.RemoveOpenCloseTags(text, HtmlUtils.TagItalic).Trim();
text = HtmlUtil.RemoveOpenCloseTags(text, HtmlUtil.TagItalic).Trim();
text = "<i>" + text + "</i>";
}
return text;
@ -10149,15 +10150,15 @@ namespace Nikse.SubtitleEdit.Forms
{
OpenSubtitle(fileName, null);
}
else if (fi.Length < 250000000 && ext == ".sup" && FileUtils.IsBluRaySup(fileName)) // max 250 mb
else if (fi.Length < 250000000 && ext == ".sup" && FileUtil.IsBluRaySup(fileName)) // max 250 mb
{
OpenSubtitle(fileName, null);
}
else if ((ext == ".ts" || ext == ".rec" || ext == ".mpg" || ext == ".mpeg") && FileUtils.IsTransportStream(fileName))
else if ((ext == ".ts" || ext == ".rec" || ext == ".mpg" || ext == ".mpeg") && FileUtil.IsTransportStream(fileName))
{
OpenSubtitle(fileName, null);
}
else if (ext == ".m2ts" && FileUtils.IsM2TransportStream(fileName))
else if (ext == ".m2ts" && FileUtil.IsM2TransportStream(fileName))
{
OpenSubtitle(fileName, null);
}
@ -10349,7 +10350,7 @@ namespace Nikse.SubtitleEdit.Forms
{
try
{
bool isHeaderOk = FileUtils.IsVobSub(subFileName);
bool isHeaderOk = FileUtil.IsVobSub(subFileName);
if (isHeaderOk)
{
if (!verbose)
@ -12622,12 +12623,12 @@ namespace Nikse.SubtitleEdit.Forms
if (Path.GetExtension(fileName).Equals(".sup", StringComparison.OrdinalIgnoreCase))
{
if (FileUtils.IsBluRaySup(fileName))
if (FileUtil.IsBluRaySup(fileName))
{
MessageBox.Show("Blu-ray sup files not supported here");
return;
}
else if (FileUtils.IsSpDvdSup(fileName))
else if (FileUtil.IsSpDvdSup(fileName))
{
MessageBox.Show("DVD sup files not supported here");
return;
@ -17014,7 +17015,7 @@ namespace Nikse.SubtitleEdit.Forms
{
if (textBoxListViewTextAlternate.Text.Contains("<i>"))
{
textBoxListViewTextAlternate.Text = HtmlUtils.RemoveOpenCloseTags(textBoxListViewTextAlternate.Text, HtmlUtils.TagItalic);
textBoxListViewTextAlternate.Text = HtmlUtil.RemoveOpenCloseTags(textBoxListViewTextAlternate.Text, HtmlUtil.TagItalic);
}
else
{

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
namespace Nikse.SubtitleEdit.Forms

View File

@ -1,4 +1,5 @@
using Nikse.SubtitleEdit.Controls;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using System;
using System.Drawing;

View File

@ -1,5 +1,6 @@
using System;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.Networking;

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
namespace Nikse.SubtitleEdit.Forms

View File

@ -1,4 +1,5 @@
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using System;
using System.Drawing;
using System.IO;

View File

@ -1,4 +1,5 @@
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.Forms;
using System;
using System.Collections.Generic;

View File

@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.VideoPlayers;
using System.Drawing;

View File

@ -1,4 +1,5 @@
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.Dictionaries;
using Nikse.SubtitleEdit.Logic.VideoPlayers;
using System;

View File

@ -1,4 +1,5 @@
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.Dictionaries;
using Nikse.SubtitleEdit.Logic.Enums;
using Nikse.SubtitleEdit.Logic.SpellCheck;

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.Forms;

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.SubtitleFormats;

View File

@ -4,6 +4,7 @@ using System.Drawing;
using System.IO;
using System.Text;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.SubtitleFormats;

View File

@ -6,6 +6,7 @@ using System.Drawing.Text;
using System.IO;
using System.Text;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.SubtitleFormats;

View File

@ -5,6 +5,7 @@ using System.Drawing.Text;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.SubtitleFormats;

View File

@ -4,6 +4,7 @@ using System.Drawing;
using System.IO;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Controls;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.VideoPlayers;

View File

@ -4,6 +4,7 @@ using System.Drawing;
using System.IO;
using System.Windows.Forms;
using System.Xml;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.Ocr.Binary;

View File

@ -1,4 +1,4 @@
using System.Net;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.BluRaySup;
using Nikse.SubtitleEdit.Logic.Ocr;
@ -12,6 +12,7 @@ using System.Diagnostics;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Net;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
@ -4720,7 +4721,7 @@ namespace Nikse.SubtitleEdit.Forms
if (allItalic && matches.Count > 0)
{
var temp = HtmlUtils.RemoveOpenCloseTags(paragraph.ToString(), HtmlUtils.TagItalic);
var temp = HtmlUtil.RemoveOpenCloseTags(paragraph.ToString(), HtmlUtil.TagItalic);
paragraph.Clear();
paragraph.Append("<i>");
paragraph.Append(temp);
@ -4742,7 +4743,7 @@ namespace Nikse.SubtitleEdit.Forms
&& (wordNonItalics == 0 || wordNonItalics < 2 && lineLettersNonItalics < 3 && line.ToString().TrimStart().StartsWith('-')))
{
paragraph.Append("<i>");
paragraph.Append(HtmlUtils.RemoveOpenCloseTags(line.ToString(), HtmlUtils.TagItalic));
paragraph.Append(HtmlUtil.RemoveOpenCloseTags(line.ToString(), HtmlUtil.TagItalic));
paragraph.Append("</i>");
paragraph.Append(appendString);
}
@ -5713,7 +5714,7 @@ namespace Nikse.SubtitleEdit.Forms
if (line.Contains('[') && line.Contains(']'))
line = line.Replace("[", string.Empty).Replace("]", string.Empty);
line = HtmlUtils.RemoveOpenCloseTags(line, HtmlUtils.TagItalic);
line = HtmlUtil.RemoveOpenCloseTags(line, HtmlUtil.TagItalic);
int count = 0;
var arr = line.Replace("a.m", string.Empty).Replace("p.m", string.Empty).Replace("o.r", string.Empty)
@ -5799,16 +5800,16 @@ namespace Nikse.SubtitleEdit.Forms
}
}
if (!checkBoxTesseractItalicsOn.Checked)
textWithOutFixes = HtmlUtils.RemoveOpenCloseTags(textWithOutFixes, HtmlUtils.TagItalic);
textWithOutFixes = HtmlUtil.RemoveOpenCloseTags(textWithOutFixes, HtmlUtil.TagItalic);
// Sometimes Tesseract has problems with small fonts - it helps to make the image larger
if (HtmlUtils.RemoveOpenCloseTags(textWithOutFixes, HtmlUtils.TagItalic).Replace("@", string.Empty).Replace("%", string.Empty).Replace("|", string.Empty).Trim().Length < 3
if (HtmlUtil.RemoveOpenCloseTags(textWithOutFixes, HtmlUtil.TagItalic).Replace("@", string.Empty).Replace("%", string.Empty).Replace("|", string.Empty).Trim().Length < 3
|| Utilities.CountTagInText("\n", textWithOutFixes) > 2)
{
string rs = TesseractResizeAndRetry(bitmap);
textWithOutFixes = rs;
if (!checkBoxTesseractItalicsOn.Checked)
textWithOutFixes = HtmlUtils.RemoveOpenCloseTags(textWithOutFixes, HtmlUtils.TagItalic);
textWithOutFixes = HtmlUtil.RemoveOpenCloseTags(textWithOutFixes, HtmlUtil.TagItalic);
}
// fix italics
@ -5990,7 +5991,7 @@ namespace Nikse.SubtitleEdit.Forms
wordsNotFound = modiWordsNotFound;
correctWords = modiCorrectWords;
line = HtmlUtils.RemoveOpenCloseTags(line, HtmlUtils.TagItalic).Trim();
line = HtmlUtil.RemoveOpenCloseTags(line, HtmlUtil.TagItalic).Trim();
if (line.Length > 7 && unItalicText.Length > 7 && unItalicText.StartsWith("I ") &&
line.StartsWith(unItalicText.Remove(0, 2).Substring(0, 4)))
@ -5998,11 +5999,11 @@ namespace Nikse.SubtitleEdit.Forms
if (checkBoxTesseractMusicOn.Checked)
{
if ((line.StartsWith("J' ") || line.StartsWith("J“ ") || line.StartsWith("J* ") || line.StartsWith("♪ ")) && unItalicText.Length > 3 && HtmlUtils.RemoveOpenCloseTags(unItalicText, HtmlUtils.TagItalic).Substring(1, 2) == "' ")
if ((line.StartsWith("J' ") || line.StartsWith("J“ ") || line.StartsWith("J* ") || line.StartsWith("♪ ")) && unItalicText.Length > 3 && HtmlUtil.RemoveOpenCloseTags(unItalicText, HtmlUtil.TagItalic).Substring(1, 2) == "' ")
{
unItalicText = "♪ " + unItalicText.Remove(0, 2).TrimStart();
}
if ((line.StartsWith("J' ") || line.StartsWith("J“ ") || line.StartsWith("J* ") || line.StartsWith("♪ ")) && unItalicText.Length > 3 && HtmlUtils.RemoveOpenCloseTags(unItalicText, HtmlUtils.TagItalic)[1] == ' ')
if ((line.StartsWith("J' ") || line.StartsWith("J“ ") || line.StartsWith("J* ") || line.StartsWith("♪ ")) && unItalicText.Length > 3 && HtmlUtil.RemoveOpenCloseTags(unItalicText, HtmlUtil.TagItalic)[1] == ' ')
{
bool ita = unItalicText.StartsWith("<i>") && unItalicText.EndsWith("</i>");
unItalicText = Utilities.RemoveHtmlTags(unItalicText);
@ -6010,7 +6011,7 @@ namespace Nikse.SubtitleEdit.Forms
if (ita)
unItalicText = "<i>" + unItalicText + "</i>";
}
if ((line.StartsWith("J' ") || line.StartsWith("J“ ") || line.StartsWith("J* ") || line.StartsWith("♪ ")) && unItalicText.Length > 3 && HtmlUtils.RemoveOpenCloseTags(unItalicText, HtmlUtils.TagItalic)[2] == ' ')
if ((line.StartsWith("J' ") || line.StartsWith("J“ ") || line.StartsWith("J* ") || line.StartsWith("♪ ")) && unItalicText.Length > 3 && HtmlUtil.RemoveOpenCloseTags(unItalicText, HtmlUtil.TagItalic)[2] == ' ')
{
bool ita = unItalicText.StartsWith("<i>") && unItalicText.EndsWith("</i>");
unItalicText = Utilities.RemoveHtmlTags(unItalicText);
@ -6177,7 +6178,7 @@ namespace Nikse.SubtitleEdit.Forms
unItalicText += "?";
}
line = HtmlUtils.RemoveOpenCloseTags(unItalicText, HtmlUtils.TagItalic);
line = HtmlUtil.RemoveOpenCloseTags(unItalicText, HtmlUtil.TagItalic);
if (checkBoxAutoFixCommonErrors.Checked)
{
if (line.Contains("'.") && !textWithOutFixes.Contains("'.") && textWithOutFixes.Contains(':') && !line.EndsWith("'.") && Configuration.Settings.Tools.OcrFixUseHardcodedRules)
@ -6371,7 +6372,7 @@ namespace Nikse.SubtitleEdit.Forms
subtitleListView1.SetBackgroundColor(index, Color.Orange);
else if (badWords > 0 || line.Contains('_') || HasSingleLetters(line))
subtitleListView1.SetBackgroundColor(index, Color.Yellow);
else if (string.IsNullOrWhiteSpace(HtmlUtils.RemoveOpenCloseTags(line, HtmlUtils.TagItalic)))
else if (string.IsNullOrWhiteSpace(HtmlUtil.RemoveOpenCloseTags(line, HtmlUtil.TagItalic)))
subtitleListView1.SetBackgroundColor(index, Color.Orange);
else
subtitleListView1.SetBackgroundColor(index, Color.LightGreen);
@ -6417,7 +6418,7 @@ namespace Nikse.SubtitleEdit.Forms
s = ("<i>I " + s.Remove(0, 5)).Replace(" ", " ");
else if (italicStartCount == 1 && s.Length > 20 &&
s.IndexOf("<i>", StringComparison.Ordinal) > 1 && s.IndexOf("<i>", StringComparison.Ordinal) < 10 && s.EndsWith("</i>"))
s = "<i>" + HtmlUtils.RemoveOpenCloseTags(s, HtmlUtils.TagItalic) + "</i>";
s = "<i>" + HtmlUtil.RemoveOpenCloseTags(s, HtmlUtil.TagItalic) + "</i>";
s = s.Replace("</i>" + Environment.NewLine + "<i>", Environment.NewLine);
return Utilities.FixInvalidItalicTags(s);
@ -7665,7 +7666,7 @@ namespace Nikse.SubtitleEdit.Forms
int selectionStart = tb.SelectionStart;
if (text.Contains("<i>"))
{
text = HtmlUtils.RemoveOpenCloseTags(text, HtmlUtils.TagItalic);
text = HtmlUtil.RemoveOpenCloseTags(text, HtmlUtil.TagItalic);
}
else
{

View File

@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using System.Drawing;

View File

@ -2,6 +2,7 @@
using System.Globalization;
using System.Text;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using System.Collections.Generic;
using System.Drawing;

View File

@ -1,10 +1,11 @@
using System;
using Nikse.SubtitleEdit.Core;
using System;
using System.IO;
namespace Nikse.SubtitleEdit.Logic
{
/// <summary>
/// Configuration settings via Singleton pattern (note: Do not call Utilities from this class)
/// Configuration settings via Singleton pattern
/// </summary>
public class Configuration
{
@ -160,50 +161,15 @@ namespace Nikse.SubtitleEdit.Logic
}
}
/// <summary>
/// Retrieves the specified registry subkey value.
/// </summary>
/// <param name="keyName">The path of the subkey to open.</param>
/// <param name="valueName">The name of the value to retrieve.</param>
/// <returns>The value of the subkey requested, or <b>null</b> if the operation failed.</returns>
public static string GetRegistryValue(string keyName, string valueName)
{
Microsoft.Win32.RegistryKey key = null;
try
{
key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(keyName);
if (key != null)
{
var value = key.GetValue(valueName);
if (value != null)
{
return (string)value;
}
}
}
catch (System.Security.SecurityException)
{
// The user does not have the permissions required to read the registry key.
}
finally
{
if (key != null)
{
key.Dispose();
}
}
return null;
}
private static string GetInstallerPath()
{
var value = GetRegistryValue(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\SubtitleEdit_is1", "InstallLocation");
var value = RegistryUtil.GetValue(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\SubtitleEdit_is1", "InstallLocation");
if (value != null && Directory.Exists(value))
{
return value;
}
value = GetRegistryValue(@"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\SubtitleEdit_is1", "InstallLocation");
value = RegistryUtil.GetValue(@"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\SubtitleEdit_is1", "InstallLocation");
if (value != null && Directory.Exists(value))
{
return value;

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Xml;
using Nikse.SubtitleEdit.Core;
namespace Nikse.SubtitleEdit.Logic.Dictionaries
{

View File

@ -5,6 +5,7 @@ using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using System.Xml;
using Nikse.SubtitleEdit.Core;
namespace Nikse.SubtitleEdit.Logic.Dictionaries
{

View File

@ -3,6 +3,7 @@ using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using Nikse.SubtitleEdit.Core;
namespace Nikse.SubtitleEdit.Logic.Forms
{

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Text.RegularExpressions;
using Nikse.SubtitleEdit.Core;
namespace Nikse.SubtitleEdit.Logic.Forms
{

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using Nikse.SubtitleEdit.Core;
namespace Nikse.SubtitleEdit.Logic.Forms
{

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic.VobSub;
using System.Text;

View File

@ -1,4 +1,5 @@
using Nikse.SubtitleEdit.Forms;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Forms;
using Nikse.SubtitleEdit.Logic.Dictionaries;
using Nikse.SubtitleEdit.Logic.SpellCheck;
using System;
@ -985,7 +986,7 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
string word = words[i].TrimStart('\'');
string wordNotEndTrimmed = word;
word = word.TrimEnd('\'');
string wordNoItalics = HtmlUtils.RemoveOpenCloseTags(word, HtmlUtils.TagItalic);
string wordNoItalics = HtmlUtil.RemoveOpenCloseTags(word, HtmlUtil.TagItalic);
if (!IsWordKnownOrNumber(wordNoItalics, line) && !localIgnoreWords.Contains(wordNoItalics))
{
bool correct = DoSpell(word);
@ -1160,7 +1161,7 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
private static string GetDashedWordBefore(string word, string line, string[] words, int index)
{
if (index > 0 && line.Contains(words[index - 1] + "-" + word))
return HtmlUtils.RemoveOpenCloseTags(words[index - 1] + "-" + word, HtmlUtils.TagItalic);
return HtmlUtil.RemoveOpenCloseTags(words[index - 1] + "-" + word, HtmlUtil.TagItalic);
return null;
}
@ -1168,7 +1169,7 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
private static string GetDashedWordAfter(string word, string line, string[] words, int index)
{
if (index < words.Length - 1 && line.Contains(word + "-" + words[index + 1].Replace("</i>", string.Empty)))
return HtmlUtils.RemoveOpenCloseTags(word + "-" + words[index + 1], HtmlUtils.TagItalic);
return HtmlUtil.RemoveOpenCloseTags(word + "-" + words[index + 1], HtmlUtil.TagItalic);
return null;
}
@ -1402,7 +1403,7 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
return 0;
int wordsNotFound = 0;
var words = HtmlUtils.RemoveOpenCloseTags(line, HtmlUtils.TagItalic).Split((Environment.NewLine + " ¡¿,.!?:;()[]{}+-$£\"#&%…“”").ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
var words = HtmlUtil.RemoveOpenCloseTags(line, HtmlUtil.TagItalic).Split((Environment.NewLine + " ¡¿,.!?:;()[]{}+-$£\"#&%…“”").ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < words.Length; i++)
{
string word = words[i];

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text;
using Nikse.SubtitleEdit.Core;
namespace Nikse.SubtitleEdit.Logic
{

View File

@ -4,6 +4,7 @@ using System.Drawing;
using System.Globalization;
using System.Text;
using System.Xml;
using Nikse.SubtitleEdit.Core;
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using Nikse.SubtitleEdit.Core;
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{

View File

@ -1,4 +1,5 @@
using System;
using Nikse.SubtitleEdit.Core;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
@ -128,7 +129,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
var fi = new FileInfo(fileName);
if (fi.Length > 1150 && fi.Length < 1024000) // not too small or too big
{
byte[] buffer = Utilities.ReadAllBytes(fileName);
byte[] buffer = FileUtil.ReadAllBytesShared(fileName);
if (buffer[0] == 0x38 &&
buffer[1] == 0x35 &&
buffer[2] == 0x30 &&
@ -177,7 +178,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{
subtitle.Paragraphs.Clear();
subtitle.Header = null;
byte[] buffer = Utilities.ReadAllBytes(fileName);
byte[] buffer = FileUtil.ReadAllBytesShared(fileName);
int index = 1024;
while (index <= buffer.Length - 128)

View File

@ -1,4 +1,5 @@
using System;
using Nikse.SubtitleEdit.Core;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
@ -267,7 +268,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
private static string EncodeText(string s)
{
s = HtmlUtils.RemoveOpenCloseTags(s, HtmlUtils.TagBold, HtmlUtils.TagUnderline, HtmlUtils.TagFont);
s = HtmlUtil.RemoveOpenCloseTags(s, HtmlUtil.TagBold, HtmlUtil.TagUnderline, HtmlUtil.TagFont);
if (s.StartsWith("{\\an3}") || s.StartsWith("{\\an6}"))
s = "/STYLE RIGHT" + Environment.NewLine + s.Remove(0, 6).Trim();
if (s.StartsWith("{\\an1}") || s.StartsWith("{\\an4}"))

View File

@ -1,4 +1,5 @@
using System;
using Nikse.SubtitleEdit.Core;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
@ -150,7 +151,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{
if (fileName.EndsWith(".cap", StringComparison.OrdinalIgnoreCase))
{
byte[] buffer = Utilities.ReadAllBytes(fileName);
byte[] buffer = FileUtil.ReadAllBytesShared(fileName);
if (buffer[0] == 0x2b) // "+"
return true;
}
@ -180,7 +181,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{
subtitle.Paragraphs.Clear();
subtitle.Header = null;
byte[] buffer = Utilities.ReadAllBytes(fileName);
byte[] buffer = FileUtil.ReadAllBytesShared(fileName);
int i = 128;
Paragraph last = null;

View File

@ -1,7 +1,8 @@
using System;
using Nikse.SubtitleEdit.Core;
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Text;
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{
@ -144,7 +145,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{
subtitle.Paragraphs.Clear();
subtitle.Header = null;
byte[] buffer = Utilities.ReadAllBytes(fileName);
byte[] buffer = FileUtil.ReadAllBytesShared(fileName);
int i = 256;
Paragraph last = null;

View File

@ -1,4 +1,5 @@
using System;
using Nikse.SubtitleEdit.Core;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
@ -619,7 +620,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
subtitle.Paragraphs.Clear();
subtitle.Header = null;
byte[] buffer = Utilities.ReadAllBytes(fileName);
byte[] buffer = FileUtil.ReadAllBytesShared(fileName);
_languageIdLine1 = buffer[146];
if (_languageIdLine1 == 0)

View File

@ -1,4 +1,5 @@
using System;
using Nikse.SubtitleEdit.Core;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
@ -219,7 +220,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{
if (fileName.EndsWith(".cap", StringComparison.OrdinalIgnoreCase))
{
byte[] buffer = Utilities.ReadAllBytes(fileName);
byte[] buffer = FileUtil.ReadAllBytesShared(fileName);
for (int i = 0; i < buffer.Length - 20; i++)
{
if (buffer[i + 0] == 0xEA &&
@ -247,7 +248,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{
subtitle.Paragraphs.Clear();
subtitle.Header = null;
byte[] buffer = Utilities.ReadAllBytes(fileName);
byte[] buffer = FileUtil.ReadAllBytesShared(fileName);
int i = 128;
Paragraph last = null;

View File

@ -1,4 +1,5 @@
using System;
using Nikse.SubtitleEdit.Core;
using System;
using System.Collections.Generic;
using System.Text;
@ -31,7 +32,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{
if (fileName.EndsWith(".chk", StringComparison.OrdinalIgnoreCase))
{
var buffer = Utilities.ReadAllBytes(fileName);
var buffer = FileUtil.ReadAllBytesShared(fileName);
return buffer.Length > 0 && buffer[0] == 0x1d;
}
return false;
@ -44,7 +45,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
{
var buffer = Utilities.ReadAllBytes(fileName);
var buffer = FileUtil.ReadAllBytesShared(fileName);
int index = 256;
_errorCount = 0;
subtitle.Paragraphs.Clear();

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using Nikse.SubtitleEdit.Core;
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using Nikse.SubtitleEdit.Core;
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using Nikse.SubtitleEdit.Core;
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Xml;
using Nikse.SubtitleEdit.Core;
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{

View File

@ -5,6 +5,7 @@ using System.IO.Compression;
using System.Text;
using System.Xml;
using System.Xml.Schema;
using Nikse.SubtitleEdit.Core;
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{

View File

@ -5,6 +5,7 @@ using System.IO.Compression;
using System.Text;
using System.Xml;
using System.Xml.Schema;
using Nikse.SubtitleEdit.Core;
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using Nikse.SubtitleEdit.Core;
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{

View File

@ -1,4 +1,5 @@
using System;
using Nikse.SubtitleEdit.Core;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
@ -39,7 +40,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{
if (fileName.EndsWith(".elr", StringComparison.OrdinalIgnoreCase))
{
byte[] buffer = Utilities.ReadAllBytes(fileName);
byte[] buffer = FileUtil.ReadAllBytesShared(fileName);
byte[] compareBuffer = { 0x05, 0x01, 0x0D, 0x15, 0x11, 0x00, 0xA9, 0x00, 0x45, 0x00, 0x6C, 0x00, 0x72, 0x00, 0x6F, 0x00, 0x6D, 0x00, 0x20, 0x00, 0x53, 0x00, 0x74, 0x00, 0x75, 0x00, 0x64, 0x00, 0x69, 0x00, 0x6F, 0x00 };
for (int i = 6; i < compareBuffer.Length; i++)
@ -65,7 +66,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
_errorCount = 0;
subtitle.Paragraphs.Clear();
subtitle.Header = null;
byte[] buffer = Utilities.ReadAllBytes(fileName);
byte[] buffer = FileUtil.ReadAllBytesShared(fileName);
int i = 128;
while (i < buffer.Length - 40)

View File

@ -1,4 +1,5 @@
using Nikse.SubtitleEdit.Forms;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Forms;
using System;
using System.Collections.Generic;
using System.IO;
@ -576,7 +577,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{
try
{
byte[] buffer = Utilities.ReadAllBytes(fileName);
byte[] buffer = FileUtil.ReadAllBytesShared(fileName);
EbuGeneralSubtitleInformation header = ReadHeader(buffer);
if (header.DiskFormatCode.StartsWith("STL23") ||
header.DiskFormatCode.StartsWith("STL24") ||
@ -609,7 +610,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{
subtitle.Paragraphs.Clear();
subtitle.Header = null;
byte[] buffer = Utilities.ReadAllBytes(fileName);
byte[] buffer = FileUtil.ReadAllBytesShared(fileName);
EbuGeneralSubtitleInformation header = ReadHeader(buffer);
subtitle.Header = Encoding.UTF8.GetString(buffer);
Paragraph last = null;

View File

@ -1,12 +1,13 @@
using System;
using Nikse.SubtitleEdit.Core;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Xml;
// - Mom, when you were my age&#13;what did you want to do?
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{
// - Mom, when you were my age&#13;what did you want to do?
public class FinalCutProTest2Xml : SubtitleFormat
{
public override string Extension
@ -121,7 +122,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{
XmlNode generatorItem = xml.CreateElement("generatoritem");
string fontStyle = "1"; //1==plain
var s = HtmlUtils.RemoveOpenCloseTags(p.Text, HtmlUtils.TagFont).Trim();
var s = HtmlUtil.RemoveOpenCloseTags(p.Text, HtmlUtil.TagFont).Trim();
if ((s.StartsWith("<i><b>") && s.EndsWith("</b></i>")) || (s.StartsWith("<b><i>") && s.EndsWith("</i></b>")))
fontStyle = "4"; //4==bold/italic
else if (s.StartsWith("<i>") && s.EndsWith("</i>"))

View File

@ -1,11 +1,12 @@
using System;
using Nikse.SubtitleEdit.Core;
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
// - Mom, when you were my age&#13;what did you want to do?
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{
// - Mom, when you were my age&#13;what did you want to do?
public class FinalCutProTestXml : SubtitleFormat
{
public override string Extension
@ -191,7 +192,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{
XmlNode generatorItem = xml.CreateElement("generatoritem");
string fontStyle = "1"; //1==plain
var s = HtmlUtils.RemoveOpenCloseTags(p.Text, HtmlUtils.TagFont).Trim();
var s = HtmlUtil.RemoveOpenCloseTags(p.Text, HtmlUtil.TagFont).Trim();
if ((s.StartsWith("<i><b>") && s.EndsWith("</b></i>")) || (s.StartsWith("<b><i>") && s.EndsWith("</i></b>")))
fontStyle = "4"; //4==bold/italic
else if (s.StartsWith("<i>") && s.EndsWith("</i>"))

View File

@ -1,12 +1,13 @@
using System;
using Nikse.SubtitleEdit.Core;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Xml;
// - Mom, when you were my age&#13;what did you want to do?
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{
// - Mom, when you were my age&#13;what did you want to do?
public class FinalCutProXml : SubtitleFormat
{
public override string Extension
@ -404,7 +405,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{
XmlNode generatorItem = xml.CreateElement("generatoritem");
string fontStyle = "1"; //1==plain
var s = HtmlUtils.RemoveOpenCloseTags(p.Text, HtmlUtils.TagFont).Trim();
var s = HtmlUtil.RemoveOpenCloseTags(p.Text, HtmlUtil.TagFont).Trim();
if ((s.StartsWith("<i><b>") && s.EndsWith("</b></i>")) || (s.StartsWith("<b><i>") && s.EndsWith("</i></b>")))
fontStyle = "4"; //4==bold/italic
else if (s.StartsWith("<i>") && s.EndsWith("</i>"))

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Text;
using System.Xml;
using Nikse.SubtitleEdit.Core;
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using Nikse.SubtitleEdit.Core;
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text;
using Nikse.SubtitleEdit.Core;
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text;
using Nikse.SubtitleEdit.Core;
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text;
using Nikse.SubtitleEdit.Core;
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using Nikse.SubtitleEdit.Core;
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using Nikse.SubtitleEdit.Core;
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using Nikse.SubtitleEdit.Core;
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{

View File

@ -1,4 +1,5 @@
using System;
using Nikse.SubtitleEdit.Core;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
@ -39,7 +40,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{
if (fileName.EndsWith(".cap", StringComparison.OrdinalIgnoreCase))
{
byte[] buffer = Utilities.ReadAllBytes(fileName);
byte[] buffer = FileUtil.ReadAllBytesShared(fileName);
return ((buffer[0] == 0x43 && // CAPT.2.0
buffer[1] == 0x41 &&
@ -89,7 +90,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
subtitle.Paragraphs.Clear();
subtitle.Header = null;
byte[] buffer = Utilities.ReadAllBytes(fileName);
byte[] buffer = FileUtil.ReadAllBytesShared(fileName);
string title = Encoding.ASCII.GetString(buffer, 82, 66);

View File

@ -1,16 +1,15 @@
using Nikse.SubtitleEdit.Forms;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Forms;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
// The PAC format was developed by Screen Electronics
// The PAC format save the contents, time code, position, justification, and italicization of each subtitle. The choice of font is not saved.
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{
// The PAC format was developed by Screen Electronics
// The PAC format save the contents, time code, position, justification, and italicization of each subtitle. The choice of font is not saved.
public class Pac : SubtitleFormat
{
public static TimeCode PacNullTime = new TimeCode(655, 35, 00, 0);
@ -848,7 +847,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
private static string MakePacItalicsAndRemoveOtherTags(string text)
{
text = HtmlUtils.RemoveOpenCloseTags(text, HtmlUtils.TagFont, HtmlUtils.TagUnderline).Trim();
text = HtmlUtil.RemoveOpenCloseTags(text, HtmlUtil.TagFont, HtmlUtil.TagUnderline).Trim();
if (!text.Contains("<i>", StringComparison.OrdinalIgnoreCase))
return text;
@ -921,7 +920,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
var fi = new FileInfo(fileName);
if (fi.Length > 100 && fi.Length < 1024000) // not too small or too big
{
byte[] buffer = Utilities.ReadAllBytes(fileName);
byte[] buffer = FileUtil.ReadAllBytesShared(fileName);
if (buffer[00] == 1 && // These bytes seems to be PAC files... TODO: Verify!
buffer[01] == 0 &&
@ -969,7 +968,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
_fileName = fileName;
subtitle.Paragraphs.Clear();
subtitle.Header = null;
byte[] buffer = Utilities.ReadAllBytes(fileName);
byte[] buffer = FileUtil.ReadAllBytesShared(fileName);
int index = 0;
while (index < buffer.Length)
@ -1206,7 +1205,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{
try
{
byte[] buffer = Utilities.ReadAllBytes(_fileName);
byte[] buffer = FileUtil.ReadAllBytesShared(_fileName);
int index = 0;
int count = 0;
_codePage = 0;

View File

@ -1,4 +1,5 @@
using System;
using Nikse.SubtitleEdit.Core;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Net;
@ -188,9 +189,9 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
if (Configuration.Settings.SubtitleSettings.SamiHtmlEncodeMode == 1)
return WebUtility.HtmlEncode(text);
else if (Configuration.Settings.SubtitleSettings.SamiHtmlEncodeMode == 2)
return HtmlUtils.EncodeNamed(text);
return HtmlUtil.EncodeNamed(text);
else if (Configuration.Settings.SubtitleSettings.SamiHtmlEncodeMode == 3)
return HtmlUtils.EncodeNumeric(text);
return HtmlUtil.EncodeNumeric(text);
return text;
}

View File

@ -4,6 +4,7 @@ using System.Drawing;
using System.Globalization;
using System.Text;
using System.Text.RegularExpressions;
using Nikse.SubtitleEdit.Core;
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Net;
using System.Text;
using Nikse.SubtitleEdit.Core;
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{

View File

@ -1,7 +1,8 @@
using System;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using Nikse.SubtitleEdit.Core;
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{

View File

@ -1,7 +1,8 @@
using System;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using Nikse.SubtitleEdit.Core;
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using Nikse.SubtitleEdit.Core;
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using Nikse.SubtitleEdit.Core;
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using Nikse.SubtitleEdit.Core;
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using Nikse.SubtitleEdit.Core;
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{

View File

@ -1,4 +1,5 @@
using System;
using Nikse.SubtitleEdit.Core;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
@ -85,7 +86,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
FileInfo fi = new FileInfo(fileName);
if (fi.Length > 100 && fi.Length < 1024000) // not too small or too big
{
byte[] buffer = Utilities.ReadAllBytes(fileName);
byte[] buffer = FileUtil.ReadAllBytesShared(fileName);
if (buffer[00] > 10 &&
buffer[01] == 0 &&
@ -109,7 +110,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
{
subtitle.Paragraphs.Clear();
byte[] buffer = Utilities.ReadAllBytes(fileName);
byte[] buffer = FileUtil.ReadAllBytesShared(fileName);
int index = buffer[0]; // go to first subtitle paragraph
while (index < buffer.Length)

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Text.RegularExpressions;
using Nikse.SubtitleEdit.Core;
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Drawing;
using System.Text;
using System.Xml;
using Nikse.SubtitleEdit.Core;
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using Nikse.SubtitleEdit.Core;
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{

View File

@ -1,4 +1,5 @@
using System;
using Nikse.SubtitleEdit.Core;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
@ -232,7 +233,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{
try
{
System.Reflection.Assembly assembly = System.Reflection.Assembly.Load(Utilities.ReadAllBytes(pluginFileName));
System.Reflection.Assembly assembly = System.Reflection.Assembly.Load(FileUtil.ReadAllBytesShared(pluginFileName));
string objectName = Path.GetFileNameWithoutExtension(pluginFileName);
if (assembly != null)
{

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text;
using Nikse.SubtitleEdit.Core;
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{

View File

@ -1,3 +1,4 @@
using Nikse.SubtitleEdit.Core;
using System.Collections.Generic;
using System.Text;
@ -43,7 +44,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
byte[] array;
try
{
array = Utilities.ReadAllBytes(fileName);
array = FileUtil.ReadAllBytesShared(fileName);
}
catch
{

View File

@ -1,4 +1,5 @@
using System;
using Nikse.SubtitleEdit.Core;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
@ -65,7 +66,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
foreach (Paragraph p in subtitle.Paragraphs)
{
count++;
var text = HtmlUtils.RemoveOpenCloseTags(p.Text, HtmlUtils.TagFont);
var text = HtmlUtil.RemoveOpenCloseTags(p.Text, HtmlUtil.TagFont);
sb.AppendLine(string.Format(paragraphWriteFormat, p.StartFrame, p.EndFrame, text));
}
return sb.ToString().Trim();

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Text;
using System.Xml;
using Nikse.SubtitleEdit.Core;
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{

View File

@ -7,6 +7,7 @@ using System.Xml;
//http://www.w3.org/TR/ttaf1-dfxp/
//Timed Text Markup Language (TTML) 1.0
//W3C Recommendation 18 November 2010
using Nikse.SubtitleEdit.Core;
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Text;
using System.Xml;
using Nikse.SubtitleEdit.Core;
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{

Some files were not shown because too many files have changed in this diff Show More