From e20656f117486da75cda053f0b4807dd80400571 Mon Sep 17 00:00:00 2001 From: niksedk Date: Tue, 12 Apr 2011 21:46:15 +0000 Subject: [PATCH] Export PNG + hunspell spell checking working on linux - thx for linux info Hawke :) git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@395 99eadd0c-20b8-1223-b5c4-2a2b2df33de2 --- src/Forms/ExportPngXml.Designer.cs | 381 +++++++++++++++++++++ src/Forms/ExportPngXml.cs | 251 ++++++++++++++ src/Forms/ExportPngXml.resx | 126 +++++++ src/Forms/Main.Designer.cs | 510 +++++++++++++++-------------- src/Forms/Main.cs | 7 + src/Forms/Main.resx | 2 +- src/Forms/SpellCheck.cs | 34 +- src/Forms/VobSubOcr.cs | 4 +- src/Logic/Language.cs | 15 + src/Logic/LanguageStructure.cs | 14 + src/Logic/LinuxHunspell.cs | 65 ++++ src/Logic/OCR/OcrFixEngine.cs | 44 ++- src/SubtitleEdit.csproj | 10 + 13 files changed, 1202 insertions(+), 261 deletions(-) create mode 100644 src/Forms/ExportPngXml.Designer.cs create mode 100644 src/Forms/ExportPngXml.cs create mode 100644 src/Forms/ExportPngXml.resx create mode 100644 src/Logic/LinuxHunspell.cs diff --git a/src/Forms/ExportPngXml.Designer.cs b/src/Forms/ExportPngXml.Designer.cs new file mode 100644 index 000000000..fa1dd0072 --- /dev/null +++ b/src/Forms/ExportPngXml.Designer.cs @@ -0,0 +1,381 @@ +namespace Nikse.SubtitleEdit.Forms +{ + partial class ExportPngXml + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.buttonExport = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog(); + this.progressBar1 = new System.Windows.Forms.ProgressBar(); + this.groupBoxImageSettings = new System.Windows.Forms.GroupBox(); + this.checkBoxAntiAlias = new System.Windows.Forms.CheckBox(); + this.labelSubtitleFontSize = new System.Windows.Forms.Label(); + this.comboBoxSubtitleFont = new System.Windows.Forms.ComboBox(); + this.comboBoxSubtitleFontSize = new System.Windows.Forms.ComboBox(); + this.labelSubtitleFont = new System.Windows.Forms.Label(); + this.labelBorderWidth = new System.Windows.Forms.Label(); + this.comboBoxBorderWidth = new System.Windows.Forms.ComboBox(); + this.panelBorderColor = new System.Windows.Forms.Panel(); + this.buttonBorderColor = new System.Windows.Forms.Button(); + this.panelColor = new System.Windows.Forms.Panel(); + this.buttonColor = new System.Windows.Forms.Button(); + this.colorDialog1 = new System.Windows.Forms.ColorDialog(); + this.labelImageResolution = new System.Windows.Forms.Label(); + this.subtitleListView1 = new Nikse.SubtitleEdit.Controls.SubtitleListView(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + this.groupBoxImageSettings.SuspendLayout(); + this.SuspendLayout(); + // + // pictureBox1 + // + this.pictureBox1.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.pictureBox1.Location = new System.Drawing.Point(12, 243); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(698, 132); + this.pictureBox1.TabIndex = 1; + this.pictureBox1.TabStop = false; + // + // buttonExport + // + this.buttonExport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonExport.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.buttonExport.Location = new System.Drawing.Point(503, 381); + this.buttonExport.Name = "buttonExport"; + this.buttonExport.Size = new System.Drawing.Size(126, 21); + this.buttonExport.TabIndex = 19; + this.buttonExport.Text = "Export all lines..."; + this.buttonExport.UseVisualStyleBackColor = true; + this.buttonExport.Click += new System.EventHandler(this.buttonExport_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(635, 381); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 21); + this.buttonCancel.TabIndex = 18; + this.buttonCancel.Text = "C&ancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // progressBar1 + // + 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(12, 381); + this.progressBar1.Name = "progressBar1"; + this.progressBar1.Size = new System.Drawing.Size(485, 21); + this.progressBar1.TabIndex = 20; + this.progressBar1.Visible = false; + // + // groupBoxImageSettings + // + this.groupBoxImageSettings.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxImageSettings.Controls.Add(this.checkBoxAntiAlias); + this.groupBoxImageSettings.Controls.Add(this.labelSubtitleFontSize); + this.groupBoxImageSettings.Controls.Add(this.comboBoxSubtitleFont); + this.groupBoxImageSettings.Controls.Add(this.comboBoxSubtitleFontSize); + this.groupBoxImageSettings.Controls.Add(this.labelSubtitleFont); + this.groupBoxImageSettings.Controls.Add(this.labelBorderWidth); + this.groupBoxImageSettings.Controls.Add(this.comboBoxBorderWidth); + this.groupBoxImageSettings.Controls.Add(this.panelBorderColor); + this.groupBoxImageSettings.Controls.Add(this.buttonBorderColor); + this.groupBoxImageSettings.Controls.Add(this.panelColor); + this.groupBoxImageSettings.Controls.Add(this.buttonColor); + this.groupBoxImageSettings.Location = new System.Drawing.Point(12, 150); + this.groupBoxImageSettings.Name = "groupBoxImageSettings"; + this.groupBoxImageSettings.Size = new System.Drawing.Size(698, 87); + this.groupBoxImageSettings.TabIndex = 21; + this.groupBoxImageSettings.TabStop = false; + this.groupBoxImageSettings.Text = "Image settings"; + // + // checkBoxAntiAlias + // + this.checkBoxAntiAlias.AutoSize = true; + this.checkBoxAntiAlias.Checked = true; + this.checkBoxAntiAlias.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxAntiAlias.Location = new System.Drawing.Point(276, 55); + this.checkBoxAntiAlias.Name = "checkBoxAntiAlias"; + this.checkBoxAntiAlias.Size = new System.Drawing.Size(66, 17); + this.checkBoxAntiAlias.TabIndex = 21; + this.checkBoxAntiAlias.Text = "AntiAlias"; + this.checkBoxAntiAlias.UseVisualStyleBackColor = true; + this.checkBoxAntiAlias.CheckedChanged += new System.EventHandler(this.checkBoxAntiAlias_CheckedChanged); + // + // labelSubtitleFontSize + // + this.labelSubtitleFontSize.AutoSize = true; + this.labelSubtitleFontSize.Location = new System.Drawing.Point(10, 54); + this.labelSubtitleFontSize.Name = "labelSubtitleFontSize"; + this.labelSubtitleFontSize.Size = new System.Drawing.Size(84, 13); + this.labelSubtitleFontSize.TabIndex = 20; + this.labelSubtitleFontSize.Text = "Subtitle font size"; + // + // comboBoxSubtitleFont + // + this.comboBoxSubtitleFont.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxSubtitleFont.FormattingEnabled = true; + this.comboBoxSubtitleFont.Location = new System.Drawing.Point(100, 24); + this.comboBoxSubtitleFont.Name = "comboBoxSubtitleFont"; + this.comboBoxSubtitleFont.Size = new System.Drawing.Size(121, 21); + this.comboBoxSubtitleFont.TabIndex = 17; + this.comboBoxSubtitleFont.SelectedValueChanged += new System.EventHandler(this.comboBoxSubtitleFont_SelectedValueChanged); + // + // comboBoxSubtitleFontSize + // + this.comboBoxSubtitleFontSize.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxSubtitleFontSize.FormattingEnabled = true; + this.comboBoxSubtitleFontSize.Items.AddRange(new object[] { + "15", + "16", + "17", + "18", + "19", + "20", + "21", + "22", + "23", + "24", + "25", + "26", + "27", + "28", + "29", + "30", + "31", + "32", + "33", + "34", + "35", + "36", + "37", + "38", + "39", + "40", + "41", + "42", + "43", + "44", + "45", + "46", + "47", + "48", + "49", + "50", + "51", + "52", + "53", + "54", + "55", + "56", + "57", + "58", + "59", + "60", + "61", + "62", + "63", + "64", + "65", + "66", + "67", + "68", + "69", + "70", + "71", + "72", + "73", + "74", + "75", + "80", + "85", + "90", + "100"}); + this.comboBoxSubtitleFontSize.Location = new System.Drawing.Point(100, 51); + this.comboBoxSubtitleFontSize.Name = "comboBoxSubtitleFontSize"; + this.comboBoxSubtitleFontSize.Size = new System.Drawing.Size(121, 21); + this.comboBoxSubtitleFontSize.TabIndex = 18; + this.comboBoxSubtitleFontSize.SelectedIndexChanged += new System.EventHandler(this.comboBoxSubtitleFontSize_SelectedIndexChanged); + // + // labelSubtitleFont + // + this.labelSubtitleFont.AutoSize = true; + this.labelSubtitleFont.Location = new System.Drawing.Point(10, 27); + this.labelSubtitleFont.Name = "labelSubtitleFont"; + this.labelSubtitleFont.Size = new System.Drawing.Size(63, 13); + this.labelSubtitleFont.TabIndex = 19; + this.labelSubtitleFont.Text = "Subtitle font"; + // + // labelBorderWidth + // + this.labelBorderWidth.AutoSize = true; + this.labelBorderWidth.Location = new System.Drawing.Point(470, 56); + this.labelBorderWidth.Name = "labelBorderWidth"; + this.labelBorderWidth.Size = new System.Drawing.Size(66, 13); + this.labelBorderWidth.TabIndex = 16; + this.labelBorderWidth.Text = "Border width"; + // + // comboBoxBorderWidth + // + this.comboBoxBorderWidth.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxBorderWidth.FormattingEnabled = true; + this.comboBoxBorderWidth.Items.AddRange(new object[] { + "0", + "1", + "2", + "3", + "4", + "5"}); + this.comboBoxBorderWidth.Location = new System.Drawing.Point(537, 51); + this.comboBoxBorderWidth.Name = "comboBoxBorderWidth"; + this.comboBoxBorderWidth.Size = new System.Drawing.Size(121, 21); + this.comboBoxBorderWidth.TabIndex = 15; + this.comboBoxBorderWidth.SelectedIndexChanged += new System.EventHandler(this.comboBoxBorderWidth_SelectedIndexChanged); + // + // panelBorderColor + // + this.panelBorderColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panelBorderColor.Location = new System.Drawing.Point(664, 25); + this.panelBorderColor.Name = "panelBorderColor"; + this.panelBorderColor.Size = new System.Drawing.Size(21, 20); + this.panelBorderColor.TabIndex = 14; + this.panelBorderColor.MouseClick += new System.Windows.Forms.MouseEventHandler(this.panelBorderColor_MouseClick); + // + // buttonBorderColor + // + this.buttonBorderColor.Location = new System.Drawing.Point(537, 24); + this.buttonBorderColor.Name = "buttonBorderColor"; + this.buttonBorderColor.Size = new System.Drawing.Size(121, 21); + this.buttonBorderColor.TabIndex = 13; + this.buttonBorderColor.Text = "Border color"; + this.buttonBorderColor.UseVisualStyleBackColor = true; + this.buttonBorderColor.Click += new System.EventHandler(this.buttonBorderColor_Click); + // + // panelColor + // + this.panelColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panelColor.Location = new System.Drawing.Point(403, 25); + this.panelColor.Name = "panelColor"; + this.panelColor.Size = new System.Drawing.Size(21, 20); + this.panelColor.TabIndex = 12; + this.panelColor.MouseClick += new System.Windows.Forms.MouseEventHandler(this.panelColor_MouseClick); + // + // buttonColor + // + this.buttonColor.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonColor.Location = new System.Drawing.Point(276, 24); + this.buttonColor.Name = "buttonColor"; + this.buttonColor.Size = new System.Drawing.Size(121, 21); + this.buttonColor.TabIndex = 11; + this.buttonColor.Text = "Color"; + this.buttonColor.UseVisualStyleBackColor = true; + this.buttonColor.Click += new System.EventHandler(this.buttonColor_Click); + // + // labelImageResolution + // + this.labelImageResolution.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.labelImageResolution.BackColor = System.Drawing.Color.Transparent; + this.labelImageResolution.Location = new System.Drawing.Point(635, 238); + this.labelImageResolution.Name = "labelImageResolution"; + this.labelImageResolution.Size = new System.Drawing.Size(73, 14); + this.labelImageResolution.TabIndex = 22; + this.labelImageResolution.Text = "320x240"; + this.labelImageResolution.TextAlign = System.Drawing.ContentAlignment.TopRight; + // + // subtitleListView1 + // + this.subtitleListView1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.subtitleListView1.FirstVisibleIndex = -1; + this.subtitleListView1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.subtitleListView1.FullRowSelect = true; + this.subtitleListView1.GridLines = true; + this.subtitleListView1.Location = new System.Drawing.Point(12, 12); + this.subtitleListView1.Name = "subtitleListView1"; + this.subtitleListView1.Size = new System.Drawing.Size(698, 131); + this.subtitleListView1.TabIndex = 0; + this.subtitleListView1.UseCompatibleStateImageBehavior = false; + this.subtitleListView1.View = System.Windows.Forms.View.Details; + this.subtitleListView1.SelectedIndexChanged += new System.EventHandler(this.subtitleListView1_SelectedIndexChanged); + // + // ExportPngXml + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(716, 407); + this.Controls.Add(this.labelImageResolution); + this.Controls.Add(this.groupBoxImageSettings); + this.Controls.Add(this.progressBar1); + this.Controls.Add(this.buttonExport); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.pictureBox1); + this.Controls.Add(this.subtitleListView1); + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(730, 430); + this.Name = "ExportPngXml"; + this.ShowIcon = false; + this.Text = "ExportPngXml"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ExportPngXml_KeyDown); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); + this.groupBoxImageSettings.ResumeLayout(false); + this.groupBoxImageSettings.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private Controls.SubtitleListView subtitleListView1; + private System.Windows.Forms.PictureBox pictureBox1; + private System.Windows.Forms.Button buttonExport; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1; + private System.Windows.Forms.ProgressBar progressBar1; + private System.Windows.Forms.GroupBox groupBoxImageSettings; + private System.Windows.Forms.Label labelBorderWidth; + private System.Windows.Forms.ComboBox comboBoxBorderWidth; + private System.Windows.Forms.Panel panelBorderColor; + private System.Windows.Forms.Button buttonBorderColor; + private System.Windows.Forms.Panel panelColor; + private System.Windows.Forms.Button buttonColor; + private System.Windows.Forms.Label labelSubtitleFontSize; + private System.Windows.Forms.ComboBox comboBoxSubtitleFont; + private System.Windows.Forms.ComboBox comboBoxSubtitleFontSize; + private System.Windows.Forms.Label labelSubtitleFont; + private System.Windows.Forms.ColorDialog colorDialog1; + private System.Windows.Forms.CheckBox checkBoxAntiAlias; + private System.Windows.Forms.Label labelImageResolution; + } +} \ No newline at end of file diff --git a/src/Forms/ExportPngXml.cs b/src/Forms/ExportPngXml.cs new file mode 100644 index 000000000..1a6458b6d --- /dev/null +++ b/src/Forms/ExportPngXml.cs @@ -0,0 +1,251 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using System.Drawing.Text; +using System.Drawing.Drawing2D; +using Nikse.SubtitleEdit.Logic; +using System.Xml; +using System.IO; + +namespace Nikse.SubtitleEdit.Forms +{ + public sealed partial class ExportPngXml : Form + { + Subtitle _subtitle; + Color _subtitleColor = Color.White; + string _subtitleFontName = "Verdana"; + float _subtitleFontSize = 75.0f; + Color _borderColor = Color.Black; + float _borderWidth = 2.0f; + bool _isLoading = true; + + public ExportPngXml() + { + InitializeComponent(); + } + + private static string BdnXmlTimeCode(TimeCode timecode) + { + int frames = timecode.Milliseconds / 40; // 40==25fps (1000/25) + return string.Format("{0:00}:{1:00}:{2:00}:{3:00}", timecode.Hours, timecode.Minutes, timecode.Seconds, frames); + } + + private void buttonExport_Click(object sender, EventArgs e) + { + SetupImageParameters(); + + if (folderBrowserDialog1.ShowDialog(this) == DialogResult.OK) + { + progressBar1.Value = 0; + progressBar1.Maximum = _subtitle.Paragraphs.Count-1; + progressBar1.Visible = true; + const int height = 1080; + const int width = 1920; + const int border = 25; + int imagesSavedCount = 0; + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < _subtitle.Paragraphs.Count; i++) + { + Bitmap bmp = GenerateImageFromText(_subtitle.Paragraphs[i].Text); + string numberString = string.Format("{0:0000}", i + 1); + if (bmp != null) + { + + string fileName = Path.Combine(folderBrowserDialog1.SelectedPath, numberString + ".png"); + bmp.Save(fileName, System.Drawing.Imaging.ImageFormat.Png); + imagesSavedCount++; + + Paragraph p = _subtitle.Paragraphs[i]; + // + // subtitle_exp_0001.png + // + sb.AppendLine(""); + int x = (width - bmp.Width) / 2; + int y = height - (bmp.Height + border); + sb.AppendLine(" " + numberString + ".png"); + sb.AppendLine(""); + + bmp.Dispose(); + progressBar1.Value = i; + } + } + XmlDocument doc = new XmlDocument(); + Paragraph first = _subtitle.Paragraphs[0]; + Paragraph last = _subtitle.Paragraphs[_subtitle.Paragraphs.Count - 1]; + doc.LoadXml("" + Environment.NewLine + + "" + Environment.NewLine + + "" + Environment.NewLine + + "" + Environment.NewLine + + "" + Environment.NewLine + + "" + Environment.NewLine + + "" + Environment.NewLine + + "" + Environment.NewLine + + "" + Environment.NewLine + + "" + Environment.NewLine + + ""); + XmlNode events = doc.DocumentElement.SelectSingleNode("Events"); + events.InnerXml = sb.ToString(); + + File.WriteAllText(Path.Combine(folderBrowserDialog1.SelectedPath, "BDN_Index.xml"), doc.OuterXml); + progressBar1.Visible = false; + MessageBox.Show(string.Format(Configuration.Settings.Language.ExportPngXml.XImagesSavedInY, imagesSavedCount, folderBrowserDialog1.SelectedPath)); + } + } + + private void SetupImageParameters() + { + if (_isLoading) + return; + + _subtitleColor = panelColor.BackColor; + _borderColor = panelBorderColor.BackColor; + _subtitleFontName = comboBoxSubtitleFont.SelectedItem.ToString(); + _subtitleFontSize = float.Parse(comboBoxSubtitleFontSize.SelectedItem.ToString()); + _borderWidth = float.Parse(comboBoxBorderWidth.SelectedItem.ToString()); + } + + private Bitmap GenerateImageFromText(string text) + { + Font font = new System.Drawing.Font(_subtitleFontName, _subtitleFontSize); + Bitmap bmp = new Bitmap(400, 200); + Graphics g = Graphics.FromImage(bmp); + SizeF textSize = g.MeasureString(text, font); + g.Dispose(); + bmp.Dispose(); + bmp = new Bitmap((int)(textSize.Width * 0.8), (int)(textSize.Height * 0.7)); + g = Graphics.FromImage(bmp); + if (checkBoxAntiAlias.Checked) + { + g.TextRenderingHint = TextRenderingHint.AntiAlias; + g.SmoothingMode = SmoothingMode.AntiAlias; + } + StringFormat sf = new StringFormat(); + sf.Alignment = StringAlignment.Center; + sf.LineAlignment = StringAlignment.Center;// draw the text to a path + System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); + path.AddString(text, font.FontFamily, 0, font.Size, new Point(bmp.Width / 2, bmp.Height / 2), sf); + g.FillPath(new SolidBrush(_subtitleColor), path); + if (_borderWidth > 0) + g.DrawPath(new Pen(_borderColor, _borderWidth), path); + g.Dispose(); + return bmp; + } + + + internal void Initialize(Subtitle subtitle) + { + this.Text = Configuration.Settings.Language.ExportPngXml.Title; + groupBoxImageSettings.Text = Configuration.Settings.Language.ExportPngXml.ImageSettings; + labelSubtitleFont.Text = Configuration.Settings.Language.ExportPngXml.FontFamily; + labelSubtitleFontSize.Text = Configuration.Settings.Language.ExportPngXml.FontSize; + buttonColor.Text = Configuration.Settings.Language.ExportPngXml.FontColor; + checkBoxAntiAlias.Text = Configuration.Settings.Language.ExportPngXml.AntiAlias; + buttonBorderColor.Text = Configuration.Settings.Language.ExportPngXml.BorderColor; + labelBorderWidth.Text = Configuration.Settings.Language.ExportPngXml.BorderWidth; + buttonExport.Text = Configuration.Settings.Language.ExportPngXml.ExportAllLines; + buttonCancel.Text = Configuration.Settings.Language.General.Cancel; + labelImageResolution.Text = string.Empty; + subtitleListView1.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings); + Utilities.InitializeSubtitleFont(subtitleListView1); + subtitleListView1.AutoSizeAllColumns(this); + + _subtitle = subtitle; + panelColor.BackColor = _subtitleColor; + panelBorderColor.BackColor = _borderColor; + comboBoxBorderWidth.SelectedIndex = 1; + + foreach (var x in System.Drawing.FontFamily.Families) + { + comboBoxSubtitleFont.Items.Add(x.Name); + if (string.Compare(x.Name, _subtitleFontName, true) == 0) + comboBoxSubtitleFont.SelectedIndex = comboBoxSubtitleFont.Items.Count - 1; + } + + subtitleListView1.Fill(_subtitle); + subtitleListView1.SelectIndexAndEnsureVisible(0); + + _isLoading = false; + comboBoxSubtitleFontSize.SelectedIndex = 15; + } + + private void subtitleListView1_SelectedIndexChanged(object sender, EventArgs e) + { + SetupImageParameters(); + if (subtitleListView1.SelectedItems.Count > 0) + { + var bmp = GenerateImageFromText(_subtitle.Paragraphs[subtitleListView1.SelectedItems[0].Index].Text); + pictureBox1.Image = bmp; + labelImageResolution.Text = string.Format("{0}x{1}", bmp.Width, bmp.Height); + } + } + + private void buttonColor_Click(object sender, EventArgs e) + { + colorDialog1.Color = panelColor.BackColor; + if (colorDialog1.ShowDialog() == DialogResult.OK) + { + panelColor.BackColor = colorDialog1.Color; + subtitleListView1_SelectedIndexChanged(null, null); + } + } + + private void panelColor_MouseClick(object sender, MouseEventArgs e) + { + buttonColor_Click(null, null); + } + + + private void buttonBorderColor_Click(object sender, EventArgs e) + { + colorDialog1.Color = panelBorderColor.BackColor; + if (colorDialog1.ShowDialog() == DialogResult.OK) + { + panelBorderColor.BackColor = colorDialog1.Color; + subtitleListView1_SelectedIndexChanged(null, null); + } + } + + private void panelBorderColor_MouseClick(object sender, MouseEventArgs e) + { + buttonBorderColor_Click(null, null); + } + + private void comboBoxSubtitleFont_SelectedValueChanged(object sender, EventArgs e) + { + subtitleListView1_SelectedIndexChanged(null, null); + } + + private void comboBoxSubtitleFontSize_SelectedIndexChanged(object sender, EventArgs e) + { + subtitleListView1_SelectedIndexChanged(null, null); + } + + private void comboBoxBorderWidth_SelectedIndexChanged(object sender, EventArgs e) + { + subtitleListView1_SelectedIndexChanged(null, null); + } + + private void checkBoxAntiAlias_CheckedChanged(object sender, EventArgs e) + { + subtitleListView1_SelectedIndexChanged(null, null); + } + + private void ExportPngXml_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Escape) + { + DialogResult = DialogResult.Cancel; + } + else if (e.KeyCode == Keys.F1) + { + Utilities.ShowHelp(string.Empty); + e.SuppressKeyPress = true; + } + } + + } +} diff --git a/src/Forms/ExportPngXml.resx b/src/Forms/ExportPngXml.resx new file mode 100644 index 000000000..b13f3c528 --- /dev/null +++ b/src/Forms/ExportPngXml.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 186, 17 + + \ No newline at end of file diff --git a/src/Forms/Main.Designer.cs b/src/Forms/Main.Designer.cs index 0f46a6b6a..afeba5ecf 100644 --- a/src/Forms/Main.Designer.cs +++ b/src/Forms/Main.Designer.cs @@ -84,6 +84,9 @@ this.toolStripMenuItemManualAnsi = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItemImportText = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItemImportTimeCodes = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator22 = new System.Windows.Forms.ToolStripSeparator(); + this.toolStripMenuItemExport = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemExportPngXml = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator10 = new System.Windows.Forms.ToolStripSeparator(); this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -216,6 +219,7 @@ this.toolStripMenuItemPlayRateNormal = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItemPlayRateFast = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItemPlayRateVeryFast = new System.Windows.Forms.ToolStripMenuItem(); + this.AudioWaveForm = new Nikse.SubtitleEdit.Controls.WaveForm(); this.tabControlButtons = new System.Windows.Forms.TabControl(); this.tabPageTranslate = new System.Windows.Forms.TabPage(); this.labelTranslateTip = new System.Windows.Forms.Label(); @@ -237,6 +241,7 @@ this.buttonPlayCurrent = new System.Windows.Forms.Button(); this.buttonPlayNext = new System.Windows.Forms.Button(); this.tabPageCreate = new System.Windows.Forms.TabPage(); + this.timeUpDownVideoPosition = new Nikse.SubtitleEdit.Controls.TimeUpDown(); this.buttonGotoSub = new System.Windows.Forms.Button(); this.buttonBeforeText = new System.Windows.Forms.Button(); this.buttonSetEnd = new System.Windows.Forms.Button(); @@ -255,6 +260,7 @@ this.labelVideoPosition = new System.Windows.Forms.Label(); this.buttonSecBack1 = new System.Windows.Forms.Button(); this.tabPageAdjust = new System.Windows.Forms.TabPage(); + this.timeUpDownVideoPositionAdjust = new Nikse.SubtitleEdit.Controls.TimeUpDown(); this.buttonAdjustSetEndTime = new System.Windows.Forms.Button(); this.buttonSetEndAndGoToNext = new System.Windows.Forms.Button(); this.buttonSetStartAndOffsetRest = new System.Windows.Forms.Button(); @@ -299,12 +305,28 @@ this.labelAlternateText = new System.Windows.Forms.Label(); this.labelText = new System.Windows.Forms.Label(); this.textBoxListViewTextAlternate = new System.Windows.Forms.TextBox(); + this.contextMenuStripTextBoxListView = new System.Windows.Forms.ContextMenuStrip(this.components); + this.cutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.pasteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItemSplitTextAtCursor = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator18 = new System.Windows.Forms.ToolStripSeparator(); + this.selectAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator17 = new System.Windows.Forms.ToolStripSeparator(); + this.normalToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.boldToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.italicToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.underlineToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.colorToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.fontNameToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.labelSingleLine = new System.Windows.Forms.Label(); this.buttonAutoBreak = new System.Windows.Forms.Button(); this.labelTextLineLengths = new System.Windows.Forms.Label(); this.labelTextLineTotal = new System.Windows.Forms.Label(); this.labelCharactersPerSecond = new System.Windows.Forms.Label(); this.buttonUnBreak = new System.Windows.Forms.Button(); + this.timeUpDownStartTime = new Nikse.SubtitleEdit.Controls.TimeUpDown(); this.buttonUndoListViewChanges = new System.Windows.Forms.Button(); this.labelStartTimeWarning = new System.Windows.Forms.Label(); this.labelDurationWarning = new System.Windows.Forms.Label(); @@ -315,33 +337,14 @@ this.textBoxListViewText = new System.Windows.Forms.TextBox(); this.labelDuration = new System.Windows.Forms.Label(); this.labelAutoDuration = new System.Windows.Forms.Label(); + this.SubtitleListview1 = new Nikse.SubtitleEdit.Controls.SubtitleListView(); this.tabPage2 = new System.Windows.Forms.TabPage(); this.textBoxSource = new System.Windows.Forms.TextBox(); this.panelVideoPlayer = new System.Windows.Forms.Panel(); + this.mediaPlayer = new Nikse.SubtitleEdit.Controls.VideoPlayerContainer(); this.contextMenuStripEmpty = new System.Windows.Forms.ContextMenuStrip(this.components); this.insertLineToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.imageListPlayRate = new System.Windows.Forms.ImageList(this.components); - this.cutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.pasteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator18 = new System.Windows.Forms.ToolStripSeparator(); - this.selectAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator17 = new System.Windows.Forms.ToolStripSeparator(); - this.normalToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); - this.boldToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); - this.italicToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); - this.underlineToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); - this.colorToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); - this.fontNameToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.contextMenuStripTextBoxListView = new System.Windows.Forms.ContextMenuStrip(this.components); - this.toolStripMenuItemSplitTextAtCursor = new System.Windows.Forms.ToolStripMenuItem(); - this.timeUpDownStartTime = new Nikse.SubtitleEdit.Controls.TimeUpDown(); - this.SubtitleListview1 = new Nikse.SubtitleEdit.Controls.SubtitleListView(); - this.mediaPlayer = new Nikse.SubtitleEdit.Controls.VideoPlayerContainer(); - this.AudioWaveForm = new Nikse.SubtitleEdit.Controls.WaveForm(); - this.timeUpDownVideoPosition = new Nikse.SubtitleEdit.Controls.TimeUpDown(); - this.timeUpDownVideoPositionAdjust = new Nikse.SubtitleEdit.Controls.TimeUpDown(); this.statusStrip1.SuspendLayout(); this.toolStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout(); @@ -371,11 +374,11 @@ this.tabControlSubtitle.SuspendLayout(); this.tabPage1.SuspendLayout(); this.groupBoxEdit.SuspendLayout(); + this.contextMenuStripTextBoxListView.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDuration)).BeginInit(); this.tabPage2.SuspendLayout(); this.panelVideoPlayer.SuspendLayout(); this.contextMenuStripEmpty.SuspendLayout(); - this.contextMenuStripTextBoxListView.SuspendLayout(); this.SuspendLayout(); // // statusStrip1 @@ -743,6 +746,8 @@ this.toolStripMenuItemManualAnsi, this.toolStripMenuItemImportText, this.toolStripMenuItemImportTimeCodes, + this.toolStripSeparator22, + this.toolStripMenuItemExport, this.toolStripSeparator10, this.exitToolStripMenuItem}); this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; @@ -893,6 +898,26 @@ this.toolStripMenuItemImportTimeCodes.Text = "Import time codes into existing subtitle..."; this.toolStripMenuItemImportTimeCodes.Click += new System.EventHandler(this.toolStripMenuItemImportTimeCodes_Click); // + // toolStripSeparator22 + // + this.toolStripSeparator22.Name = "toolStripSeparator22"; + this.toolStripSeparator22.Size = new System.Drawing.Size(331, 6); + // + // toolStripMenuItemExport + // + this.toolStripMenuItemExport.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripMenuItemExportPngXml}); + this.toolStripMenuItemExport.Name = "toolStripMenuItemExport"; + this.toolStripMenuItemExport.Size = new System.Drawing.Size(334, 22); + this.toolStripMenuItemExport.Text = "Export"; + // + // toolStripMenuItemExportPngXml + // + this.toolStripMenuItemExportPngXml.Name = "toolStripMenuItemExportPngXml"; + this.toolStripMenuItemExportPngXml.Size = new System.Drawing.Size(157, 22); + this.toolStripMenuItemExportPngXml.Text = "BDN xml/png..."; + this.toolStripMenuItemExportPngXml.Click += new System.EventHandler(this.toolStripMenuItemExportPngXml_Click); + // // toolStripSeparator10 // this.toolStripSeparator10.Name = "toolStripSeparator10"; @@ -1957,6 +1982,34 @@ this.toolStripMenuItemPlayRateVeryFast.Text = "Very fast"; this.toolStripMenuItemPlayRateVeryFast.Click += new System.EventHandler(this.veryFastToolStripMenuItem_Click); // + // AudioWaveForm + // + this.AudioWaveForm.AllowDrop = true; + this.AudioWaveForm.AllowNewSelection = true; + this.AudioWaveForm.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.AudioWaveForm.BackColor = System.Drawing.Color.Black; + this.AudioWaveForm.BackgroundColor = System.Drawing.Color.Black; + this.AudioWaveForm.Color = System.Drawing.Color.GreenYellow; + this.AudioWaveForm.DrawGridLines = true; + this.AudioWaveForm.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(18))))); + this.AudioWaveForm.Location = new System.Drawing.Point(472, 32); + this.AudioWaveForm.Margin = new System.Windows.Forms.Padding(0); + this.AudioWaveForm.Name = "AudioWaveForm"; + this.AudioWaveForm.NewSelectionParagraph = null; + this.AudioWaveForm.SelectedColor = System.Drawing.Color.Red; + this.AudioWaveForm.Size = new System.Drawing.Size(768, 229); + this.AudioWaveForm.StartPositionSeconds = 0D; + this.AudioWaveForm.TabIndex = 6; + this.AudioWaveForm.TextColor = System.Drawing.Color.Gray; + this.AudioWaveForm.WaveFormNotLoadedText = "Click to add wave form"; + this.AudioWaveForm.WavePeaks = null; + this.AudioWaveForm.ZoomFactor = 1D; + this.AudioWaveForm.Click += new System.EventHandler(this.AudioWaveForm_Click); + this.AudioWaveForm.DragDrop += new System.Windows.Forms.DragEventHandler(this.AudioWaveForm_DragDrop); + this.AudioWaveForm.DragEnter += new System.Windows.Forms.DragEventHandler(this.AudioWaveForm_DragEnter); + // // tabControlButtons // this.tabControlButtons.Controls.Add(this.tabPageTranslate); @@ -2232,6 +2285,16 @@ this.tabPageCreate.Text = "Create"; this.tabPageCreate.UseVisualStyleBackColor = true; // + // timeUpDownVideoPosition + // + this.timeUpDownVideoPosition.AutoSize = true; + this.timeUpDownVideoPosition.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.timeUpDownVideoPosition.Location = new System.Drawing.Point(86, 192); + this.timeUpDownVideoPosition.Margin = new System.Windows.Forms.Padding(4); + this.timeUpDownVideoPosition.Name = "timeUpDownVideoPosition"; + this.timeUpDownVideoPosition.Size = new System.Drawing.Size(92, 25); + this.timeUpDownVideoPosition.TabIndex = 12; + // // buttonGotoSub // this.buttonGotoSub.Location = new System.Drawing.Point(6, 58); @@ -2455,6 +2518,16 @@ this.tabPageAdjust.Text = "Adjust"; this.tabPageAdjust.UseVisualStyleBackColor = true; // + // timeUpDownVideoPositionAdjust + // + this.timeUpDownVideoPositionAdjust.AutoSize = true; + this.timeUpDownVideoPositionAdjust.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.timeUpDownVideoPositionAdjust.Location = new System.Drawing.Point(87, 214); + this.timeUpDownVideoPositionAdjust.Margin = new System.Windows.Forms.Padding(4); + this.timeUpDownVideoPositionAdjust.Name = "timeUpDownVideoPositionAdjust"; + this.timeUpDownVideoPositionAdjust.Size = new System.Drawing.Size(92, 25); + this.timeUpDownVideoPositionAdjust.TabIndex = 13; + // // buttonAdjustSetEndTime // this.buttonAdjustSetEndTime.Location = new System.Drawing.Point(6, 84); @@ -2929,6 +3002,126 @@ this.textBoxListViewTextAlternate.TextChanged += new System.EventHandler(this.textBoxListViewTextAlternate_TextChanged); this.textBoxListViewTextAlternate.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBoxListViewTextAlternate_KeyDown); // + // contextMenuStripTextBoxListView + // + this.contextMenuStripTextBoxListView.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.cutToolStripMenuItem, + this.copyToolStripMenuItem, + this.pasteToolStripMenuItem, + this.deleteToolStripMenuItem, + this.toolStripMenuItemSplitTextAtCursor, + this.toolStripSeparator18, + this.selectAllToolStripMenuItem, + this.toolStripSeparator17, + this.normalToolStripMenuItem1, + this.boldToolStripMenuItem1, + this.italicToolStripMenuItem1, + this.underlineToolStripMenuItem1, + this.colorToolStripMenuItem1, + this.fontNameToolStripMenuItem}); + this.contextMenuStripTextBoxListView.Name = "contextMenuStripTextBoxListView"; + this.contextMenuStripTextBoxListView.Size = new System.Drawing.Size(215, 280); + this.contextMenuStripTextBoxListView.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStripTextBoxListView_Opening); + // + // cutToolStripMenuItem + // + this.cutToolStripMenuItem.Name = "cutToolStripMenuItem"; + this.cutToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.X))); + this.cutToolStripMenuItem.Size = new System.Drawing.Size(214, 22); + this.cutToolStripMenuItem.Text = "Cut"; + this.cutToolStripMenuItem.Click += new System.EventHandler(this.cutToolStripMenuItem_Click); + // + // copyToolStripMenuItem + // + this.copyToolStripMenuItem.Name = "copyToolStripMenuItem"; + this.copyToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C))); + this.copyToolStripMenuItem.Size = new System.Drawing.Size(214, 22); + this.copyToolStripMenuItem.Text = "Copy"; + this.copyToolStripMenuItem.Click += new System.EventHandler(this.copyToolStripMenuItem_Click); + // + // pasteToolStripMenuItem + // + this.pasteToolStripMenuItem.Name = "pasteToolStripMenuItem"; + this.pasteToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.V))); + this.pasteToolStripMenuItem.Size = new System.Drawing.Size(214, 22); + this.pasteToolStripMenuItem.Text = "Paste"; + this.pasteToolStripMenuItem.Click += new System.EventHandler(this.pasteToolStripMenuItem_Click); + // + // deleteToolStripMenuItem + // + this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem"; + this.deleteToolStripMenuItem.Size = new System.Drawing.Size(214, 22); + this.deleteToolStripMenuItem.Text = "Delete"; + this.deleteToolStripMenuItem.Click += new System.EventHandler(this.deleteToolStripMenuItem_Click); + // + // toolStripMenuItemSplitTextAtCursor + // + this.toolStripMenuItemSplitTextAtCursor.Name = "toolStripMenuItemSplitTextAtCursor"; + this.toolStripMenuItemSplitTextAtCursor.Size = new System.Drawing.Size(214, 22); + this.toolStripMenuItemSplitTextAtCursor.Text = "Split text at cursor position"; + this.toolStripMenuItemSplitTextAtCursor.Click += new System.EventHandler(this.toolStripMenuItemSplitTextAtCursor_Click); + // + // toolStripSeparator18 + // + this.toolStripSeparator18.Name = "toolStripSeparator18"; + this.toolStripSeparator18.Size = new System.Drawing.Size(211, 6); + // + // selectAllToolStripMenuItem + // + this.selectAllToolStripMenuItem.Name = "selectAllToolStripMenuItem"; + this.selectAllToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.A))); + this.selectAllToolStripMenuItem.Size = new System.Drawing.Size(214, 22); + this.selectAllToolStripMenuItem.Text = "Select all"; + this.selectAllToolStripMenuItem.Click += new System.EventHandler(this.selectAllToolStripMenuItem_Click); + // + // toolStripSeparator17 + // + this.toolStripSeparator17.Name = "toolStripSeparator17"; + this.toolStripSeparator17.Size = new System.Drawing.Size(211, 6); + // + // normalToolStripMenuItem1 + // + this.normalToolStripMenuItem1.Name = "normalToolStripMenuItem1"; + this.normalToolStripMenuItem1.Size = new System.Drawing.Size(214, 22); + this.normalToolStripMenuItem1.Text = "Normal"; + this.normalToolStripMenuItem1.Click += new System.EventHandler(this.normalToolStripMenuItem1_Click); + // + // boldToolStripMenuItem1 + // + this.boldToolStripMenuItem1.Name = "boldToolStripMenuItem1"; + this.boldToolStripMenuItem1.Size = new System.Drawing.Size(214, 22); + this.boldToolStripMenuItem1.Text = "Bold"; + this.boldToolStripMenuItem1.Click += new System.EventHandler(this.boldToolStripMenuItem1_Click); + // + // italicToolStripMenuItem1 + // + this.italicToolStripMenuItem1.Name = "italicToolStripMenuItem1"; + this.italicToolStripMenuItem1.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.I))); + this.italicToolStripMenuItem1.Size = new System.Drawing.Size(214, 22); + this.italicToolStripMenuItem1.Text = "Italic"; + this.italicToolStripMenuItem1.Click += new System.EventHandler(this.italicToolStripMenuItem1_Click); + // + // underlineToolStripMenuItem1 + // + this.underlineToolStripMenuItem1.Name = "underlineToolStripMenuItem1"; + this.underlineToolStripMenuItem1.Size = new System.Drawing.Size(214, 22); + this.underlineToolStripMenuItem1.Text = "Underline"; + this.underlineToolStripMenuItem1.Click += new System.EventHandler(this.underlineToolStripMenuItem1_Click); + // + // colorToolStripMenuItem1 + // + this.colorToolStripMenuItem1.Name = "colorToolStripMenuItem1"; + this.colorToolStripMenuItem1.Size = new System.Drawing.Size(214, 22); + this.colorToolStripMenuItem1.Text = "Color..."; + this.colorToolStripMenuItem1.Click += new System.EventHandler(this.colorToolStripMenuItem1_Click); + // + // fontNameToolStripMenuItem + // + this.fontNameToolStripMenuItem.Name = "fontNameToolStripMenuItem"; + this.fontNameToolStripMenuItem.Size = new System.Drawing.Size(214, 22); + this.fontNameToolStripMenuItem.Text = "Font name..."; + this.fontNameToolStripMenuItem.Click += new System.EventHandler(this.fontNameToolStripMenuItem_Click); + // // labelSingleLine // this.labelSingleLine.AutoSize = true; @@ -2988,6 +3181,16 @@ this.buttonUnBreak.UseVisualStyleBackColor = true; this.buttonUnBreak.Click += new System.EventHandler(this.ButtonUnBreakClick); // + // timeUpDownStartTime + // + this.timeUpDownStartTime.AutoSize = true; + this.timeUpDownStartTime.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.timeUpDownStartTime.Location = new System.Drawing.Point(9, 27); + this.timeUpDownStartTime.Margin = new System.Windows.Forms.Padding(4); + this.timeUpDownStartTime.Name = "timeUpDownStartTime"; + this.timeUpDownStartTime.Size = new System.Drawing.Size(92, 25); + this.timeUpDownStartTime.TabIndex = 0; + // // buttonUndoListViewChanges // this.buttonUndoListViewChanges.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); @@ -3109,6 +3312,31 @@ this.labelAutoDuration.TabIndex = 30; this.labelAutoDuration.Text = "Auto"; // + // SubtitleListview1 + // + this.SubtitleListview1.AllowDrop = true; + this.SubtitleListview1.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.SubtitleListview1.ContextMenuStrip = this.contextMenuStripListview; + this.SubtitleListview1.FirstVisibleIndex = -1; + this.SubtitleListview1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.SubtitleListview1.FullRowSelect = true; + this.SubtitleListview1.GridLines = true; + this.SubtitleListview1.HideSelection = false; + this.SubtitleListview1.Location = new System.Drawing.Point(1, 3); + this.SubtitleListview1.Name = "SubtitleListview1"; + this.SubtitleListview1.Size = new System.Drawing.Size(932, 148); + this.SubtitleListview1.SmallImageList = this.imageList1; + this.SubtitleListview1.TabIndex = 0; + this.SubtitleListview1.UseCompatibleStateImageBehavior = false; + this.SubtitleListview1.View = System.Windows.Forms.View.Details; + this.SubtitleListview1.SelectedIndexChanged += new System.EventHandler(this.SubtitleListview1_SelectedIndexChanged); + this.SubtitleListview1.DragDrop += new System.Windows.Forms.DragEventHandler(this.SubtitleListview1_DragDrop); + this.SubtitleListview1.DragEnter += new System.Windows.Forms.DragEventHandler(this.SubtitleListview1_DragEnter); + this.SubtitleListview1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.SubtitleListview1_KeyDown); + this.SubtitleListview1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.SubtitleListview1_MouseDoubleClick); + // // tabPage2 // this.tabPage2.Controls.Add(this.textBoxSource); @@ -3153,182 +3381,6 @@ this.panelVideoPlayer.Size = new System.Drawing.Size(282, 278); this.panelVideoPlayer.TabIndex = 5; // - // contextMenuStripEmpty - // - this.contextMenuStripEmpty.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.insertLineToolStripMenuItem}); - this.contextMenuStripEmpty.Name = "contextMenuStripEmpty"; - this.contextMenuStripEmpty.Size = new System.Drawing.Size(126, 26); - // - // insertLineToolStripMenuItem - // - this.insertLineToolStripMenuItem.Name = "insertLineToolStripMenuItem"; - this.insertLineToolStripMenuItem.Size = new System.Drawing.Size(125, 22); - this.insertLineToolStripMenuItem.Text = "Insert line"; - this.insertLineToolStripMenuItem.Click += new System.EventHandler(this.insertLineToolStripMenuItem_Click); - // - // imageListPlayRate - // - this.imageListPlayRate.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageListPlayRate.ImageStream"))); - this.imageListPlayRate.TransparentColor = System.Drawing.Color.Transparent; - this.imageListPlayRate.Images.SetKeyName(0, "FastForward.png"); - this.imageListPlayRate.Images.SetKeyName(1, "FastForwardHighLight.png"); - // - // cutToolStripMenuItem - // - this.cutToolStripMenuItem.Name = "cutToolStripMenuItem"; - this.cutToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.X))); - this.cutToolStripMenuItem.Size = new System.Drawing.Size(214, 22); - this.cutToolStripMenuItem.Text = "Cut"; - this.cutToolStripMenuItem.Click += new System.EventHandler(this.cutToolStripMenuItem_Click); - // - // copyToolStripMenuItem - // - this.copyToolStripMenuItem.Name = "copyToolStripMenuItem"; - this.copyToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C))); - this.copyToolStripMenuItem.Size = new System.Drawing.Size(214, 22); - this.copyToolStripMenuItem.Text = "Copy"; - this.copyToolStripMenuItem.Click += new System.EventHandler(this.copyToolStripMenuItem_Click); - // - // pasteToolStripMenuItem - // - this.pasteToolStripMenuItem.Name = "pasteToolStripMenuItem"; - this.pasteToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.V))); - this.pasteToolStripMenuItem.Size = new System.Drawing.Size(214, 22); - this.pasteToolStripMenuItem.Text = "Paste"; - this.pasteToolStripMenuItem.Click += new System.EventHandler(this.pasteToolStripMenuItem_Click); - // - // deleteToolStripMenuItem - // - this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem"; - this.deleteToolStripMenuItem.Size = new System.Drawing.Size(214, 22); - this.deleteToolStripMenuItem.Text = "Delete"; - this.deleteToolStripMenuItem.Click += new System.EventHandler(this.deleteToolStripMenuItem_Click); - // - // toolStripSeparator18 - // - this.toolStripSeparator18.Name = "toolStripSeparator18"; - this.toolStripSeparator18.Size = new System.Drawing.Size(211, 6); - // - // selectAllToolStripMenuItem - // - this.selectAllToolStripMenuItem.Name = "selectAllToolStripMenuItem"; - this.selectAllToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.A))); - this.selectAllToolStripMenuItem.Size = new System.Drawing.Size(214, 22); - this.selectAllToolStripMenuItem.Text = "Select all"; - this.selectAllToolStripMenuItem.Click += new System.EventHandler(this.selectAllToolStripMenuItem_Click); - // - // toolStripSeparator17 - // - this.toolStripSeparator17.Name = "toolStripSeparator17"; - this.toolStripSeparator17.Size = new System.Drawing.Size(211, 6); - // - // normalToolStripMenuItem1 - // - this.normalToolStripMenuItem1.Name = "normalToolStripMenuItem1"; - this.normalToolStripMenuItem1.Size = new System.Drawing.Size(214, 22); - this.normalToolStripMenuItem1.Text = "Normal"; - this.normalToolStripMenuItem1.Click += new System.EventHandler(this.normalToolStripMenuItem1_Click); - // - // boldToolStripMenuItem1 - // - this.boldToolStripMenuItem1.Name = "boldToolStripMenuItem1"; - this.boldToolStripMenuItem1.Size = new System.Drawing.Size(214, 22); - this.boldToolStripMenuItem1.Text = "Bold"; - this.boldToolStripMenuItem1.Click += new System.EventHandler(this.boldToolStripMenuItem1_Click); - // - // italicToolStripMenuItem1 - // - this.italicToolStripMenuItem1.Name = "italicToolStripMenuItem1"; - this.italicToolStripMenuItem1.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.I))); - this.italicToolStripMenuItem1.Size = new System.Drawing.Size(214, 22); - this.italicToolStripMenuItem1.Text = "Italic"; - this.italicToolStripMenuItem1.Click += new System.EventHandler(this.italicToolStripMenuItem1_Click); - // - // underlineToolStripMenuItem1 - // - this.underlineToolStripMenuItem1.Name = "underlineToolStripMenuItem1"; - this.underlineToolStripMenuItem1.Size = new System.Drawing.Size(214, 22); - this.underlineToolStripMenuItem1.Text = "Underline"; - this.underlineToolStripMenuItem1.Click += new System.EventHandler(this.underlineToolStripMenuItem1_Click); - // - // colorToolStripMenuItem1 - // - this.colorToolStripMenuItem1.Name = "colorToolStripMenuItem1"; - this.colorToolStripMenuItem1.Size = new System.Drawing.Size(214, 22); - this.colorToolStripMenuItem1.Text = "Color..."; - this.colorToolStripMenuItem1.Click += new System.EventHandler(this.colorToolStripMenuItem1_Click); - // - // fontNameToolStripMenuItem - // - this.fontNameToolStripMenuItem.Name = "fontNameToolStripMenuItem"; - this.fontNameToolStripMenuItem.Size = new System.Drawing.Size(214, 22); - this.fontNameToolStripMenuItem.Text = "Font name..."; - this.fontNameToolStripMenuItem.Click += new System.EventHandler(this.fontNameToolStripMenuItem_Click); - // - // contextMenuStripTextBoxListView - // - this.contextMenuStripTextBoxListView.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.cutToolStripMenuItem, - this.copyToolStripMenuItem, - this.pasteToolStripMenuItem, - this.deleteToolStripMenuItem, - this.toolStripMenuItemSplitTextAtCursor, - this.toolStripSeparator18, - this.selectAllToolStripMenuItem, - this.toolStripSeparator17, - this.normalToolStripMenuItem1, - this.boldToolStripMenuItem1, - this.italicToolStripMenuItem1, - this.underlineToolStripMenuItem1, - this.colorToolStripMenuItem1, - this.fontNameToolStripMenuItem}); - this.contextMenuStripTextBoxListView.Name = "contextMenuStripTextBoxListView"; - this.contextMenuStripTextBoxListView.Size = new System.Drawing.Size(215, 302); - this.contextMenuStripTextBoxListView.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStripTextBoxListView_Opening); - // - // toolStripMenuItemSplitTextAtCursor - // - this.toolStripMenuItemSplitTextAtCursor.Name = "toolStripMenuItemSplitTextAtCursor"; - this.toolStripMenuItemSplitTextAtCursor.Size = new System.Drawing.Size(214, 22); - this.toolStripMenuItemSplitTextAtCursor.Text = "Split text at cursor position"; - this.toolStripMenuItemSplitTextAtCursor.Click += new System.EventHandler(this.toolStripMenuItemSplitTextAtCursor_Click); - // - // timeUpDownStartTime - // - this.timeUpDownStartTime.AutoSize = true; - this.timeUpDownStartTime.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.timeUpDownStartTime.Location = new System.Drawing.Point(9, 27); - this.timeUpDownStartTime.Margin = new System.Windows.Forms.Padding(4); - this.timeUpDownStartTime.Name = "timeUpDownStartTime"; - this.timeUpDownStartTime.Size = new System.Drawing.Size(92, 25); - this.timeUpDownStartTime.TabIndex = 0; - // - // SubtitleListview1 - // - this.SubtitleListview1.AllowDrop = true; - this.SubtitleListview1.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.SubtitleListview1.ContextMenuStrip = this.contextMenuStripListview; - this.SubtitleListview1.FirstVisibleIndex = -1; - this.SubtitleListview1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.SubtitleListview1.FullRowSelect = true; - this.SubtitleListview1.GridLines = true; - this.SubtitleListview1.HideSelection = false; - this.SubtitleListview1.Location = new System.Drawing.Point(1, 3); - this.SubtitleListview1.Name = "SubtitleListview1"; - this.SubtitleListview1.Size = new System.Drawing.Size(932, 148); - this.SubtitleListview1.SmallImageList = this.imageList1; - this.SubtitleListview1.TabIndex = 0; - this.SubtitleListview1.UseCompatibleStateImageBehavior = false; - this.SubtitleListview1.View = System.Windows.Forms.View.Details; - this.SubtitleListview1.SelectedIndexChanged += new System.EventHandler(this.SubtitleListview1_SelectedIndexChanged); - this.SubtitleListview1.DragDrop += new System.Windows.Forms.DragEventHandler(this.SubtitleListview1_DragDrop); - this.SubtitleListview1.DragEnter += new System.Windows.Forms.DragEventHandler(this.SubtitleListview1_DragEnter); - this.SubtitleListview1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.SubtitleListview1_KeyDown); - this.SubtitleListview1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.SubtitleListview1_MouseDoubleClick); - // // mediaPlayer // this.mediaPlayer.AllowDrop = true; @@ -3349,53 +3401,26 @@ this.mediaPlayer.DragDrop += new System.Windows.Forms.DragEventHandler(this.mediaPlayer_DragDrop); this.mediaPlayer.DragEnter += new System.Windows.Forms.DragEventHandler(this.mediaPlayer_DragEnter); // - // AudioWaveForm + // contextMenuStripEmpty // - this.AudioWaveForm.AllowDrop = true; - this.AudioWaveForm.AllowNewSelection = true; - this.AudioWaveForm.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.AudioWaveForm.BackColor = System.Drawing.Color.Black; - this.AudioWaveForm.BackgroundColor = System.Drawing.Color.Black; - this.AudioWaveForm.Color = System.Drawing.Color.GreenYellow; - this.AudioWaveForm.DrawGridLines = true; - this.AudioWaveForm.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(18))))); - this.AudioWaveForm.Location = new System.Drawing.Point(472, 32); - this.AudioWaveForm.Margin = new System.Windows.Forms.Padding(0); - this.AudioWaveForm.Name = "AudioWaveForm"; - this.AudioWaveForm.NewSelectionParagraph = null; - this.AudioWaveForm.SelectedColor = System.Drawing.Color.Red; - this.AudioWaveForm.Size = new System.Drawing.Size(768, 229); - this.AudioWaveForm.StartPositionSeconds = 0D; - this.AudioWaveForm.TabIndex = 6; - this.AudioWaveForm.TextColor = System.Drawing.Color.Gray; - this.AudioWaveForm.WaveFormNotLoadedText = "Click to add wave form"; - this.AudioWaveForm.WavePeaks = null; - this.AudioWaveForm.ZoomFactor = 1D; - this.AudioWaveForm.Click += new System.EventHandler(this.AudioWaveForm_Click); - this.AudioWaveForm.DragDrop += new System.Windows.Forms.DragEventHandler(this.AudioWaveForm_DragDrop); - this.AudioWaveForm.DragEnter += new System.Windows.Forms.DragEventHandler(this.AudioWaveForm_DragEnter); + this.contextMenuStripEmpty.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.insertLineToolStripMenuItem}); + this.contextMenuStripEmpty.Name = "contextMenuStripEmpty"; + this.contextMenuStripEmpty.Size = new System.Drawing.Size(126, 26); // - // timeUpDownVideoPosition + // insertLineToolStripMenuItem // - this.timeUpDownVideoPosition.AutoSize = true; - this.timeUpDownVideoPosition.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.timeUpDownVideoPosition.Location = new System.Drawing.Point(86, 192); - this.timeUpDownVideoPosition.Margin = new System.Windows.Forms.Padding(4); - this.timeUpDownVideoPosition.Name = "timeUpDownVideoPosition"; - this.timeUpDownVideoPosition.Size = new System.Drawing.Size(92, 25); - this.timeUpDownVideoPosition.TabIndex = 12; + this.insertLineToolStripMenuItem.Name = "insertLineToolStripMenuItem"; + this.insertLineToolStripMenuItem.Size = new System.Drawing.Size(125, 22); + this.insertLineToolStripMenuItem.Text = "Insert line"; + this.insertLineToolStripMenuItem.Click += new System.EventHandler(this.insertLineToolStripMenuItem_Click); // - // timeUpDownVideoPositionAdjust + // imageListPlayRate // - this.timeUpDownVideoPositionAdjust.AutoSize = true; - this.timeUpDownVideoPositionAdjust.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.timeUpDownVideoPositionAdjust.Location = new System.Drawing.Point(87, 214); - this.timeUpDownVideoPositionAdjust.Margin = new System.Windows.Forms.Padding(4); - this.timeUpDownVideoPositionAdjust.Name = "timeUpDownVideoPositionAdjust"; - this.timeUpDownVideoPositionAdjust.Size = new System.Drawing.Size(92, 25); - this.timeUpDownVideoPositionAdjust.TabIndex = 13; + this.imageListPlayRate.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageListPlayRate.ImageStream"))); + this.imageListPlayRate.TransparentColor = System.Drawing.Color.Transparent; + this.imageListPlayRate.Images.SetKeyName(0, "FastForward.png"); + this.imageListPlayRate.Images.SetKeyName(1, "FastForwardHighLight.png"); // // Main // @@ -3459,12 +3484,12 @@ this.tabPage1.ResumeLayout(false); this.groupBoxEdit.ResumeLayout(false); this.groupBoxEdit.PerformLayout(); + this.contextMenuStripTextBoxListView.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownDuration)).EndInit(); this.tabPage2.ResumeLayout(false); this.tabPage2.PerformLayout(); this.panelVideoPlayer.ResumeLayout(false); this.contextMenuStripEmpty.ResumeLayout(false); - this.contextMenuStripTextBoxListView.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -3784,6 +3809,9 @@ private System.Windows.Forms.ToolStripMenuItem underlineToolStripMenuItem1; private System.Windows.Forms.ToolStripMenuItem colorToolStripMenuItem1; private System.Windows.Forms.ToolStripMenuItem fontNameToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator22; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemExport; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemExportPngXml; } } diff --git a/src/Forms/Main.cs b/src/Forms/Main.cs index 716cf7631..a00011ad3 100644 --- a/src/Forms/Main.cs +++ b/src/Forms/Main.cs @@ -9790,5 +9790,12 @@ namespace Nikse.SubtitleEdit.Forms } + private void toolStripMenuItemExportPngXml_Click(object sender, EventArgs e) + { + ExportPngXml exportBdnXmlPng = new ExportPngXml(); + exportBdnXmlPng.Initialize(_subtitle); + exportBdnXmlPng.ShowDialog(this); + } + } } \ No newline at end of file diff --git a/src/Forms/Main.resx b/src/Forms/Main.resx index 00ea9701f..3ec2c15db 100644 --- a/src/Forms/Main.resx +++ b/src/Forms/Main.resx @@ -684,7 +684,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAD2 - CAAAAk1TRnQBSQFMAgEBAgEAAVABBAFQAQQBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + CAAAAk1TRnQBSQFMAgEBAgEAAWgBBAFoAQQBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA diff --git a/src/Forms/SpellCheck.cs b/src/Forms/SpellCheck.cs index 0c1edf5f6..f4abe7efd 100644 --- a/src/Forms/SpellCheck.cs +++ b/src/Forms/SpellCheck.cs @@ -37,6 +37,7 @@ namespace Nikse.SubtitleEdit.Forms string _prefix = string.Empty; string _postfix = string.Empty; Hunspell _hunspell; + LinuxHunspell _linuxHunspell; string _dictionaryFolder; Paragraph _currentParagraph; int _currentIndex; @@ -237,11 +238,30 @@ namespace Nikse.SubtitleEdit.Forms } _changeAllDictionary = new Dictionary(); - _hunspell = new Hunspell(dictionary + ".aff", dictionary + ".dic"); + + if (Utilities.IsRunningOnLinux()) + _linuxHunspell = new LinuxHunspell(dictionary + ".aff", dictionary + ".dic"); + else + _hunspell = new Hunspell(dictionary + ".aff", dictionary + ".dic"); _wordsIndex--; PrepareNextWord(); + } + public bool DoSpell(string word) + { + if (_hunspell != null) + return _hunspell.Spell(word); + else + return _linuxHunspell.Spell(word); + } + + public List DoSuggest(string word) + { + if (_hunspell != null) + return _hunspell.Suggest(word); + else + return _linuxHunspell.Suggest(word); } private void ButtonChangeAllClick(object sender, EventArgs e) @@ -361,7 +381,7 @@ namespace Nikse.SubtitleEdit.Forms _skipAllList.Add(_currentWord.ToUpper()); break; case SpellCheckAction.AddToDictionary: - bool correct = _hunspell.Spell(ChangeWord); + bool correct = DoSpell(ChangeWord); if (!correct) { if (_userWordList.IndexOf(ChangeWord) < 0) @@ -541,7 +561,7 @@ namespace Nikse.SubtitleEdit.Forms } else { - bool correct = _hunspell.Spell(_currentWord); + bool correct = DoSpell(_currentWord); if (correct) { _noOfCorrectWords++; @@ -553,7 +573,7 @@ namespace Nikse.SubtitleEdit.Forms List suggestions = new List(); if (_currentWord != "Lt'S" && _currentWord != "Sox's") //TODO: get fixed nhunspell - suggestions = _hunspell.Suggest(_currentWord); //TODO: 0.9.6 fails on "Lt'S" + suggestions = DoSuggest(_currentWord); //TODO: 0.9.6 fails on "Lt'S" if (AutoFixNames && _currentWord.Length > 1 && suggestions.Contains(_currentWord.Substring(0, 1).ToUpper() + _currentWord.Substring(1))) { @@ -700,7 +720,11 @@ namespace Nikse.SubtitleEdit.Forms } _changeAllDictionary = new Dictionary(); - _hunspell = new Hunspell(dictionary + ".aff", dictionary + ".dic"); + + if (Utilities.IsRunningOnLinux()) + _linuxHunspell = new LinuxHunspell(dictionary + ".aff", dictionary + ".dic"); + else + _hunspell = new Hunspell(dictionary + ".aff", dictionary + ".dic"); _currentIndex = 0; _currentParagraph = _subtitle.Paragraphs[_currentIndex]; diff --git a/src/Forms/VobSubOcr.cs b/src/Forms/VobSubOcr.cs index 8c33fe880..2e4cf661c 100644 --- a/src/Forms/VobSubOcr.cs +++ b/src/Forms/VobSubOcr.cs @@ -1241,8 +1241,8 @@ namespace Nikse.SubtitleEdit.Forms private string Tesseract3DoOcrViaExe(Bitmap bmp, string language) { - string tempTiffFileName = Path.GetTempPath() + Guid.NewGuid().ToString() + ".tiff"; - bmp.Save(tempTiffFileName, System.Drawing.Imaging.ImageFormat.Tiff); + string tempTiffFileName = Path.GetTempPath() + Guid.NewGuid().ToString() + ".png"; + bmp.Save(tempTiffFileName, System.Drawing.Imaging.ImageFormat.Png); string tempTextFileName = Path.GetTempPath() + Guid.NewGuid().ToString(); Process process = new Process(); diff --git a/src/Logic/Language.cs b/src/Logic/Language.cs index 1a8e80460..9828350e4 100644 --- a/src/Logic/Language.cs +++ b/src/Logic/Language.cs @@ -28,6 +28,7 @@ namespace Nikse.SubtitleEdit.Logic public LanguageStructure.EbuSaveOtpions EbuSaveOtpions; public LanguageStructure.EffectKaraoke EffectKaraoke; public LanguageStructure.EffectTypewriter EffectTypewriter; + public LanguageStructure.ExportPngXml ExportPngXml; public LanguageStructure.FindDialog FindDialog; public LanguageStructure.FindSubtitleLine FindSubtitleLine; public LanguageStructure.FixCommonErrors FixCommonErrors; @@ -299,6 +300,20 @@ namespace Nikse.SubtitleEdit.Logic EndDelayInMillisecs = "End delay in millisecs.:" }; + ExportPngXml = new LanguageStructure.ExportPngXml + { + Title = "Export BDN XML/PNG", + ImageSettings = "Image settings", + AntiAlias = "Anti alias", + BorderColor = "Border color", + BorderWidth = "Border width", + ExportAllLines = "Export all lines...", + FontColor = "Font color", + FontFamily = "Font family", + FontSize = "Font size", + XImagesSavedInY = "{0} images saved in {1}", + }; + FindDialog = new LanguageStructure.FindDialog { Title = "Find", diff --git a/src/Logic/LanguageStructure.cs b/src/Logic/LanguageStructure.cs index bd824271e..2298f24a8 100644 --- a/src/Logic/LanguageStructure.cs +++ b/src/Logic/LanguageStructure.cs @@ -229,6 +229,20 @@ public string EndDelayInMillisecs { get; set; } } + public class ExportPngXml + { + public string Title { get; set; } + public string ImageSettings { get; set; } + public string FontFamily { get; set; } + public string FontSize { get; set; } + public string FontColor { get; set; } + public string BorderColor { get; set; } + public string BorderWidth { get; set; } + public string AntiAlias { get; set; } + public string ExportAllLines { get; set; } + public string XImagesSavedInY { get; set; } + } + public class FindDialog { public string Title { get; set; } diff --git a/src/Logic/LinuxHunspell.cs b/src/Logic/LinuxHunspell.cs new file mode 100644 index 000000000..ceeac25a6 --- /dev/null +++ b/src/Logic/LinuxHunspell.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; + +namespace Nikse.SubtitleEdit.Logic +{ + public class LinuxHunspell + { + [DllImport ("libhunspell")] + private static extern IntPtr Hunspell_create(string affpath, string dpath); + + [DllImport ("libhunspell")] + private static extern IntPtr Hunspell_destroy(IntPtr hunspellHandle); + + [DllImport ("libhunspell")] + private static extern int Hunspell_spell(IntPtr hunspellHandle, string word); + + [DllImport ("libhunspell")] + private static extern int Hunspell_suggest(IntPtr hunspellHandle, IntPtr slst, string word); + + [DllImport ("libhunspell")] + private static extern void Hunspell_free_list(IntPtr hunspellHandle, IntPtr slst, int n); + + private IntPtr _hunspellHandle = IntPtr.Zero; + + public LinuxHunspell (string affDirectory, string dicDictory) + { + //Also search - /usr/share/hunspell + _hunspellHandle = Hunspell_create(affDirectory, dicDictory); + } + + public bool Spell(string word) + { + return Hunspell_spell(_hunspellHandle, word) != 0; + } + + public List Suggest(string word) + { + IntPtr pointerToAddressStringArray = Marshal.AllocHGlobal(IntPtr.Size); + int resultCount = Hunspell_suggest(_hunspellHandle, pointerToAddressStringArray, word); + IntPtr addressStringArray = Marshal.ReadIntPtr(pointerToAddressStringArray); + List results = new List(); + for (int i = 0; i < resultCount; i++) + { + IntPtr addressCharArray = Marshal.ReadIntPtr(addressStringArray, i * 4); + int offset = 0; + List bytesList = new List(); + byte newByte = Marshal.ReadByte(addressCharArray, offset++); + while (newByte != 0) + { + bytesList.Add(newByte); + newByte = Marshal.ReadByte(addressCharArray, offset++); + } + byte[] bytesArray = new byte[offset]; + bytesList.CopyTo(bytesArray); + string suggestion = System.Text.Encoding.UTF8.GetString(bytesArray); + results.Add(suggestion); + } + Hunspell_free_list(_hunspellHandle, pointerToAddressStringArray, resultCount); + Marshal.FreeHGlobal(pointerToAddressStringArray); + return results; + } + } +} + diff --git a/src/Logic/OCR/OcrFixEngine.cs b/src/Logic/OCR/OcrFixEngine.cs index 0384a010b..dc080bbe3 100644 --- a/src/Logic/OCR/OcrFixEngine.cs +++ b/src/Logic/OCR/OcrFixEngine.cs @@ -33,6 +33,7 @@ namespace Nikse.SubtitleEdit.Logic.OCR List _userWordList = new List(); List _wordSkipList = new List(); Hunspell _hunspell; + LinuxHunspell _linuxHunspell; readonly OcrSpellCheck _spellCheck; readonly Form _parentForm; private string _spellCheckDictionaryName; @@ -188,7 +189,10 @@ namespace Nikse.SubtitleEdit.Logic.OCR // Load NHunspell spellchecker try { - _hunspell = new Hunspell(dictionary + ".aff", dictionary + ".dic"); + if (Utilities.IsRunningOnLinux()) + _linuxHunspell = new LinuxHunspell(dictionary + ".aff", dictionary + ".dic"); + else + _hunspell = new Hunspell(dictionary + ".aff", dictionary + ".dic"); IsDictionaryLoaded = true; _spellCheckDictionaryName = dictionary; DictionaryCulture = culture; @@ -565,15 +569,15 @@ namespace Nikse.SubtitleEdit.Logic.OCR if (Configuration.Settings.Tools.OcrFixUseHardcodedRules) { // e.g. "selectionsu." -> "selections..." - if (input.EndsWith("u.") && _hunspell != null) + if (input.EndsWith("u.") && (_hunspell != null || _linuxHunspell != null)) { string[] words = input.Split(" .".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (words.Length > 0) { string lastWord = words[words.Length - 1].Trim(); if (lastWord.Length > 2 && - !IsWordOrWordsCorrect(_hunspell, lastWord) && - IsWordOrWordsCorrect(_hunspell, lastWord.Substring(0, lastWord.Length - 1))) + !IsWordOrWordsCorrect(lastWord) && + IsWordOrWordsCorrect(lastWord.Substring(0, lastWord.Length - 1))) input = input.Substring(0, input.Length - 2) + "..."; } } @@ -722,7 +726,7 @@ namespace Nikse.SubtitleEdit.Logic.OCR { List localIgnoreWords = new List(); wordsNotFound = 0; - if (_hunspell == null) + if (_hunspell == null && _linuxHunspell == null) return line; string tempLine = line; @@ -760,9 +764,9 @@ namespace Nikse.SubtitleEdit.Logic.OCR string word = words[i]; if (!IsWordKnownOrNumber(word, line) && !localIgnoreWords.Contains(word)) { - bool correct = _hunspell.Spell(word); + bool correct = DoSpell(word); if (!correct) - correct = _hunspell.Spell(word.Trim('\'')); + correct = DoSpell(word.Trim('\'')); if (!correct) { wordsNotFound++; @@ -777,7 +781,7 @@ namespace Nikse.SubtitleEdit.Logic.OCR guesses = (List)CreateGuessesFromLetters(word); string wordWithCasingChanged = GetWordWithDominatedCasing(word); - if (_hunspell.Spell(word.ToLower())) + if (DoSpell(word.ToLower())) guesses.Insert(0, wordWithCasingChanged); } else @@ -794,7 +798,7 @@ namespace Nikse.SubtitleEdit.Logic.OCR } foreach (string guess in guesses) { - if (IsWordOrWordsCorrect(_hunspell, guess)) + if (IsWordOrWordsCorrect(guess)) { string replacedLine = ReplaceWord(line, word, guess); if (replacedLine != line) @@ -816,7 +820,7 @@ namespace Nikse.SubtitleEdit.Logic.OCR List suggestions = new List(); if (word != "Lt'S" && word != "Sox's") //TODO: get fixed nhunspell - suggestions = _hunspell.Suggest(word); // 0.9.6 fails on "Lt'S" + suggestions = DoSuggest(word); // 0.9.6 fails on "Lt'S" SpellcheckOcrTextResult res = SpellcheckOcrText(line, bitmap, words, i, word, suggestions); if (res.FixedWholeLine) @@ -1022,11 +1026,27 @@ namespace Nikse.SubtitleEdit.Logic.OCR } } - public bool IsWordOrWordsCorrect(Hunspell hunspell, string word) + public bool DoSpell(string word) { + if (_hunspell != null) + return _hunspell.Spell(word); + else + return _linuxHunspell.Spell(word); + } + + public List DoSuggest(string word) + { + if (_hunspell != null) + return _hunspell.Suggest(word); + else + return _linuxHunspell.Suggest(word); + } + + public bool IsWordOrWordsCorrect(string word) + { foreach (string s in word.Split(' ')) { - if (!hunspell.Spell(s)) + if (!DoSpell(s)) { if (!IsWordKnownOrNumber(word, word)) return false; diff --git a/src/SubtitleEdit.csproj b/src/SubtitleEdit.csproj index c775318e6..4a6b34abc 100644 --- a/src/SubtitleEdit.csproj +++ b/src/SubtitleEdit.csproj @@ -195,6 +195,12 @@ EffectTypewriter.cs + + Form + + + ExportPngXml.cs + Form @@ -497,6 +503,7 @@ + Code @@ -668,6 +675,9 @@ EffectTypewriter.cs Designer + + ExportPngXml.cs + FindDialog.cs Designer