diff --git a/src/Core/StringExtensions.cs b/src/Core/StringExtensions.cs index 278109475..d987e9863 100644 --- a/src/Core/StringExtensions.cs +++ b/src/Core/StringExtensions.cs @@ -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; diff --git a/src/Forms/ExportPngXml.cs b/src/Forms/ExportPngXml.cs index 93a6bcf13..5b44ba366 100644 --- a/src/Forms/ExportPngXml.cs +++ b/src/Forms/ExportPngXml.cs @@ -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) { diff --git a/src/Forms/JoinSubtitles.cs b/src/Forms/JoinSubtitles.cs index 5edfa07fb..1e5403438 100644 --- a/src/Forms/JoinSubtitles.cs +++ b/src/Forms/JoinSubtitles.cs @@ -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) { diff --git a/src/Forms/Main.cs b/src/Forms/Main.cs index d77e712ba..7e29a00ff 100644 --- a/src/Forms/Main.cs +++ b/src/Forms/Main.cs @@ -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) { diff --git a/src/Forms/Styles/SubStationAlphaStyles.cs b/src/Forms/Styles/SubStationAlphaStyles.cs index fdef06146..9536f9f68 100644 --- a/src/Forms/Styles/SubStationAlphaStyles.cs +++ b/src/Forms/Styles/SubStationAlphaStyles.cs @@ -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(); diff --git a/src/Forms/SubStationAlphaProperties.cs b/src/Forms/SubStationAlphaProperties.cs index 58e5348c1..12c7d50bc 100644 --- a/src/Forms/SubStationAlphaProperties.cs +++ b/src/Forms/SubStationAlphaProperties.cs @@ -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; diff --git a/src/Logic/CommandLineConvert.cs b/src/Logic/CommandLineConvert.cs index 4920568d0..a24c60b4f 100644 --- a/src/Logic/CommandLineConvert.cs +++ b/src/Logic/CommandLineConvert.cs @@ -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(); diff --git a/src/Logic/SubtitleFormats/AvidStl.cs b/src/Logic/SubtitleFormats/AvidStl.cs index f58384ee5..b6f90429c 100644 --- a/src/Logic/SubtitleFormats/AvidStl.cs +++ b/src/Logic/SubtitleFormats/AvidStl.cs @@ -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 diff --git a/src/Logic/SubtitleFormats/CapMakerPlus.cs b/src/Logic/SubtitleFormats/CapMakerPlus.cs index 869b67780..8b2bd618b 100644 --- a/src/Logic/SubtitleFormats/CapMakerPlus.cs +++ b/src/Logic/SubtitleFormats/CapMakerPlus.cs @@ -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 diff --git a/src/Logic/SubtitleFormats/Captionate.cs b/src/Logic/SubtitleFormats/Captionate.cs index b573bf9e6..4476b6b54 100644 --- a/src/Logic/SubtitleFormats/Captionate.cs +++ b/src/Logic/SubtitleFormats/Captionate.cs @@ -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 diff --git a/src/Logic/SubtitleFormats/Cavena890.cs b/src/Logic/SubtitleFormats/Cavena890.cs index f2dc6445d..c5307e5d4 100644 --- a/src/Logic/SubtitleFormats/Cavena890.cs +++ b/src/Logic/SubtitleFormats/Cavena890.cs @@ -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 diff --git a/src/Logic/SubtitleFormats/CheetahCaption.cs b/src/Logic/SubtitleFormats/CheetahCaption.cs index 413c35c0b..e602dec61 100644 --- a/src/Logic/SubtitleFormats/CheetahCaption.cs +++ b/src/Logic/SubtitleFormats/CheetahCaption.cs @@ -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 diff --git a/src/Logic/SubtitleFormats/Chk.cs b/src/Logic/SubtitleFormats/Chk.cs index 75c768fc9..899877c72 100644 --- a/src/Logic/SubtitleFormats/Chk.cs +++ b/src/Logic/SubtitleFormats/Chk.cs @@ -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 diff --git a/src/Logic/SubtitleFormats/NciCaption.cs b/src/Logic/SubtitleFormats/NciCaption.cs index 3fffc771f..35b212242 100644 --- a/src/Logic/SubtitleFormats/NciCaption.cs +++ b/src/Logic/SubtitleFormats/NciCaption.cs @@ -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 diff --git a/src/Logic/SubtitleFormats/Pac.cs b/src/Logic/SubtitleFormats/Pac.cs index 1a66a4a86..2020ac57c 100644 --- a/src/Logic/SubtitleFormats/Pac.cs +++ b/src/Logic/SubtitleFormats/Pac.cs @@ -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 diff --git a/src/Logic/SubtitleFormats/Spt.cs b/src/Logic/SubtitleFormats/Spt.cs index 3818d4943..5399d0d1e 100644 --- a/src/Logic/SubtitleFormats/Spt.cs +++ b/src/Logic/SubtitleFormats/Spt.cs @@ -13,9 +13,11 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats get { return ".spt"; } } + public const string NameOfFormat = "NCI Caption"; + public override string Name { - get { return "spt"; } + get { return NameOfFormat; } } public override bool IsTimeBased diff --git a/src/Logic/SubtitleFormats/SubStationAlpha.cs b/src/Logic/SubtitleFormats/SubStationAlpha.cs index c5e058759..fbe51138a 100644 --- a/src/Logic/SubtitleFormats/SubStationAlpha.cs +++ b/src/Logic/SubtitleFormats/SubStationAlpha.cs @@ -17,7 +17,6 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats get { return ".ssa"; } } - public const string NameOfFormat = "Sub Station Alpha"; public override string Name diff --git a/src/Logic/SubtitleFormats/Ultech130.cs b/src/Logic/SubtitleFormats/Ultech130.cs index 764e40fb8..a9d6c5797 100644 --- a/src/Logic/SubtitleFormats/Ultech130.cs +++ b/src/Logic/SubtitleFormats/Ultech130.cs @@ -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