Add "Fix RTL" to batch convert - thx OmrSi/MosDos96/ghost :)

Work on #2708 + #2780 + #3184
This commit is contained in:
Nikolaj Olsson 2018-11-24 08:10:49 +01:00
parent 026a43dc92
commit 9df48f4aaf
11 changed files with 468 additions and 19 deletions

View File

@ -187,6 +187,10 @@ Note: Do check free disk space.</WaveFileMalformed>
<NotConverted>Failed</NotConverted>
<Converted>Converted</Converted>
<Settings>Settings</Settings>
<FixRtl>Fix RTL</FixRtl>
<FixRtlAddUnicode>Fix RTL via Unicode tags</FixRtlAddUnicode>
<FixRtlRemoveUnicode>Remove RTL unicode tags</FixRtlRemoveUnicode>
<FixRtlReverseStartEnd>Reverse RTL start/end</FixRtlReverseStartEnd>
<SplitLongLines>Split long lines</SplitLongLines>
<AutoBalance>Auto balance lines</AutoBalance>
<ScanFolder>Scan folder...</ScanFolder>

View File

@ -324,6 +324,10 @@ namespace Nikse.SubtitleEdit.Core
NotConverted = "Failed",
Converted = "Converted",
Settings = "Settings",
FixRtl = "Fix RTL",
FixRtlAddUnicode = "Fix RTL via Unicode tags",
FixRtlRemoveUnicode = "Remove RTL unicode tags",
FixRtlReverseStartEnd = "Reverse RTL start/end",
SplitLongLines = "Split long lines",
AutoBalance = "Auto balance lines",
OverwriteOriginalFiles = "Overwrite original files (new extension if format is changed)",

View File

@ -496,6 +496,18 @@ namespace Nikse.SubtitleEdit.Core
case "BatchConvert/Settings":
language.BatchConvert.Settings = reader.Value;
break;
case "BatchConvert/FixRtl":
language.BatchConvert.FixRtl = reader.Value;
break;
case "BatchConvert/FixRtlAddUnicode":
language.BatchConvert.FixRtlAddUnicode = reader.Value;
break;
case "BatchConvert/FixRtlRemoveUnicode":
language.BatchConvert.FixRtlRemoveUnicode = reader.Value;
break;
case "BatchConvert/FixRtlReverseStartEnd":
language.BatchConvert.FixRtlReverseStartEnd = reader.Value;
break;
case "BatchConvert/SplitLongLines":
language.BatchConvert.SplitLongLines = reader.Value;
break;

View File

@ -197,6 +197,10 @@
public string NotConverted { get; set; }
public string Converted { get; set; }
public string Settings { get; set; }
public string FixRtl { get; set; }
public string FixRtlAddUnicode { get; set; }
public string FixRtlRemoveUnicode { get; set; }
public string FixRtlReverseStartEnd { get; set; }
public string SplitLongLines { get; set; }
public string AutoBalance { get; set; }
public string ScanFolder { get; set; }

View File

@ -125,6 +125,8 @@ namespace Nikse.SubtitleEdit.Core
public bool BatchConvertRemoveTextForHI { get; set; }
public bool BatchConvertFixCommonErrors { get; set; }
public bool BatchConvertMultipleReplace { get; set; }
public bool BatchConvertFixRtl { get; set; }
public string BatchConvertFixRtlMode { get; set; }
public bool BatchConvertSplitLongLines { get; set; }
public bool BatchConvertAutoBalance { get; set; }
public bool BatchConvertSetMinDisplayTimeBetweenSubtitles { get; set; }
@ -2039,6 +2041,12 @@ $HorzAlign = Center
subNode = node.SelectSingleNode("BatchConvertMultipleReplace");
if (subNode != null)
settings.Tools.BatchConvertMultipleReplace = Convert.ToBoolean(subNode.InnerText);
subNode = node.SelectSingleNode("BatchConvertFixRtl");
if (subNode != null)
settings.Tools.BatchConvertFixRtl = Convert.ToBoolean(subNode.InnerText);
subNode = node.SelectSingleNode("BatchConvertFixRtlMode");
if (subNode != null)
settings.Tools.BatchConvertFixRtlMode = subNode.InnerText;
subNode = node.SelectSingleNode("BatchConvertAutoBalance");
if (subNode != null)
settings.Tools.BatchConvertAutoBalance = Convert.ToBoolean(subNode.InnerText);
@ -3651,6 +3659,8 @@ $HorzAlign = Center
textWriter.WriteElementString("BatchConvertSplitLongLines", settings.Tools.BatchConvertSplitLongLines.ToString());
textWriter.WriteElementString("BatchConvertFixCommonErrors", settings.Tools.BatchConvertFixCommonErrors.ToString());
textWriter.WriteElementString("BatchConvertMultipleReplace", settings.Tools.BatchConvertMultipleReplace.ToString());
textWriter.WriteElementString("BatchConvertFixRtl", settings.Tools.BatchConvertFixRtl.ToString());
textWriter.WriteElementString("BatchConvertFixRtlMode", settings.Tools.BatchConvertFixRtlMode);
textWriter.WriteElementString("BatchConvertAutoBalance", settings.Tools.BatchConvertAutoBalance.ToString());
textWriter.WriteElementString("BatchConvertSetMinDisplayTimeBetweenSubtitles", settings.Tools.BatchConvertSetMinDisplayTimeBetweenSubtitles.ToString());
textWriter.WriteElementString("BatchConvertLanguage", settings.Tools.BatchConvertLanguage);

View File

@ -33,6 +33,8 @@
this.buttonConvert = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.groupBoxConvertOptions = new System.Windows.Forms.GroupBox();
this.buttonFixRtlSettings = new System.Windows.Forms.Button();
this.checkBoxFixRtl = new System.Windows.Forms.CheckBox();
this.buttonBridgeGapsSettings = new System.Windows.Forms.Button();
this.checkBoxBridgeGaps = new System.Windows.Forms.CheckBox();
this.groupBoxSpeed = new System.Windows.Forms.GroupBox();
@ -109,7 +111,7 @@
//
this.buttonConvert.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonConvert.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonConvert.Location = new System.Drawing.Point(844, 598);
this.buttonConvert.Location = new System.Drawing.Point(844, 618);
this.buttonConvert.Name = "buttonConvert";
this.buttonConvert.Size = new System.Drawing.Size(98, 21);
this.buttonConvert.TabIndex = 2;
@ -121,7 +123,7 @@
//
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonCancel.Location = new System.Drawing.Point(948, 598);
this.buttonCancel.Location = new System.Drawing.Point(948, 618);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 21);
this.buttonCancel.TabIndex = 3;
@ -133,6 +135,8 @@
//
this.groupBoxConvertOptions.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBoxConvertOptions.Controls.Add(this.buttonFixRtlSettings);
this.groupBoxConvertOptions.Controls.Add(this.checkBoxFixRtl);
this.groupBoxConvertOptions.Controls.Add(this.buttonBridgeGapsSettings);
this.groupBoxConvertOptions.Controls.Add(this.checkBoxBridgeGaps);
this.groupBoxConvertOptions.Controls.Add(this.groupBoxSpeed);
@ -151,11 +155,32 @@
this.groupBoxConvertOptions.Controls.Add(this.checkBoxRemoveFormatting);
this.groupBoxConvertOptions.Location = new System.Drawing.Point(422, 19);
this.groupBoxConvertOptions.Name = "groupBoxConvertOptions";
this.groupBoxConvertOptions.Size = new System.Drawing.Size(583, 234);
this.groupBoxConvertOptions.Size = new System.Drawing.Size(583, 275);
this.groupBoxConvertOptions.TabIndex = 11;
this.groupBoxConvertOptions.TabStop = false;
this.groupBoxConvertOptions.Text = "Convert options";
//
// buttonFixRtlSettings
//
this.buttonFixRtlSettings.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonFixRtlSettings.Location = new System.Drawing.Point(183, 164);
this.buttonFixRtlSettings.Name = "buttonFixRtlSettings";
this.buttonFixRtlSettings.Size = new System.Drawing.Size(104, 21);
this.buttonFixRtlSettings.TabIndex = 29;
this.buttonFixRtlSettings.Text = "Settings...";
this.buttonFixRtlSettings.UseVisualStyleBackColor = true;
this.buttonFixRtlSettings.Click += new System.EventHandler(this.buttonFixRtlSettings_Click);
//
// checkBoxFixRtl
//
this.checkBoxFixRtl.AutoSize = true;
this.checkBoxFixRtl.Location = new System.Drawing.Point(15, 167);
this.checkBoxFixRtl.Name = "checkBoxFixRtl";
this.checkBoxFixRtl.Size = new System.Drawing.Size(63, 17);
this.checkBoxFixRtl.TabIndex = 28;
this.checkBoxFixRtl.Text = "Fix RTL";
this.checkBoxFixRtl.UseVisualStyleBackColor = true;
//
// buttonBridgeGapsSettings
//
this.buttonBridgeGapsSettings.ImeMode = System.Windows.Forms.ImeMode.NoControl;
@ -262,7 +287,7 @@
// checkBoxSplitLongLines
//
this.checkBoxSplitLongLines.AutoSize = true;
this.checkBoxSplitLongLines.Location = new System.Drawing.Point(15, 167);
this.checkBoxSplitLongLines.Location = new System.Drawing.Point(15, 190);
this.checkBoxSplitLongLines.Name = "checkBoxSplitLongLines";
this.checkBoxSplitLongLines.Size = new System.Drawing.Size(93, 17);
this.checkBoxSplitLongLines.TabIndex = 40;
@ -283,7 +308,7 @@
// checkBoxSetMinimumDisplayTimeBetweenSubs
//
this.checkBoxSetMinimumDisplayTimeBetweenSubs.AutoSize = true;
this.checkBoxSetMinimumDisplayTimeBetweenSubs.Location = new System.Drawing.Point(15, 213);
this.checkBoxSetMinimumDisplayTimeBetweenSubs.Location = new System.Drawing.Point(15, 236);
this.checkBoxSetMinimumDisplayTimeBetweenSubs.Name = "checkBoxSetMinimumDisplayTimeBetweenSubs";
this.checkBoxSetMinimumDisplayTimeBetweenSubs.Size = new System.Drawing.Size(208, 17);
this.checkBoxSetMinimumDisplayTimeBetweenSubs.TabIndex = 50;
@ -293,7 +318,7 @@
// checkBoxAutoBalance
//
this.checkBoxAutoBalance.AutoSize = true;
this.checkBoxAutoBalance.Location = new System.Drawing.Point(15, 190);
this.checkBoxAutoBalance.Location = new System.Drawing.Point(15, 213);
this.checkBoxAutoBalance.Name = "checkBoxAutoBalance";
this.checkBoxAutoBalance.Size = new System.Drawing.Size(113, 17);
this.checkBoxAutoBalance.TabIndex = 45;
@ -306,7 +331,7 @@
this.buttonMultipleReplaceSettings.Location = new System.Drawing.Point(183, 140);
this.buttonMultipleReplaceSettings.Name = "buttonMultipleReplaceSettings";
this.buttonMultipleReplaceSettings.Size = new System.Drawing.Size(104, 21);
this.buttonMultipleReplaceSettings.TabIndex = 30;
this.buttonMultipleReplaceSettings.TabIndex = 26;
this.buttonMultipleReplaceSettings.Text = "Settings...";
this.buttonMultipleReplaceSettings.UseVisualStyleBackColor = true;
this.buttonMultipleReplaceSettings.Click += new System.EventHandler(this.buttonMultipleReplaceSettings_Click);
@ -500,9 +525,9 @@
this.groupBoxOutput.Controls.Add(this.labelChooseOutputFolder);
this.groupBoxOutput.Controls.Add(this.buttonChooseFolder);
this.groupBoxOutput.Controls.Add(this.textBoxOutputFolder);
this.groupBoxOutput.Location = new System.Drawing.Point(12, 326);
this.groupBoxOutput.Location = new System.Drawing.Point(12, 305);
this.groupBoxOutput.Name = "groupBoxOutput";
this.groupBoxOutput.Size = new System.Drawing.Size(1014, 259);
this.groupBoxOutput.Size = new System.Drawing.Size(1014, 300);
this.groupBoxOutput.TabIndex = 1;
this.groupBoxOutput.TabStop = false;
this.groupBoxOutput.Text = "Output";
@ -639,7 +664,7 @@
this.groupBoxInput.Controls.Add(this.listViewInputFiles);
this.groupBoxInput.Location = new System.Drawing.Point(15, 12);
this.groupBoxInput.Name = "groupBoxInput";
this.groupBoxInput.Size = new System.Drawing.Size(1011, 308);
this.groupBoxInput.Size = new System.Drawing.Size(1011, 287);
this.groupBoxInput.TabIndex = 0;
this.groupBoxInput.TabStop = false;
this.groupBoxInput.Text = "Input";
@ -647,7 +672,7 @@
// textBoxFilter
//
this.textBoxFilter.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.textBoxFilter.Location = new System.Drawing.Point(422, 279);
this.textBoxFilter.Location = new System.Drawing.Point(422, 258);
this.textBoxFilter.Name = "textBoxFilter";
this.textBoxFilter.Size = new System.Drawing.Size(158, 20);
this.textBoxFilter.TabIndex = 13;
@ -656,7 +681,7 @@
//
this.labelFilter.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.labelFilter.AutoSize = true;
this.labelFilter.Location = new System.Drawing.Point(11, 282);
this.labelFilter.Location = new System.Drawing.Point(11, 261);
this.labelFilter.Name = "labelFilter";
this.labelFilter.Size = new System.Drawing.Size(29, 13);
this.labelFilter.TabIndex = 11;
@ -672,7 +697,7 @@
"SubRip .srt files without BOM header",
"Files with subtitle with more than two lines",
"Files that contains..."});
this.comboBoxFilter.Location = new System.Drawing.Point(81, 279);
this.comboBoxFilter.Location = new System.Drawing.Point(81, 258);
this.comboBoxFilter.Name = "comboBoxFilter";
this.comboBoxFilter.Size = new System.Drawing.Size(335, 21);
this.comboBoxFilter.TabIndex = 12;
@ -738,7 +763,7 @@
this.listViewInputFiles.HideSelection = false;
this.listViewInputFiles.Location = new System.Drawing.Point(6, 41);
this.listViewInputFiles.Name = "listViewInputFiles";
this.listViewInputFiles.Size = new System.Drawing.Size(965, 232);
this.listViewInputFiles.Size = new System.Drawing.Size(965, 211);
this.listViewInputFiles.TabIndex = 2;
this.listViewInputFiles.UseCompatibleStateImageBehavior = false;
this.listViewInputFiles.View = System.Windows.Forms.View.Details;
@ -797,7 +822,7 @@
//
this.progressBar1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.progressBar1.Location = new System.Drawing.Point(15, 607);
this.progressBar1.Location = new System.Drawing.Point(15, 627);
this.progressBar1.Name = "progressBar1";
this.progressBar1.Size = new System.Drawing.Size(820, 10);
this.progressBar1.TabIndex = 8;
@ -806,7 +831,7 @@
//
this.labelStatus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.labelStatus.AutoSize = true;
this.labelStatus.Location = new System.Drawing.Point(12, 591);
this.labelStatus.Location = new System.Drawing.Point(12, 611);
this.labelStatus.Name = "labelStatus";
this.labelStatus.Size = new System.Drawing.Size(59, 13);
this.labelStatus.TabIndex = 9;
@ -817,7 +842,7 @@
this.AllowDrop = true;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1035, 631);
this.ClientSize = new System.Drawing.Size(1035, 651);
this.Controls.Add(this.labelStatus);
this.Controls.Add(this.progressBar1);
this.Controls.Add(this.groupBoxOutput);
@ -917,5 +942,7 @@
private System.Windows.Forms.CheckBox checkBoxUseStyleFromSource;
private System.Windows.Forms.CheckBox checkBoxBridgeGaps;
private System.Windows.Forms.Button buttonBridgeGapsSettings;
private System.Windows.Forms.Button buttonFixRtlSettings;
private System.Windows.Forms.CheckBox checkBoxFixRtl;
}
}

View File

@ -26,6 +26,7 @@ namespace Nikse.SubtitleEdit.Forms
{
public bool FixCommonErrors { get; set; }
public bool MultipleReplaceActive { get; set; }
public bool FixRtl { get; set; }
public bool SplitLongLinesActive { get; set; }
public bool AutoBalanceActive { get; set; }
public bool SetMinDisplayTimeBetweenSubtitles { get; set; }
@ -38,10 +39,11 @@ namespace Nikse.SubtitleEdit.Forms
public string FileName { get; set; }
public string ToFormat { get; set; }
public SubtitleFormat SourceFormat { get; set; }
public ThreadDoWorkParameter(bool fixCommonErrors, bool multipleReplace, bool splitLongLinesActive, bool autoBalance, bool setMinDisplayTimeBetweenSubtitles, ListViewItem item, Subtitle subtitle, SubtitleFormat format, Encoding encoding, string language, string fileName, string toFormat, SubtitleFormat sourceFormat)
public ThreadDoWorkParameter(bool fixCommonErrors, bool multipleReplace, bool fixRtl, bool splitLongLinesActive, bool autoBalance, bool setMinDisplayTimeBetweenSubtitles, ListViewItem item, Subtitle subtitle, SubtitleFormat format, Encoding encoding, string language, string fileName, string toFormat, SubtitleFormat sourceFormat)
{
FixCommonErrors = fixCommonErrors;
MultipleReplaceActive = multipleReplace;
FixRtl = fixRtl;
SplitLongLinesActive = splitLongLinesActive;
AutoBalanceActive = autoBalance;
SetMinDisplayTimeBetweenSubtitles = setMinDisplayTimeBetweenSubtitles;
@ -187,6 +189,7 @@ namespace Nikse.SubtitleEdit.Forms
checkBoxFixCasing.Checked = Configuration.Settings.Tools.BatchConvertFixCasing;
checkBoxFixCommonErrors.Checked = Configuration.Settings.Tools.BatchConvertFixCommonErrors;
checkBoxMultipleReplace.Checked = Configuration.Settings.Tools.BatchConvertMultipleReplace;
checkBoxFixRtl.Checked = Configuration.Settings.Tools.BatchConvertFixRtl;
checkBoxSplitLongLines.Checked = Configuration.Settings.Tools.BatchConvertSplitLongLines;
checkBoxAutoBalance.Checked = Configuration.Settings.Tools.BatchConvertAutoBalance;
checkBoxRemoveFormatting.Checked = Configuration.Settings.Tools.BatchConvertRemoveFormatting;
@ -200,6 +203,7 @@ namespace Nikse.SubtitleEdit.Forms
checkBoxFixCommonErrors.Text = Configuration.Settings.Language.FixCommonErrors.Title;
checkBoxMultipleReplace.Text = Configuration.Settings.Language.MultipleReplace.Title;
checkBoxAutoBalance.Text = l.AutoBalance;
checkBoxFixRtl.Text = l.FixRtl;
checkBoxSplitLongLines.Text = l.SplitLongLines;
radioButtonShowEarlier.Text = Configuration.Settings.Language.ShowEarlierLater.ShowEarlier;
radioButtonShowLater.Text = Configuration.Settings.Language.ShowEarlierLater.ShowLater;
@ -1078,7 +1082,7 @@ namespace Nikse.SubtitleEdit.Forms
Application.DoEvents();
System.Threading.Thread.Sleep(100);
}
var parameter = new ThreadDoWorkParameter(checkBoxFixCommonErrors.Checked, checkBoxMultipleReplace.Checked, checkBoxSplitLongLines.Checked, checkBoxAutoBalance.Checked, checkBoxSetMinimumDisplayTimeBetweenSubs.Checked, item, sub, GetCurrentSubtitleFormat(), GetCurrentEncoding(), Configuration.Settings.Tools.BatchConvertLanguage, fileName, toFormat, format);
var parameter = new ThreadDoWorkParameter(checkBoxFixCommonErrors.Checked, checkBoxMultipleReplace.Checked, checkBoxFixRtl.Checked, checkBoxSplitLongLines.Checked, checkBoxAutoBalance.Checked, checkBoxSetMinimumDisplayTimeBetweenSubs.Checked, item, sub, GetCurrentSubtitleFormat(), GetCurrentEncoding(), Configuration.Settings.Tools.BatchConvertLanguage, fileName, toFormat, format);
if (!worker1.IsBusy)
worker1.RunWorkerAsync(parameter);
else if (!worker2.IsBusy)
@ -1330,6 +1334,33 @@ namespace Nikse.SubtitleEdit.Forms
}
}
}
if (p.FixRtl)
{
var mode = Configuration.Settings.Tools.BatchConvertFixRtlMode;
string rtl = "\u202B";
for (int i = 0; i < p.Subtitle.Paragraphs.Count - 1; i++)
{
var paragraph = p.Subtitle.Paragraphs[i];
if (mode == BatchConvertFixRtl.RemoveUnicode)
{
paragraph.Text = paragraph.Text.Replace("\u200E", string.Empty);
paragraph.Text = paragraph.Text.Replace("\u200F", string.Empty);
paragraph.Text = paragraph.Text.Replace("\u202A", string.Empty);
paragraph.Text = paragraph.Text.Replace("\u202B", string.Empty);
paragraph.Text = paragraph.Text.Replace("\u202D", string.Empty);
paragraph.Text = paragraph.Text.Replace("\u202E", string.Empty);
}
else if (mode == BatchConvertFixRtl.ReverseStartEnd)
{
paragraph.Text = Utilities.ReverseStartAndEndingForRightToLeft(paragraph.Text);
}
else // fix with unicode char
{
paragraph.Text = paragraph.Text.Replace(rtl, string.Empty);
paragraph.Text = rtl + paragraph.Text.Replace(Environment.NewLine, Environment.NewLine + rtl);
}
}
}
// always re-number
p.Subtitle.Renumber();
@ -1634,6 +1665,7 @@ namespace Nikse.SubtitleEdit.Forms
Configuration.Settings.Tools.BatchConvertFixCasing = checkBoxFixCasing.Checked;
Configuration.Settings.Tools.BatchConvertFixCommonErrors = checkBoxFixCommonErrors.Checked;
Configuration.Settings.Tools.BatchConvertMultipleReplace = checkBoxMultipleReplace.Checked;
Configuration.Settings.Tools.BatchConvertFixRtl = checkBoxFixRtl.Checked;
Configuration.Settings.Tools.BatchConvertSplitLongLines = checkBoxSplitLongLines.Checked;
Configuration.Settings.Tools.BatchConvertAutoBalance = checkBoxAutoBalance.Checked;
Configuration.Settings.Tools.BatchConvertRemoveFormatting = checkBoxRemoveFormatting.Checked;
@ -1946,5 +1978,13 @@ namespace Nikse.SubtitleEdit.Forms
{
_bridgeGaps.ShowDialog(this);
}
private void buttonFixRtlSettings_Click(object sender, EventArgs e)
{
using (var form = new BatchConvertFixRtl())
{
form.ShowDialog(this);
}
}
}
}

146
src/Forms/BatchConvertFixRtl.Designer.cs generated Normal file
View File

@ -0,0 +1,146 @@
namespace Nikse.SubtitleEdit.Forms
{
sealed partial class BatchConvertFixRtl
{
/// <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.buttonOK = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.radioButtonReverseStartEnd = new System.Windows.Forms.RadioButton();
this.radioButtonRemoveUnicode = new System.Windows.Forms.RadioButton();
this.radioButtonAddUnicode = new System.Windows.Forms.RadioButton();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// buttonOK
//
this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonOK.Location = new System.Drawing.Point(173, 142);
this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new System.Drawing.Size(75, 21);
this.buttonOK.TabIndex = 6;
this.buttonOK.Text = "&OK";
this.buttonOK.UseVisualStyleBackColor = true;
this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click);
//
// buttonCancel
//
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonCancel.Location = new System.Drawing.Point(254, 142);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 21);
this.buttonCancel.TabIndex = 7;
this.buttonCancel.Text = "C&ancel";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// groupBox1
//
this.groupBox1.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.groupBox1.Controls.Add(this.radioButtonReverseStartEnd);
this.groupBox1.Controls.Add(this.radioButtonRemoveUnicode);
this.groupBox1.Controls.Add(this.radioButtonAddUnicode);
this.groupBox1.Location = new System.Drawing.Point(12, 12);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(317, 124);
this.groupBox1.TabIndex = 8;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Settings";
//
// radioButtonReverseStartEnd
//
this.radioButtonReverseStartEnd.AutoSize = true;
this.radioButtonReverseStartEnd.Location = new System.Drawing.Point(19, 77);
this.radioButtonReverseStartEnd.Name = "radioButtonReverseStartEnd";
this.radioButtonReverseStartEnd.Size = new System.Drawing.Size(135, 17);
this.radioButtonReverseStartEnd.TabIndex = 2;
this.radioButtonReverseStartEnd.TabStop = true;
this.radioButtonReverseStartEnd.Text = "Reverse RTL start/end";
this.radioButtonReverseStartEnd.UseVisualStyleBackColor = true;
//
// radioButtonRemoveUnicode
//
this.radioButtonRemoveUnicode.AutoSize = true;
this.radioButtonRemoveUnicode.Location = new System.Drawing.Point(19, 54);
this.radioButtonRemoveUnicode.Name = "radioButtonRemoveUnicode";
this.radioButtonRemoveUnicode.Size = new System.Drawing.Size(153, 17);
this.radioButtonRemoveUnicode.TabIndex = 1;
this.radioButtonRemoveUnicode.TabStop = true;
this.radioButtonRemoveUnicode.Text = "Remove RTL unicode tags";
this.radioButtonRemoveUnicode.UseVisualStyleBackColor = true;
//
// radioButtonAddUnicode
//
this.radioButtonAddUnicode.AutoSize = true;
this.radioButtonAddUnicode.Location = new System.Drawing.Point(19, 31);
this.radioButtonAddUnicode.Name = "radioButtonAddUnicode";
this.radioButtonAddUnicode.Size = new System.Drawing.Size(145, 17);
this.radioButtonAddUnicode.TabIndex = 0;
this.radioButtonAddUnicode.TabStop = true;
this.radioButtonAddUnicode.Text = "Fix RTL via Unicode tags";
this.radioButtonAddUnicode.UseVisualStyleBackColor = true;
//
// BatchConvertFixRtl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(341, 175);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.buttonOK);
this.Controls.Add(this.buttonCancel);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.KeyPreview = true;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "BatchConvertFixRtl";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Fix RTL";
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.BatchConvertFixRtl_KeyDown);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button buttonOK;
private System.Windows.Forms.Button buttonCancel;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.RadioButton radioButtonReverseStartEnd;
private System.Windows.Forms.RadioButton radioButtonRemoveUnicode;
private System.Windows.Forms.RadioButton radioButtonAddUnicode;
}
}

View File

@ -0,0 +1,73 @@
using System;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
namespace Nikse.SubtitleEdit.Forms
{
public sealed partial class BatchConvertFixRtl : Form
{
public const string AddUnicode = "ADD_UNICODE";
public const string RemoveUnicode = "REMOVE_UNICODE";
public const string ReverseStartEnd = "REVERSE_START_END";
public BatchConvertFixRtl()
{
UiUtil.PreInitialize(this);
InitializeComponent();
UiUtil.FixFonts(this);
Text = Configuration.Settings.Language.BatchConvert.FixRtl;
groupBox1.Text = Configuration.Settings.Language.BatchConvert.Settings;
buttonCancel.Text = Configuration.Settings.Language.General.Cancel;
buttonOK.Text = Configuration.Settings.Language.General.Ok;
radioButtonAddUnicode.Text = Configuration.Settings.Language.BatchConvert.FixRtlAddUnicode;
radioButtonRemoveUnicode.Text = Configuration.Settings.Language.BatchConvert.FixRtlRemoveUnicode;
radioButtonReverseStartEnd.Text = Configuration.Settings.Language.BatchConvert.FixRtlReverseStartEnd;
UiUtil.FixLargeFonts(this, buttonOK);
var mode = Configuration.Settings.Tools.BatchConvertFixRtlMode;
switch (mode)
{
case AddUnicode:
radioButtonRemoveUnicode.Checked = true;
break;
case ReverseStartEnd:
radioButtonReverseStartEnd.Checked = true;
break;
default:
radioButtonAddUnicode.Checked = true;
break;
}
}
private void buttonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
}
private void BatchConvertFixRtl_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape)
{
DialogResult = DialogResult.Cancel;
}
}
private void buttonOK_Click(object sender, EventArgs e)
{
if (radioButtonRemoveUnicode.Checked)
{
Configuration.Settings.Tools.BatchConvertFixRtlMode = RemoveUnicode;
}
else if (radioButtonReverseStartEnd.Checked)
{
Configuration.Settings.Tools.BatchConvertFixRtlMode = ReverseStartEnd;
}
else
{
Configuration.Settings.Tools.BatchConvertFixRtlMode = AddUnicode;
}
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

@ -98,6 +98,12 @@
<Compile Include="Forms\AudioToText.Designer.cs">
<DependentUpon>AudioToText.cs</DependentUpon>
</Compile>
<Compile Include="Forms\BatchConvertFixRtl.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\BatchConvertFixRtl.Designer.cs">
<DependentUpon>BatchConvertFixRtl.cs</DependentUpon>
</Compile>
<Compile Include="Forms\Cavena890SaveOptions.cs">
<SubType>Form</SubType>
</Compile>
@ -1026,6 +1032,9 @@
<EmbeddedResource Include="Forms\AudioToText.resx">
<DependentUpon>AudioToText.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\BatchConvertFixRtl.resx">
<DependentUpon>BatchConvertFixRtl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\Cavena890SaveOptions.resx">
<DependentUpon>Cavena890SaveOptions.cs</DependentUpon>
</EmbeddedResource>