Merge branch 'master-u' into upstream-merge

# Conflicts:
#	libse/SubtitleFormats/TimedText10.cs
This commit is contained in:
askolesov 2017-02-07 14:42:33 +03:00
commit 1634cdf3ff
27 changed files with 914 additions and 248 deletions

View File

@ -14,15 +14,23 @@
* Updated Basque translation - thx Xabier
* Minor improvements for format "Structured titles" - thx Yamato-ua
* List view columns arrangable and non-clickable - thx Ingo
* EBU STL: New settings regarding vertical position
* EBU STL: New color picker dialog
* FIXED:
* Fixed bug in spell check "change word" regarding "¿?" - thx locotus
* Fixed play current/selection not stopping - thx rhazor
* Fixed fast forward waveform scrolling with mouse wheel
* Fixed bug in spell check "change word" regarding "¿?" - thx locotus
* Fix in "Fix common errors" regarding de-selected fixes - thx Tronar
* Fix for MPC-HC 32-bit - thx ZoneX
* Fixed issue with importing "Unknown 53" format - thx darnn
* Fixed italic rendering issue in format DCinema SMPTE - thx Miga
* Fixed bug in image export - thx marb99
* Word spell check does not change format - thx Yamato-ua
* Better reading of top alignment in dfxp - thx Plazik
* "Fix common errors" - only delete/merge line still enables "OK" button
* "Batch convert" - don't clear ASS/SSA style after format change - thx Thunderbolt8
* Fix for multi-line italic in format TTML 1.0 - thx nathaniel1977
* EBU STL writing now works with multiple colors in samee line - thx George
3.5.1 (13th December 2016)

View File

@ -41,6 +41,7 @@
<Word from="bolesan" to="bolestan" />
<Word from="braon" to="smeđa" />
<Word from="bregu" to="brijegu" />
<Word from="bti" to="biti" />
<Word from="ceo" to="cijeli" />
<Word from="Ceo" to="Cijeli" />
<Word from="cepa" to="cijepa" />
@ -159,12 +160,13 @@
<Word from="Interesuje" to="Zanima" />
<Word from="Interesuju" to="Zanimaju" />
<Word from="interesuju" to="zanimaju" />
<Word from="isekao" to="izrezao" />
<Word from="isterao" to="istjerao" />
<Word from="isuviše" to="previše" />
<Word from="ivica" to="rub" />
<Word from="ivice" to="ruba" />
<Word from="ivici" to="rubu" />
<Word from="ivicu" to="rub" />
<Word from="isuviše" to="previše" />
<Word from="isterao" to="istjerao" />
<Word from="izgladneo" to="izgladnio" />
<Word from="izmeriti" to="izmjeriti" />
<Word from="izvinim" to="ispričam" />
@ -245,6 +247,7 @@
<Word from="Lejn" to="Lane" />
<Word from="lenji" to="lijeni" />
<Word from="lenja" to="lijena" />
<Word from="lešnik" to="lješnjak" />
<Word from="leto" to="ljeto" />
<Word from="letiti" to="letjeti" />
<Word from="leve" to="lijeve" />
@ -386,7 +389,7 @@
<Word from="plaćeš" to="plačeš" />
<Word from="podnesti" to="podnijeti" />
<Word from="podstrekač" to="poticatelj" />
<Word from="pomaći" to="pomaknuti" />
<Word from="podsete" to="podsjete" />
<Word from="poen" to="bod" />
<Word from="poena" to="boda" />
<Word from="poene" to="bodove" />
@ -394,6 +397,7 @@
<Word from="Poeni" to="Bodovi" />
<Word from="poenima" to="bodovima" />
<Word from="poludili" to="poludjeli" />
<Word from="pomaći" to="pomaknuti" />
<Word from="pomaknim" to="pomaknem" />
<Word from="pomaknio" to="pomaknuo" />
<Word from="pomakniti" to="pomaknuti" />
@ -433,6 +437,7 @@
<Word from="postarajmo" to="pobrinimo" />
<Word from="postaramo" to="pobrinemo" />
<Word from="postaraš" to="pobrineš" />
<Word from="povesne" to="povijesne" />
<Word from="Povinuju" to="Pokoravaju" />
<Word from="povinuju" to="pokoravaju" />
<Word from="pozadi" to="iza" />
@ -662,6 +667,7 @@
<Word from="Usled" to="Uslijed" />
<Word from="usljed" to="uslijed" />
<Word from="Usljed" to="Uslijed" />
<Word from="utehe" to="utjehe" />
<Word from="uveče" to="navečer" />
<Word from="uvijet" to="uvjet" />
<Word from="uvo" to="uho" />
@ -904,6 +910,7 @@
<RegEx find="\b([bB])j?edn([aeiou]|k[aeou]?)" replaceWith="$1ijedn$2" />
<RegEx find="\b([bB])j?el([aeiou]|ac|c[aeiu]|cima|o[mgj]|i[mh])\b" replaceWith="$1ijel$2" />
<RegEx find="(?&lt;![uU]rne)([bB])j?esn([aeiou])" replaceWith="$1ijesn$2" />
<RegEx find="zvrj?ed" replaceWith="zvrijed" />
<RegEx find="znadež" replaceWith="znad" />
<RegEx find="([bB])ežanj" replaceWith="$1ježanj" />
<RegEx find="([bB])i?j?ež([ei]|i[mš]|imo|ite|ao|al[aeio]|ati)\b" replaceWith="$1jež$2" />
@ -946,6 +953,7 @@
<RegEx find="\b([dD])a[čć]([eu])" replaceWith="$1at ć$2" />
<RegEx find="ejstv(?!o)" replaceWith="jelovanj" />
<RegEx find="ejstvo" replaceWith="jelo" />
<RegEx find="eklarisa" replaceWith="eklarira" />
<RegEx find="\b([dD])el([aou](?!x)|ić|ić[aeiu]|ima)" replaceWith="$1jel$2" />
<RegEx find="([dD])elova([lnt])" replaceWith="$1jelova$2" />
<RegEx find="\b([dD])j?eli([mšo]|mo|l[aeio]|t[ei])\b" replaceWith="$1ijeli$2" />
@ -1000,6 +1008,7 @@
<RegEx find="\bĐep" replaceWith="Džep" />
<RegEx find="\bđubret" replaceWith="smeć" />
<RegEx find="\bđubriš" replaceWith="smetliš" />
<RegEx find="eklariše" replaceWith="eklarira" />
<RegEx find="ekspert(?![ni])" replaceWith="stručnjak" />
<RegEx find="Ekspert(?![ni])" replaceWith="Stručnjak" />
<RegEx find="ekspertn" replaceWith="stručn" />
@ -1184,7 +1193,7 @@
<RegEx find="([lL])ović" replaceWith="$1ovit ć" />
<RegEx find="\b([lL])jep([aeiou]|om|oj|ima)\b" replaceWith="$1ijep$2" />
<RegEx find="\b([lL])uda([kcč])" replaceWith="$1uđa$2" />
<RegEx find="([lL]u|[Pp]re|[sS]vi)deo" replaceWith="$1dio" />
<RegEx find="(u|[Pp]re|[sS]vi)deo" replaceWith="$1dio" />
<RegEx find="\b([lL])juski" replaceWith="$1judski" />
<RegEx find="makaz" replaceWith="škar" />
<RegEx find="Makaz" replaceWith="Škar" />
@ -1197,13 +1206,13 @@
<RegEx find="([mM])ese([cč])" replaceWith="$1jese$2" />
<RegEx find="\b([mM])est([aoiu])" replaceWith="$1jest$2" />
<RegEx find="igracion" replaceWith="igracijsk" />
<RegEx find="([mM])islić" replaceWith="$1islit ć" />
<RegEx find="([mM])išič" replaceWith="$1išić" />
<RegEx find="islić" replaceWith="islit ć" />
<RegEx find="išič" replaceWith="išić" />
<RegEx find="([mM])j?ešalic" replaceWith="$1iješalic" />
<RegEx find="([mM])j?eša([jmnšo]|n[aio]|no[mgj]|nima?|mo|ju|njem|nj[aeu]|l[aeio]|t[ei])?\b" replaceWith="$1iješa$2" />
<RegEx find="([mM])edve([dđ])" replaceWith="$1edvje$2" />
<RegEx find="minđuš" replaceWith="naušnic" />
<RegEx find="([mM])ilij?on" replaceWith="$1ilijun" />
<RegEx find="ilij?on" replaceWith="ilijun" />
<RegEx find="(?&lt;![iI]|[kK]a)([mM])j?enja([jmnšo]|mo|njem?|ju|l[aeio]|t[ei])?\b" replaceWith="$1ijenja$2" />
<RegEx find="([mM])lj?ek([aou])" replaceWith="$1lijek$2" />
<RegEx find="([mM])lj?ečn" replaceWith="$1liječn" />
@ -1324,7 +1333,7 @@
<RegEx find="([dDpP])odel" replaceWith="$1odjel" />
<RegEx find="([dDpP])odj?eli([lto])" replaceWith="$1odijeli$2" />
<RegEx find="odretl" replaceWith="orijekl" />
<RegEx find="(?&lt;![mn])o(d?)se([kć])" replaceWith="o$1sje$2" />
<RegEx find="(?&lt;![mn])o(d?)se([kć])(?!s)" replaceWith="o$1sje$2" />
<RegEx find="odu?hvat" replaceWith="othvat" />
<RegEx find="([pP])oent" replaceWith="$1oant" />
<RegEx find="([pP])ogrj?eši(?!v)" replaceWith="$1ogriješi" />
@ -1345,6 +1354,7 @@
<RegEx find="([pP])os([lt])a[čć]" replaceWith="$1os$2at ć" />
<RegEx find="([pP])os(l?)e([dt])" replaceWith="$1os$2je$3" />
<RegEx find="([pP])osmatra" replaceWith="$1romatra" />
<RegEx find="([pP])ose([td])" replaceWith="$1osje$2" />
<RegEx find="([pP])oter" replaceWith="$1otjer" />
<RegEx find="ovinuje" replaceWith="okorava" />
<RegEx find="([pP]o|[uU])vrj?edi([lomšt])" replaceWith="$1vrijedi$2" />
@ -1359,6 +1369,7 @@
<RegEx find="redamnom" replaceWith="reda mnom" />
<RegEx find="red?postav" replaceWith="retpostav" />
<RegEx find="ređaš" replaceWith="rijaš" />
<RegEx find="premić" replaceWith="premit ć" />
<RegEx find="renje([lt])" replaceWith="renije$1" />
<RegEx find="([pP])rese([čk])" replaceWith="$1resje$2" />
<RegEx find="([pP])r([oe])ter" replaceWith="$1r$2tjer" />
@ -1653,7 +1664,6 @@
<RegEx find="\b([vV])oz([au]|om|ov[ie]|ovima)?\b" replaceWith="$1lak$2" />
<RegEx find="\b([vV])ozi[čć]([eu])" replaceWith="$1ozit ć$2" />
<RegEx find="\b([vV])rj?ed(e|an|n[aeiou]|nih|nosti?|nošću)?\b" replaceWith="$1rijed$2" />
<RegEx find="([Bb])ezvrj?ed" replaceWith="$1ezvrijed" />
<RegEx find="\b([vV])red([ei])" replaceWith="$1rijed$2" />
<RegEx find="([vV])rj?eđa" replaceWith="$1rijeđa" />
<RegEx find="vređen" replaceWith="vrijeđen" />
@ -1682,9 +1692,10 @@
<RegEx find="([žŽ])eleć([eu])" replaceWith="$1eljet ć$2" />
<RegEx find="([žŽ])elj?eo" replaceWith="$1elio" />
<RegEx find="([žŽ])ive([lt])" replaceWith="$1ivje$2" />
<RegEx find="([žŽ])iveć(?!i)" replaceWith="$1ivjet ć" />
<RegEx find="iveć(?!i)" replaceWith="ivjet ć" />
<RegEx find="lj?ezd" replaceWith="lijezd" />
<RegEx find="([žŽ])muri" replaceWith="$1miri" />
<RegEx find="([žŽ])ude([lt])" replaceWith="$1udje$2" />
<RegEx find="žur[ck]" replaceWith="zabav" />
<RegEx find="Žur[ck]" replaceWith="Zabav" />
<RegEx find="([sSzZ])amnom" replaceWith="$1a mnom" />
@ -1836,10 +1847,12 @@
<RegEx find="struiše" replaceWith="struira" />
<RegEx find="struišu" replaceWith="struiraju" />
<RegEx find="stvrn" replaceWith="stvarn" />
<RegEx find="(?&lt;!n)svesti([lt])" replaceWith="svijest$1" />
<RegEx find="svetić" replaceWith="svetit ć" />
<RegEx find="šević" replaceWith="ševit ć" />
<RegEx find="šunjać" replaceWith="šuljat ć" />
<RegEx find="tćeš" replaceWith="t ćeš" />
<RegEx find="tideo" replaceWith="tidio" />
<RegEx find="tede(?![oć])" replaceWith="tedje" />
<RegEx find="tedeo" replaceWith="tedio" />
<RegEx find="tešn" replaceWith="tješn" />

View File

@ -371,6 +371,10 @@ Note: Do check free disk space.</WaveFileMalformed>
<Import>Import...</Import>
<TextAndTimingInformation>Text and timing information</TextAndTimingInformation>
<JustificationCode>Justification code</JustificationCode>
<VerticalPosition>Vertical position</VerticalPosition>
<MarginTop>Margin top (for top aligned subtitles)</MarginTop>
<MarginBottom>Margin bottom (for bottom aligned subtitles)</MarginBottom>
<NewLineRows>Number of rows added by a new line</NewLineRows>
<Teletext>Teletext</Teletext>
<UseBox>Use box around text</UseBox>
<DoubleHeight>Use double height for text</DoubleHeight>

View File

@ -31,7 +31,7 @@
#endif
#define app_copyright "Copyright © 2001-2016, Nikse"
#define app_copyright "Copyright © 2001-2017, Nikse"
; If you don't define "localize", i.e. comment out the following line then no translations
; for SubtitleEdit or the installer itself will be included in the installer
#define localize

View File

@ -538,6 +538,10 @@ namespace Nikse.SubtitleEdit.Core
Import = "Import...",
TextAndTimingInformation = "Text and timing information",
JustificationCode = "Justification code",
VerticalPosition = "Vertical position",
MarginTop = "Margin top (for top aligned subtitles)",
MarginBottom = "Margin bottom (for bottom aligned subtitles)",
NewLineRows = "Number of rows added by a new line",
Teletext = "Teletext",
UseBox = "Use box around text",
DoubleHeight = "Use double height for text",

View File

@ -952,6 +952,18 @@ namespace Nikse.SubtitleEdit.Core
case "EbuSaveOptions/JustificationCode":
language.EbuSaveOptions.JustificationCode = reader.Value;
break;
case "EbuSaveOptions/VerticalPosition":
language.EbuSaveOptions.VerticalPosition = reader.Value;
break;
case "EbuSaveOptions/MarginTop":
language.EbuSaveOptions.MarginTop = reader.Value;
break;
case "EbuSaveOptions/MarginBottom":
language.EbuSaveOptions.MarginBottom = reader.Value;
break;
case "EbuSaveOptions/NewLineRows":
language.EbuSaveOptions.NewLineRows = reader.Value;
break;
case "EbuSaveOptions/Teletext":
language.EbuSaveOptions.Teletext = reader.Value;
break;

View File

@ -413,6 +413,10 @@
public string Import { get; set; }
public string TextAndTimingInformation { get; set; }
public string JustificationCode { get; set; }
public string VerticalPosition { get; set; }
public string MarginTop { get; set; }
public string MarginBottom { get; set; }
public string NewLineRows { get; set; }
public string Teletext { get; set; }
public string UseBox { get; set; }
public string DoubleHeight { get; set; }

View File

@ -7,7 +7,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Nikse")]
[assembly: AssemblyProduct("libse")]
[assembly: AssemblyCopyright("Copyright 2001-2016, Nikse")]
[assembly: AssemblyCopyright("Copyright 2001-2017, Nikse")]
[assembly: AssemblyTrademark("Licensed under the GPL v3")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]

View File

@ -319,6 +319,11 @@ namespace Nikse.SubtitleEdit.Core
public bool EbuStlTeletextUseBox { get; set; }
public bool EbuStlTeletextUseDoubleHeight { get; set; }
public int EbuStlMarginTop { get; set; }
public int EbuStlMarginBottom { get; set; }
public int EbuStlNewLineRows { get; set; }
public bool CheetahCaptionAlwayWriteEndTime { get; set; }
@ -356,6 +361,9 @@ namespace Nikse.SubtitleEdit.Core
EbuStlTeletextUseBox = true;
EbuStlTeletextUseDoubleHeight = true;
EbuStlMarginTop = 0;
EbuStlMarginBottom = 2;
EbuStlNewLineRows = 2;
SamiDisplayTwoClassesAsTwoSubtitles = true;
SamiHtmlEncodeMode = 0;
@ -509,6 +517,7 @@ namespace Nikse.SubtitleEdit.Core
public string DefaultSubtitleFormat { get; set; }
public string DefaultEncoding { get; set; }
public bool AutoConvertToUtf8 { get; set; }
public bool WriteUtf8Bom { get; set; }
public bool AutoGuessAnsiEncoding { get; set; }
public string SubtitleFontName { get; set; }
public int SubtitleFontSize { get; set; }
@ -632,6 +641,7 @@ namespace Nikse.SubtitleEdit.Core
DefaultSubtitleFormat = "SubRip";
DefaultEncoding = Encoding.UTF8.WebName;
AutoConvertToUtf8 = false;
WriteUtf8Bom = true;
AutoGuessAnsiEncoding = false;
ShowRecentFiles = true;
RememberSelectedLine = true;
@ -1406,6 +1416,9 @@ namespace Nikse.SubtitleEdit.Core
subNode = node.SelectSingleNode("AutoConvertToUtf8");
if (subNode != null)
settings.General.AutoConvertToUtf8 = Convert.ToBoolean(subNode.InnerText);
subNode = node.SelectSingleNode("WriteUtf8Bom");
if (subNode != null)
settings.General.WriteUtf8Bom = Convert.ToBoolean(subNode.InnerText);
subNode = node.SelectSingleNode("AutoGuessAnsiEncoding");
if (subNode != null)
settings.General.AutoGuessAnsiEncoding = Convert.ToBoolean(subNode.InnerText);
@ -2090,6 +2103,15 @@ namespace Nikse.SubtitleEdit.Core
subNode = node.SelectSingleNode("EbuStlTeletextUseDoubleHeight");
if (subNode != null)
settings.SubtitleSettings.EbuStlTeletextUseDoubleHeight = Convert.ToBoolean(subNode.InnerText);
subNode = node.SelectSingleNode("EbuStlMarginTop");
if (subNode != null)
settings.SubtitleSettings.EbuStlMarginTop = Convert.ToInt32(subNode.InnerText);
subNode = node.SelectSingleNode("EbuStlMarginBottom");
if (subNode != null)
settings.SubtitleSettings.EbuStlMarginBottom = Convert.ToInt32(subNode.InnerText);
subNode = node.SelectSingleNode("EbuStlNewLineRows");
if (subNode != null)
settings.SubtitleSettings.EbuStlNewLineRows = Convert.ToInt32(subNode.InnerText);
subNode = node.SelectSingleNode("CheetahCaptionAlwayWriteEndTime");
if (subNode != null)
settings.SubtitleSettings.CheetahCaptionAlwayWriteEndTime = Convert.ToBoolean(subNode.InnerText);
@ -3070,6 +3092,7 @@ namespace Nikse.SubtitleEdit.Core
textWriter.WriteElementString("DefaultSubtitleFormat", settings.General.DefaultSubtitleFormat);
textWriter.WriteElementString("DefaultEncoding", settings.General.DefaultEncoding);
textWriter.WriteElementString("AutoConvertToUtf8", settings.General.AutoConvertToUtf8.ToString());
textWriter.WriteElementString("WriteUtf8Bom", settings.General.WriteUtf8Bom.ToString());
textWriter.WriteElementString("AutoGuessAnsiEncoding", settings.General.AutoGuessAnsiEncoding.ToString());
textWriter.WriteElementString("_subtitleFontName", settings.General.SubtitleFontName);
textWriter.WriteElementString("SubtitleFontSize", settings.General.SubtitleFontSize.ToString(CultureInfo.InvariantCulture));
@ -3314,6 +3337,9 @@ namespace Nikse.SubtitleEdit.Core
textWriter.WriteElementString("Cavena890StartOfMessage", settings.SubtitleSettings.Cavena890StartOfMessage);
textWriter.WriteElementString("EbuStlTeletextUseBox", settings.SubtitleSettings.EbuStlTeletextUseBox.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("EbuStlTeletextUseDoubleHeight", settings.SubtitleSettings.EbuStlTeletextUseDoubleHeight.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("EbuStlMarginTop", settings.SubtitleSettings.EbuStlMarginTop.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("EbuStlMarginBottom", settings.SubtitleSettings.EbuStlMarginBottom.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("EbuStlNewLineRows", settings.SubtitleSettings.EbuStlNewLineRows.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("CheetahCaptionAlwayWriteEndTime", settings.SubtitleSettings.CheetahCaptionAlwayWriteEndTime.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("NuendoCharacterListFile", settings.SubtitleSettings.NuendoCharacterListFile);
textWriter.WriteEndElement();

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
@ -13,7 +14,8 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
/// </summary>
public class Ebu : SubtitleFormat, IBinaryPersistableSubtitle
{
private static readonly Regex FontTagsNoSpace1 = new Regex("[a-zA-z.!?]</font><font[a-zA-Z =\"']+>[a-zA-Z-]", RegexOptions.Compiled);
private static readonly Regex FontTagsNoSpace2 = new Regex("[a-zA-z.!?]<font[a-zA-Z =\"']+>[a-zA-Z-]", RegexOptions.Compiled);
private const string LanguageCodeChinese = "75";
public interface IEbuUiHelper
@ -320,55 +322,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
}
else // teletext
{
var lines = TextField.SplitToLines();
var sb = new StringBuilder();
string veryFirstColor = null;
foreach (string line in lines)
{
string firstColor = null;
string s = line;
var start = s.IndexOf("<font ", StringComparison.Ordinal);
if (start >= 0)
{
int end = s.IndexOf('>', start);
if (end > 0)
{
string f = s.Substring(start, end - start);
if (f.Contains(" color="))
{
var colorStart = f.IndexOf(" color=", StringComparison.Ordinal);
if (s.IndexOf('"', colorStart + " color=".Length + 1) > 0)
{
int colorEnd = f.IndexOf('"', colorStart + " color=".Length + 1);
if (colorStart > 1)
{
string color = f.Substring(colorStart + 7, colorEnd - (colorStart + 7));
color = color.Trim('\'');
color = color.Trim('\"');
color = color.Trim('#');
s = s.Remove(start, end - start + 1);
if (veryFirstColor == null)
veryFirstColor = GetNearestEbuColorCode(color, encoding);
firstColor = GetNearestEbuColorCode(color, encoding);
}
}
}
}
}
//byte colorByte = 0x07; // white
byte colorByte = 255;
if (!string.IsNullOrEmpty(veryFirstColor))
colorByte = encoding.GetBytes(veryFirstColor)[0];
if (!string.IsNullOrEmpty(firstColor))
colorByte = encoding.GetBytes(firstColor)[0];
string prefix = encoding.GetString(new byte[] { 0xd, colorByte, 0xb, 0xb });
if (colorByte != 255)
sb.Append(prefix);
sb.AppendLine(s);
}
TextField = HtmlUtil.RemoveHtmlTags(sb.ToString()).TrimEnd();
TextField = GetTextWithColors(TextField, encoding);
}
// newline
@ -444,6 +398,80 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
return buffer;
}
private static string GetTextWithColors(string text, Encoding encoding)
{
var sb = new StringBuilder();
string veryFirstColor = null;
foreach (string line in text.SplitToLines())
{
var textWithcolorCodes = new StringBuilder(line.Length);
string firstColor = null;
int i = 0;
while (i < line.Length)
{
if (line.Substring(i).StartsWith("<font ", StringComparison.Ordinal))
{
int end = line.IndexOf('>', i);
if (end > 0)
{
string f = line.Substring(i, end - i);
i = end + 1;
if (f.Contains(" color="))
{
var colorStart = f.IndexOf(" color=", StringComparison.Ordinal);
if (line.IndexOf('"', colorStart + " color=".Length + 1) > 0)
{
int colorEnd = f.IndexOf('"', colorStart + " color=".Length + 1);
if (colorStart > 1)
{
string color = f.Substring(colorStart + 7, colorEnd - (colorStart + 7));
color = color.Trim('\'');
color = color.Trim('\"');
color = color.Trim('#');
var nearestColor = GetNearestEbuColorCode(color, encoding);
if (nearestColor != string.Empty)
{
if (firstColor != null || textWithcolorCodes.ToString().Trim().Length > 0)
{
textWithcolorCodes.Append(nearestColor);
}
else
{
if (veryFirstColor == null)
veryFirstColor = nearestColor;
firstColor = nearestColor;
}
}
}
}
}
}
else
{
i++;
}
}
else
{
textWithcolorCodes.Append(line[i]);
i++;
}
}
byte colorByte = 255;
if (!string.IsNullOrEmpty(veryFirstColor))
colorByte = encoding.GetBytes(veryFirstColor)[0];
if (!string.IsNullOrEmpty(firstColor))
colorByte = encoding.GetBytes(firstColor)[0];
string prefix = encoding.GetString(new byte[] { 0xd, colorByte, 0xb, 0xb });
if (colorByte != 255)
sb.Append(prefix);
sb.AppendLine(textWithcolorCodes.ToString());
}
return HtmlUtil.RemoveHtmlTags(sb.ToString()).TrimEnd();
}
private static string GetNearestEbuColorCode(string color, Encoding encoding)
{
color = color.ToLower();
@ -468,9 +496,9 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
if (RegExpr.IsMatch(color))
{
const int maxDiff = 130;
int r = int.Parse(color.Substring(0, 2), System.Globalization.NumberStyles.HexNumber);
int g = int.Parse(color.Substring(2, 2), System.Globalization.NumberStyles.HexNumber);
int b = int.Parse(color.Substring(4, 2), System.Globalization.NumberStyles.HexNumber);
int r = int.Parse(color.Substring(0, 2), NumberStyles.HexNumber);
int g = int.Parse(color.Substring(2, 2), NumberStyles.HexNumber);
int b = int.Parse(color.Substring(4, 2), NumberStyles.HexNumber);
if (r < maxDiff && g < maxDiff && b < maxDiff)
return encoding.GetString(new byte[] { 0x00 }); // black
if (r > 255 - maxDiff && g < maxDiff && b < maxDiff)
@ -571,7 +599,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
header.TotalNumberOfSubtitles = subtitle.Paragraphs.Count.ToString("D5"); // seems to be 1 higher than actual number of subtitles
header.TotalNumberOfTextAndTimingInformationBlocks = header.TotalNumberOfSubtitles;
var today = string.Format("{0:yyMMdd}", DateTime.Now);
var today = $"{DateTime.Now:yyMMdd}";
if (today.Length == 6)
{
header.CreationDate = today;
@ -582,7 +610,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
if (firstParagraph != null)
{
var tc = firstParagraph.StartTime;
string firstTimeCode = string.Format("{0:00}{1:00}{2:00}{3:00}", tc.Hours, tc.Minutes, tc.Seconds, EbuTextTimingInformation.GetFrameFromMilliseconds(tc.Milliseconds, header.FrameRate));
string firstTimeCode = $"{tc.Hours:00}{tc.Minutes:00}{tc.Seconds:00}{EbuTextTimingInformation.GetFrameFromMilliseconds(tc.Milliseconds, header.FrameRate):00}";
if (firstTimeCode.Length == 8)
header.TimeCodeFirstInCue = firstTimeCode;
}
@ -607,7 +635,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
var text = p.Text.Trim(Utilities.NewLineChars);
if (text.StartsWith("{\\an7}", StringComparison.Ordinal) || text.StartsWith("{\\an8}", StringComparison.Ordinal) || text.StartsWith("{\\an9}", StringComparison.Ordinal))
{
tti.VerticalPosition = 1; // top (vertical)
tti.VerticalPosition = (byte)(1 + Configuration.Settings.SubtitleSettings.EbuStlMarginTop); // top (vertical)
}
else if (text.StartsWith("{\\an4}", StringComparison.Ordinal) || text.StartsWith("{\\an5}", StringComparison.Ordinal) || text.StartsWith("{\\an6}", StringComparison.Ordinal))
{
@ -615,7 +643,8 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
}
else
{
int startRow = (rows - 1) - Utilities.CountTagInText(text, Environment.NewLine) * 2;
int startRow = rows - Configuration.Settings.SubtitleSettings.EbuStlMarginBottom -
(Utilities.GetNumberOfLines(text) - 1) * Configuration.Settings.SubtitleSettings.EbuStlNewLineRows;
if (startRow < 0)
startRow = 0;
tti.VerticalPosition = (byte)startRow; // bottom (vertical)
@ -718,10 +747,13 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
{
if (tti.ExtensionBlockNumber != 0xfe) // FEh : Reserved for User Data
{
var p = new Paragraph();
p.Text = tti.TextField;
p.StartTime = new TimeCode(tti.TimeCodeInHours, tti.TimeCodeInMinutes, tti.TimeCodeInSeconds, tti.TimeCodeInMilliseconds);
p.EndTime = new TimeCode(tti.TimeCodeOutHours, tti.TimeCodeOutMinutes, tti.TimeCodeOutSeconds, tti.TimeCodeOutMilliseconds);
var p = new Paragraph
{
Text = tti.TextField,
StartTime = new TimeCode(tti.TimeCodeInHours, tti.TimeCodeInMinutes, tti.TimeCodeInSeconds, tti.TimeCodeInMilliseconds),
EndTime = new TimeCode(tti.TimeCodeOutHours, tti.TimeCodeOutMinutes, tti.TimeCodeOutSeconds, tti.TimeCodeOutMilliseconds),
MarginV = tti.VerticalPosition.ToString(CultureInfo.InvariantCulture)
};
if (lastExtensionBlockNumber != 0xff && last != null)
{
@ -742,33 +774,34 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
public static EbuGeneralSubtitleInformation ReadHeader(byte[] buffer)
{
var header = new EbuGeneralSubtitleInformation();
header.CodePageNumber = Encoding.Default.GetString(buffer, 0, 3);
header.DiskFormatCode = Encoding.Default.GetString(buffer, 3, 8);
header.DisplayStandardCode = Encoding.Default.GetString(buffer, 11, 1);
header.CharacterCodeTableNumber = Encoding.Default.GetString(buffer, 12, 2);
header.LanguageCode = Encoding.Default.GetString(buffer, 14, 2);
header.OriginalProgrammeTitle = Encoding.Default.GetString(buffer, 16, 32);
header.OriginalEpisodeTitle = Encoding.Default.GetString(buffer, 48, 32);
header.TranslatedProgrammeTitle = Encoding.Default.GetString(buffer, 80, 32);
header.TranslatedEpisodeTitle = Encoding.Default.GetString(buffer, 112, 32);
header.TranslatorsName = Encoding.Default.GetString(buffer, 144, 32);
header.TranslatorsContactDetails = Encoding.Default.GetString(buffer, 176, 32);
header.SubtitleListReferenceCode = Encoding.Default.GetString(buffer, 208, 16);
header.CreationDate = Encoding.Default.GetString(buffer, 224, 6);
header.RevisionDate = Encoding.Default.GetString(buffer, 230, 6);
header.RevisionNumber = Encoding.Default.GetString(buffer, 236, 2);
header.TotalNumberOfTextAndTimingInformationBlocks = Encoding.Default.GetString(buffer, 238, 5);
header.TotalNumberOfSubtitles = Encoding.Default.GetString(buffer, 243, 5);
header.TotalNumberOfSubtitleGroups = Encoding.Default.GetString(buffer, 248, 3);
header.MaximumNumberOfDisplayableCharactersInAnyTextRow = Encoding.Default.GetString(buffer, 251, 2);
header.MaximumNumberOfDisplayableRows = Encoding.Default.GetString(buffer, 253, 2);
header.TimeCodeStatus = Encoding.Default.GetString(buffer, 255, 1);
header.TimeCodeStartOfProgramme = Encoding.Default.GetString(buffer, 256, 8);
header.CountryOfOrigin = Encoding.Default.GetString(buffer, 274, 3);
header.SpareBytes = Encoding.Default.GetString(buffer, 373, 75);
header.UserDefinedArea = Encoding.Default.GetString(buffer, 448, 576);
var header = new EbuGeneralSubtitleInformation
{
CodePageNumber = Encoding.Default.GetString(buffer, 0, 3),
DiskFormatCode = Encoding.Default.GetString(buffer, 3, 8),
DisplayStandardCode = Encoding.Default.GetString(buffer, 11, 1),
CharacterCodeTableNumber = Encoding.Default.GetString(buffer, 12, 2),
LanguageCode = Encoding.Default.GetString(buffer, 14, 2),
OriginalProgrammeTitle = Encoding.Default.GetString(buffer, 16, 32),
OriginalEpisodeTitle = Encoding.Default.GetString(buffer, 48, 32),
TranslatedProgrammeTitle = Encoding.Default.GetString(buffer, 80, 32),
TranslatedEpisodeTitle = Encoding.Default.GetString(buffer, 112, 32),
TranslatorsName = Encoding.Default.GetString(buffer, 144, 32),
TranslatorsContactDetails = Encoding.Default.GetString(buffer, 176, 32),
SubtitleListReferenceCode = Encoding.Default.GetString(buffer, 208, 16),
CreationDate = Encoding.Default.GetString(buffer, 224, 6),
RevisionDate = Encoding.Default.GetString(buffer, 230, 6),
RevisionNumber = Encoding.Default.GetString(buffer, 236, 2),
TotalNumberOfTextAndTimingInformationBlocks = Encoding.Default.GetString(buffer, 238, 5),
TotalNumberOfSubtitles = Encoding.Default.GetString(buffer, 243, 5),
TotalNumberOfSubtitleGroups = Encoding.Default.GetString(buffer, 248, 3),
MaximumNumberOfDisplayableCharactersInAnyTextRow = Encoding.Default.GetString(buffer, 251, 2),
MaximumNumberOfDisplayableRows = Encoding.Default.GetString(buffer, 253, 2),
TimeCodeStatus = Encoding.Default.GetString(buffer, 255, 1),
TimeCodeStartOfProgramme = Encoding.Default.GetString(buffer, 256, 8),
CountryOfOrigin = Encoding.Default.GetString(buffer, 274, 3),
SpareBytes = Encoding.Default.GetString(buffer, 373, 75),
UserDefinedArea = Encoding.Default.GetString(buffer, 448, 576)
};
return header;
}
@ -1073,28 +1106,26 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
int index = startOfTextAndTimingBlock;
while (index + ttiSize <= buffer.Length)
{
var tti = new EbuTextTimingInformation();
tti.SubtitleGroupNumber = buffer[index];
tti.SubtitleNumber = (ushort)(buffer[index + 2] * 256 + buffer[index + 1]);
tti.ExtensionBlockNumber = buffer[index + 3];
tti.CumulativeStatus = buffer[index + 4];
tti.TimeCodeInHours = buffer[index + 5 + 0];
tti.TimeCodeInMinutes = buffer[index + 5 + 1];
tti.TimeCodeInSeconds = buffer[index + 5 + 2];
tti.TimeCodeInMilliseconds = FramesToMillisecondsMax999(buffer[index + 5 + 3]);
tti.TimeCodeOutHours = buffer[index + 9 + 0];
tti.TimeCodeOutMinutes = buffer[index + 9 + 1];
tti.TimeCodeOutSeconds = buffer[index + 9 + 2];
tti.TimeCodeOutMilliseconds = FramesToMillisecondsMax999(buffer[index + 9 + 3]);
tti.VerticalPosition = buffer[index + 13];
var tti = new EbuTextTimingInformation
{
SubtitleGroupNumber = buffer[index],
SubtitleNumber = (ushort)(buffer[index + 2] * 256 + buffer[index + 1]),
ExtensionBlockNumber = buffer[index + 3],
CumulativeStatus = buffer[index + 4],
TimeCodeInHours = buffer[index + 5 + 0],
TimeCodeInMinutes = buffer[index + 5 + 1],
TimeCodeInSeconds = buffer[index + 5 + 2],
TimeCodeInMilliseconds = FramesToMillisecondsMax999(buffer[index + 5 + 3]),
TimeCodeOutHours = buffer[index + 9 + 0],
TimeCodeOutMinutes = buffer[index + 9 + 1],
TimeCodeOutSeconds = buffer[index + 9 + 2],
TimeCodeOutMilliseconds = FramesToMillisecondsMax999(buffer[index + 9 + 3]),
VerticalPosition = buffer[index + 13],
JustificationCode = buffer[index + 14],
CommentFlag = buffer[index + 15]
};
VerticalPositions.Add(tti.VerticalPosition);
tti.JustificationCode = buffer[index + 14];
JustificationCodes.Add(tti.JustificationCode);
tti.CommentFlag = buffer[index + 15];
// build text
bool skipNext = false;
@ -1221,7 +1252,8 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
}
}
}
tti.TextField = sb.ToString().Replace(Environment.NewLine + Environment.NewLine, Environment.NewLine).TrimEnd() + endTags;
var text = sb.ToString().Replace(Environment.NewLine + Environment.NewLine, Environment.NewLine).TrimEnd() + endTags;
tti.TextField = FixMissingSpacesBetweenFontTags(text);
int rows;
if (!int.TryParse(header.MaximumNumberOfDisplayableRows, out rows))
@ -1257,14 +1289,27 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
return list;
}
public override bool IsTextBased
private string FixMissingSpacesBetweenFontTags(string text)
{
get
var match = FontTagsNoSpace1.Match(text);
while (match.Success)
{
return false;
text = text.Remove(match.Index, match.Length).Insert(match.Index, match.Value.Replace("</font><font", "</font> <font"));
match = FontTagsNoSpace1.Match(text);
}
match = FontTagsNoSpace2.Match(text);
while (match.Success)
{
text = text.Remove(match.Index, match.Length).Insert(match.Index, match.Value.Replace("<font", " <font"));
match = FontTagsNoSpace2.Match(text);
}
return text;
}
public override bool IsTextBased => false;
public bool Save(string fileName, Stream stream, Subtitle subtitle, bool batchMode)
{
return Save(fileName, stream, subtitle, batchMode, null);

View File

@ -302,7 +302,10 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
foreach (Paragraph p in subtitle.Paragraphs)
{
if (p.StartTime.Milliseconds > 30 || p.EndTime.Milliseconds > 30)
{
all30OrBelow = false;
break;
}
}
if (all30OrBelow)
{

View File

@ -457,6 +457,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
region = "topCenter";
}
text = Utilities.RemoveSsaTags(text);
text = HtmlUtil.FixInvalidItalicTags(text);
// Trying to parse and convert pararagraph content
try

View File

@ -87,7 +87,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
}
else
{
p = new Paragraph(DecodeTimeCodeFramesTwoParts(parts1), DecodeTimeCodeFramesTwoParts(parts2), string.Empty);
p = new Paragraph(DecodeTimeCodeFramesTwoParts(new[] { parts1[0], parts1[1] }), DecodeTimeCodeFramesTwoParts(new[] { parts2[0], parts2[1] }), string.Empty);
}
}
}

View File

@ -396,17 +396,20 @@ namespace Nikse.SubtitleEdit.Controls
private class IsSelectedHelper
{
private readonly List<SelectionRange> _ranges = new List<SelectionRange>();
private readonly SelectionRange[] _ranges;
private int _lastPosition = int.MaxValue;
private SelectionRange _nextSelection;
public IsSelectedHelper(IEnumerable<Paragraph> paragraphs, int sampleRate)
public IsSelectedHelper(List<Paragraph> paragraphs, int sampleRate)
{
foreach (Paragraph p in paragraphs)
var count = paragraphs.Count;
_ranges = new SelectionRange[count];
for (int index = 0; index < count; index++)
{
Paragraph p = paragraphs[index];
int start = (int)Math.Round(p.StartTime.TotalSeconds * sampleRate);
int end = (int)Math.Round(p.EndTime.TotalSeconds * sampleRate);
_ranges.Add(new SelectionRange(start, end));
_ranges[index] = new SelectionRange(start, end);
}
}
@ -423,8 +426,9 @@ namespace Nikse.SubtitleEdit.Controls
private void FindNextSelection(int position)
{
_nextSelection = new SelectionRange(int.MaxValue, int.MaxValue);
foreach (SelectionRange range in _ranges)
for (int index = 0; index < _ranges.Length; index++)
{
SelectionRange range = _ranges[index];
if (range.End >= position && (range.Start < _nextSelection.Start || (range.Start == _nextSelection.Start && range.End > _nextSelection.End)))
_nextSelection = range;
}

View File

@ -887,6 +887,7 @@ namespace Nikse.SubtitleEdit.Forms
}
catch
{
// ignored
}
System.Threading.Thread.Sleep(100);
}
@ -1117,8 +1118,6 @@ namespace Nikse.SubtitleEdit.Forms
buttonStyles.Visible = false;
comboBoxEncoding.Enabled = true;
}
_assStyle = null;
_ssaStyle = null;
}
private void ButtonStylesClick(object sender, EventArgs e)
@ -1241,10 +1240,7 @@ namespace Nikse.SubtitleEdit.Forms
}
finally
{
if (form != null)
{
form.Dispose();
}
form?.Dispose();
}
}
@ -1489,6 +1485,7 @@ namespace Nikse.SubtitleEdit.Forms
}
catch
{
// ignored
}
}
if (checkBoxScanFolderRecursive.Checked)

167
src/Forms/EbuColorPicker.Designer.cs generated Normal file
View File

@ -0,0 +1,167 @@
namespace Nikse.SubtitleEdit.Forms
{
sealed partial class EbuColorPicker
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.buttonBlack = new System.Windows.Forms.Button();
this.buttonRed = new System.Windows.Forms.Button();
this.buttonGreen = new System.Windows.Forms.Button();
this.buttonYellow = new System.Windows.Forms.Button();
this.buttonBlue = new System.Windows.Forms.Button();
this.buttonMagenta = new System.Windows.Forms.Button();
this.buttonCyan = new System.Windows.Forms.Button();
this.buttonWhite = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// buttonBlack
//
this.buttonBlack.BackColor = System.Drawing.Color.Black;
this.buttonBlack.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonBlack.Location = new System.Drawing.Point(12, 12);
this.buttonBlack.Name = "buttonBlack";
this.buttonBlack.Size = new System.Drawing.Size(216, 30);
this.buttonBlack.TabIndex = 0;
this.buttonBlack.UseVisualStyleBackColor = false;
this.buttonBlack.Click += new System.EventHandler(this.buttonBlack_Click);
//
// buttonRed
//
this.buttonRed.BackColor = System.Drawing.Color.Red;
this.buttonRed.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonRed.Location = new System.Drawing.Point(12, 48);
this.buttonRed.Name = "buttonRed";
this.buttonRed.Size = new System.Drawing.Size(216, 30);
this.buttonRed.TabIndex = 1;
this.buttonRed.UseVisualStyleBackColor = false;
this.buttonRed.Click += new System.EventHandler(this.buttonRed_Click);
//
// buttonGreen
//
this.buttonGreen.BackColor = System.Drawing.Color.Green;
this.buttonGreen.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonGreen.Location = new System.Drawing.Point(12, 84);
this.buttonGreen.Name = "buttonGreen";
this.buttonGreen.Size = new System.Drawing.Size(216, 30);
this.buttonGreen.TabIndex = 2;
this.buttonGreen.UseVisualStyleBackColor = false;
this.buttonGreen.Click += new System.EventHandler(this.buttonGreen_Click);
//
// buttonYellow
//
this.buttonYellow.BackColor = System.Drawing.Color.Yellow;
this.buttonYellow.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonYellow.Location = new System.Drawing.Point(12, 120);
this.buttonYellow.Name = "buttonYellow";
this.buttonYellow.Size = new System.Drawing.Size(216, 30);
this.buttonYellow.TabIndex = 3;
this.buttonYellow.UseVisualStyleBackColor = false;
this.buttonYellow.Click += new System.EventHandler(this.buttonYellow_Click);
//
// buttonBlue
//
this.buttonBlue.BackColor = System.Drawing.Color.Blue;
this.buttonBlue.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonBlue.Location = new System.Drawing.Point(12, 156);
this.buttonBlue.Name = "buttonBlue";
this.buttonBlue.Size = new System.Drawing.Size(216, 30);
this.buttonBlue.TabIndex = 4;
this.buttonBlue.UseVisualStyleBackColor = false;
this.buttonBlue.Click += new System.EventHandler(this.buttonBlue_Click);
//
// buttonMagenta
//
this.buttonMagenta.BackColor = System.Drawing.Color.Magenta;
this.buttonMagenta.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonMagenta.Location = new System.Drawing.Point(12, 192);
this.buttonMagenta.Name = "buttonMagenta";
this.buttonMagenta.Size = new System.Drawing.Size(216, 30);
this.buttonMagenta.TabIndex = 5;
this.buttonMagenta.UseVisualStyleBackColor = false;
this.buttonMagenta.Click += new System.EventHandler(this.buttonMagenta_Click);
//
// buttonCyan
//
this.buttonCyan.BackColor = System.Drawing.Color.Cyan;
this.buttonCyan.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonCyan.Location = new System.Drawing.Point(12, 228);
this.buttonCyan.Name = "buttonCyan";
this.buttonCyan.Size = new System.Drawing.Size(216, 30);
this.buttonCyan.TabIndex = 6;
this.buttonCyan.UseVisualStyleBackColor = false;
this.buttonCyan.Click += new System.EventHandler(this.buttonCyan_Click);
//
// buttonWhite
//
this.buttonWhite.BackColor = System.Drawing.Color.White;
this.buttonWhite.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonWhite.Location = new System.Drawing.Point(12, 264);
this.buttonWhite.Name = "buttonWhite";
this.buttonWhite.Size = new System.Drawing.Size(216, 30);
this.buttonWhite.TabIndex = 7;
this.buttonWhite.UseVisualStyleBackColor = false;
this.buttonWhite.Click += new System.EventHandler(this.buttonWhite_Click);
//
// EbuColorPicker
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(243, 312);
this.Controls.Add(this.buttonWhite);
this.Controls.Add(this.buttonCyan);
this.Controls.Add(this.buttonMagenta);
this.Controls.Add(this.buttonBlue);
this.Controls.Add(this.buttonYellow);
this.Controls.Add(this.buttonGreen);
this.Controls.Add(this.buttonRed);
this.Controls.Add(this.buttonBlack);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.KeyPreview = true;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "EbuColorPicker";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "EbuColorPicker";
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.EbuColorPicker_KeyDown);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button buttonBlack;
private System.Windows.Forms.Button buttonRed;
private System.Windows.Forms.Button buttonGreen;
private System.Windows.Forms.Button buttonYellow;
private System.Windows.Forms.Button buttonBlue;
private System.Windows.Forms.Button buttonMagenta;
private System.Windows.Forms.Button buttonCyan;
private System.Windows.Forms.Button buttonWhite;
}
}

View File

@ -0,0 +1,75 @@
using System;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Core;
namespace Nikse.SubtitleEdit.Forms
{
public sealed partial class EbuColorPicker : Form
{
public string Color { get; private set; }
public EbuColorPicker()
{
InitializeComponent();
Text = Configuration.Settings.Language.ColorChooser.Title;
}
private void EbuColorPicker_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape)
{
DialogResult = DialogResult.Cancel;
}
}
private void buttonBlack_Click(object sender, EventArgs e)
{
Color = "Black";
DialogResult = DialogResult.OK;
}
private void buttonRed_Click(object sender, EventArgs e)
{
Color = "Red";
DialogResult = DialogResult.OK;
}
private void buttonGreen_Click(object sender, EventArgs e)
{
Color = "Green";
DialogResult = DialogResult.OK;
}
private void buttonYellow_Click(object sender, EventArgs e)
{
Color = "Yellow";
DialogResult = DialogResult.OK;
}
private void buttonBlue_Click(object sender, EventArgs e)
{
Color = "Blue";
DialogResult = DialogResult.OK;
}
private void buttonMagenta_Click(object sender, EventArgs e)
{
Color = "Magenta";
DialogResult = DialogResult.OK;
}
private void buttonCyan_Click(object sender, EventArgs e)
{
Color = "Cyan";
DialogResult = DialogResult.OK;
}
private void buttonWhite_Click(object sender, EventArgs e)
{
Color = "White";
DialogResult = DialogResult.OK;
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -29,6 +29,7 @@
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
Nikse.SubtitleEdit.Core.TimeCode timeCode2 = new Nikse.SubtitleEdit.Core.TimeCode();
this.buttonOK = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
@ -82,6 +83,13 @@
this.textBoxOriginalProgramTitle = new System.Windows.Forms.TextBox();
this.labelOriginalProgramTitle = new System.Windows.Forms.Label();
this.tabPageTextAndTiming = new System.Windows.Forms.TabPage();
this.groupBoxVerticalPosition = new System.Windows.Forms.GroupBox();
this.numericUpDownNewLineRows = new System.Windows.Forms.NumericUpDown();
this.labelNewLineRows = new System.Windows.Forms.Label();
this.numericUpDownMarginBottom = new System.Windows.Forms.NumericUpDown();
this.labelMarginBottom = new System.Windows.Forms.Label();
this.numericUpDownMarginTop = new System.Windows.Forms.NumericUpDown();
this.labelMarginTop = new System.Windows.Forms.Label();
this.groupBoxTeletext = new System.Windows.Forms.GroupBox();
this.checkBoxTeletextDoubleHeight = new System.Windows.Forms.CheckBox();
this.checkBoxTeletextBox = new System.Windows.Forms.CheckBox();
@ -99,6 +107,10 @@
((System.ComponentModel.ISupportInitialize)(this.numericUpDownTotalNumberOfDiscs)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownRevisionNumber)).BeginInit();
this.tabPageTextAndTiming.SuspendLayout();
this.groupBoxVerticalPosition.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownNewLineRows)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownMarginBottom)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownMarginTop)).BeginInit();
this.groupBoxTeletext.SuspendLayout();
this.tabPageErrors.SuspendLayout();
this.SuspendLayout();
@ -253,6 +265,15 @@
this.timeUpDownStartTime.Name = "timeUpDownStartTime";
this.timeUpDownStartTime.Size = new System.Drawing.Size(96, 24);
this.timeUpDownStartTime.TabIndex = 14;
timeCode2.Hours = 99;
timeCode2.Milliseconds = 999;
timeCode2.Minutes = 59;
timeCode2.Seconds = 59;
timeCode2.TimeSpan = System.TimeSpan.Parse("4.03:59:59.9990000");
timeCode2.TotalMilliseconds = 359999999D;
timeCode2.TotalSeconds = 359999.999D;
this.timeUpDownStartTime.TimeCode = timeCode2;
this.timeUpDownStartTime.UseVideoOffset = false;
//
// comboBoxDisplayStandardCode
//
@ -646,6 +667,7 @@
//
// tabPageTextAndTiming
//
this.tabPageTextAndTiming.Controls.Add(this.groupBoxVerticalPosition);
this.tabPageTextAndTiming.Controls.Add(this.groupBoxTeletext);
this.tabPageTextAndTiming.Controls.Add(this.comboBoxJustificationCode);
this.tabPageTextAndTiming.Controls.Add(this.labelJustificationCode);
@ -656,6 +678,92 @@
this.tabPageTextAndTiming.Text = "Text and timing information";
this.tabPageTextAndTiming.UseVisualStyleBackColor = true;
//
// groupBoxVerticalPosition
//
this.groupBoxVerticalPosition.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBoxVerticalPosition.Controls.Add(this.numericUpDownNewLineRows);
this.groupBoxVerticalPosition.Controls.Add(this.labelNewLineRows);
this.groupBoxVerticalPosition.Controls.Add(this.labelMarginTop);
this.groupBoxVerticalPosition.Controls.Add(this.numericUpDownMarginBottom);
this.groupBoxVerticalPosition.Controls.Add(this.numericUpDownMarginTop);
this.groupBoxVerticalPosition.Controls.Add(this.labelMarginBottom);
this.groupBoxVerticalPosition.Location = new System.Drawing.Point(9, 49);
this.groupBoxVerticalPosition.Name = "groupBoxVerticalPosition";
this.groupBoxVerticalPosition.Size = new System.Drawing.Size(727, 201);
this.groupBoxVerticalPosition.TabIndex = 46;
this.groupBoxVerticalPosition.TabStop = false;
this.groupBoxVerticalPosition.Text = "Vertical position";
//
// numericUpDownNewLineRows
//
this.numericUpDownNewLineRows.Location = new System.Drawing.Point(256, 78);
this.numericUpDownNewLineRows.Maximum = new decimal(new int[] {
10,
0,
0,
0});
this.numericUpDownNewLineRows.Name = "numericUpDownNewLineRows";
this.numericUpDownNewLineRows.Size = new System.Drawing.Size(56, 20);
this.numericUpDownNewLineRows.TabIndex = 54;
this.numericUpDownNewLineRows.Value = new decimal(new int[] {
2,
0,
0,
0});
//
// labelNewLineRows
//
this.labelNewLineRows.AutoSize = true;
this.labelNewLineRows.Location = new System.Drawing.Point(13, 80);
this.labelNewLineRows.Name = "labelNewLineRows";
this.labelNewLineRows.Size = new System.Drawing.Size(179, 13);
this.labelNewLineRows.TabIndex = 53;
this.labelNewLineRows.Text = "Number of rows added by a new line";
//
// numericUpDownMarginBottom
//
this.numericUpDownMarginBottom.Location = new System.Drawing.Point(256, 52);
this.numericUpDownMarginBottom.Maximum = new decimal(new int[] {
50,
0,
0,
0});
this.numericUpDownMarginBottom.Name = "numericUpDownMarginBottom";
this.numericUpDownMarginBottom.Size = new System.Drawing.Size(56, 20);
this.numericUpDownMarginBottom.TabIndex = 52;
//
// labelMarginBottom
//
this.labelMarginBottom.AutoSize = true;
this.labelMarginBottom.Location = new System.Drawing.Point(13, 54);
this.labelMarginBottom.Name = "labelMarginBottom";
this.labelMarginBottom.Size = new System.Drawing.Size(208, 13);
this.labelMarginBottom.TabIndex = 51;
this.labelMarginBottom.Text = "Margin bottom (for bottom aligned subtitles)";
//
// numericUpDownMarginTop
//
this.numericUpDownMarginTop.Location = new System.Drawing.Point(256, 26);
this.numericUpDownMarginTop.Maximum = new decimal(new int[] {
50,
0,
0,
0});
this.numericUpDownMarginTop.Name = "numericUpDownMarginTop";
this.numericUpDownMarginTop.Size = new System.Drawing.Size(56, 20);
this.numericUpDownMarginTop.TabIndex = 48;
//
// labelMarginTop
//
this.labelMarginTop.AutoSize = true;
this.labelMarginTop.Location = new System.Drawing.Point(13, 28);
this.labelMarginTop.Name = "labelMarginTop";
this.labelMarginTop.Size = new System.Drawing.Size(174, 13);
this.labelMarginTop.TabIndex = 49;
this.labelMarginTop.Text = "Margin top (for top aligned subtitles)";
//
// groupBoxTeletext
//
this.groupBoxTeletext.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
@ -663,9 +771,9 @@
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBoxTeletext.Controls.Add(this.checkBoxTeletextDoubleHeight);
this.groupBoxTeletext.Controls.Add(this.checkBoxTeletextBox);
this.groupBoxTeletext.Location = new System.Drawing.Point(9, 54);
this.groupBoxTeletext.Location = new System.Drawing.Point(9, 256);
this.groupBoxTeletext.Name = "groupBoxTeletext";
this.groupBoxTeletext.Size = new System.Drawing.Size(727, 392);
this.groupBoxTeletext.Size = new System.Drawing.Size(727, 190);
this.groupBoxTeletext.TabIndex = 45;
this.groupBoxTeletext.TabStop = false;
this.groupBoxTeletext.Text = "Teletext";
@ -772,6 +880,11 @@
((System.ComponentModel.ISupportInitialize)(this.numericUpDownRevisionNumber)).EndInit();
this.tabPageTextAndTiming.ResumeLayout(false);
this.tabPageTextAndTiming.PerformLayout();
this.groupBoxVerticalPosition.ResumeLayout(false);
this.groupBoxVerticalPosition.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownNewLineRows)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownMarginBottom)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownMarginTop)).EndInit();
this.groupBoxTeletext.ResumeLayout(false);
this.groupBoxTeletext.PerformLayout();
this.tabPageErrors.ResumeLayout(false);
@ -843,5 +956,12 @@
private System.Windows.Forms.GroupBox groupBoxTeletext;
private System.Windows.Forms.CheckBox checkBoxTeletextDoubleHeight;
private System.Windows.Forms.CheckBox checkBoxTeletextBox;
private System.Windows.Forms.GroupBox groupBoxVerticalPosition;
private System.Windows.Forms.Label labelMarginBottom;
private System.Windows.Forms.NumericUpDown numericUpDownMarginTop;
private System.Windows.Forms.Label labelMarginTop;
private System.Windows.Forms.NumericUpDown numericUpDownNewLineRows;
private System.Windows.Forms.Label labelNewLineRows;
private System.Windows.Forms.NumericUpDown numericUpDownMarginBottom;
}
}

View File

@ -56,6 +56,14 @@ namespace Nikse.SubtitleEdit.Forms
comboBoxJustificationCode.Items.Add(language.TextCenteredText);
comboBoxJustificationCode.Items.Add(language.TextRightJustifiedText);
groupBoxTeletext.Text = language.Teletext;
groupBoxVerticalPosition.Text = language.VerticalPosition;
labelMarginTop.Text = language.MarginTop;
labelMarginBottom.Text = language.MarginBottom;
labelNewLineRows.Text = language.NewLineRows;
int tempW = labelMarginTop.Left + 9 + Math.Max(Math.Max(labelMarginTop.Width, labelMarginBottom.Width), labelNewLineRows.Width);
numericUpDownMarginTop.Left = tempW;
numericUpDownMarginBottom.Left = tempW;
numericUpDownNewLineRows.Left = tempW;
checkBoxTeletextBox.Text = language.UseBox;
checkBoxTeletextDoubleHeight.Text = language.DoubleHeight;
@ -93,6 +101,9 @@ namespace Nikse.SubtitleEdit.Forms
}
comboBoxJustificationCode.SelectedIndex = justificationCode;
numericUpDownMarginTop.Value = Configuration.Settings.SubtitleSettings.EbuStlMarginTop;
numericUpDownMarginBottom.Value = Configuration.Settings.SubtitleSettings.EbuStlMarginBottom;
numericUpDownNewLineRows.Value = Configuration.Settings.SubtitleSettings.EbuStlNewLineRows;
checkBoxTeletextBox.Checked = Configuration.Settings.SubtitleSettings.EbuStlTeletextUseBox;
checkBoxTeletextDoubleHeight.Checked = Configuration.Settings.SubtitleSettings.EbuStlTeletextUseDoubleHeight;
@ -286,10 +297,13 @@ namespace Nikse.SubtitleEdit.Forms
_header.TotalNumberOfDisks = numericUpDownTotalNumberOfDiscs.Value.ToString(CultureInfo.InvariantCulture);
JustificationCode = (byte)comboBoxJustificationCode.SelectedIndex;
Configuration.Settings.SubtitleSettings.EbuStlMarginTop = (int)Math.Round(numericUpDownMarginTop.Value);
Configuration.Settings.SubtitleSettings.EbuStlMarginBottom = (int)Math.Round(numericUpDownMarginBottom.Value);
Configuration.Settings.SubtitleSettings.EbuStlNewLineRows = (int)Math.Round(numericUpDownNewLineRows.Value);
Configuration.Settings.SubtitleSettings.EbuStlTeletextUseBox = checkBoxTeletextBox.Checked;
Configuration.Settings.SubtitleSettings.EbuStlTeletextUseDoubleHeight = checkBoxTeletextDoubleHeight.Checked;
if (_subtitle != null && _subtitle.Header != null && (_subtitle.Header.Contains("STL2") || _subtitle.Header.Contains("STL3")))
if (_subtitle != null)
{
_subtitle.Header = _header.ToString();
}

View File

@ -2078,6 +2078,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
}
if (fontStack.Count > 0)
{
font.Dispose();
font = fontStack.Pop();
}
i += 6;
@ -2678,6 +2679,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
}
if (fontStack.Count > 0)
{
font.Dispose();
font = fontStack.Pop();
}
i += 6;
@ -3368,7 +3370,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine +
comboBoxLeftRightMargin.Items.Clear();
for (int i = 0; i < 1000; i++)
comboBoxLeftRightMargin.Items.Add(i);
if (Configuration.Settings.Tools.ExportLeftRightMargin >= 0 && Configuration.Settings.Tools.ExportLeftRightMargin < comboBoxBottomMargin.Items.Count)
if (Configuration.Settings.Tools.ExportLeftRightMargin >= 0 && Configuration.Settings.Tools.ExportLeftRightMargin < comboBoxLeftRightMargin.Items.Count)
comboBoxLeftRightMargin.SelectedIndex = Configuration.Settings.Tools.ExportLeftRightMargin;
if (exportType == "BLURAYSUP" || exportType == "IMAGE/FRAME" && Configuration.Settings.Tools.ExportBluRayBottomMargin >= 0 && Configuration.Settings.Tools.ExportBluRayBottomMargin < comboBoxBottomMargin.Items.Count)

View File

@ -87,13 +87,14 @@ namespace Nikse.SubtitleEdit.Forms
private bool _onlyListFixes = true;
private bool _batchMode;
private string _autoDetectGoogleLanguage;
private List<string> _namesEtcList;
private HashSet<string> _namesEtcList;
private HashSet<string> _abbreviationList;
private readonly StringBuilder _newLog = new StringBuilder();
private readonly StringBuilder _appliedLog = new StringBuilder();
private int _numberOfImportantLogMessages;
private List<int> _deleteIndices = new List<int>();
private HashSet<string> _allowedFixes;
private bool _linesDeletedOrMerged;
public SubtitleFormat Format
{
@ -522,19 +523,22 @@ namespace Nikse.SubtitleEdit.Forms
public bool IsName(string candidate)
{
MakeSureNamesListIsLoaded();
return _namesEtcList.Contains(candidate);
return _namesEtcList.Contains(candidate); // O(1)
}
private void MakeSureNamesListIsLoaded()
{
if (_namesEtcList == null)
{
_namesEtcList = new List<string>();
string languageTwoLetterCode = LanguageAutoDetect.AutoDetectGoogleLanguage(Subtitle);
string languageTwoLetterCode = LanguageAutoDetect.AutoDetectGoogleLanguage(Subtitle);
// Will contains both one word names and multi names
var namesList = new NamesList(Configuration.DictionariesDirectory, languageTwoLetterCode, Configuration.Settings.WordLists.UseOnlineNamesEtc, Configuration.Settings.WordLists.NamesEtcUrl);
_namesEtcList = namesList.GetAllNames();
_namesEtcList = namesList.GetNames();
// Multi word names.
foreach (var name in namesList.GetMultiNames())
{
_namesEtcList.Add(name);
}
}
}
@ -615,7 +619,7 @@ namespace Nikse.SubtitleEdit.Forms
buttonBack.Enabled = true;
buttonNextFinish.Text = _languageGeneral.Ok;
buttonNextFinish.Enabled = _hasFixesBeenMade;
buttonNextFinish.Enabled = _hasFixesBeenMade || _linesDeletedOrMerged;
groupBoxStep1.Visible = false;
groupBox2.Visible = true;
listViewFixes.Sort();
@ -1331,8 +1335,8 @@ namespace Nikse.SubtitleEdit.Forms
{
if (_originalSubtitle.Paragraphs.Count > 0 && subtitleListView1.SelectedItems.Count > 0)
{
_linesDeletedOrMerged = true;
_subtitleListViewIndex = -1;
var indexes = new List<int>();
foreach (ListViewItem item in subtitleListView1.SelectedItems)
indexes.Add(item.Index);
@ -1385,6 +1389,7 @@ namespace Nikse.SubtitleEdit.Forms
{
if (_originalSubtitle.Paragraphs.Count > 0 && subtitleListView1.SelectedItems.Count > 0)
{
_linesDeletedOrMerged = true;
int startNumber = _originalSubtitle.Paragraphs[0].Number;
int firstSelectedIndex = subtitleListView1.SelectedItems[0].Index;

View File

@ -153,7 +153,7 @@ namespace Nikse.SubtitleEdit.Forms
private Keys _video5000MsLeft = Keys.None;
private Keys _video5000MsRight = Keys.None;
private Keys _videoPlayFirstSelected = Keys.None;
private Keys _mainVideoFullscreen = Keys.None;
private Keys _mainVideoFullscreen = Keys.None;
private Keys _mainGoToPrevoiusSubtitleAndFocusVideo = Keys.None;
private Keys _mainGoToNextSubtitleAndFocusVideo = Keys.None;
private Keys _mainAdjustExtendCurrentSubtitle = Keys.None;
@ -684,7 +684,7 @@ namespace Nikse.SubtitleEdit.Forms
{
SubtitleListview1.SelectIndexAndEnsureVisible(index);
mediaPlayer.CurrentPosition = e.Seconds;
ButtonSetStartAndOffsetRestClick(null, null);
SetStartAndOffsetTheRest(e.Seconds);
}
audioVisualizer.Invalidate();
}
@ -3477,7 +3477,7 @@ namespace Nikse.SubtitleEdit.Forms
file.Write(allText);
}
}
else if (currentEncoding == Encoding.UTF8 && (format.GetType() == typeof(TmpegEncAW5) || format.GetType() == typeof(TmpegEncXml)))
else if (Equals(currentEncoding, Encoding.UTF8) && (format.GetType() == typeof(TmpegEncAW5) || format.GetType() == typeof(TmpegEncXml)))
{
var outputEnc = new UTF8Encoding(false); // create encoding with no BOM
using (var file = new StreamWriter(_fileName, false, outputEnc)) // open file with encoding
@ -3492,11 +3492,22 @@ namespace Nikse.SubtitleEdit.Forms
MessageBox.Show(string.Format(_language.UnableToSaveSubtitleX, _fileName), String.Empty, MessageBoxButtons.OK, MessageBoxIcon.Stop);
return DialogResult.Cancel;
}
using (var fs = new FileStream(_fileName, FileMode.Create, FileAccess.Write, FileShare.Read))
using (var sw = new StreamWriter(fs, currentEncoding))
if (Equals(currentEncoding, Encoding.UTF8) && !Configuration.Settings.General.WriteUtf8Bom)
{
sw.Write(allText);
var outputEnc = new UTF8Encoding(false); // create encoding with no BOM
using (var file = new StreamWriter(_fileName, false, outputEnc)) // open file with encoding
{
file.Write(allText);
}
}
else
{
// create file - includes BOM for Unicode formats
using (var fs = new FileStream(_fileName, FileMode.Create, FileAccess.Write, FileShare.Read))
using (var sw = new StreamWriter(fs, currentEncoding))
{
sw.Write(allText);
}
}
}
Configuration.Settings.RecentFiles.Add(_fileName, FirstVisibleIndex, FirstSelectedIndex, _videoFileName, _subtitleAlternateFileName, Configuration.Settings.General.CurrentVideoOffsetInMs);
@ -8867,32 +8878,45 @@ namespace Nikse.SubtitleEdit.Forms
{
if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count > 0)
{
if (colorDialog1.ShowDialog(this) == DialogResult.OK)
string color;
if (GetCurrentSubtitleFormat().GetType() == typeof(Ebu))
{
string color = Utilities.ColorToHex(colorDialog1.Color);
MakeHistoryForUndo(_language.BeforeSettingColor);
foreach (ListViewItem item in SubtitleListview1.SelectedItems)
using (var form = new EbuColorPicker())
{
var p = _subtitle.GetParagraphOrDefault(item.Index);
if (p != null)
if (form.ShowDialog(this) != DialogResult.OK)
return;
color = form.Color;
}
}
else
{
if (colorDialog1.ShowDialog(this) != DialogResult.OK)
return;
color = Utilities.ColorToHex(colorDialog1.Color);
}
MakeHistoryForUndo(_language.BeforeSettingColor);
foreach (ListViewItem item in SubtitleListview1.SelectedItems)
{
var p = _subtitle.GetParagraphOrDefault(item.Index);
if (p != null)
{
SetFontColor(p, color);
SubtitleListview1.SetText(item.Index, p.Text);
if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle && SubtitleListview1.IsAlternateTextColumnVisible)
{
SetFontColor(p, color);
SubtitleListview1.SetText(item.Index, p.Text);
if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle && SubtitleListview1.IsAlternateTextColumnVisible)
var original = Utilities.GetOriginalParagraph(item.Index, p, _subtitleAlternate.Paragraphs);
if (original != null)
{
var original = Utilities.GetOriginalParagraph(item.Index, p, _subtitleAlternate.Paragraphs);
if (original != null)
{
SetFontColor(original, color);
SubtitleListview1.SetAlternateText(item.Index, original.Text);
}
SetFontColor(original, color);
SubtitleListview1.SetAlternateText(item.Index, original.Text);
}
}
}
RefreshSelectedParagraph();
}
RefreshSelectedParagraph();
}
}
@ -11912,19 +11936,16 @@ namespace Nikse.SubtitleEdit.Forms
private void MoveVideoSeconds(double seconds)
{
var oldPosition = mediaPlayer.CurrentPosition;
var newPosition = oldPosition + seconds;
if (mediaPlayer.IsPaused && Configuration.Settings.General.MoveVideo100Or500MsPlaySmallSample)
{
double p = mediaPlayer.CurrentPosition + seconds;
mediaPlayer.CurrentPosition = p;
mediaPlayer.CurrentPosition = newPosition;
mediaPlayer.Play();
System.Threading.Thread.Sleep(99);
mediaPlayer.Stop();
mediaPlayer.CurrentPosition = p;
}
else
{
mediaPlayer.CurrentPosition += seconds;
}
mediaPlayer.CurrentPosition = newPosition;
}
private void RunCustomSearch(string url)
@ -13195,6 +13216,9 @@ namespace Nikse.SubtitleEdit.Forms
private void toolStripMenuItemTranslationMode_Click(object sender, EventArgs e)
{
if (_subtitle != null)
return;
if (SubtitleListview1.IsAlternateTextColumnVisible)
{
SubtitleListview1.HideColumn(SubtitleListView.SubtitleColumn.TextAlternate);
@ -14730,6 +14754,11 @@ namespace Nikse.SubtitleEdit.Forms
}
private void ButtonSetStartAndOffsetRestClick(object sender, EventArgs e)
{
SetStartAndOffsetTheRest(mediaPlayer.CurrentPosition);
}
private void SetStartAndOffsetTheRest(double videoPosition)
{
if (SubtitleListview1.SelectedItems.Count == 1)
{
@ -14738,9 +14767,8 @@ namespace Nikse.SubtitleEdit.Forms
timeUpDownStartTime.MaskedTextBox.TextChanged -= MaskedTextBoxTextChanged;
int index = SubtitleListview1.SelectedItems[0].Index;
double videoPosition = mediaPlayer.CurrentPosition;
if (!mediaPlayer.IsPaused)
videoPosition -= Configuration.Settings.General.SetStartEndHumanDelay / TimeCode.BaseUnit;
videoPosition -= Configuration.Settings.General.SetStartEndHumanDelay/TimeCode.BaseUnit;
var tc = TimeCode.FromSeconds(videoPosition);
timeUpDownStartTime.TimeCode = tc;
@ -16268,48 +16296,59 @@ namespace Nikse.SubtitleEdit.Forms
private void ColorToolStripMenuItem1Click(object sender, EventArgs e)
{
var tb = GetFocusedTextBox();
//color
string text = tb.SelectedText;
int selectionStart = tb.SelectionStart;
if (colorDialog1.ShowDialog(this) == DialogResult.OK)
string color;
if (GetCurrentSubtitleFormat().GetType() == typeof(Ebu))
{
string color = Utilities.ColorToHex(colorDialog1.Color);
bool done = false;
string s = text;
if (s.StartsWith("<font "))
using (var form = new EbuColorPicker())
{
int end = s.IndexOf('>');
if (end > 0)
if (form.ShowDialog(this) != DialogResult.OK)
return;
color = form.Color;
}
}
else
{
if (colorDialog1.ShowDialog(this) != DialogResult.OK)
return;
color = Utilities.ColorToHex(colorDialog1.Color);
}
bool done = false;
string s = text;
if (s.StartsWith("<font "))
{
int end = s.IndexOf('>');
if (end > 0)
{
string f = s.Substring(0, end);
if (f.Contains(" face=") && !f.Contains(" color="))
{
string f = s.Substring(0, end);
if (f.Contains(" face=") && !f.Contains(" color="))
{
var start = s.IndexOf(" face=", StringComparison.Ordinal);
s = s.Insert(start, string.Format(" color=\"{0}\"", color));
text = s;
done = true;
}
else if (f.Contains(" color="))
{
int colorStart = f.IndexOf(" color=", StringComparison.Ordinal);
if (s.IndexOf('"', colorStart + " color=".Length + 1) > 0)
end = s.IndexOf('"', colorStart + " color=".Length + 1);
s = s.Substring(0, colorStart) + string.Format(" color=\"{0}", color) + s.Substring(end);
text = s;
done = true;
}
var start = s.IndexOf(" face=", StringComparison.Ordinal);
s = s.Insert(start, string.Format(" color=\"{0}\"", color));
text = s;
done = true;
}
else if (f.Contains(" color="))
{
int colorStart = f.IndexOf(" color=", StringComparison.Ordinal);
if (s.IndexOf('"', colorStart + " color=".Length + 1) > 0)
end = s.IndexOf('"', colorStart + " color=".Length + 1);
s = s.Substring(0, colorStart) + string.Format(" color=\"{0}", color) + s.Substring(end);
text = s;
done = true;
}
}
if (!done)
text = string.Format("<font color=\"{0}\">{1}</font>", color, text);
tb.SelectedText = text;
tb.SelectionStart = selectionStart;
tb.SelectionLength = text.Length;
}
if (!done)
text = string.Format("<font color=\"{0}\">{1}</font>", color, text);
tb.SelectedText = text;
tb.SelectionStart = selectionStart;
tb.SelectionLength = text.Length;
}
private void FontNameToolStripMenuItemClick(object sender, EventArgs e)

View File

@ -10,9 +10,9 @@ namespace Nikse.SubtitleEdit.Forms
{
public sealed partial class Statistics : PositionAndSizeForm
{
private Subtitle _subtitle;
private SubtitleFormat _format;
private LanguageStructure.Statistics _l;
private readonly Subtitle _subtitle;
private readonly SubtitleFormat _format;
private readonly LanguageStructure.Statistics _l;
private string _mostUsedLines;
private string _general;
private string _mostUsedWords;
@ -36,10 +36,7 @@ https://github.com/SubtitleEdit/subtitleedit
_format = format;
_l = Configuration.Settings.Language.Statistics;
if (string.IsNullOrEmpty(fileName))
Text = _l.Title;
else
Text = string.Format(_l.TitleWithFileName, fileName);
Text = string.IsNullOrEmpty(fileName) ? _l.Title : string.Format(_l.TitleWithFileName, fileName);
groupBoxGeneral.Text = _l.GeneralStatistics;
groupBoxMostUsed.Text = _l.MostUsed;
labelMostUsedWords.Text = _l.MostUsedWords;
@ -172,7 +169,7 @@ https://github.com/SubtitleEdit/subtitleedit
var endIdx = text.IndexOf('>', idx + 5);
if (endIdx < idx)
{
error = !error;
error = true;
break;
}
endIdx++;
@ -316,12 +313,14 @@ https://github.com/SubtitleEdit/subtitleedit
private void buttonExport_Click(object sender, EventArgs e)
{
var saveFile = new SaveFileDialog { Filter = "Text files (*.txt)|*.txt|NFO files (*.nfo)|*.nfo" };
if (saveFile.ShowDialog() == DialogResult.OK)
using (var saveFile = new SaveFileDialog { Filter = Configuration.Settings.Language.Main.TextFiles + " (*.txt)|*.txt|NFO files (*.nfo)|*.nfo" })
{
string fileName = saveFile.FileName;
var statistic = string.Format(WriteFormat, _general, _mostUsedWords, _mostUsedLines);
System.IO.File.WriteAllText(fileName, statistic);
if (saveFile.ShowDialog() == DialogResult.OK)
{
string fileName = saveFile.FileName;
var statistic = string.Format(WriteFormat, _general, _mostUsedWords, _mostUsedLines);
System.IO.File.WriteAllText(fileName, statistic);
}
}
}

View File

@ -6012,9 +6012,8 @@ namespace Nikse.SubtitleEdit.Forms
if (!_ocrFixEngine.IsDictionaryLoaded || !_ocrFixEngine.SpellCheckDictionaryName.StartsWith("en_"))
return false;
if (line.Contains('[') && line.Contains(']'))
line = line.Replace("[", string.Empty).Replace("]", string.Empty);
line = line.Replace("[", string.Empty);
line = line.Replace("]", string.Empty);
line = HtmlUtil.RemoveOpenCloseTags(line, HtmlUtil.TagItalic);
int count = 0;
@ -6024,7 +6023,10 @@ namespace Nikse.SubtitleEdit.Forms
foreach (string s in arr)
{
if (s.Length == 1 && !@"♪♫-:'”1234567890&aAI""".Contains(s))
{
count++;
break;
}
}
return count > 0;
}
@ -8445,32 +8447,25 @@ namespace Nikse.SubtitleEdit.Forms
private void vobSubToolStripMenuItem_Click(object sender, EventArgs e)
{
using (var exportBdnXmlPng = new ExportPngXml())
{
_fromMenuItem = true;
exportBdnXmlPng.InitializeFromVobSubOcr(_subtitle, new SubRip(), "VOBSUB", FileName, this, _importLanguageString);
exportBdnXmlPng.ShowDialog(this);
_fromMenuItem = false;
}
ExportToPngXml("VOBSUB");
}
private void bluraySupToolStripMenuItem_Click(object sender, EventArgs e)
{
using (var exportBdnXmlPng = new ExportPngXml())
{
_fromMenuItem = true;
exportBdnXmlPng.InitializeFromVobSubOcr(_subtitle, new SubRip(), "BLURAYSUP", FileName, this, _importLanguageString);
exportBdnXmlPng.ShowDialog(this);
_fromMenuItem = false;
}
ExportToPngXml("BLURAYSUP");
}
private void bDNXMLToolStripMenuItem_Click(object sender, EventArgs e)
{
ExportToPngXml("BDNXML");
}
private void ExportToPngXml(string exportType)
{
using (var exportBdnXmlPng = new ExportPngXml())
{
_fromMenuItem = true;
exportBdnXmlPng.InitializeFromVobSubOcr(_subtitle, new SubRip(), "BDNXML", FileName, this, _importLanguageString);
exportBdnXmlPng.InitializeFromVobSubOcr(_subtitle, new SubRip(), exportType, FileName, this, _importLanguageString);
exportBdnXmlPng.ShowDialog(this);
_fromMenuItem = false;
}

View File

@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Nikse")]
[assembly: AssemblyProduct("SubtitleEdit")]
[assembly: AssemblyCopyright("Copyright 2001-2016, Nikse")]
[assembly: AssemblyCopyright("Copyright 2001-2017, Nikse")]
[assembly: AssemblyTrademark("Licensed under the GPL v3")]
[assembly: AssemblyCulture("")]

View File

@ -264,6 +264,12 @@
<Compile Include="Forms\DurationsBridgeGaps.Designer.cs">
<DependentUpon>DurationsBridgeGaps.cs</DependentUpon>
</Compile>
<Compile Include="Forms\EbuColorPicker.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\EbuColorPicker.Designer.cs">
<DependentUpon>EbuColorPicker.cs</DependentUpon>
</Compile>
<Compile Include="Forms\ExportCustomText.cs">
<SubType>Form</SubType>
</Compile>
@ -996,6 +1002,9 @@
<EmbeddedResource Include="Forms\DurationsBridgeGaps.resx">
<DependentUpon>DurationsBridgeGaps.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\EbuColorPicker.resx">
<DependentUpon>EbuColorPicker.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\ExportCustomText.resx">
<DependentUpon>ExportCustomText.cs</DependentUpon>
</EmbeddedResource>