Merge pull request #695 from ivandrofly/fix/patch-33

Refact + Fix
This commit is contained in:
Nikolaj Olsson 2015-04-05 17:35:42 +02:00
commit 1294a3ae85
3 changed files with 7 additions and 8 deletions

View File

@ -1789,7 +1789,7 @@ namespace Nikse.SubtitleEdit.Forms
{ {
var cb = comboBoxWordListLanguage.Items[comboBoxWordListLanguage.SelectedIndex] as ComboBoxLanguage; var cb = comboBoxWordListLanguage.Items[comboBoxWordListLanguage.SelectedIndex] as ComboBoxLanguage;
if (cb != null) if (cb != null)
return cb.CultureInfo.Name.Replace("-", "_"); return cb.CultureInfo.Name.Replace('-', '_');
return null; return null;
} }

View File

@ -46,7 +46,7 @@ namespace Nikse.SubtitleEdit.Forms
SubStationAlpha ssa = new SubStationAlpha(); SubStationAlpha ssa = new SubStationAlpha();
var sub = new Subtitle(); var sub = new Subtitle();
var lines = new List<string>(); var lines = new List<string>();
foreach (string line in subtitle.ToText(ssa).Replace(Environment.NewLine, "\n").Split('\n')) foreach (string line in subtitle.ToText(ssa).SplitToLines())
lines.Add(line); lines.Add(line);
string title = "Untitled"; string title = "Untitled";
if (!string.IsNullOrEmpty(subtitleFileName)) if (!string.IsNullOrEmpty(subtitleFileName))
@ -61,7 +61,7 @@ namespace Nikse.SubtitleEdit.Forms
{ {
foreach (string line in header.SplitToLines()) foreach (string line in header.SplitToLines())
{ {
string s = line.ToLower().Trim(); string s = line.ToLowerInvariant().Trim();
if (s.StartsWith("title:")) if (s.StartsWith("title:"))
{ {
textBoxTitle.Text = s.Remove(0, 6).Trim(); textBoxTitle.Text = s.Remove(0, 6).Trim();
@ -113,7 +113,7 @@ namespace Nikse.SubtitleEdit.Forms
} }
else if (s.StartsWith("scaledborderandshadow:")) else if (s.StartsWith("scaledborderandshadow:"))
{ {
checkBoxScaleBorderAndShadow.Checked = s.Remove(0, 22).Trim().Equals("yes", StringComparison.OrdinalIgnoreCase); checkBoxScaleBorderAndShadow.Checked = s.Remove(0, 22).Trim().Equals("yes");
} }
} }
} }
@ -165,9 +165,8 @@ namespace Nikse.SubtitleEdit.Forms
format = new AdvancedSubStationAlpha(); format = new AdvancedSubStationAlpha();
var sub = new Subtitle(); var sub = new Subtitle();
string text = format.ToText(sub, string.Empty); string text = format.ToText(sub, string.Empty);
string[] lineArray = text.Split(Utilities.NewLineChars);
var lines = new List<string>(); var lines = new List<string>();
foreach (string line in lineArray) foreach (string line in text.SplitToLines())
lines.Add(line); lines.Add(line);
format.LoadSubtitle(sub, lines, string.Empty); format.LoadSubtitle(sub, lines, string.Empty);
return sub.Header.Trim(); return sub.Header.Trim();

View File

@ -336,10 +336,10 @@ namespace Nikse.SubtitleEdit.Logic
private static bool IsPartOfNumber(string s, int position) private static bool IsPartOfNumber(string s, int position)
{ {
if (string.IsNullOrWhiteSpace(s) || position + 2 > s.Length) if (string.IsNullOrWhiteSpace(s) || position + 1 >= s.Length)
return false; return false;
if (position > 0 && position < s.Length - 1 && @",.".Contains(s[position])) if (position > 0 && @",.".Contains(s[position]))
{ {
return char.IsDigit(s[position - 1]) && char.IsDigit(s[position + 1]); return char.IsDigit(s[position - 1]) && char.IsDigit(s[position + 1]);
} }