Merge pull request #671 from ivandrofly/fix/patch_10

Use constant for subtitle format name + Refact
This commit is contained in:
Nikolaj Olsson 2015-03-27 19:42:49 +01:00
commit 9cf8cd3705
18 changed files with 53 additions and 35 deletions

View File

@ -39,7 +39,6 @@ namespace Nikse.SubtitleEdit.Core
return false;
}
private static bool EndsWithHtmlTag(string text, bool threeLengthTag, bool includeFont)
{
var len = text.Length;
@ -53,6 +52,7 @@ namespace Nikse.SubtitleEdit.Core
return true;
return false;
}
public static bool StartsWith(this string s, char c)
{
return s.Length > 0 && s[0] == c;

View File

@ -943,13 +943,13 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
nbmp.ReplaceTransparentWith(Color.Blue);
using (var bmp = nbmp.GetBitmap())
{
// param.Bitmap.Save(fileName, ImageFormat);
// param.Bitmap.Save(fileName, ImageFormat);
imagesSavedCount++;
//RACE001.TIF 00;00;02;02 00;00;03;15 000 000 720 480
//RACE002.TIF 00;00;05;18 00;00;09;20 000 000 720 480
int top = param.ScreenHeight - (param.Bitmap.Height + param.BottomMargin);
int left = (param.ScreenWidth - param.Bitmap.Width)/2;
int left = (param.ScreenWidth - param.Bitmap.Width) / 2;
var b = new NikseBitmap(param.ScreenWidth, param.ScreenHeight);
{
@ -963,7 +963,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
if (param.Alignment == ContentAlignment.TopLeft || param.Alignment == ContentAlignment.TopCenter || param.Alignment == ContentAlignment.TopRight)
top = param.BottomMargin;
if (param.Alignment == ContentAlignment.MiddleLeft || param.Alignment == ContentAlignment.MiddleCenter || param.Alignment == ContentAlignment.MiddleRight)
top = param.ScreenHeight - (param.Bitmap.Height/2);
top = param.ScreenHeight - (param.Bitmap.Height / 2);
using (var g = Graphics.FromImage(fullSize))
{
@ -3475,8 +3475,8 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
{
if (_subtitle.Paragraphs.Count > 0 && subtitleListView1.SelectedItems.Count > 0)
{
bool isSsa = _format.FriendlyName == new SubStationAlpha().FriendlyName ||
_format.FriendlyName == new AdvancedSubStationAlpha().FriendlyName;
bool isSsa = _format.FriendlyName == SubStationAlpha.NameOfFormat ||
_format.FriendlyName == AdvancedSubStationAlpha.NameOfFormat;
foreach (ListViewItem item in subtitleListView1.SelectedItems)
{

View File

@ -169,7 +169,7 @@ namespace Nikse.SubtitleEdit.Forms
}
JoinedSubtitle = new Subtitle();
if (JoinedFormat.FriendlyName != new SubRip().FriendlyName)
if (JoinedFormat.FriendlyName != SubRip.NameOfFormat)
JoinedSubtitle.Header = header;
foreach (Subtitle sub in subtitles)
{

View File

@ -5032,10 +5032,9 @@ namespace Nikse.SubtitleEdit.Forms
dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string responseFromServer = reader.ReadToEnd();
string result = responseFromServer;
reader.Close();
response.Close();
return result;
return responseFromServer;
}
private void TranslateFromSwedishToDanishToolStripMenuItemClick(object sender, EventArgs e)
@ -6561,8 +6560,8 @@ namespace Nikse.SubtitleEdit.Forms
{
MakeHistoryForUndo(_language.BeforeSettingFontToNormal);
var subFormatName = GetCurrentSubtitleFormat().FriendlyName;
bool isSsa = subFormatName == new SubStationAlpha().FriendlyName ||
subFormatName == new AdvancedSubStationAlpha().FriendlyName;
bool isSsa = subFormatName == SubStationAlpha.NameOfFormat ||
subFormatName == AdvancedSubStationAlpha.NameOfFormat;
foreach (ListViewItem item in SubtitleListview1.SelectedItems)
{

View File

@ -29,7 +29,7 @@ namespace Nikse.SubtitleEdit.Forms.Styles
labelStatus.Text = string.Empty;
_header = subtitle.Header;
_format = format;
_isSubStationAlpha = _format.FriendlyName == new SubStationAlpha().FriendlyName;
_isSubStationAlpha = _format.FriendlyName == SubStationAlpha.NameOfFormat;
if (_header == null || !_header.Contains("style:", StringComparison.OrdinalIgnoreCase))
ResetHeader();

View File

@ -20,7 +20,7 @@ namespace Nikse.SubtitleEdit.Forms
{
InitializeComponent();
_subtitle = subtitle;
_isSubStationAlpha = format.FriendlyName == new SubStationAlpha().FriendlyName;
_isSubStationAlpha = format.FriendlyName == SubStationAlpha.NameOfFormat;
_videoFileName = videoFileName;
var l = Configuration.Settings.Language.SubStationAlphaProperties;

View File

@ -42,18 +42,18 @@ namespace Nikse.SubtitleEdit.Logic
}
Console.WriteLine();
Console.WriteLine("- Supported formats (input only):");
Console.WriteLine(" " + new CapMakerPlus().FriendlyName);
Console.WriteLine(" " + new Captionate().FriendlyName);
Console.WriteLine(" " + new Cavena890().FriendlyName);
Console.WriteLine(" " + new CheetahCaption().FriendlyName);
Console.WriteLine(" " + new Chk().FriendlyName);
Console.WriteLine(" " + CapMakerPlus.NameOfFormat);
Console.WriteLine(" " + Captionate.NameOfFormat);
Console.WriteLine(" " + Cavena890.NameOfFormat);
Console.WriteLine(" " + CheetahCaption.NameOfFormat);
Console.WriteLine(" " + Chk.NameOfFormat);
Console.WriteLine(" Matroska (.mkv)");
Console.WriteLine(" Matroska subtitle (.mks)");
Console.WriteLine(" " + new NciCaption().FriendlyName);
Console.WriteLine(" " + new AvidStl().FriendlyName);
Console.WriteLine(" " + new Pac().FriendlyName);
Console.WriteLine(" " + new Spt().FriendlyName);
Console.WriteLine(" " + new Ultech130().FriendlyName);
Console.WriteLine(" " + NciCaption.NameOfFormat);
Console.WriteLine(" " + AvidStl.NameOfFormat);
Console.WriteLine(" " + Pac.NameOfFormat);
Console.WriteLine(" " + Spt.NameOfFormat);
Console.WriteLine(" " + Ultech130.NameOfFormat);
}
Console.WriteLine();

View File

@ -82,9 +82,11 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
get { return ".stl"; }
}
public const string NameOfFormat = "Avid STL";
public override string Name
{
get { return "Avid STL"; }
get { return NameOfFormat; }
}
public override bool IsTimeBased

View File

@ -17,9 +17,11 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
get { return ".cap"; }
}
public const string NameOfFormat = "CapMaker Plus";
public override string Name
{
get { return "CapMaker Plus"; }
get { return NameOfFormat; }
}
public override bool IsTimeBased

View File

@ -14,9 +14,11 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
get { return ".xml"; }
}
public const string NameOfFormat = "Captionate";
public override string Name
{
get { return "Captionate"; }
get { return NameOfFormat; }
}
public override bool IsTimeBased

View File

@ -179,9 +179,11 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
get { return ".890"; }
}
public const string NameOfFormat = "Cavena 890";
public override string Name
{
get { return "Cavena 890"; }
get { return NameOfFormat; }
}
public override bool IsTimeBased

View File

@ -62,9 +62,11 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
get { return ".cap"; }
}
public const string NameOfFormat = "Cheetah Caption";
public override string Name
{
get { return "Cheetah Caption"; }
get { return NameOfFormat; }
}
public override bool IsTimeBased

View File

@ -11,16 +11,18 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
public class Chk : SubtitleFormat
{
private readonly Encoding _codePage = Encoding.GetEncoding(850);
// private string _languageId = "DEN"; // English
// private string _languageId = "DEN"; // English
public override string Extension
{
get { return ".chk"; }
}
public const string NameOfFormat = "CHK";
public override string Name
{
get { return "CHK"; }
get { return NameOfFormat; }
}
public override bool IsTimeBased

View File

@ -13,9 +13,11 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
get { return ".cap"; }
}
public const string NameOfFormat = "NCI Caption";
public override string Name
{
get { return "NCI Caption"; }
get { return NameOfFormat; }
}
public override bool IsTimeBased

View File

@ -786,9 +786,11 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
get { return ".pac"; }
}
public const string NameOfFormat = "PAC (Screen Electronics)";
public override string Name
{
get { return "PAC (Screen Electronics)"; }
get { return NameOfFormat; }
}
public override bool IsTimeBased

View File

@ -13,9 +13,11 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
get { return ".spt"; }
}
public const string NameOfFormat = "spt";
public override string Name
{
get { return "spt"; }
get { return NameOfFormat; }
}
public override bool IsTimeBased

View File

@ -17,7 +17,6 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
get { return ".ssa"; }
}
public const string NameOfFormat = "Sub Station Alpha";
public override string Name

View File

@ -19,9 +19,11 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
get { return ".ult"; }
}
public const string NameOfFormat = "Ultech 1.30 Caption";
public override string Name
{
get { return "Ultech 1.30 Caption"; }
get { return NameOfFormat; }
}
public override bool IsTimeBased