Working on Cavena890

This commit is contained in:
Nikolaj Olsson 2016-04-09 21:20:30 +02:00
parent bf3e789c95
commit 1ff41fe0a6
8 changed files with 664 additions and 46 deletions

View File

@ -7,6 +7,7 @@
* Updated Finnish translation - thx Teijo S.
* Some updates for format "sif"
* Some updates for format "Cavena 890" - thx Elad
* Ctrl+Backspace in text box works better with html tags - thx xylographe
* FIXED:
* Fix updating of main list view after "Remove text for HI" + "Apply" - thx Henry
* Spell check "change" / "change all" issue regarding brackets/dash - thx jc
@ -19,6 +20,10 @@
* Fix for border size in vobsub export via cmd line - thx S_E_New
* Adjust duration fixed for last subtitle - thx mariner
* Read more variations of "S_DVBSUB" from mkv files - thx dreammday
* Fixed some "Remove text for HI" issues - thx Thunderbolt8
* Fixed "Remove text for HI" issue - thx Andrew
* Fixed "Add missing spaces" issue - thx Andrew
* "Fix short display time" is improved even if chars/sec still high - thx Frédéric
* + Many minor fixes from ivandrofly and xylographe

View File

@ -281,6 +281,12 @@ namespace Nikse.SubtitleEdit.Core
public int CurrentCavena890LanguageIdLine1 { get; set; }
public int CurrentCavena890LanguageIdLine2 { get; set; }
public string CurrentCavena89Title { get; set; }
public string CurrentCavena890riginalTitle { get; set; }
public string CurrentCavena890Translator { get; set; }
public string CurrentCavena89Comment { get; set; }
public int CurrentCavena89LanguageId { get; set; }
public string Cavena890StartOfMessage { get; set; }
public bool EbuStlTeletextUseBox { get; set; }
public bool EbuStlTeletextUseDoubleHeight { get; set; }
@ -330,6 +336,8 @@ namespace Nikse.SubtitleEdit.Core
FcpFontSize = 18;
FcpFontName = "Lucida Grande";
Cavena890StartOfMessage = "10:00:00:00";
}
public void InitializeDCinameSettings(bool smpte)
@ -1911,6 +1919,10 @@ namespace Nikse.SubtitleEdit.Core
subNode = node.SelectSingleNode("NuendoCharacterListFile");
if (subNode != null)
settings.SubtitleSettings.NuendoCharacterListFile = subNode.InnerText;
subNode = node.SelectSingleNode("Cavena890StartOfMessage");
if (subNode != null)
settings.SubtitleSettings.Cavena890StartOfMessage = subNode.InnerText;
}
settings.Proxy = new ProxySettings();
@ -3003,6 +3015,7 @@ namespace Nikse.SubtitleEdit.Core
textWriter.WriteElementString("TimedText10ShowStyleAndLanguage", settings.SubtitleSettings.TimedText10ShowStyleAndLanguage.ToString());
textWriter.WriteElementString("FcpFontSize", settings.SubtitleSettings.FcpFontSize.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("FcpFontName", settings.SubtitleSettings.FcpFontName);
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("CheetahCaptionAlwayWriteEndTime", settings.SubtitleSettings.CheetahCaptionAlwayWriteEndTime.ToString(CultureInfo.InvariantCulture));

View File

@ -8,13 +8,13 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
{
public class Cavena890 : SubtitleFormat
{
private const int LanguageIdDanish = 0x07;
private const int LanguageIdEnglish = 0x09;
private const int LanguageIdRussian = 0x56;
private const int LanguageIdArabic = 0x80;
private const int LanguageIdHebrew = 0x8f;
private const int LanguageIdChineseTraditional = 0x90;
private const int LanguageIdChineseSimplified = 0x91;
public const int LanguageIdDanish = 0x07;
public const int LanguageIdEnglish = 0x09;
public const int LanguageIdRussian = 0x56;
public const int LanguageIdArabic = 0x80;
public const int LanguageIdHebrew = 0x8f;
public const int LanguageIdChineseTraditional = 0x90;
public const int LanguageIdChineseSimplified = 0x91;
private static readonly List<int> HebrewCodes = new List<int> {
0x40, // א
@ -217,26 +217,33 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
}
}
var language = LanguageAutoDetect.AutoDetectGoogleLanguage(subtitle);
if (language == "he") // Hebrew
if (Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId > 0)
{
_languageIdLine1 = LanguageIdHebrew;
_languageIdLine2 = LanguageIdHebrew; // or 0x09
_languageIdLine1 = Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId;
_languageIdLine2 = Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId;
}
else if (language == "ru")
else
{
_languageIdLine1 = LanguageIdRussian;
_languageIdLine2 = LanguageIdRussian; // or 0x09?
}
else if (language == "zh")
{
_languageIdLine1 = LanguageIdChineseSimplified;
_languageIdLine2 = LanguageIdChineseSimplified;
}
else if (language == "da")
{
_languageIdLine1 = LanguageIdDanish;
_languageIdLine2 = LanguageIdDanish;
var language = LanguageAutoDetect.AutoDetectGoogleLanguage(subtitle);
switch (language)
{
case "he":
_languageIdLine1 = LanguageIdHebrew;
_languageIdLine2 = LanguageIdHebrew; // or 0x09
break;
case "ru":
_languageIdLine1 = LanguageIdRussian;
_languageIdLine2 = LanguageIdRussian; // or 0x09?
break;
case "zh":
_languageIdLine1 = LanguageIdChineseSimplified;
_languageIdLine2 = LanguageIdChineseSimplified;
break;
case "da":
_languageIdLine1 = LanguageIdDanish;
_languageIdLine2 = LanguageIdDanish;
break;
}
}
// prompt???
@ -262,14 +269,26 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
string title = Path.GetFileNameWithoutExtension(fileName) ?? string.Empty;
if (title.Length > 28)
title = title.Substring(0, 28);
if (!string.IsNullOrWhiteSpace(Configuration.Settings.SubtitleSettings.CurrentCavena89Title) && Configuration.Settings.SubtitleSettings.CurrentCavena89Title.Length <= 28)
title = Configuration.Settings.SubtitleSettings.CurrentCavena89Title;
var buffer = Encoding.ASCII.GetBytes(title);
fs.Write(buffer, 0, buffer.Length);
for (int i = 0; i < 28 - buffer.Length; i++)
fs.WriteByte(0);
// translator (28 bytes)
for (int i = 0; i < 28; i++)
fs.WriteByte(0);
if (!string.IsNullOrWhiteSpace(Configuration.Settings.SubtitleSettings.CurrentCavena890Translator) && Configuration.Settings.SubtitleSettings.CurrentCavena890Translator.Length <= 28)
{
buffer = Encoding.ASCII.GetBytes(Configuration.Settings.SubtitleSettings.CurrentCavena890Translator);
fs.Write(buffer, 0, buffer.Length);
for (int i = 0; i < 28 - buffer.Length; i++)
fs.WriteByte(0);
}
else
{
for (int i = 0; i < 28; i++)
fs.WriteByte(0);
}
// ?
for (int i = 0; i < 9; i++)
@ -288,7 +307,10 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
fs.Write(buffer, 0, buffer.Length);
// comments (24 bytes)
buffer = Encoding.ASCII.GetBytes("Made with Subtitle Edit");
buffer = Encoding.ASCII.GetBytes("");
if (!string.IsNullOrWhiteSpace(Configuration.Settings.SubtitleSettings.CurrentCavena89Comment) && Configuration.Settings.SubtitleSettings.CurrentCavena89Comment.Length <= 24)
buffer = Encoding.ASCII.GetBytes(Configuration.Settings.SubtitleSettings.CurrentCavena89Comment);
fs.Write(buffer, 0, buffer.Length);
for (int i = 0; i < 24 - buffer.Length; i++)
fs.WriteByte(0);
@ -311,37 +333,52 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
for (int i = 0; i < 13; i++)
fs.WriteByte(0);
// some language codes again?
if (_languageIdLine1 == LanguageIdHebrew || _languageIdLine2 == LanguageIdHebrew)
{
buffer = new byte[] { 0x64, 0x02, 0x64, 0x02 };
}
else if (_languageIdLine1 == LanguageIdRussian || _languageIdLine2 == LanguageIdRussian)
{
buffer = new byte[] { 0xce, 0x00, 0xce, 0x00 };
}
else
{
buffer = new byte[] { 0x37, 0x00, 0x37, 0x00 }; // seen in English files
}
fs.Write(buffer, 0, buffer.Length);
// number of subtitles again
fs.WriteByte((byte)(subtitle.Paragraphs.Count % 256));
fs.WriteByte((byte)(subtitle.Paragraphs.Count / 256));
// number of subtitles again again
fs.WriteByte((byte)(subtitle.Paragraphs.Count % 256));
fs.WriteByte((byte)(subtitle.Paragraphs.Count / 256));
// ?
for (int i = 0; i < 6; i++)
fs.WriteByte(0);
// original programme title (28 chars)
for (int i = 0; i < 28; i++)
fs.WriteByte(0);
if (!string.IsNullOrWhiteSpace(Configuration.Settings.SubtitleSettings.CurrentCavena890riginalTitle) && Configuration.Settings.SubtitleSettings.CurrentCavena890riginalTitle.Length <= 28)
{
buffer = Encoding.ASCII.GetBytes(Configuration.Settings.SubtitleSettings.CurrentCavena890riginalTitle);
fs.Write(buffer, 0, buffer.Length);
for (int i = 0; i < 28 - buffer.Length; i++)
fs.WriteByte(0);
}
else
{
for (int i = 0; i < 28; i++)
fs.WriteByte(0);
}
// write font (use same font id from line 1)
buffer = GetFontBytesFromLanguageId(_languageIdLine1);
fs.Write(buffer, 0, buffer.Length);
// ?
fs.WriteByte(0x3d);
fs.WriteByte(0x8d);
// start of message time
string startOfMessage = "10:00:00:00";
if (Configuration.Settings.SubtitleSettings.Cavena890StartOfMessage != null &&
Configuration.Settings.SubtitleSettings.Cavena890StartOfMessage.Length == startOfMessage.Length)
startOfMessage = Configuration.Settings.SubtitleSettings.Cavena890StartOfMessage;
buffer = Encoding.ASCII.GetBytes(startOfMessage);
fs.Write(buffer, 0, buffer.Length);
buffer = new byte[]
{
0x3d, 0x8d, 0x31, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x54, 0x44
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x54, 0x44
};
fs.Write(buffer, 0, buffer.Length);

257
src/Forms/Cavena890SaveOptions.Designer.cs generated Normal file
View File

@ -0,0 +1,257 @@
namespace Nikse.SubtitleEdit.Forms
{
partial class Cavena890SaveOptions
{
/// <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.labelTimeCodeStartOfProgramme = new System.Windows.Forms.Label();
this.buttonOK = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonImport = new System.Windows.Forms.Button();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.textBoxComment = new System.Windows.Forms.TextBox();
this.labelComment = new System.Windows.Forms.Label();
this.textBoxTranslatedTitle = new System.Windows.Forms.TextBox();
this.labelTranslatedTitle = new System.Windows.Forms.Label();
this.textBoxOriginalTitle = new System.Windows.Forms.TextBox();
this.labelOriginalTitle = new System.Windows.Forms.Label();
this.textBoxTranslator = new System.Windows.Forms.TextBox();
this.labelTranslator = new System.Windows.Forms.Label();
this.timeUpDownStartTime = new Nikse.SubtitleEdit.Controls.TimeUpDown();
this.comboBoxLanguage = new System.Windows.Forms.ComboBox();
this.labelLanguage = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// labelTimeCodeStartOfProgramme
//
this.labelTimeCodeStartOfProgramme.AutoSize = true;
this.labelTimeCodeStartOfProgramme.Location = new System.Drawing.Point(12, 180);
this.labelTimeCodeStartOfProgramme.Name = "labelTimeCodeStartOfProgramme";
this.labelTimeCodeStartOfProgramme.Size = new System.Drawing.Size(152, 13);
this.labelTimeCodeStartOfProgramme.TabIndex = 10;
this.labelTimeCodeStartOfProgramme.Text = "Time code: Start of programme";
//
// 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(250, 264);
this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new System.Drawing.Size(75, 21);
this.buttonOK.TabIndex = 12;
this.buttonOK.Text = "Save";
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(331, 264);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 21);
this.buttonCancel.TabIndex = 13;
this.buttonCancel.Text = "C&ancel";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// buttonImport
//
this.buttonImport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonImport.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonImport.Location = new System.Drawing.Point(290, 12);
this.buttonImport.Name = "buttonImport";
this.buttonImport.Size = new System.Drawing.Size(116, 21);
this.buttonImport.TabIndex = 14;
this.buttonImport.Text = "Import...";
this.buttonImport.UseVisualStyleBackColor = true;
this.buttonImport.Click += new System.EventHandler(this.buttonImport_Click);
//
// openFileDialog1
//
this.openFileDialog1.FileName = "openFileDialog1";
//
// textBoxComment
//
this.textBoxComment.Location = new System.Drawing.Point(185, 117);
this.textBoxComment.MaxLength = 24;
this.textBoxComment.Name = "textBoxComment";
this.textBoxComment.Size = new System.Drawing.Size(219, 20);
this.textBoxComment.TabIndex = 7;
//
// labelComment
//
this.labelComment.AutoSize = true;
this.labelComment.Location = new System.Drawing.Point(13, 120);
this.labelComment.Name = "labelComment";
this.labelComment.Size = new System.Drawing.Size(51, 13);
this.labelComment.TabIndex = 6;
this.labelComment.Text = "Comment";
//
// textBoxTranslatedTitle
//
this.textBoxTranslatedTitle.Location = new System.Drawing.Point(185, 39);
this.textBoxTranslatedTitle.MaxLength = 28;
this.textBoxTranslatedTitle.Name = "textBoxTranslatedTitle";
this.textBoxTranslatedTitle.Size = new System.Drawing.Size(219, 20);
this.textBoxTranslatedTitle.TabIndex = 1;
//
// labelTranslatedTitle
//
this.labelTranslatedTitle.AutoSize = true;
this.labelTranslatedTitle.Location = new System.Drawing.Point(13, 42);
this.labelTranslatedTitle.Name = "labelTranslatedTitle";
this.labelTranslatedTitle.Size = new System.Drawing.Size(76, 13);
this.labelTranslatedTitle.TabIndex = 0;
this.labelTranslatedTitle.Text = "Translated title";
//
// textBoxOriginalTitle
//
this.textBoxOriginalTitle.Location = new System.Drawing.Point(185, 65);
this.textBoxOriginalTitle.MaxLength = 24;
this.textBoxOriginalTitle.Name = "textBoxOriginalTitle";
this.textBoxOriginalTitle.Size = new System.Drawing.Size(219, 20);
this.textBoxOriginalTitle.TabIndex = 3;
//
// labelOriginalTitle
//
this.labelOriginalTitle.AutoSize = true;
this.labelOriginalTitle.Location = new System.Drawing.Point(13, 68);
this.labelOriginalTitle.Name = "labelOriginalTitle";
this.labelOriginalTitle.Size = new System.Drawing.Size(61, 13);
this.labelOriginalTitle.TabIndex = 2;
this.labelOriginalTitle.Text = "Original title";
//
// textBoxTranslator
//
this.textBoxTranslator.Location = new System.Drawing.Point(185, 91);
this.textBoxTranslator.MaxLength = 24;
this.textBoxTranslator.Name = "textBoxTranslator";
this.textBoxTranslator.Size = new System.Drawing.Size(219, 20);
this.textBoxTranslator.TabIndex = 5;
//
// labelTranslator
//
this.labelTranslator.AutoSize = true;
this.labelTranslator.Location = new System.Drawing.Point(13, 94);
this.labelTranslator.Name = "labelTranslator";
this.labelTranslator.Size = new System.Drawing.Size(54, 13);
this.labelTranslator.TabIndex = 4;
this.labelTranslator.Text = "Translator";
//
// timeUpDownStartTime
//
this.timeUpDownStartTime.AutoSize = true;
this.timeUpDownStartTime.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.timeUpDownStartTime.Location = new System.Drawing.Point(183, 175);
this.timeUpDownStartTime.Margin = new System.Windows.Forms.Padding(4);
this.timeUpDownStartTime.Name = "timeUpDownStartTime";
this.timeUpDownStartTime.Size = new System.Drawing.Size(96, 24);
this.timeUpDownStartTime.TabIndex = 11;
this.timeUpDownStartTime.UseVideoOffset = false;
//
// comboBoxLanguage
//
this.comboBoxLanguage.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxLanguage.FormattingEnabled = true;
this.comboBoxLanguage.Items.AddRange(new object[] {
"Arabic",
"Danish",
"Chinese Simplified",
"Chinese Traditional",
"English",
"Hebrew",
"Russian"});
this.comboBoxLanguage.Location = new System.Drawing.Point(185, 147);
this.comboBoxLanguage.Name = "comboBoxLanguage";
this.comboBoxLanguage.Size = new System.Drawing.Size(219, 21);
this.comboBoxLanguage.TabIndex = 9;
//
// labelLanguage
//
this.labelLanguage.AutoSize = true;
this.labelLanguage.Location = new System.Drawing.Point(16, 150);
this.labelLanguage.Name = "labelLanguage";
this.labelLanguage.Size = new System.Drawing.Size(55, 13);
this.labelLanguage.TabIndex = 8;
this.labelLanguage.Text = "Language";
//
// Cavena890SaveOptions
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(418, 297);
this.Controls.Add(this.labelLanguage);
this.Controls.Add(this.comboBoxLanguage);
this.Controls.Add(this.textBoxTranslator);
this.Controls.Add(this.labelTranslator);
this.Controls.Add(this.textBoxOriginalTitle);
this.Controls.Add(this.labelOriginalTitle);
this.Controls.Add(this.textBoxComment);
this.Controls.Add(this.labelComment);
this.Controls.Add(this.textBoxTranslatedTitle);
this.Controls.Add(this.labelTranslatedTitle);
this.Controls.Add(this.buttonImport);
this.Controls.Add(this.buttonOK);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.labelTimeCodeStartOfProgramme);
this.Controls.Add(this.timeUpDownStartTime);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.KeyPreview = true;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "Cavena890SaveOptions";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Cavena 890 save options";
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Cavena890SaveOptions_KeyDown);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label labelTimeCodeStartOfProgramme;
private Controls.TimeUpDown timeUpDownStartTime;
private System.Windows.Forms.Button buttonOK;
private System.Windows.Forms.Button buttonCancel;
private System.Windows.Forms.Button buttonImport;
private System.Windows.Forms.OpenFileDialog openFileDialog1;
private System.Windows.Forms.TextBox textBoxComment;
private System.Windows.Forms.Label labelComment;
private System.Windows.Forms.TextBox textBoxTranslatedTitle;
private System.Windows.Forms.Label labelTranslatedTitle;
private System.Windows.Forms.TextBox textBoxOriginalTitle;
private System.Windows.Forms.Label labelOriginalTitle;
private System.Windows.Forms.TextBox textBoxTranslator;
private System.Windows.Forms.Label labelTranslator;
private System.Windows.Forms.ComboBox comboBoxLanguage;
private System.Windows.Forms.Label labelLanguage;
}
}

View File

@ -0,0 +1,168 @@
using System;
using System.IO;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Core.SubtitleFormats;
namespace Nikse.SubtitleEdit.Forms
{
public partial class Cavena890SaveOptions : Form
{
public Cavena890SaveOptions(Subtitle subtitle, string subtitleFileName)
{
InitializeComponent();
buttonCancel.Text = Configuration.Settings.Language.General.Cancel;
buttonOK.Text = Configuration.Settings.Language.General.Ok;
timeUpDownStartTime.ForceHHMMSSFF();
timeUpDownStartTime.TimeCode = new TimeCode(TimeCode.ParseHHMMSSFFToMilliseconds(Configuration.Settings.SubtitleSettings.Cavena890StartOfMessage));
textBoxTranslatedTitle.Text = Configuration.Settings.SubtitleSettings.CurrentCavena89Title;
textBoxOriginalTitle.Text = Configuration.Settings.SubtitleSettings.CurrentCavena890riginalTitle;
textBoxTranslator.Text = Configuration.Settings.SubtitleSettings.CurrentCavena890Translator;
textBoxComment.Text = Configuration.Settings.SubtitleSettings.CurrentCavena89Comment;
if (string.IsNullOrWhiteSpace(textBoxComment.Text))
{
textBoxComment.Text = "Made with Subtitle Edit";
}
if (string.IsNullOrWhiteSpace(Configuration.Settings.SubtitleSettings.CurrentCavena89Title))
{
string title = Path.GetFileNameWithoutExtension(subtitleFileName) ?? string.Empty;
if (title.Length > 28)
title = title.Substring(0, 28);
textBoxTranslatedTitle.Text = title;
}
var language = LanguageAutoDetect.AutoDetectGoogleLanguage(subtitle);
switch (language)
{
case "he":
Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdHebrew;
comboBoxLanguage.SelectedIndex = 5;
break;
case "ru":
Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdRussian;
comboBoxLanguage.SelectedIndex = 6;
break;
case "zh":
Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdChineseSimplified;
comboBoxLanguage.SelectedIndex = 2;
break;
case "da":
Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdDanish;
comboBoxLanguage.SelectedIndex = 1;
break;
default:
Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdEnglish;
comboBoxLanguage.SelectedIndex = 4;
break;
}
}
private void Cavena890SaveOptions_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape)
{
DialogResult = DialogResult.Cancel;
}
}
private void buttonOK_Click(object sender, EventArgs e)
{
Configuration.Settings.SubtitleSettings.Cavena890StartOfMessage = timeUpDownStartTime.TimeCode.ToHHMMSSFF();
Configuration.Settings.SubtitleSettings.CurrentCavena89Title = textBoxTranslatedTitle.Text;
Configuration.Settings.SubtitleSettings.CurrentCavena890riginalTitle = textBoxOriginalTitle.Text;
Configuration.Settings.SubtitleSettings.CurrentCavena890Translator = textBoxTranslator.Text;
Configuration.Settings.SubtitleSettings.CurrentCavena89Comment = textBoxComment.Text;
switch (comboBoxLanguage.SelectedIndex)
{
case 0:
Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdArabic;
break;
case 1:
Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdDanish;
break;
case 2:
Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdChineseSimplified;
break;
case 3:
Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdChineseTraditional;
break;
case 5:
Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdHebrew;
break;
case 6:
Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdRussian;
break;
default:
Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdEnglish;
break;
}
DialogResult = DialogResult.OK;
}
private void buttonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
}
private void buttonImport_Click(object sender, EventArgs e)
{
openFileDialog1.Filter = "Cavena 890 (*.890)|*.890";
openFileDialog1.FileName = string.Empty;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
var buffer = FileUtil.ReadAllBytesShared(openFileDialog1.FileName);
if (buffer.Length > 270)
{
var s = System.Text.Encoding.ASCII.GetString(buffer, 40, 28);
textBoxTranslatedTitle.Text = s.Replace("\0", string.Empty);
s = System.Text.Encoding.ASCII.GetString(buffer, 218, 28);
textBoxOriginalTitle.Text = s.Replace("\0", string.Empty);
s = System.Text.Encoding.ASCII.GetString(buffer, 68, 28);
textBoxTranslator.Text = s.Replace("\0", string.Empty);
s = System.Text.Encoding.ASCII.GetString(buffer, 148, 24);
textBoxComment.Text = s.Replace("\0", string.Empty);
s = System.Text.Encoding.ASCII.GetString(buffer, 256, 11);
timeUpDownStartTime.TimeCode = new TimeCode(TimeCode.ParseHHMMSSFFToMilliseconds(s));
switch (buffer[146])
{
case Cavena890.LanguageIdHebrew:
Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdHebrew;
comboBoxLanguage.SelectedIndex = 5;
break;
case Cavena890.LanguageIdRussian:
Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdRussian;
comboBoxLanguage.SelectedIndex = 6;
break;
case Cavena890.LanguageIdChineseSimplified:
Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdChineseSimplified;
comboBoxLanguage.SelectedIndex = 2;
break;
case Cavena890.LanguageIdChineseTraditional:
Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdChineseSimplified;
comboBoxLanguage.SelectedIndex = 3;
break;
case Cavena890.LanguageIdDanish:
Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdDanish;
comboBoxLanguage.SelectedIndex = 1;
break;
default:
Configuration.Settings.SubtitleSettings.CurrentCavena89LanguageId = Cavena890.LanguageIdEnglish;
comboBoxLanguage.SelectedIndex = 4;
break;
}
}
}
}
}
}

View File

@ -0,0 +1,123 @@
<?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>
<metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -17575,7 +17575,13 @@ namespace Nikse.SubtitleEdit.Forms
fileName = fileName.Substring(0, fileName.Length - 1);
fileName += cavena890.Extension;
}
cavena890.Save(fileName, _subtitle);
using (var form = new Cavena890SaveOptions(_subtitle, _fileName))
{
if (form.ShowDialog(this) == DialogResult.OK)
{
cavena890.Save(fileName, _subtitle);
}
}
}
}

View File

@ -94,6 +94,12 @@
<Compile Include="Forms\AddWaveformBatch.Designer.cs">
<DependentUpon>AddWaveformBatch.cs</DependentUpon>
</Compile>
<Compile Include="Forms\Cavena890SaveOptions.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\Cavena890SaveOptions.Designer.cs">
<DependentUpon>Cavena890SaveOptions.cs</DependentUpon>
</Compile>
<Compile Include="Forms\CheckForUpdates.cs">
<SubType>Form</SubType>
</Compile>
@ -894,6 +900,9 @@
<EmbeddedResource Include="Forms\AddWaveformBatch.resx">
<DependentUpon>AddWaveformBatch.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\Cavena890SaveOptions.resx">
<DependentUpon>Cavena890SaveOptions.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\CheckForUpdates.resx">
<DependentUpon>CheckForUpdates.cs</DependentUpon>
</EmbeddedResource>