Merge pull request #885 from ivandrofly/patch-6

Clean up + Minor Refact
This commit is contained in:
Nikolaj Olsson 2015-06-19 22:10:16 +02:00
commit 7178c3a9a2
20 changed files with 52 additions and 59 deletions

View File

@ -101,4 +101,4 @@ namespace Nikse.SubtitleEdit.Core
return base.ReadByte();
}
}
}
}

View File

@ -167,4 +167,4 @@ namespace Nikse.SubtitleEdit.Core
return false;
}
}
}
}

View File

@ -10,7 +10,7 @@ namespace Nikse.SubtitleEdit.Forms
{
public partial class HardSubExtract : Form
{
// HardExtractCapture cam = null;
// HardExtractCapture cam = null;
private string _videoFileName;
private LibVlcDynamic _libVlc;
private VideoInfo _videoInfo;
@ -45,7 +45,6 @@ namespace Nikse.SubtitleEdit.Forms
Utilities.InitializeVideoPlayerAndContainer(_videoFileName, _videoInfo, mediaPlayer, VideoLoaded, null);
Configuration.Settings.General.VideoPlayer = oldPlayer;
_libVlc = mediaPlayer.VideoPlayer as LibVlcDynamic;
}
else
{
@ -276,27 +275,29 @@ namespace Nikse.SubtitleEdit.Forms
DialogResult result = saveFileDialog1.ShowDialog(this);
if (result == DialogResult.OK)
{
Bitmap bmp = pictureBox2.Image as Bitmap;
if (bmp == null)
using (var bmp = pictureBox2.Image as Bitmap)
{
MessageBox.Show("No image!");
return;
}
if (bmp == null)
{
MessageBox.Show("No image!");
return;
}
try
{
if (saveFileDialog1.FilterIndex == 0)
bmp.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Png);
else if (saveFileDialog1.FilterIndex == 1)
bmp.Save(saveFileDialog1.FileName);
else if (saveFileDialog1.FilterIndex == 2)
bmp.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Gif);
else
bmp.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Tiff);
}
catch (Exception exception)
{
MessageBox.Show(exception.Message);
try
{
if (saveFileDialog1.FilterIndex == 0)
bmp.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Png);
else if (saveFileDialog1.FilterIndex == 1)
bmp.Save(saveFileDialog1.FileName);
else if (saveFileDialog1.FilterIndex == 2)
bmp.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Gif);
else
bmp.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Tiff);
}
catch (Exception exception)
{
MessageBox.Show(exception.Message);
}
}
}
}

View File

@ -260,4 +260,4 @@ namespace Nikse.SubtitleEdit.Forms
}
}
}
}

View File

@ -36,4 +36,4 @@ namespace Nikse.SubtitleEdit.Forms
DialogResult = DialogResult.Cancel;
}
}
}
}

View File

@ -7,7 +7,6 @@ namespace Nikse.SubtitleEdit.Forms
{
public partial class NuendoProperties : PositionAndSizeForm
{
public string CharacterListFile { get; set; }
public NuendoProperties()
@ -78,9 +77,7 @@ namespace Nikse.SubtitleEdit.Forms
}
}
}
catch
{
}
catch { }
}
lineNumber++;
}
@ -88,4 +85,4 @@ namespace Nikse.SubtitleEdit.Forms
}
}
}
}

View File

@ -161,4 +161,4 @@ namespace Nikse.SubtitleEdit.Forms
}
}
}
}

View File

@ -347,4 +347,4 @@ https://github.com/SubtitleEdit/subtitleedit
}
}
}
}

View File

@ -261,4 +261,4 @@ namespace Nikse.SubtitleEdit.Forms
}
}
}
}

View File

@ -167,4 +167,4 @@ namespace Nikse.SubtitleEdit.Forms
this.Refresh();
}
}
}
}

View File

@ -6,4 +6,4 @@
CaseSensitive,
RegEx
}
}
}

View File

@ -6,4 +6,4 @@
AllLines,
SelectionAndForward,
}
}
}

View File

@ -12,4 +12,4 @@
AddToNamesEtc,
ChangeWholeText
}
}
}

View File

@ -14,4 +14,4 @@
WordsPerMinute,
Style,
}
}
}

View File

@ -6,7 +6,6 @@ namespace Nikse.SubtitleEdit.Logic.Forms
{
public static class FixCommonErrorsHelper
{
public static string FixEllipsesStartHelper(string text)
{
if (string.IsNullOrEmpty(text) || text.Trim().Length < 4 || !(text.Contains("..", StringComparison.Ordinal) || text.Contains(". .", StringComparison.Ordinal)))
@ -463,4 +462,4 @@ namespace Nikse.SubtitleEdit.Logic.Forms
}
}
}
}

View File

@ -684,15 +684,15 @@ namespace Nikse.SubtitleEdit.Logic.Forms
if (temp.TrimEnd().EndsWith(Environment.NewLine + "-"))
temp = temp.TrimEnd().TrimEnd('-').TrimEnd();
}
else if (index == 2 && temp.StartsWith("- —"))
else if (index == 2 && temp.StartsWith("- —", StringComparison.Ordinal))
{
temp = temp.Remove(2, 2);
}
else if (index == 2 && temp.StartsWith("- —"))
else if (index == 2 && temp.StartsWith("- —", StringComparison.Ordinal))
{
temp = temp.Remove(2, 1);
}
else if (index == 0 && temp.StartsWith(" —"))
else if (index == 0 && temp.StartsWith(" —", StringComparison.Ordinal))
{
temp = temp.Remove(0, 2);
}
@ -771,12 +771,12 @@ namespace Nikse.SubtitleEdit.Logic.Forms
}
}
if (index > 3 && index - 2 < temp.Length && temp.Substring(index - 2).StartsWith(", —"))
if (index > 3 && index - 2 < temp.Length && temp.Substring(index - 2).StartsWith(", —", StringComparison.Ordinal))
{
temp = temp.Remove(index - 2, 1);
index--;
}
else if (index > 3 && index - 2 < temp.Length && temp.Substring(index - 2).StartsWith(", —"))
else if (index > 3 && index - 2 < temp.Length && temp.Substring(index - 2).StartsWith(", —", StringComparison.Ordinal))
{
temp = temp.Remove(index - 2, 1);
index--;
@ -789,7 +789,7 @@ namespace Nikse.SubtitleEdit.Logic.Forms
if (!string.IsNullOrEmpty(temp) && temp.StartsWith('-'))
temp = temp.Remove(0, 1).Trim();
}
else if (index == 3 && !string.IsNullOrEmpty(temp) && temp.StartsWith("<i>-"))
else if (index == 3 && !string.IsNullOrEmpty(temp) && temp.StartsWith("<i>-", StringComparison.Ordinal))
{
temp = temp.Remove(3, 1);
}

View File

@ -6,7 +6,6 @@ namespace Nikse.SubtitleEdit.Logic.Forms
{
public static class SplitLongLinesHelper
{
public static bool QualifiesForSplit(string text, int singleLineMaxCharacters, int totalLineMaxCharacters)
{
string s = HtmlUtil.RemoveHtmlTags(text.Trim(), true);
@ -20,7 +19,7 @@ namespace Nikse.SubtitleEdit.Logic.Forms
return true;
}
var tempText = text.Replace(Environment.NewLine, " ").Replace(" ", " ");
var tempText = Utilities.UnbreakLine(text);
if (Utilities.CountTagInText(tempText, '-') == 2 && (text.StartsWith('-') || text.StartsWith("<i>-")))
{
var idx = tempText.IndexOfAny(new[] { ". -", "! -", "? -" }, StringComparison.Ordinal);
@ -35,7 +34,6 @@ namespace Nikse.SubtitleEdit.Logic.Forms
}
}
}
return false;
}
@ -93,24 +91,24 @@ namespace Nikse.SubtitleEdit.Logic.Forms
newParagraph1.Text = newParagraph1.Text.Remove(0, 1).Trim();
newParagraph2.Text = newParagraph2.Text.Remove(0, 1).Trim();
}
else if (newParagraph1.Text.StartsWith("<i>-") && newParagraph2.Text.StartsWith('-'))
else if (newParagraph1.Text.StartsWith("<i>-", StringComparison.Ordinal) && newParagraph2.Text.StartsWith('-'))
{
newParagraph1.Text = newParagraph1.Text.Remove(3, 1).Trim();
if (newParagraph1.Text.StartsWith("<i> "))
if (newParagraph1.Text.StartsWith("<i> ", StringComparison.Ordinal))
newParagraph1.Text = newParagraph1.Text.Remove(3, 1).Trim();
newParagraph2.Text = newParagraph2.Text.Remove(0, 1).Trim();
}
}
else
{
if (newParagraph1.Text.EndsWith("</i>"))
if (newParagraph1.Text.EndsWith("</i>", StringComparison.Ordinal))
{
const string post = "</i>";
newParagraph1.Text = newParagraph1.Text.Remove(newParagraph1.Text.Length - post.Length);
}
//newParagraph1.Text += comboBoxLineContinuationEnd.Text.TrimEnd() + post;
if (newParagraph2.Text.StartsWith("<i>"))
if (newParagraph2.Text.StartsWith("<i>", StringComparison.Ordinal))
{
const string pre = "<i>";
newParagraph2.Text = newParagraph2.Text.Remove(0, pre.Length);

View File

@ -22,9 +22,7 @@ namespace Nikse.SubtitleEdit.Logic.SpellCheck
public abstract bool Spell(string word);
public abstract List<string> Suggest(string word);
public virtual void Dispose()
{
}
public virtual void Dispose() { }
}
}
}

View File

@ -3210,4 +3210,4 @@ namespace Nikse.SubtitleEdit.Logic
}
}
}
}

View File

@ -636,4 +636,4 @@ namespace Nikse.SubtitleEdit.Logic
}
}
}
}