Add Assa categories

This commit is contained in:
OmrSi 2021-01-30 21:30:51 +02:00
parent 1bd203a193
commit 6de8ab251d
14 changed files with 445 additions and 240 deletions

View File

@ -2588,6 +2588,10 @@ Continue?</RestoreDefaultSettingsMsg>
<AddToStorage>Add to storage</AddToStorage>
<StyleStorage>Style storage</StyleStorage>
<OverwriteX>Overwrite {0}?</OverwriteX>
<Category>Category</Category>
<NewCategory>New category</NewCategory>
<CategoryName>Category name</CategoryName>
<CategoryNote>Note: "Default" styles will be applied to new ASSA files</CategoryNote>
</SubStationAlphaStyles>
<PointSync>
<Title>Point synchronization</Title>

View File

@ -542,13 +542,8 @@ namespace Nikse.SubtitleEdit.Core.Common
finalSub.Paragraphs.AddRange(SplitToAssRenderLines(paragraph, width, height));
}
var oldFontSize = Configuration.Settings.SubtitleSettings.SsaFontSize;
var oldFontBold = Configuration.Settings.SubtitleSettings.SsaFontBold;
Configuration.Settings.SubtitleSettings.SsaFontSize = 40; // font size
Configuration.Settings.SubtitleSettings.SsaFontBold = false;
finalSub.Header = AdvancedSubStationAlpha.DefaultHeader;
Configuration.Settings.SubtitleSettings.SsaFontSize = oldFontSize;
Configuration.Settings.SubtitleSettings.SsaFontBold = oldFontBold;
var style = new SsaStyle{ FontSize = 40, Bold = false};
finalSub.Header = string.Format(AdvancedSubStationAlpha.HeaderNoStyles, string.Empty, style.ToRawAss());
finalSub.Header = finalSub.Header.Replace("PlayDepth: 0", @"PlayDepth: 0
PlayResX: 1280

View File

@ -492,17 +492,7 @@ namespace Nikse.SubtitleEdit.Core.Common
public class SubtitleSettings
{
public string SsaFontName { get; set; }
public double SsaFontSize { get; set; }
public int SsaFontColorArgb { get; set; }
public bool SsaFontBold { get; set; }
public decimal SsaOutline { get; set; }
public decimal SsaShadow { get; set; }
public bool SsaOpaqueBox { get; set; }
public int SsaMarginLeft { get; set; }
public int SsaMarginRight { get; set; }
public int SsaMarginTopBottom { get; set; }
public string AssaStyleStorage { get; set; }
public List<AssaStorageCategory> AssaStyleStorageCategories { get; set; }
public string DCinemaFontFile { get; set; }
public string DCinemaLoadFontResource { get; set; }
@ -573,19 +563,7 @@ namespace Nikse.SubtitleEdit.Core.Common
public SubtitleSettings()
{
SsaFontName = "Arial";
if (Configuration.IsRunningOnLinux)
{
SsaFontName = Configuration.DefaultLinuxFontName;
}
SsaFontSize = 20;
SsaFontColorArgb = Color.FromArgb(255, 255, 255).ToArgb();
SsaOutline = 2;
SsaShadow = 1;
SsaOpaqueBox = false;
SsaMarginLeft = 10;
SsaMarginRight = 10;
SsaMarginTopBottom = 10;
AssaStyleStorageCategories = new List<AssaStorageCategory>();
DCinemaFontFile = "Arial.ttf";
DCinemaLoadFontResource = "urn:uuid:3dec6dc0-39d0-498d-97d0-928d2eb78391";
@ -1774,6 +1752,13 @@ $HorzAlign = Center
public List<MultipleSearchAndReplaceSetting> Rules { get; set; }
}
public class AssaStorageCategory
{
public string Name { get; set; }
public bool IsDefault { get; set; }
public List<SsaStyle> Styles { get; set; }
}
public class NetworkSettings
{
public string UserName { get; set; }
@ -2298,7 +2283,7 @@ $HorzAlign = Center
public void Save()
{
//this is too slow: Serialize(Configuration.SettingsFileName, this);
// this is too slow: Serialize(Configuration.SettingsFileName, this);
CustomSerialize(Configuration.SettingsFileName, this);
}
@ -4951,70 +4936,115 @@ $HorzAlign = Center
node = doc.DocumentElement.SelectSingleNode("SubtitleSettings");
if (node != null)
{
subNode = node.SelectSingleNode("SsaFontName");
foreach (XmlNode categoryNode in node.SelectNodes("AssaStyleStorageCategories/Category"))
{
var category = new AssaStorageCategory
{
Styles = new List<SsaStyle>()
};
subNode = categoryNode.SelectSingleNode("Name");
if (subNode != null)
{
settings.SubtitleSettings.SsaFontName = subNode.InnerText;
category.Name = subNode.InnerText;
}
subNode = node.SelectSingleNode("SsaFontSize");
subNode = categoryNode.SelectSingleNode("IsDefault");
if (subNode != null)
{
settings.SubtitleSettings.SsaFontSize = Convert.ToDouble(subNode.InnerText, CultureInfo.InvariantCulture);
category.IsDefault = Convert.ToBoolean(subNode.InnerText, CultureInfo.InvariantCulture);
}
subNode = node.SelectSingleNode("SsaFontColorArgb");
settings.SubtitleSettings.AssaStyleStorageCategories.Add(category);
foreach (XmlNode listNode in categoryNode.SelectNodes("Style"))
{
var item = new SsaStyle();
subNode = listNode.SelectSingleNode("Name");
if (subNode != null)
{
settings.SubtitleSettings.SsaFontColorArgb = Convert.ToInt32(subNode.InnerText, CultureInfo.InvariantCulture);
item.Name = subNode.InnerText;
}
subNode = node.SelectSingleNode("SsaFontBold");
subNode = listNode.SelectSingleNode("FontName");
if (subNode != null)
{
settings.SubtitleSettings.SsaFontBold = Convert.ToBoolean(subNode.InnerText, CultureInfo.InvariantCulture);
item.FontName = subNode.InnerText;
}
subNode = node.SelectSingleNode("SsaOutline");
subNode = listNode.SelectSingleNode("FontSize");
if (subNode != null)
{
settings.SubtitleSettings.SsaOutline = Convert.ToDecimal(subNode.InnerText);
item.FontSize = Convert.ToSingle(subNode.InnerText);
}
subNode = node.SelectSingleNode("SsaShadow");
subNode = listNode.SelectSingleNode("Primary");
if (subNode != null)
{
settings.SubtitleSettings.SsaShadow = Convert.ToDecimal(subNode.InnerText);
item.Primary = Color.FromArgb(int.Parse(subNode.InnerText, CultureInfo.InvariantCulture));
}
subNode = node.SelectSingleNode("SsaOpaqueBox");
subNode = listNode.SelectSingleNode("Secondary");
if (subNode != null)
{
settings.SubtitleSettings.SsaOpaqueBox = Convert.ToBoolean(subNode.InnerText, CultureInfo.InvariantCulture);
item.Secondary = Color.FromArgb(int.Parse(subNode.InnerText, CultureInfo.InvariantCulture));
}
subNode = node.SelectSingleNode("SsaMarginLeft");
subNode = listNode.SelectSingleNode("Outline");
if (subNode != null)
{
settings.SubtitleSettings.SsaMarginLeft = Convert.ToInt32(subNode.InnerText, CultureInfo.InvariantCulture);
item.Outline = Color.FromArgb(int.Parse(subNode.InnerText, CultureInfo.InvariantCulture));
}
subNode = node.SelectSingleNode("SsaMarginRight");
subNode = listNode.SelectSingleNode("Background");
if (subNode != null)
{
settings.SubtitleSettings.SsaMarginRight = Convert.ToInt32(subNode.InnerText, CultureInfo.InvariantCulture);
item.Background = Color.FromArgb(int.Parse(subNode.InnerText, CultureInfo.InvariantCulture));
}
subNode = node.SelectSingleNode("SsaMarginTopBottom");
subNode = listNode.SelectSingleNode("ShadowWidth");
if (subNode != null)
{
settings.SubtitleSettings.SsaMarginTopBottom = Convert.ToInt32(subNode.InnerText, CultureInfo.InvariantCulture);
item.ShadowWidth = Convert.ToDecimal(subNode.InnerText);
}
subNode = node.SelectSingleNode("AssaStyleStorage");
subNode = listNode.SelectSingleNode("OutlineWidth");
if (subNode != null)
{
settings.SubtitleSettings.AssaStyleStorage = subNode.InnerText;
item.OutlineWidth = Convert.ToDecimal(subNode.InnerText);
}
subNode = listNode.SelectSingleNode("Alignment");
if (subNode != null)
{
item.Alignment = subNode.InnerText;
}
subNode = listNode.SelectSingleNode("MarginLeft");
if (subNode != null)
{
item.MarginLeft = Convert.ToInt32(subNode.InnerText);
}
subNode = listNode.SelectSingleNode("MarginRight");
if (subNode != null)
{
item.MarginRight = Convert.ToInt32(subNode.InnerText);
}
subNode = listNode.SelectSingleNode("MarginVertical");
if (subNode != null)
{
item.MarginVertical = Convert.ToInt32(subNode.InnerText);
}
subNode = listNode.SelectSingleNode("BorderStyle");
if (subNode != null)
{
item.BorderStyle = subNode.InnerText;
}
category.Styles.Add(item);
}
}
subNode = node.SelectSingleNode("DCinemaFontFile");
@ -8346,17 +8376,38 @@ $HorzAlign = Center
textWriter.WriteEndElement();
textWriter.WriteStartElement("SubtitleSettings", string.Empty);
textWriter.WriteElementString("SsaFontName", settings.SubtitleSettings.SsaFontName);
textWriter.WriteElementString("SsaFontSize", settings.SubtitleSettings.SsaFontSize.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("SsaFontColorArgb", settings.SubtitleSettings.SsaFontColorArgb.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("SsaFontBold", settings.SubtitleSettings.SsaFontBold.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("SsaOutline", settings.SubtitleSettings.SsaOutline.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("SsaShadow", settings.SubtitleSettings.SsaShadow.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("SsaOpaqueBox", settings.SubtitleSettings.SsaOpaqueBox.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("SsaMarginLeft", settings.SubtitleSettings.SsaMarginLeft.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("SsaMarginRight", settings.SubtitleSettings.SsaMarginRight.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("SsaMarginTopBottom", settings.SubtitleSettings.SsaMarginTopBottom.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("AssaStyleStorage", settings.SubtitleSettings.AssaStyleStorage);
textWriter.WriteStartElement("AssaStyleStorageCategories", string.Empty);
foreach (var category in settings.SubtitleSettings.AssaStyleStorageCategories)
{
if (!string.IsNullOrEmpty(category?.Name))
{
textWriter.WriteStartElement("Category", string.Empty);
textWriter.WriteElementString("Name", category.Name);
textWriter.WriteElementString("IsDefault", category.IsDefault.ToString(CultureInfo.InvariantCulture));
foreach (var style in category.Styles)
{
textWriter.WriteStartElement("Style");
textWriter.WriteElementString("Name", style.Name);
textWriter.WriteElementString("FontName", style.FontName);
textWriter.WriteElementString("FontSize", style.FontSize.ToString());
textWriter.WriteElementString("Primary", style.Primary.ToArgb().ToString());
textWriter.WriteElementString("Secondary", style.Secondary.ToArgb().ToString());
textWriter.WriteElementString("Outline", style.Outline.ToArgb().ToString());
textWriter.WriteElementString("Background", style.Background.ToArgb().ToString());
textWriter.WriteElementString("ShadowWidth", style.ShadowWidth.ToString());
textWriter.WriteElementString("OutlineWidth", style.OutlineWidth.ToString());
textWriter.WriteElementString("Alignment", style.Alignment);
textWriter.WriteElementString("MarginLeft", style.MarginLeft.ToString());
textWriter.WriteElementString("MarginRight", style.MarginRight.ToString());
textWriter.WriteElementString("MarginVertical", style.MarginVertical.ToString());
textWriter.WriteElementString("BorderStyle", style.BorderStyle.ToString());
textWriter.WriteEndElement();
}
textWriter.WriteEndElement();
}
}
textWriter.WriteEndElement();
textWriter.WriteElementString("DCinemaFontFile", settings.SubtitleSettings.DCinemaFontFile);
textWriter.WriteElementString("DCinemaFontSize", settings.SubtitleSettings.DCinemaFontSize.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("DCinemaBottomMargin", settings.SubtitleSettings.DCinemaBottomMargin.ToString(CultureInfo.InvariantCulture));

View File

@ -32,24 +32,20 @@ namespace Nikse.SubtitleEdit.Core.Common
public SsaStyle()
{
FontName = Configuration.Settings.SubtitleSettings.SsaFontName;
FontSize = (float)Configuration.Settings.SubtitleSettings.SsaFontSize;
Primary = Color.FromArgb(Configuration.Settings.SubtitleSettings.SsaFontColorArgb);
Name = "Default";
FontName = "Arial";
FontSize = 20F;
Primary = Color.White;
Secondary = Color.Yellow;
Outline = Color.Black;
Background = Color.Black;
Alignment = "2";
OutlineWidth = Configuration.Settings.SubtitleSettings.SsaOutline;
ShadowWidth = Configuration.Settings.SubtitleSettings.SsaShadow;
OutlineWidth = 1M;
ShadowWidth = 1M;
MarginLeft = 10;
MarginRight = 10;
MarginVertical = 10;
BorderStyle = "1";
if (Configuration.Settings.SubtitleSettings.SsaOpaqueBox)
{
BorderStyle = "3";
}
RawLine = string.Empty;
LoadedFromHeader = false;
}
@ -117,10 +113,6 @@ namespace Nikse.SubtitleEdit.Core.Common
{
sb.Append(ColorTranslator.ToWin32(Tertiary));
}
else if (f == "outlinecolour")
{
sb.Append(ColorTranslator.ToWin32(Outline));
}
else if (f == "backcolour")
{
sb.Append(ColorTranslator.ToWin32(Background));
@ -192,7 +184,7 @@ namespace Nikse.SubtitleEdit.Core.Common
return s.Substring(0, s.Length - 1);
}
public string ToRawAss(string styleFormat)
public string ToRawAss(string styleFormat = DefaultAssStyleFormat)
{
var sb = new StringBuilder();
sb.Append("Style: ");
@ -220,10 +212,6 @@ namespace Nikse.SubtitleEdit.Core.Common
{
sb.Append(AdvancedSubStationAlpha.GetSsaColorString(Secondary));
}
else if (f == "tertiarycolour")
{
sb.Append(AdvancedSubStationAlpha.GetSsaColorString(Tertiary));
}
else if (f == "outlinecolour")
{
sb.Append(AdvancedSubStationAlpha.GetSsaColorString(Outline));

View File

@ -17,24 +17,25 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
{
get
{
var borderStyle = "1"; // 1=normal, 3=opaque box
if (Configuration.Settings.SubtitleSettings.SsaOpaqueBox)
string defaultStyle = string.Empty;
var defaultCategory = Configuration.Settings.SubtitleSettings.AssaStyleStorageCategories.SingleOrDefault(item => item.IsDefault);
if (defaultCategory == null || defaultCategory.Styles.Count < 0)
{
borderStyle = "3";
defaultStyle = new SsaStyle().ToRawAss();
}
else
{
foreach (var defaultCategoryStyle in defaultCategory.Styles)
{
defaultStyle += defaultCategoryStyle.ToRawAss();
if (defaultCategory.Styles.IndexOf(defaultCategoryStyle) != defaultCategory.Styles.Count - 1)
{
defaultStyle += Environment.NewLine;
}
}
}
var boldStyle = "0"; // 0=regular
if (Configuration.Settings.SubtitleSettings.SsaFontBold)
{
boldStyle = "-1";
}
var ssa = Configuration.Settings.SubtitleSettings;
return "Style: Default," + ssa.SsaFontName + "," +
ssa.SsaFontSize.ToString(CultureInfo.InvariantCulture) + "," +
GetSsaColorString(Color.FromArgb(ssa.SsaFontColorArgb)) + "," +
"&H0300FFFF,&H00000000,&H02000000," + boldStyle + ",0,0,0,100,100,0,0," + borderStyle + "," + ssa.SsaOutline.ToString(CultureInfo.InvariantCulture) + "," +
Configuration.Settings.SubtitleSettings.SsaShadow.ToString(CultureInfo.InvariantCulture) + ",2," + ssa.SsaMarginLeft + "," + ssa.SsaMarginRight + "," + ssa.SsaMarginTopBottom + ",1";
return defaultStyle;
}
}
@ -698,6 +699,7 @@ Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text"
}
}
}
return list;
}
@ -2184,7 +2186,7 @@ Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text"
var format = line.Substring(6).Split(',');
for (int i = 0; i < format.Length; i++)
{
string f = format[i].Trim().ToLowerInvariant();
string f = format[i].Trim();
if (i == nameIndex)
{
style.Name = format[i].Trim();
@ -2286,6 +2288,7 @@ Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text"
}
}
}
return new SsaStyle { Name = styleName };
}
}

View File

@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Xml;
@ -65,7 +66,6 @@ Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
const string commentWriteFormat = "Comment: Marked={4},{0},{1},{3},{5},{6},{7},{8},{9},{2}";
var sb = new StringBuilder();
Color fontColor = Color.FromArgb(Configuration.Settings.SubtitleSettings.SsaFontColorArgb);
bool isValidAssHeader = !string.IsNullOrEmpty(subtitle.Header) && subtitle.Header.Contains("[V4 Styles]");
var styles = new List<string>();
if (isValidAssHeader)
@ -91,23 +91,32 @@ Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
}
else
{
var ssa = Configuration.Settings.SubtitleSettings;
SsaStyle style = null;
var storageCategories = Configuration.Settings.SubtitleSettings.AssaStyleStorageCategories;
if (storageCategories.Count > 0 && storageCategories.Exists(x => x.IsDefault))
{
var defaultStyle = storageCategories.SingleOrDefault(x => x.IsDefault).Styles.SingleOrDefault(x => x.Name.ToLowerInvariant() == "default");
style = defaultStyle ?? storageCategories.SingleOrDefault(x => x.IsDefault).Styles[0];
}
style = style ?? new SsaStyle();
string boldStyle = "0"; // 0=regular
if (ssa.SsaFontBold)
if (style.Bold)
{
boldStyle = "-1"; // -1 = true, 0 is false
}
sb.AppendLine(string.Format(header,
title,
ssa.SsaFontName,
(int)ssa.SsaFontSize,
ColorTranslator.ToWin32(fontColor),
ssa.SsaOutline,
ssa.SsaShadow,
ssa.SsaMarginLeft,
ssa.SsaMarginRight,
ssa.SsaMarginTopBottom,
style.FontName,
style.FontSize,
ColorTranslator.ToWin32(style.Primary),
style.OutlineWidth,
style.ShadowWidth,
style.MarginLeft,
style.MarginRight,
style.MarginVertical,
boldStyle
));
}

View File

@ -7860,6 +7860,10 @@ namespace Nikse.SubtitleEdit.Forms
actors = new List<string>();
toolStripMenuItemWebVTT.Visible = false;
var styles = AdvancedSubStationAlpha.GetStylesFromHeader(_subtitle.Header);
if (styles.Count == 0)
{
styles = AdvancedSubStationAlpha.GetStylesFromHeader(AdvancedSubStationAlpha.DefaultHeader);
}
setStylesForSelectedLinesToolStripMenuItem.DropDownItems.Clear();
foreach (var style in styles)
{

View File

@ -1,4 +1,6 @@
namespace Nikse.SubtitleEdit.Forms.Styles
using System.Windows.Forms;
namespace Nikse.SubtitleEdit.Forms.Styles
{
sealed partial class SubStationAlphaStyles
{
@ -129,6 +131,11 @@
this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader6 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.labelCategoryDefaultNote = new System.Windows.Forms.Label();
this.buttonStorageCategoryDelete = new System.Windows.Forms.Button();
this.buttonStorageCategoryNew = new System.Windows.Forms.Button();
this.comboboxStorageCategories = new System.Windows.Forms.ComboBox();
this.labelStorageCategory = new System.Windows.Forms.Label();
this.contextMenuStripStorage = new System.Windows.Forms.ContextMenuStrip(this.components);
this.toolStripMenuItemStorageRemove = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemStorageRemoveAll = new System.Windows.Forms.ToolStripMenuItem();
@ -1042,6 +1049,11 @@
this.groupBoxStorage.Controls.Add(this.buttonStorageAdd);
this.groupBoxStorage.Controls.Add(this.buttonStorageRemove);
this.groupBoxStorage.Controls.Add(this.listViewStorage);
this.groupBoxStorage.Controls.Add(this.labelCategoryDefaultNote);
this.groupBoxStorage.Controls.Add(this.buttonStorageCategoryDelete);
this.groupBoxStorage.Controls.Add(this.buttonStorageCategoryNew);
this.groupBoxStorage.Controls.Add(this.comboboxStorageCategories);
this.groupBoxStorage.Controls.Add(this.labelStorageCategory);
this.groupBoxStorage.Dock = System.Windows.Forms.DockStyle.Fill;
this.groupBoxStorage.Location = new System.Drawing.Point(0, 0);
this.groupBoxStorage.Name = "groupBoxStorage";
@ -1057,7 +1069,7 @@
this.buttonAddToFile.Location = new System.Drawing.Point(280, 222);
this.buttonAddToFile.Name = "buttonAddToFile";
this.buttonAddToFile.Size = new System.Drawing.Size(163, 52);
this.buttonAddToFile.TabIndex = 135;
this.buttonAddToFile.TabIndex = 12;
this.buttonAddToFile.Text = "Add to file";
this.buttonAddToFile.UseVisualStyleBackColor = true;
this.buttonAddToFile.Click += new System.EventHandler(this.buttonAddToFile_Click);
@ -1069,7 +1081,7 @@
this.buttonStorageExport.Location = new System.Drawing.Point(6, 251);
this.buttonStorageExport.Name = "buttonStorageExport";
this.buttonStorageExport.Size = new System.Drawing.Size(82, 23);
this.buttonStorageExport.TabIndex = 140;
this.buttonStorageExport.TabIndex = 7;
this.buttonStorageExport.Text = "Export...";
this.buttonStorageExport.UseVisualStyleBackColor = true;
this.buttonStorageExport.Click += new System.EventHandler(this.buttonStorageExport_Click);
@ -1081,7 +1093,7 @@
this.buttonStorageImport.Location = new System.Drawing.Point(6, 222);
this.buttonStorageImport.Name = "buttonStorageImport";
this.buttonStorageImport.Size = new System.Drawing.Size(82, 23);
this.buttonStorageImport.TabIndex = 120;
this.buttonStorageImport.TabIndex = 6;
this.buttonStorageImport.Text = "Import...";
this.buttonStorageImport.UseVisualStyleBackColor = true;
this.buttonStorageImport.Click += new System.EventHandler(this.buttonStorageImport_Click);
@ -1093,7 +1105,7 @@
this.buttonStorageCopy.Location = new System.Drawing.Point(94, 251);
this.buttonStorageCopy.Name = "buttonStorageCopy";
this.buttonStorageCopy.Size = new System.Drawing.Size(82, 23);
this.buttonStorageCopy.TabIndex = 150;
this.buttonStorageCopy.TabIndex = 9;
this.buttonStorageCopy.Text = "Copy";
this.buttonStorageCopy.UseVisualStyleBackColor = true;
this.buttonStorageCopy.Click += new System.EventHandler(this.buttonStorageCopy_Click);
@ -1105,7 +1117,7 @@
this.buttonStorageRemoveAll.Location = new System.Drawing.Point(182, 251);
this.buttonStorageRemoveAll.Name = "buttonStorageRemoveAll";
this.buttonStorageRemoveAll.Size = new System.Drawing.Size(92, 23);
this.buttonStorageRemoveAll.TabIndex = 160;
this.buttonStorageRemoveAll.TabIndex = 11;
this.buttonStorageRemoveAll.Text = "Remove all";
this.buttonStorageRemoveAll.UseVisualStyleBackColor = true;
this.buttonStorageRemoveAll.Click += new System.EventHandler(this.buttonStorageRemoveAll_Click);
@ -1117,7 +1129,7 @@
this.buttonStorageAdd.Location = new System.Drawing.Point(94, 222);
this.buttonStorageAdd.Name = "buttonStorageAdd";
this.buttonStorageAdd.Size = new System.Drawing.Size(82, 23);
this.buttonStorageAdd.TabIndex = 125;
this.buttonStorageAdd.TabIndex = 8;
this.buttonStorageAdd.Text = "New";
this.buttonStorageAdd.UseVisualStyleBackColor = true;
this.buttonStorageAdd.Click += new System.EventHandler(this.buttonStorageAdd_Click);
@ -1129,7 +1141,7 @@
this.buttonStorageRemove.Location = new System.Drawing.Point(182, 222);
this.buttonStorageRemove.Name = "buttonStorageRemove";
this.buttonStorageRemove.Size = new System.Drawing.Size(92, 23);
this.buttonStorageRemove.TabIndex = 130;
this.buttonStorageRemove.TabIndex = 10;
this.buttonStorageRemove.Text = "Remove";
this.buttonStorageRemove.UseVisualStyleBackColor = true;
this.buttonStorageRemove.Click += new System.EventHandler(this.buttonStorageRemove_Click);
@ -1149,11 +1161,11 @@
this.listViewStorage.ContextMenuStrip = this.contextMenuStripStorage;
this.listViewStorage.FullRowSelect = true;
this.listViewStorage.HideSelection = false;
this.listViewStorage.Location = new System.Drawing.Point(6, 19);
this.listViewStorage.Location = new System.Drawing.Point(6, 68);
this.listViewStorage.MultiSelect = false;
this.listViewStorage.Name = "listViewStorage";
this.listViewStorage.Size = new System.Drawing.Size(545, 197);
this.listViewStorage.TabIndex = 110;
this.listViewStorage.Size = new System.Drawing.Size(545, 148);
this.listViewStorage.TabIndex = 5;
this.listViewStorage.UseCompatibleStateImageBehavior = false;
this.listViewStorage.View = System.Windows.Forms.View.Details;
this.listViewStorage.SelectedIndexChanged += new System.EventHandler(this.listViewStorage_SelectedIndexChanged);
@ -1190,6 +1202,58 @@
this.columnHeader6.Text = "Outline";
this.columnHeader6.Width = 55;
//
// labelCategoryDefaultNote
//
this.labelCategoryDefaultNote.AutoSize = true;
this.labelCategoryDefaultNote.Location = new System.Drawing.Point(10, 48);
this.labelCategoryDefaultNote.Name = "labelCategoryDefaultNote";
this.labelCategoryDefaultNote.Size = new System.Drawing.Size(59, 13);
this.labelCategoryDefaultNote.TabIndex = 4;
this.labelCategoryDefaultNote.Text = "Note: \"Default\" styles will be applied to new ASSA files";
//
// buttonStorageCategoryDelete
//
this.buttonStorageCategoryDelete.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)));
this.buttonStorageCategoryDelete.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonStorageCategoryDelete.Location = new System.Drawing.Point(365, 19);
this.buttonStorageCategoryDelete.Name = "buttonStorageRemove";
this.buttonStorageCategoryDelete.Size = new System.Drawing.Size(92, 23);
this.buttonStorageCategoryDelete.TabIndex = 3;
this.buttonStorageCategoryDelete.Text = "Remove";
this.buttonStorageCategoryDelete.UseVisualStyleBackColor = true;
this.buttonStorageCategoryDelete.Click += new System.EventHandler(this.buttonStorageCategoryDelete_Click);
//
// buttonStorageCategoryNew
//
this.buttonStorageCategoryNew.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)));
this.buttonStorageCategoryNew.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonStorageCategoryNew.Location = new System.Drawing.Point(267, 19);
this.buttonStorageCategoryNew.Name = "buttonStorageCategoryNew";
this.buttonStorageCategoryNew.Size = new System.Drawing.Size(92, 23);
this.buttonStorageCategoryNew.TabIndex = 2;
this.buttonStorageCategoryNew.Text = "New";
this.buttonStorageCategoryNew.UseVisualStyleBackColor = true;
this.buttonStorageCategoryNew.Click += new System.EventHandler(this.buttonStorageCategoryNew_Click);
//
// comboboxStorageCategories
//
this.comboboxStorageCategories.DropDownStyle = ComboBoxStyle.DropDownList;
this.comboboxStorageCategories.FormattingEnabled = true;
this.comboboxStorageCategories.Location = new System.Drawing.Point(73, 19);
this.comboboxStorageCategories.Name = "comboboxStorageCategories";
this.comboboxStorageCategories.Size = new System.Drawing.Size(188, 21);
this.comboboxStorageCategories.TabIndex = 1;
this.comboboxStorageCategories.SelectedIndexChanged += new System.EventHandler(this.comboboxStorageCategory_SelectedIndexChanged);
//
// labelStorageCategory
//
this.labelStorageCategory.AutoSize = true;
this.labelStorageCategory.Location = new System.Drawing.Point(10, 21);
this.labelStorageCategory.Name = "labelStorageCategory";
this.labelStorageCategory.Size = new System.Drawing.Size(59, 13);
this.labelStorageCategory.TabIndex = 0;
this.labelStorageCategory.Text = "Category";
//
// contextMenuStripStorage
//
this.contextMenuStripStorage.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
@ -1464,6 +1528,11 @@
private System.Windows.Forms.Label labelStatus;
private System.Windows.Forms.Timer timerClearStatus;
private System.Windows.Forms.GroupBox groupBoxStorage;
private System.Windows.Forms.Label labelStorageCategory;
private System.Windows.Forms.ComboBox comboboxStorageCategories;
private System.Windows.Forms.Button buttonStorageCategoryNew;
private System.Windows.Forms.Button buttonStorageCategoryDelete;
private System.Windows.Forms.Label labelCategoryDefaultNote;
private System.Windows.Forms.ListView listViewStorage;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2;

View File

@ -16,13 +16,14 @@ namespace Nikse.SubtitleEdit.Forms.Styles
{
public class NameEdit
{
public string OldName { get; set; }
public string NewName { get; set; }
public NameEdit(string oldName, string newName)
{
OldName = oldName;
NewName = newName;
}
public string OldName { get; set; }
public string NewName { get; set; }
}
public List<NameEdit> RenameActions { get; set; }
@ -37,16 +38,11 @@ namespace Nikse.SubtitleEdit.Forms.Styles
private Bitmap _fixedBackgroundImage;
private bool _backgroundImageDark;
private bool _fileStyleActive = true;
private List<SsaStyle> _storageStyles;
private List<AssaStorageCategory> _storageCategories;
private AssaStorageCategory _currentCategory;
private FormWindowState _lastFormWindowState = FormWindowState.Normal;
private ListView ActiveListView
{
get
{
return _fileStyleActive ? listViewStyles : listViewStorage;
}
}
private ListView ActiveListView => _fileStyleActive ? listViewStyles : listViewStorage;
public SubStationAlphaStyles(Subtitle subtitle, SubtitleFormat format)
: base(subtitle)
@ -126,6 +122,10 @@ namespace Nikse.SubtitleEdit.Forms.Styles
groupBoxPreview.Text = LanguageSettings.Current.General.Preview;
groupBoxStorage.Text = l.StyleStorage;
labelStorageCategory.Text = l.Category;
buttonStorageCategoryNew.Text = l.New;
buttonStorageCategoryDelete.Text = l.Remove;
labelCategoryDefaultNote.Text = l.CategoryNote;
buttonStorageImport.Text = l.Import;
buttonStorageExport.Text = l.Export;
buttonStorageAdd.Text = l.New;
@ -202,23 +202,34 @@ namespace Nikse.SubtitleEdit.Forms.Styles
}
else
{
_storageStyles = new List<SsaStyle>();
var styles = AdvancedSubStationAlpha.GetStylesFromHeader(Configuration.Settings.SubtitleSettings.AssaStyleStorage);
foreach (var styleName in styles)
_storageCategories = new List<AssaStorageCategory>();
if (Configuration.Settings.SubtitleSettings.AssaStyleStorageCategories.Count == 0 || !Configuration.Settings.SubtitleSettings.AssaStyleStorageCategories.Exists(item => item.IsDefault))
{
if (!string.IsNullOrEmpty(styleName))
Configuration.Settings.SubtitleSettings.AssaStyleStorageCategories.Add(new AssaStorageCategory { Name = "Default", IsDefault = true, Styles = new List<SsaStyle>() });
}
var defaultCat = Configuration.Settings.SubtitleSettings.AssaStyleStorageCategories.Single(item => item.IsDefault);
if (defaultCat.Styles.Count == 0)
{
var storageStyle = AdvancedSubStationAlpha.GetSsaStyle(styleName, Configuration.Settings.SubtitleSettings.AssaStyleStorage);
_storageStyles.Add(storageStyle);
AddStyle(listViewStorage, storageStyle, Subtitle, _isSubStationAlpha);
defaultCat.Styles.Add(new SsaStyle());
}
foreach (var category in Configuration.Settings.SubtitleSettings.AssaStyleStorageCategories)
{
comboboxStorageCategories.Items.Add(category.Name);
_storageCategories.Add(category);
}
_currentCategory = _storageCategories.Single(item => item.IsDefault);
comboboxStorageCategories.SelectedItem = _currentCategory.Name;
}
buttonOK.Text = LanguageSettings.Current.General.Ok;
buttonCancel.Text = LanguageSettings.Current.General.Cancel;
InitializeListView();
InitializeStylesListView();
listViewStorage_SelectedIndexChanged(this, EventArgs.Empty);
UiUtil.FixLargeFonts(this, buttonCancel);
comboBoxFontName.Left = labelFontName.Left + labelFontName.Width + 5;
@ -341,7 +352,7 @@ namespace Nikse.SubtitleEdit.Forms.Styles
font.Dispose();
}
private void InitializeListView()
private void InitializeStylesListView()
{
var styles = AdvancedSubStationAlpha.GetStylesFromHeader(_header);
listViewStyles.Items.Clear();
@ -452,7 +463,7 @@ namespace Nikse.SubtitleEdit.Forms.Styles
{
if (!_fileStyleActive)
{
var style = _storageStyles.FirstOrDefault(p => p.Name == styleName);
var style = _currentCategory.Styles.FirstOrDefault(p => p.Name == styleName);
if (style == null)
{
return false;
@ -549,7 +560,6 @@ namespace Nikse.SubtitleEdit.Forms.Styles
return true;
}
return false;
}
@ -658,7 +668,7 @@ namespace Nikse.SubtitleEdit.Forms.Styles
private SsaStyle GetSsaStyleStorage(string styleName)
{
return _storageStyles.FirstOrDefault(p => p.Name == styleName);
return _currentCategory.Styles.FirstOrDefault(p => p.Name == styleName);
}
private void ResetHeader()
@ -696,7 +706,7 @@ namespace Nikse.SubtitleEdit.Forms.Styles
{
if (!_isSubStationAlpha)
{
Configuration.Settings.SubtitleSettings.AssaStyleStorage = GetStorageHeader();
Configuration.Settings.SubtitleSettings.AssaStyleStorageCategories = _storageCategories;
_header = GetFileHeader();
}
@ -751,15 +761,17 @@ namespace Nikse.SubtitleEdit.Forms.Styles
private string GetStorageHeader()
{
var header = AdvancedSubStationAlpha.DefaultHeader;
var end = header.IndexOf(Environment.NewLine + "Style:");
header = header.Substring(0, end).Trim();
foreach (var style in _storageStyles)
var styles = string.Empty;
foreach (var currentCategoryStyle in _currentCategory.Styles)
{
header = AdvancedSubStationAlpha.AddSsaStyle(style, header);
styles += currentCategoryStyle.ToRawAss();
if (_currentCategory.Styles.IndexOf(currentCategoryStyle) != _currentCategory.Styles.Count - 1)
{
styles += Environment.NewLine;
}
}
return header;
return string.Format(AdvancedSubStationAlpha.HeaderNoStyles, string.Empty, styles);
}
private void listViewStyles_SelectedIndexChanged(object sender, EventArgs e)
@ -1250,11 +1262,11 @@ namespace Nikse.SubtitleEdit.Forms.Styles
textBoxStyleName.BackColor = ActiveListView.BackColor;
ActiveListView.SelectedItems[0].Text = textBoxStyleName.Text.RemoveChar(',').Trim();
var idx = ActiveListView.SelectedItems[0].Index;
_storageStyles[idx].Name = textBoxStyleName.Text.RemoveChar(',').Trim();
_currentCategory.Styles[idx].Name = textBoxStyleName.Text.RemoveChar(',').Trim();
for (int i = 0; i < _storageStyles.Count; i++)
for (int i = 0; i < _currentCategory.Styles.Count; i++)
{
var storageName = _storageStyles[i].Name;
var storageName = _currentCategory.Styles[i].Name;
if (idx != i && storageName == textBoxStyleName.Text.RemoveChar(',').Trim())
{
textBoxStyleName.BackColor = Configuration.Settings.Tools.ListViewSyntaxErrorColor;
@ -1357,7 +1369,7 @@ namespace Nikse.SubtitleEdit.Forms.Styles
ass.LoadSubtitle(sub, lines, string.Empty);
_header = _header.Remove(_header.IndexOf("[V4+ Styles]", StringComparison.Ordinal)) + sub.Header.Substring(sub.Header.IndexOf("[V4+ Styles]", StringComparison.Ordinal));
}
InitializeListView();
InitializeStylesListView();
}
private void comboBoxFontName_TextChanged(object sender, EventArgs e)
@ -1708,7 +1720,7 @@ namespace Nikse.SubtitleEdit.Forms.Styles
count++;
}
style.RawLine = style.RawLine.Replace(" " + style.Name + ",", " " + style.Name + count + ",");
style.Name = style.Name + count;
style.Name += count;
}
_doUpdate = false;
@ -1800,8 +1812,8 @@ namespace Nikse.SubtitleEdit.Forms.Styles
return;
}
var idx = _storageStyles.IndexOf(_storageStyles.First(p => p.Name == styleName));
_storageStyles[idx] = style;
var idx = _currentCategory.Styles.IndexOf(_currentCategory.Styles.First(p => p.Name == styleName));
_currentCategory.Styles[idx] = style;
listViewStorage.Items.RemoveAt(idx);
AddStyle(listViewStorage, style, Subtitle, _isSubStationAlpha, idx);
listViewStorage.Items[idx].Selected = true;
@ -1810,7 +1822,7 @@ namespace Nikse.SubtitleEdit.Forms.Styles
return;
}
_storageStyles.Add(style);
_currentCategory.Styles.Add(style);
AddStyle(listViewStorage, style, Subtitle, _isSubStationAlpha);
listViewStorage.Items[listViewStorage.Items.Count - 1].Selected = true;
listViewStorage.Items[listViewStorage.Items.Count - 1].EnsureVisible();
@ -1827,15 +1839,16 @@ namespace Nikse.SubtitleEdit.Forms.Styles
_startName = styleName;
_editedName = null;
_oldSsaName = styleName;
SsaStyle style = _storageStyles.First(p => p.Name == styleName);
SsaStyle style = _currentCategory.Styles.First(p => p.Name == styleName);
SetControlsFromStyle(style);
_doUpdate = true;
groupBoxProperties.Enabled = true;
GeneratePreview();
buttonRemove.Enabled = listViewStorage.Items.Count > 1;
buttonStorageRemove.Enabled = listViewStorage.Items.Count > 1 || !_currentCategory.IsDefault;
}
else
{
buttonStorageRemove.Enabled = false;
groupBoxProperties.Enabled = false;
_doUpdate = false;
}
@ -1843,15 +1856,15 @@ namespace Nikse.SubtitleEdit.Forms.Styles
private void buttonStorageRemoveAll_Click(object sender, EventArgs e)
{
if (_storageStyles.Count == 0)
if (_currentCategory.Styles.Count == 0)
{
return;
}
string askText;
if (_storageStyles.Count > 1)
if (_currentCategory.Styles.Count > 1)
{
askText = string.Format(LanguageSettings.Current.Main.DeleteXLinesPrompt, _storageStyles.Count);
askText = string.Format(LanguageSettings.Current.Main.DeleteXLinesPrompt, _currentCategory.Styles.Count);
}
else
{
@ -1863,8 +1876,12 @@ namespace Nikse.SubtitleEdit.Forms.Styles
return;
}
_storageStyles.Clear();
listViewStorage.Items.Clear();
_currentCategory.Styles.Clear();
var defaultStyle = new SsaStyle();
AddStyle(listViewStorage, defaultStyle, Subtitle, _isSubStationAlpha);
_currentCategory.Styles.Add(defaultStyle);
}
private void buttonStorageRemove_Click(object sender, EventArgs e)
@ -1892,7 +1909,7 @@ namespace Nikse.SubtitleEdit.Forms.Styles
if (listViewStorage.SelectedItems.Count == 1)
{
int index = listViewStorage.SelectedItems[0].Index;
_storageStyles.RemoveAt(index);
_currentCategory.Styles.RemoveAt(index);
listViewStorage.Items.RemoveAt(index);
if (listViewStorage.Items.Count == 0)
@ -1913,14 +1930,14 @@ namespace Nikse.SubtitleEdit.Forms.Styles
private void buttonStorageAdd_Click(object sender, EventArgs e)
{
var name = LanguageSettings.Current.SubStationAlphaStyles.New;
if (_storageStyles.Any(p => p.Name == name))
if (_currentCategory.Styles.Any(p => p.Name == name))
{
int count = 2;
bool doRepeat = true;
while (doRepeat)
{
name = LanguageSettings.Current.SubStationAlphaStyles.New + count;
doRepeat = _storageStyles.Any(p => p.Name == name);
doRepeat = _currentCategory.Styles.Any(p => p.Name == name);
count++;
}
}
@ -1928,7 +1945,7 @@ namespace Nikse.SubtitleEdit.Forms.Styles
_doUpdate = false;
var style = new SsaStyle { Name = name };
AddStyle(listViewStorage, style, Subtitle, _isSubStationAlpha);
_storageStyles.Add(style);
_currentCategory.Styles.Add(style);
listViewStorage.Items[listViewStorage.Items.Count - 1].Selected = true;
listViewStorage.Items[listViewStorage.Items.Count - 1].EnsureVisible();
listViewStorage.Items[listViewStorage.Items.Count - 1].Focused = true;
@ -1947,23 +1964,23 @@ namespace Nikse.SubtitleEdit.Forms.Styles
}
var index = listViewStorage.SelectedItems[0].Index;
SsaStyle oldStyle = _storageStyles[index];
SsaStyle oldStyle = _currentCategory.Styles[index];
var style = new SsaStyle(oldStyle) { Name = string.Format(LanguageSettings.Current.SubStationAlphaStyles.CopyOfY, oldStyle.Name) }; // Copy contructor
var styleName = style.Name;
if (_storageStyles.Any(p => p.Name == styleName))
if (_currentCategory.Styles.Any(p => p.Name == styleName))
{
int count = 2;
bool doRepeat = true;
while (doRepeat)
{
style.Name = string.Format(LanguageSettings.Current.SubStationAlphaStyles.CopyXOfY, count, styleName);
doRepeat = _storageStyles.Any(p => p.Name == styleName);
doRepeat = _currentCategory.Styles.Any(p => p.Name == styleName);
count++;
}
}
_doUpdate = false;
_storageStyles.Add(style);
_currentCategory.Styles.Add(style);
AddStyle(listViewStorage, style, Subtitle, _isSubStationAlpha);
listViewStorage.Items[listViewStorage.Items.Count - 1].Selected = true;
listViewStorage.Items[listViewStorage.Items.Count - 1].EnsureVisible();
@ -2020,11 +2037,11 @@ namespace Nikse.SubtitleEdit.Forms.Styles
count++;
}
style.RawLine = style.RawLine.Replace(" " + style.Name + ",", " " + style.Name + count + ",");
style.Name = style.Name + count;
style.Name += count;
}
_doUpdate = false;
_storageStyles.Add(style);
_currentCategory.Styles.Add(style);
AddStyle(listViewStorage, style, Subtitle, _isSubStationAlpha);
listViewStorage.Items[listViewStorage.Items.Count - 1].Selected = true;
listViewStorage.Items[listViewStorage.Items.Count - 1].EnsureVisible();
@ -2108,6 +2125,46 @@ namespace Nikse.SubtitleEdit.Forms.Styles
}
}
private void buttonStorageCategoryDelete_Click(object sender, EventArgs e)
{
_storageCategories.Remove(_currentCategory);
comboboxStorageCategories.Items.Remove(_currentCategory.Name);
_currentCategory = _storageCategories.Single(x => x.IsDefault);
comboboxStorageCategories.SelectedItem = _currentCategory.Name;
}
private void buttonStorageCategoryNew_Click(object sender, EventArgs e)
{
using (var form = new TextPrompt(LanguageSettings.Current.SubStationAlphaStyles.NewCategory, LanguageSettings.Current.SubStationAlphaStyles.CategoryName, string.Empty))
{
if (form.ShowDialog() == DialogResult.OK && !_storageCategories.Exists(x => x.Name == form.InputText))
{
var newCategory = new AssaStorageCategory { Name = form.InputText, IsDefault = false, Styles = new List<SsaStyle>()};
_storageCategories.Add(newCategory);
comboboxStorageCategories.Items.Add(newCategory.Name);
comboboxStorageCategories.SelectedItem = newCategory.Name;
_currentCategory = newCategory;
}
}
}
private void comboboxStorageCategory_SelectedIndexChanged(object sender, EventArgs e)
{
listViewStorage.BeginUpdate();
listViewStorage.Items.Clear();
var focusCategory = _storageCategories.FirstOrDefault(x => x.Name == comboboxStorageCategories.SelectedItem.ToString());
foreach (var style in focusCategory.Styles)
{
if (!string.IsNullOrEmpty(style.Name))
{
AddStyle(listViewStorage, style, Subtitle, _isSubStationAlpha);
}
}
listViewStorage.EndUpdate();
_currentCategory = focusCategory;
buttonStorageCategoryDelete.Enabled = !focusCategory.IsDefault;
}
private bool StyleExistsInListView(string styleName, ListView listView)
{
foreach (ListViewItem item in listView.Items)
@ -2140,7 +2197,7 @@ namespace Nikse.SubtitleEdit.Forms.Styles
}
string styleName = listViewStorage.SelectedItems[0].Text;
SsaStyle oldStyle = _storageStyles.FirstOrDefault(p => p.Name == styleName);
SsaStyle oldStyle = _currentCategory.Styles.FirstOrDefault(p => p.Name == styleName);
var style = new SsaStyle(oldStyle);
if (StyleExistsInListView(styleName, listViewStyles))
@ -2196,9 +2253,9 @@ namespace Nikse.SubtitleEdit.Forms.Styles
listView.Items.RemoveAt(idx);
if (listView == listViewStorage)
{
var style = _storageStyles[idx];
_storageStyles.RemoveAt(idx);
_storageStyles.Insert(idx - 1, style);
var style = _currentCategory.Styles[idx];
_currentCategory.Styles.RemoveAt(idx);
_currentCategory.Styles.Insert(idx - 1, style);
}
idx--;
@ -2225,9 +2282,9 @@ namespace Nikse.SubtitleEdit.Forms.Styles
listView.Items.RemoveAt(idx);
if (listView == listViewStorage)
{
var style = _storageStyles[idx];
_storageStyles.RemoveAt(idx);
_storageStyles.Insert(idx + 1, style);
var style = _currentCategory.Styles[idx];
_currentCategory.Styles.RemoveAt(idx);
_currentCategory.Styles.Insert(idx + 1, style);
}
idx++;
@ -2254,9 +2311,9 @@ namespace Nikse.SubtitleEdit.Forms.Styles
listView.Items.RemoveAt(idx);
if (listView == listViewStorage)
{
var style = _storageStyles[idx];
_storageStyles.RemoveAt(idx);
_storageStyles.Insert(0, style);
var style = _currentCategory.Styles[idx];
_currentCategory.Styles.RemoveAt(idx);
_currentCategory.Styles.Insert(0, style);
}
idx = 0;
@ -2283,9 +2340,9 @@ namespace Nikse.SubtitleEdit.Forms.Styles
listView.Items.RemoveAt(idx);
if (listView == listViewStorage)
{
var style = _storageStyles[idx];
_storageStyles.RemoveAt(idx);
_storageStyles.Add(style);
var style = _currentCategory.Styles[idx];
_currentCategory.Styles.RemoveAt(idx);
_currentCategory.Styles.Add(style);
}
listView.Items.Add(item);

View File

@ -161,7 +161,7 @@ namespace Nikse.SubtitleEdit.Forms.Styles
toLower = toLower.Replace(" :", ":");
}
if (toLower.StartsWith("style:" + styleName.ToLowerInvariant().Trim(), StringComparison.Ordinal))
if (toLower.StartsWith("style:" + styleName.ToLowerInvariant().Trim() + ",", StringComparison.Ordinal))
{
sb.AppendLine(line);
}
@ -176,7 +176,12 @@ namespace Nikse.SubtitleEdit.Forms.Styles
if (content.TrimEnd().EndsWith("[Events]", StringComparison.Ordinal))
{
content = content.Trim() + Environment.NewLine +
"Format: Layer, Start, End, Style, Actor, MarginL, MarginR, MarginV, Effect, Text" + Environment.NewLine +
"Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text" + Environment.NewLine +
"Dialogue: 0,0:00:31.91,0:00:33.91,Default,,0,0,0,,My Styles :)";
}
else if (content.TrimEnd().EndsWith("Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text", StringComparison.Ordinal))
{
content = content.Trim() + Environment.NewLine +
"Dialogue: 0,0:00:31.91,0:00:33.91,Default,,0,0,0,,My Styles :)";
}
else if (!content.Contains("[Events]", StringComparison.OrdinalIgnoreCase))
@ -184,7 +189,7 @@ namespace Nikse.SubtitleEdit.Forms.Styles
content = content.Trim() + Environment.NewLine +
Environment.NewLine +
"[Events]" + Environment.NewLine +
"Format: Layer, Start, End, Style, Actor, MarginL, MarginR, MarginV, Effect, Text" + Environment.NewLine +
"Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text" + Environment.NewLine +
"Dialogue: 0,0:00:31.91,0:00:33.91,Default,,0,0,0,,My Styles :)";
}
File.WriteAllText(saveFileDialogStyle.FileName, content, Encoding.UTF8);

View File

@ -2923,7 +2923,11 @@ can edit in same subtitle file (collaboration)",
AddToFile = "Add to file",
AddToStorage = "Add to storage",
StyleStorage = "Style storage",
OverwriteX = "Overwrite {0}?"
OverwriteX = "Overwrite {0}?",
Category = "Category",
NewCategory = "New category",
CategoryName = "Category name",
CategoryNote = "Note: \"Default\" styles will be applied to new ASSA files"
};
PointSync = new LanguageStructure.PointSync

View File

@ -7084,6 +7084,18 @@ namespace Nikse.SubtitleEdit.Logic
case "SubStationAlphaStyles/OverwriteX":
language.SubStationAlphaStyles.OverwriteX = reader.Value;
break;
case "SubStationAlphaStyles/Category":
language.SubStationAlphaStyles.Category = reader.Value;
break;
case "SubStationAlphaStyles/NewCategory":
language.SubStationAlphaStyles.NewCategory = reader.Value;
break;
case "SubStationAlphaStyles/CategoryName":
language.SubStationAlphaStyles.CategoryName = reader.Value;
break;
case "SubStationAlphaStyles/CategoryNote":
language.SubStationAlphaStyles.CategoryNote = reader.Value;
break;
case "PointSync/Title":
language.PointSync.Title = reader.Value;
break;

View File

@ -2781,6 +2781,10 @@
public string AddToStorage { get; set; }
public string StyleStorage { get; set; }
public string OverwriteX { get; set; }
public string Category { get; set; }
public string NewCategory { get; set; }
public string CategoryName { get; set; }
public string CategoryNote { get; set; }
}
public class PointSync