Work on WebVTT

This commit is contained in:
niksedk 2023-06-23 20:46:25 +02:00
parent af84210907
commit c69666b583
2 changed files with 151 additions and 134 deletions

View File

@ -44,6 +44,20 @@
this.columnHeaderForeColor = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeaderBackgroundColor = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeaderUseCount = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.contextMenuStripStyles = new System.Windows.Forms.ContextMenuStrip(this.components);
this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemRemoveAll = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator();
this.moveUpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.moveDownToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.moveTopToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.moveBottomToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
this.newToolStripMenuItemNew = new System.Windows.Forms.ToolStripMenuItem();
this.copyToolStripMenuItemCopy = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripMenuItemImport = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemExport = new System.Windows.Forms.ToolStripMenuItem();
this.groupBoxProperties = new System.Windows.Forms.GroupBox();
this.groupBoxAfter = new System.Windows.Forms.GroupBox();
this.labelAfter = new System.Windows.Forms.Label();
@ -77,22 +91,9 @@
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonOK = new System.Windows.Forms.Button();
this.labelDuplicateStyleNames = new System.Windows.Forms.Label();
this.contextMenuStripStyles = new System.Windows.Forms.ContextMenuStrip(this.components);
this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemRemoveAll = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator();
this.moveUpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.moveDownToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.moveTopToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.moveBottomToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
this.newToolStripMenuItemNew = new System.Windows.Forms.ToolStripMenuItem();
this.copyToolStripMenuItemCopy = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripMenuItemImport = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemExport = new System.Windows.Forms.ToolStripMenuItem();
this.labelInfo = new System.Windows.Forms.Label();
this.groupBoxStyles.SuspendLayout();
this.contextMenuStripStyles.SuspendLayout();
this.groupBoxProperties.SuspendLayout();
this.groupBoxAfter.SuspendLayout();
this.groupBoxBefore.SuspendLayout();
@ -101,7 +102,6 @@
this.groupBoxFont.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownShadowWidth)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownFontSize)).BeginInit();
this.contextMenuStripStyles.SuspendLayout();
this.SuspendLayout();
//
// groupBoxStyles
@ -118,7 +118,7 @@
this.groupBoxStyles.Size = new System.Drawing.Size(600, 599);
this.groupBoxStyles.TabIndex = 1;
this.groupBoxStyles.TabStop = false;
this.groupBoxStyles.Text = "File styles";
this.groupBoxStyles.Text = "Styles";
//
// buttonExport
//
@ -250,6 +250,119 @@
//
this.columnHeaderUseCount.Text = "Used#";
//
// contextMenuStripStyles
//
this.contextMenuStripStyles.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.deleteToolStripMenuItem,
this.toolStripMenuItemRemoveAll,
this.toolStripSeparator4,
this.moveUpToolStripMenuItem,
this.moveDownToolStripMenuItem,
this.moveTopToolStripMenuItem,
this.moveBottomToolStripMenuItem,
this.toolStripSeparator3,
this.newToolStripMenuItemNew,
this.copyToolStripMenuItemCopy,
this.toolStripSeparator1,
this.toolStripMenuItemImport,
this.toolStripMenuItemExport});
this.contextMenuStripStyles.Name = "contextMenuStrip1";
this.contextMenuStripStyles.Size = new System.Drawing.Size(216, 242);
//
// deleteToolStripMenuItem
//
this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem";
this.deleteToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Delete;
this.deleteToolStripMenuItem.Size = new System.Drawing.Size(215, 22);
this.deleteToolStripMenuItem.Text = "Remove";
this.deleteToolStripMenuItem.Click += new System.EventHandler(this.deleteToolStripMenuItem_Click);
//
// toolStripMenuItemRemoveAll
//
this.toolStripMenuItemRemoveAll.Name = "toolStripMenuItemRemoveAll";
this.toolStripMenuItemRemoveAll.Size = new System.Drawing.Size(215, 22);
this.toolStripMenuItemRemoveAll.Text = "Remove all";
this.toolStripMenuItemRemoveAll.Click += new System.EventHandler(this.toolStripMenuItemRemoveAll_Click);
//
// toolStripSeparator4
//
this.toolStripSeparator4.Name = "toolStripSeparator4";
this.toolStripSeparator4.Size = new System.Drawing.Size(212, 6);
//
// moveUpToolStripMenuItem
//
this.moveUpToolStripMenuItem.Name = "moveUpToolStripMenuItem";
this.moveUpToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Up)));
this.moveUpToolStripMenuItem.Size = new System.Drawing.Size(215, 22);
this.moveUpToolStripMenuItem.Text = "Move up";
this.moveUpToolStripMenuItem.Click += new System.EventHandler(this.moveUpToolStripMenuItem_Click);
//
// moveDownToolStripMenuItem
//
this.moveDownToolStripMenuItem.Name = "moveDownToolStripMenuItem";
this.moveDownToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Down)));
this.moveDownToolStripMenuItem.Size = new System.Drawing.Size(215, 22);
this.moveDownToolStripMenuItem.Text = "Move down";
this.moveDownToolStripMenuItem.Click += new System.EventHandler(this.moveDownToolStripMenuItem_Click);
//
// moveTopToolStripMenuItem
//
this.moveTopToolStripMenuItem.Name = "moveTopToolStripMenuItem";
this.moveTopToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Home)));
this.moveTopToolStripMenuItem.Size = new System.Drawing.Size(215, 22);
this.moveTopToolStripMenuItem.Text = "Move to top";
this.moveTopToolStripMenuItem.Click += new System.EventHandler(this.moveTopToolStripMenuItem_Click);
//
// moveBottomToolStripMenuItem
//
this.moveBottomToolStripMenuItem.Name = "moveBottomToolStripMenuItem";
this.moveBottomToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.End)));
this.moveBottomToolStripMenuItem.Size = new System.Drawing.Size(215, 22);
this.moveBottomToolStripMenuItem.Text = "Move to bottom";
this.moveBottomToolStripMenuItem.Click += new System.EventHandler(this.moveBottomToolStripMenuItem_Click);
//
// toolStripSeparator3
//
this.toolStripSeparator3.Name = "toolStripSeparator3";
this.toolStripSeparator3.Size = new System.Drawing.Size(212, 6);
//
// newToolStripMenuItemNew
//
this.newToolStripMenuItemNew.Name = "newToolStripMenuItemNew";
this.newToolStripMenuItemNew.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.N)));
this.newToolStripMenuItemNew.Size = new System.Drawing.Size(215, 22);
this.newToolStripMenuItemNew.Text = "New";
this.newToolStripMenuItemNew.Click += new System.EventHandler(this.newToolStripMenuItemNew_Click);
//
// copyToolStripMenuItemCopy
//
this.copyToolStripMenuItemCopy.Name = "copyToolStripMenuItemCopy";
this.copyToolStripMenuItemCopy.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C)));
this.copyToolStripMenuItemCopy.Size = new System.Drawing.Size(215, 22);
this.copyToolStripMenuItemCopy.Text = "Copy";
this.copyToolStripMenuItemCopy.Click += new System.EventHandler(this.copyToolStripMenuItemCopy_Click);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(212, 6);
//
// toolStripMenuItemImport
//
this.toolStripMenuItemImport.Name = "toolStripMenuItemImport";
this.toolStripMenuItemImport.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.I)));
this.toolStripMenuItemImport.Size = new System.Drawing.Size(215, 22);
this.toolStripMenuItemImport.Text = "Import...";
this.toolStripMenuItemImport.Click += new System.EventHandler(this.toolStripMenuItemImport_Click);
//
// toolStripMenuItemExport
//
this.toolStripMenuItemExport.Name = "toolStripMenuItemExport";
this.toolStripMenuItemExport.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.E)));
this.toolStripMenuItemExport.Size = new System.Drawing.Size(215, 22);
this.toolStripMenuItemExport.Text = "Export...";
this.toolStripMenuItemExport.Click += new System.EventHandler(this.toolStripMenuItemExport_Click);
//
// groupBoxProperties
//
this.groupBoxProperties.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
@ -628,119 +741,6 @@
this.labelDuplicateStyleNames.TabIndex = 11;
this.labelDuplicateStyleNames.Text = "labelDuplicateStyleNames";
//
// contextMenuStripStyles
//
this.contextMenuStripStyles.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.deleteToolStripMenuItem,
this.toolStripMenuItemRemoveAll,
this.toolStripSeparator4,
this.moveUpToolStripMenuItem,
this.moveDownToolStripMenuItem,
this.moveTopToolStripMenuItem,
this.moveBottomToolStripMenuItem,
this.toolStripSeparator3,
this.newToolStripMenuItemNew,
this.copyToolStripMenuItemCopy,
this.toolStripSeparator1,
this.toolStripMenuItemImport,
this.toolStripMenuItemExport});
this.contextMenuStripStyles.Name = "contextMenuStrip1";
this.contextMenuStripStyles.Size = new System.Drawing.Size(216, 242);
//
// deleteToolStripMenuItem
//
this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem";
this.deleteToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Delete;
this.deleteToolStripMenuItem.Size = new System.Drawing.Size(215, 22);
this.deleteToolStripMenuItem.Text = "Remove";
this.deleteToolStripMenuItem.Click += new System.EventHandler(this.deleteToolStripMenuItem_Click);
//
// toolStripMenuItemRemoveAll
//
this.toolStripMenuItemRemoveAll.Name = "toolStripMenuItemRemoveAll";
this.toolStripMenuItemRemoveAll.Size = new System.Drawing.Size(215, 22);
this.toolStripMenuItemRemoveAll.Text = "Remove all";
this.toolStripMenuItemRemoveAll.Click += new System.EventHandler(this.toolStripMenuItemRemoveAll_Click);
//
// toolStripSeparator4
//
this.toolStripSeparator4.Name = "toolStripSeparator4";
this.toolStripSeparator4.Size = new System.Drawing.Size(212, 6);
//
// moveUpToolStripMenuItem
//
this.moveUpToolStripMenuItem.Name = "moveUpToolStripMenuItem";
this.moveUpToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Up)));
this.moveUpToolStripMenuItem.Size = new System.Drawing.Size(215, 22);
this.moveUpToolStripMenuItem.Text = "Move up";
this.moveUpToolStripMenuItem.Click += new System.EventHandler(this.moveUpToolStripMenuItem_Click);
//
// moveDownToolStripMenuItem
//
this.moveDownToolStripMenuItem.Name = "moveDownToolStripMenuItem";
this.moveDownToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Down)));
this.moveDownToolStripMenuItem.Size = new System.Drawing.Size(215, 22);
this.moveDownToolStripMenuItem.Text = "Move down";
this.moveDownToolStripMenuItem.Click += new System.EventHandler(this.moveDownToolStripMenuItem_Click);
//
// moveTopToolStripMenuItem
//
this.moveTopToolStripMenuItem.Name = "moveTopToolStripMenuItem";
this.moveTopToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Home)));
this.moveTopToolStripMenuItem.Size = new System.Drawing.Size(215, 22);
this.moveTopToolStripMenuItem.Text = "Move to top";
this.moveTopToolStripMenuItem.Click += new System.EventHandler(this.moveTopToolStripMenuItem_Click);
//
// moveBottomToolStripMenuItem
//
this.moveBottomToolStripMenuItem.Name = "moveBottomToolStripMenuItem";
this.moveBottomToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.End)));
this.moveBottomToolStripMenuItem.Size = new System.Drawing.Size(215, 22);
this.moveBottomToolStripMenuItem.Text = "Move to bottom";
this.moveBottomToolStripMenuItem.Click += new System.EventHandler(this.moveBottomToolStripMenuItem_Click);
//
// toolStripSeparator3
//
this.toolStripSeparator3.Name = "toolStripSeparator3";
this.toolStripSeparator3.Size = new System.Drawing.Size(212, 6);
//
// newToolStripMenuItemNew
//
this.newToolStripMenuItemNew.Name = "newToolStripMenuItemNew";
this.newToolStripMenuItemNew.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.N)));
this.newToolStripMenuItemNew.Size = new System.Drawing.Size(215, 22);
this.newToolStripMenuItemNew.Text = "New";
this.newToolStripMenuItemNew.Click += new System.EventHandler(this.newToolStripMenuItemNew_Click);
//
// copyToolStripMenuItemCopy
//
this.copyToolStripMenuItemCopy.Name = "copyToolStripMenuItemCopy";
this.copyToolStripMenuItemCopy.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C)));
this.copyToolStripMenuItemCopy.Size = new System.Drawing.Size(215, 22);
this.copyToolStripMenuItemCopy.Text = "Copy";
this.copyToolStripMenuItemCopy.Click += new System.EventHandler(this.copyToolStripMenuItemCopy_Click);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(212, 6);
//
// toolStripMenuItemImport
//
this.toolStripMenuItemImport.Name = "toolStripMenuItemImport";
this.toolStripMenuItemImport.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.I)));
this.toolStripMenuItemImport.Size = new System.Drawing.Size(215, 22);
this.toolStripMenuItemImport.Text = "Import...";
this.toolStripMenuItemImport.Click += new System.EventHandler(this.toolStripMenuItemImport_Click);
//
// toolStripMenuItemExport
//
this.toolStripMenuItemExport.Name = "toolStripMenuItemExport";
this.toolStripMenuItemExport.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.E)));
this.toolStripMenuItemExport.Size = new System.Drawing.Size(215, 22);
this.toolStripMenuItemExport.Text = "Export...";
this.toolStripMenuItemExport.Click += new System.EventHandler(this.toolStripMenuItemExport_Click);
//
// labelInfo
//
this.labelInfo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
@ -771,6 +771,7 @@
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "WebVttStyleManager";
this.groupBoxStyles.ResumeLayout(false);
this.contextMenuStripStyles.ResumeLayout(false);
this.groupBoxProperties.ResumeLayout(false);
this.groupBoxProperties.PerformLayout();
this.groupBoxAfter.ResumeLayout(false);
@ -783,7 +784,6 @@
this.groupBoxFont.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownShadowWidth)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownFontSize)).EndInit();
this.contextMenuStripStyles.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();

View File

@ -243,7 +243,7 @@ namespace Nikse.SubtitleEdit.Forms.VTT
}
else
{
labelBefore.Text = style.ToString().Replace("; ", ";" + Environment.NewLine);
labelBefore.Text = beforeStyle.ToString().Replace("; ", ";" + Environment.NewLine);
}
UpdateRawBeforeStyle();
@ -587,6 +587,7 @@ namespace Nikse.SubtitleEdit.Forms.VTT
return;
}
var tempStyles = new List<WebVttStyle>();
foreach (ListViewItem selectedItem in listViewStyles.SelectedItems)
{
var styleName = selectedItem.Text;
@ -608,11 +609,21 @@ namespace Nikse.SubtitleEdit.Forms.VTT
}
_doUpdate = false;
tempStyles.Add(style);
_doUpdate = true;
selectedItem.Selected = false;
}
foreach (var style in tempStyles)
{
AddStyle(listViewStyles, style, _subtitle);
_webVttStyles.Add(style);
_doUpdate = true;
}
listViewStyles.Items[listViewStyles.Items.Count - 1].Selected = true;
listViewStyles.Items[listViewStyles.Items.Count - 1].Focused = true;
CheckDuplicateStyles();
}
@ -642,7 +653,7 @@ namespace Nikse.SubtitleEdit.Forms.VTT
{
labelInfo.Text = string.Empty;
}
catch
catch
{
// ignore
}
@ -766,6 +777,8 @@ namespace Nikse.SubtitleEdit.Forms.VTT
{
_currentStyle.Bold = null;
}
UpdateRawBeforeStyle();
}
private void checkBoxFontItalic_CheckedChanged(object sender, EventArgs e)
@ -786,6 +799,7 @@ namespace Nikse.SubtitleEdit.Forms.VTT
}
listViewStyles.SelectedItems[0].SubItems[3].Text = _currentStyle.Italic.HasValue && _currentStyle.Italic.Value == true ? LanguageSettings.Current.General.Yes : "-";
UpdateRawBeforeStyle();
}
private void checkBoxFontUnderline_CheckedChanged(object sender, EventArgs e)
@ -803,6 +817,8 @@ namespace Nikse.SubtitleEdit.Forms.VTT
{
_currentStyle.Underline = null;
}
UpdateRawBeforeStyle();
}
private void checkBoxStrikeout_CheckedChanged(object sender, EventArgs e)
@ -820,6 +836,8 @@ namespace Nikse.SubtitleEdit.Forms.VTT
{
_currentStyle.StrikeThrough = null;
}
UpdateRawBeforeStyle();
}
private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
@ -857,7 +875,6 @@ namespace Nikse.SubtitleEdit.Forms.VTT
MoveUp(listViewStyles);
}
private void MoveUp(ListView listView)
{
if (listView.SelectedItems.Count != 1)