Minor refact + cleanup.

This commit is contained in:
Ivandro Ismael 2016-08-10 03:40:15 +01:00
parent 4976f33026
commit 203984a2c3
No known key found for this signature in database
GPG Key ID: A8832757DEFB7EDC
7 changed files with 14 additions and 15 deletions

View File

@ -432,7 +432,7 @@ Format: Layer, Start, End, Style, Actor, MarginL, MarginR, MarginV, Effect, Text
int count = 0;
while (text.Contains("<font ") && count < 10)
{
int start = text.IndexOf(@"<font ", StringComparison.Ordinal);
int start = text.IndexOf("<font ", StringComparison.Ordinal);
int end = text.IndexOf('>', start);
if (end > 0)
{
@ -1556,7 +1556,7 @@ Format: Layer, Start, End, Style, Actor, MarginL, MarginR, MarginV, Effect, Text
}
else if (i == underlineIndex)
{
style.Underline = f == "-1"|| f == "1";
style.Underline = f == "-1" || f == "1";
}
else if (i == outlineIndex)
{

View File

@ -355,7 +355,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
string text = p.Text.RemoveControlCharactersButWhiteSpace();
string region = GetEffect(p, "region");
if (text.StartsWith("{\\an8}") && string.IsNullOrEmpty(region))
if (text.StartsWith("{\\an8}", StringComparison.Ordinal) && string.IsNullOrEmpty(region))
{
if (regions.Contains("top"))
region = "top";
@ -383,7 +383,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
{
skipCount--;
}
else if (line.Substring(i).StartsWith("<i>"))
else if (line.Substring(i).StartsWith("<i>", StringComparison.Ordinal))
{
styles.Push(currentStyle);
currentStyle = xml.CreateNode(XmlNodeType.Element, "span", null);
@ -393,7 +393,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
currentStyle.Attributes.Append(attr);
skipCount = 2;
}
else if (line.Substring(i).StartsWith("<b>"))
else if (line.Substring(i).StartsWith("<b>", StringComparison.Ordinal))
{
currentStyle = xml.CreateNode(XmlNodeType.Element, "span", null);
paragraph.AppendChild(currentStyle);
@ -428,7 +428,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
skipCount = line.Length;
}
}
else if (line.Substring(i).StartsWith("</i>") || line.Substring(i).StartsWith("</b>") || line.Substring(i).StartsWith("</font>"))
else if (line.Substring(i).StartsWith("</i>", StringComparison.Ordinal) || line.Substring(i).StartsWith("</b>", StringComparison.Ordinal) || line.Substring(i).StartsWith("</font>", StringComparison.Ordinal))
{
currentStyle = xml.CreateTextNode(string.Empty);
if (styles.Count > 0)
@ -437,7 +437,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
currentStyle.InnerText = string.Empty;
}
paragraph.AppendChild(currentStyle);
if (line.Substring(i).StartsWith("</font>"))
if (line.Substring(i).StartsWith("</font>", StringComparison.Ordinal))
skipCount = 6;
else
skipCount = 3;

View File

@ -42,9 +42,9 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
{
string line1 = string.Empty;
string line2 = string.Empty;
string[] lines = p.Text.Replace(Environment.NewLine, "\r").Split('\r');
string[] lines = p.Text.SplitToLines();
if (lines.Length > 2)
lines = Utilities.AutoBreakLine(p.Text).Replace(Environment.NewLine, "\r").Split('\r');
lines = Utilities.AutoBreakLine(p.Text).SplitToLines();
if (lines.Length == 1)
{
line2 = lines[0];

View File

@ -69,7 +69,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
sb.AppendLine(line);
string rtf = sb.ToString().Trim();
if (!rtf.StartsWith("{\\rtf"))
if (!rtf.StartsWith("{\\rtf", StringComparison.Ordinal))
return;
lines = rtf.FromRtf().SplitToLines().ToList();

View File

@ -83,7 +83,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
sb.AppendLine(line);
string rtf = sb.ToString().Trim();
if (!rtf.StartsWith("{\\rtf"))
if (!rtf.StartsWith("{\\rtf", StringComparison.Ordinal))
return;
lines = rtf.FromRtf().SplitToLines().ToList();

View File

@ -105,7 +105,7 @@ NOTE=
else if (!string.IsNullOrWhiteSpace(s))
{
if (subtitle.Paragraphs.Count == 0 && (s.StartsWith("TITLE=", StringComparison.Ordinal) || s.StartsWith("TITLE=", StringComparison.Ordinal) || s.StartsWith("FILE=", StringComparison.Ordinal) || s.StartsWith("AUTHOR=", StringComparison.Ordinal) ||
s.StartsWith("TYPE=VIDEO") || s.StartsWith("FORMAT=", StringComparison.Ordinal) || s.StartsWith("NOTE=", StringComparison.Ordinal)))
s.StartsWith("TYPE=VIDEO", StringComparison.Ordinal) || s.StartsWith("FORMAT=", StringComparison.Ordinal) || s.StartsWith("NOTE=", StringComparison.Ordinal)))
{
}
else

View File

@ -181,7 +181,6 @@ namespace Nikse.SubtitleEdit.Forms
{
return _batchMode;
}
set
{
_batchMode = value;