mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-25 12:44:46 +01:00
Export TextST can now "Duplicate" a "Region style"
This commit is contained in:
parent
cf6a9170d6
commit
5ea0bb5601
@ -85,6 +85,34 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
|
||||
public class RegionStyle
|
||||
{
|
||||
public RegionStyle()
|
||||
{
|
||||
}
|
||||
|
||||
public RegionStyle(RegionStyle regionStyle)
|
||||
{
|
||||
RegionStyleId = regionStyle.RegionStyleId;
|
||||
RegionHorizontalPosition = regionStyle.RegionHorizontalPosition;
|
||||
RegionVerticalPosition = regionStyle.RegionVerticalPosition;
|
||||
RegionWidth = regionStyle.RegionWidth;
|
||||
RegionHeight = regionStyle.RegionHeight;
|
||||
RegionBgPaletteEntryIdRef = regionStyle.RegionBgPaletteEntryIdRef;
|
||||
TextBoxHorizontalPosition = regionStyle.TextBoxHorizontalPosition;
|
||||
TextBoxVerticalPosition = regionStyle.TextBoxVerticalPosition;
|
||||
TextBoxWidth = regionStyle.TextBoxWidth;
|
||||
TextBoxHeight = regionStyle.TextBoxHeight;
|
||||
TextFlow = regionStyle.TextFlow;
|
||||
TextHorizontalAlignment = regionStyle.TextHorizontalAlignment;
|
||||
TextVerticalAlignment = regionStyle.TextVerticalAlignment;
|
||||
LineSpace = regionStyle.LineSpace;
|
||||
FontIdRef = regionStyle.FontIdRef;
|
||||
FontStyle = regionStyle.FontStyle;
|
||||
FontSize = regionStyle.FontSize;
|
||||
FontPaletteEntryIdRef = regionStyle.FontPaletteEntryIdRef;
|
||||
FontOutlinePaletteEntryIdRef = regionStyle.FontOutlinePaletteEntryIdRef;
|
||||
FontOutlineThickness = regionStyle.FontOutlineThickness;
|
||||
}
|
||||
|
||||
public int RegionStyleId { get; set; }
|
||||
public int RegionHorizontalPosition { get; set; }
|
||||
public int RegionVerticalPosition { get; set; }
|
||||
@ -231,6 +259,9 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
|
||||
public void WriteToStream(Stream stream, int numberOfSubtitles)
|
||||
{
|
||||
NumberOfRegionStyles = RegionStyles.Count;
|
||||
NumberOfUserStyles = UserStyles.Count;
|
||||
|
||||
byte[] regionStyle = MakeRegionStyle();
|
||||
stream.Write(new byte[] { 0, 0, 1, 0xbf }, 0, 4); // MPEG-2 Private stream 2
|
||||
var size = regionStyle.Length + 5;
|
||||
|
54
src/Forms/ExportTextST.Designer.cs
generated
54
src/Forms/ExportTextST.Designer.cs
generated
@ -79,6 +79,7 @@
|
||||
this.numericUpDownRegionStyleId = new System.Windows.Forms.NumericUpDown();
|
||||
this.label6 = new System.Windows.Forms.Label();
|
||||
this.groupBoxPropertiesPalette = new System.Windows.Forms.GroupBox();
|
||||
this.label47 = new System.Windows.Forms.Label();
|
||||
this.panelPaletteColor = new System.Windows.Forms.Panel();
|
||||
this.buttonColor = new System.Windows.Forms.Button();
|
||||
this.numericUpDownPaletteOpacity = new System.Windows.Forms.NumericUpDown();
|
||||
@ -153,6 +154,7 @@
|
||||
this.label44 = new System.Windows.Forms.Label();
|
||||
this.contextMenuStripAddSubtitleContent = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.addFontSetToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.addFontStyleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.addFontSizeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.addLineBreakToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
@ -165,11 +167,11 @@
|
||||
this.toolStripMenuItemRegionAddFontSize = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItemRegionAddLineBreak = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItemRegionAddInlineStyle = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.label47 = new System.Windows.Forms.Label();
|
||||
this.groupBoxFontSet = new System.Windows.Forms.GroupBox();
|
||||
this.numericUpDownFontSetFontId = new System.Windows.Forms.NumericUpDown();
|
||||
this.label48 = new System.Windows.Forms.Label();
|
||||
this.addFontSetToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.contextMenuStripRegionStyle = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.toolStripMenuItemDuplicateRegionStyle = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.groupBoxPropertiesRoot.SuspendLayout();
|
||||
this.groupBoxTextST.SuspendLayout();
|
||||
this.groupBoxPropertiesRegionStyle.SuspendLayout();
|
||||
@ -231,6 +233,7 @@
|
||||
this.contextMenuStripAddSubtitleContentFromSubRegion.SuspendLayout();
|
||||
this.groupBoxFontSet.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownFontSetFontId)).BeginInit();
|
||||
this.contextMenuStripRegionStyle.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// groupBoxPropertiesRoot
|
||||
@ -857,6 +860,15 @@
|
||||
this.groupBoxPropertiesPalette.Text = "Properties: Region palette";
|
||||
this.groupBoxPropertiesPalette.Visible = false;
|
||||
//
|
||||
// label47
|
||||
//
|
||||
this.label47.AutoSize = true;
|
||||
this.label47.Location = new System.Drawing.Point(164, 133);
|
||||
this.label47.Name = "label47";
|
||||
this.label47.Size = new System.Drawing.Size(137, 13);
|
||||
this.label47.TabIndex = 15;
|
||||
this.label47.Text = "0 is transparent, 255 is solid";
|
||||
//
|
||||
// panelPaletteColor
|
||||
//
|
||||
this.panelPaletteColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
@ -1724,7 +1736,7 @@
|
||||
this.toolStripMenuItem2,
|
||||
this.deleteToolStripMenuItem});
|
||||
this.contextMenuStripAddSubtitleContent.Name = "contextMenuStripAddPalette";
|
||||
this.contextMenuStripAddSubtitleContent.Size = new System.Drawing.Size(193, 186);
|
||||
this.contextMenuStripAddSubtitleContent.Size = new System.Drawing.Size(193, 164);
|
||||
//
|
||||
// toolStripMenuItem1
|
||||
//
|
||||
@ -1733,6 +1745,13 @@
|
||||
this.toolStripMenuItem1.Text = "Add text";
|
||||
this.toolStripMenuItem1.Click += new System.EventHandler(this.toolStripMenuItem1_Click);
|
||||
//
|
||||
// addFontSetToolStripMenuItem
|
||||
//
|
||||
this.addFontSetToolStripMenuItem.Name = "addFontSetToolStripMenuItem";
|
||||
this.addFontSetToolStripMenuItem.Size = new System.Drawing.Size(192, 22);
|
||||
this.addFontSetToolStripMenuItem.Text = "Add font set";
|
||||
this.addFontSetToolStripMenuItem.Click += new System.EventHandler(this.addFontSetToolStripMenuItem_Click);
|
||||
//
|
||||
// addFontStyleToolStripMenuItem
|
||||
//
|
||||
this.addFontStyleToolStripMenuItem.Name = "addFontStyleToolStripMenuItem";
|
||||
@ -1819,15 +1838,6 @@
|
||||
this.toolStripMenuItemRegionAddInlineStyle.Text = "Add end of inline style";
|
||||
this.toolStripMenuItemRegionAddInlineStyle.Click += new System.EventHandler(this.toolStripMenuItemRegionAddInlineStyle_Click);
|
||||
//
|
||||
// label47
|
||||
//
|
||||
this.label47.AutoSize = true;
|
||||
this.label47.Location = new System.Drawing.Point(164, 133);
|
||||
this.label47.Name = "label47";
|
||||
this.label47.Size = new System.Drawing.Size(137, 13);
|
||||
this.label47.TabIndex = 15;
|
||||
this.label47.Text = "0 is transparent, 255 is solid";
|
||||
//
|
||||
// groupBoxFontSet
|
||||
//
|
||||
this.groupBoxFontSet.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
@ -1864,12 +1874,19 @@
|
||||
this.label48.TabIndex = 14;
|
||||
this.label48.Text = "Font id from CIF";
|
||||
//
|
||||
// addFontSetToolStripMenuItem
|
||||
// contextMenuStripRegionStyle
|
||||
//
|
||||
this.addFontSetToolStripMenuItem.Name = "addFontSetToolStripMenuItem";
|
||||
this.addFontSetToolStripMenuItem.Size = new System.Drawing.Size(192, 22);
|
||||
this.addFontSetToolStripMenuItem.Text = "Add font set";
|
||||
this.addFontSetToolStripMenuItem.Click += new System.EventHandler(this.addFontSetToolStripMenuItem_Click);
|
||||
this.contextMenuStripRegionStyle.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.toolStripMenuItemDuplicateRegionStyle});
|
||||
this.contextMenuStripRegionStyle.Name = "contextMenuStripAddPalette";
|
||||
this.contextMenuStripRegionStyle.Size = new System.Drawing.Size(153, 48);
|
||||
//
|
||||
// toolStripMenuItemDuplicateRegionStyle
|
||||
//
|
||||
this.toolStripMenuItemDuplicateRegionStyle.Name = "toolStripMenuItemDuplicateRegionStyle";
|
||||
this.toolStripMenuItemDuplicateRegionStyle.Size = new System.Drawing.Size(152, 22);
|
||||
this.toolStripMenuItemDuplicateRegionStyle.Text = "Duplicate";
|
||||
this.toolStripMenuItemDuplicateRegionStyle.Click += new System.EventHandler(this.toolStripMenuItemDuplicateRegionStyle_Click);
|
||||
//
|
||||
// ExportTextST
|
||||
//
|
||||
@ -1967,6 +1984,7 @@
|
||||
this.groupBoxFontSet.ResumeLayout(false);
|
||||
this.groupBoxFontSet.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownFontSetFontId)).EndInit();
|
||||
this.contextMenuStripRegionStyle.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
@ -2114,5 +2132,7 @@
|
||||
private System.Windows.Forms.NumericUpDown numericUpDownFontSetFontId;
|
||||
private System.Windows.Forms.Label label48;
|
||||
private System.Windows.Forms.ToolStripMenuItem addFontSetToolStripMenuItem;
|
||||
private System.Windows.Forms.ContextMenuStrip contextMenuStripRegionStyle;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemDuplicateRegionStyle;
|
||||
}
|
||||
}
|
@ -618,6 +618,10 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
contextMenuStripAddSubtitleContent.Show(treeView1, p);
|
||||
}
|
||||
else if (node.Tag is TextST.RegionStyle)
|
||||
{
|
||||
contextMenuStripRegionStyle.Show(treeView1, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -791,5 +795,26 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
_currentSubtitleFontSet.FontId = GetIntFromNumericUpDown(sender);
|
||||
}
|
||||
|
||||
private void toolStripMenuItemDuplicateRegionStyle_Click(object sender, EventArgs e)
|
||||
{
|
||||
var regionStyle = _currentNode.Tag as TextST.RegionStyle;
|
||||
if (regionStyle != null)
|
||||
{
|
||||
int regionStyleId = 0;
|
||||
foreach (var rs in _textST.StyleSegment.RegionStyles)
|
||||
{
|
||||
regionStyleId = Math.Max(regionStyleId, rs.RegionStyleId);
|
||||
}
|
||||
regionStyleId++;
|
||||
|
||||
var newRegionStyle = new TextST.RegionStyle(regionStyle) { RegionStyleId = regionStyleId };
|
||||
_textST.StyleSegment.RegionStyles.Add(newRegionStyle);
|
||||
var newNode = new TreeNode("Region style") { Tag = newRegionStyle };
|
||||
_currentNode.Parent.Nodes.Add(newNode);
|
||||
_currentNode.Parent.Text = "Region styles (" + _textST.StyleSegment.RegionStyles.Count + ")";
|
||||
treeView1.SelectedNode = newNode;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -132,7 +132,10 @@
|
||||
<metadata name="contextMenuStripAddSubtitleContentFromSubRegion.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>630, 17</value>
|
||||
</metadata>
|
||||
<metadata name="contextMenuStripRegionStyle.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>974, 17</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>36</value>
|
||||
<value>178</value>
|
||||
</metadata>
|
||||
</root>
|
Loading…
Reference in New Issue
Block a user