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> <AddToStorage>Add to storage</AddToStorage>
<StyleStorage>Style storage</StyleStorage> <StyleStorage>Style storage</StyleStorage>
<OverwriteX>Overwrite {0}?</OverwriteX> <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> </SubStationAlphaStyles>
<PointSync> <PointSync>
<Title>Point synchronization</Title> <Title>Point synchronization</Title>

View File

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

View File

@ -492,17 +492,7 @@ namespace Nikse.SubtitleEdit.Core.Common
public class SubtitleSettings public class SubtitleSettings
{ {
public string SsaFontName { get; set; } public List<AssaStorageCategory> AssaStyleStorageCategories { 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 string DCinemaFontFile { get; set; } public string DCinemaFontFile { get; set; }
public string DCinemaLoadFontResource { get; set; } public string DCinemaLoadFontResource { get; set; }
@ -573,19 +563,7 @@ namespace Nikse.SubtitleEdit.Core.Common
public SubtitleSettings() public SubtitleSettings()
{ {
SsaFontName = "Arial"; AssaStyleStorageCategories = new List<AssaStorageCategory>();
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;
DCinemaFontFile = "Arial.ttf"; DCinemaFontFile = "Arial.ttf";
DCinemaLoadFontResource = "urn:uuid:3dec6dc0-39d0-498d-97d0-928d2eb78391"; DCinemaLoadFontResource = "urn:uuid:3dec6dc0-39d0-498d-97d0-928d2eb78391";
@ -1774,6 +1752,13 @@ $HorzAlign = Center
public List<MultipleSearchAndReplaceSetting> Rules { get; set; } 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 class NetworkSettings
{ {
public string UserName { get; set; } public string UserName { get; set; }
@ -2298,7 +2283,7 @@ $HorzAlign = Center
public void Save() public void Save()
{ {
//this is too slow: Serialize(Configuration.SettingsFileName, this); // this is too slow: Serialize(Configuration.SettingsFileName, this);
CustomSerialize(Configuration.SettingsFileName, this); CustomSerialize(Configuration.SettingsFileName, this);
} }
@ -4951,70 +4936,115 @@ $HorzAlign = Center
node = doc.DocumentElement.SelectSingleNode("SubtitleSettings"); node = doc.DocumentElement.SelectSingleNode("SubtitleSettings");
if (node != null) if (node != null)
{ {
subNode = node.SelectSingleNode("SsaFontName"); foreach (XmlNode categoryNode in node.SelectNodes("AssaStyleStorageCategories/Category"))
if (subNode != null)
{ {
settings.SubtitleSettings.SsaFontName = subNode.InnerText; var category = new AssaStorageCategory
} {
Styles = new List<SsaStyle>()
};
subNode = categoryNode.SelectSingleNode("Name");
if (subNode != null)
{
category.Name = subNode.InnerText;
}
subNode = node.SelectSingleNode("SsaFontSize"); subNode = categoryNode.SelectSingleNode("IsDefault");
if (subNode != null) 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);
if (subNode != null)
{
settings.SubtitleSettings.SsaFontColorArgb = Convert.ToInt32(subNode.InnerText, CultureInfo.InvariantCulture);
}
subNode = node.SelectSingleNode("SsaFontBold"); foreach (XmlNode listNode in categoryNode.SelectNodes("Style"))
if (subNode != null) {
{ var item = new SsaStyle();
settings.SubtitleSettings.SsaFontBold = Convert.ToBoolean(subNode.InnerText, CultureInfo.InvariantCulture); subNode = listNode.SelectSingleNode("Name");
} if (subNode != null)
{
item.Name = subNode.InnerText;
}
subNode = node.SelectSingleNode("SsaOutline"); subNode = listNode.SelectSingleNode("FontName");
if (subNode != null) if (subNode != null)
{ {
settings.SubtitleSettings.SsaOutline = Convert.ToDecimal(subNode.InnerText); item.FontName = subNode.InnerText;
} }
subNode = node.SelectSingleNode("SsaShadow"); subNode = listNode.SelectSingleNode("FontSize");
if (subNode != null) if (subNode != null)
{ {
settings.SubtitleSettings.SsaShadow = Convert.ToDecimal(subNode.InnerText); item.FontSize = Convert.ToSingle(subNode.InnerText);
} }
subNode = node.SelectSingleNode("SsaOpaqueBox"); subNode = listNode.SelectSingleNode("Primary");
if (subNode != null) if (subNode != null)
{ {
settings.SubtitleSettings.SsaOpaqueBox = Convert.ToBoolean(subNode.InnerText, CultureInfo.InvariantCulture); item.Primary = Color.FromArgb(int.Parse(subNode.InnerText, CultureInfo.InvariantCulture));
} }
subNode = node.SelectSingleNode("SsaMarginLeft"); subNode = listNode.SelectSingleNode("Secondary");
if (subNode != null) if (subNode != null)
{ {
settings.SubtitleSettings.SsaMarginLeft = Convert.ToInt32(subNode.InnerText, CultureInfo.InvariantCulture); item.Secondary = Color.FromArgb(int.Parse(subNode.InnerText, CultureInfo.InvariantCulture));
} }
subNode = node.SelectSingleNode("SsaMarginRight"); subNode = listNode.SelectSingleNode("Outline");
if (subNode != null) if (subNode != null)
{ {
settings.SubtitleSettings.SsaMarginRight = Convert.ToInt32(subNode.InnerText, CultureInfo.InvariantCulture); item.Outline = Color.FromArgb(int.Parse(subNode.InnerText, CultureInfo.InvariantCulture));
} }
subNode = node.SelectSingleNode("SsaMarginTopBottom"); subNode = listNode.SelectSingleNode("Background");
if (subNode != null) if (subNode != null)
{ {
settings.SubtitleSettings.SsaMarginTopBottom = Convert.ToInt32(subNode.InnerText, CultureInfo.InvariantCulture); item.Background = Color.FromArgb(int.Parse(subNode.InnerText, CultureInfo.InvariantCulture));
} }
subNode = node.SelectSingleNode("AssaStyleStorage"); subNode = listNode.SelectSingleNode("ShadowWidth");
if (subNode != null) if (subNode != null)
{ {
settings.SubtitleSettings.AssaStyleStorage = subNode.InnerText; item.ShadowWidth = Convert.ToDecimal(subNode.InnerText);
}
subNode = listNode.SelectSingleNode("OutlineWidth");
if (subNode != null)
{
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"); subNode = node.SelectSingleNode("DCinemaFontFile");
@ -8346,17 +8376,38 @@ $HorzAlign = Center
textWriter.WriteEndElement(); textWriter.WriteEndElement();
textWriter.WriteStartElement("SubtitleSettings", string.Empty); textWriter.WriteStartElement("SubtitleSettings", string.Empty);
textWriter.WriteElementString("SsaFontName", settings.SubtitleSettings.SsaFontName); textWriter.WriteStartElement("AssaStyleStorageCategories", string.Empty);
textWriter.WriteElementString("SsaFontSize", settings.SubtitleSettings.SsaFontSize.ToString(CultureInfo.InvariantCulture)); foreach (var category in settings.SubtitleSettings.AssaStyleStorageCategories)
textWriter.WriteElementString("SsaFontColorArgb", settings.SubtitleSettings.SsaFontColorArgb.ToString(CultureInfo.InvariantCulture)); {
textWriter.WriteElementString("SsaFontBold", settings.SubtitleSettings.SsaFontBold.ToString(CultureInfo.InvariantCulture)); if (!string.IsNullOrEmpty(category?.Name))
textWriter.WriteElementString("SsaOutline", settings.SubtitleSettings.SsaOutline.ToString(CultureInfo.InvariantCulture)); {
textWriter.WriteElementString("SsaShadow", settings.SubtitleSettings.SsaShadow.ToString(CultureInfo.InvariantCulture)); textWriter.WriteStartElement("Category", string.Empty);
textWriter.WriteElementString("SsaOpaqueBox", settings.SubtitleSettings.SsaOpaqueBox.ToString(CultureInfo.InvariantCulture)); textWriter.WriteElementString("Name", category.Name);
textWriter.WriteElementString("SsaMarginLeft", settings.SubtitleSettings.SsaMarginLeft.ToString(CultureInfo.InvariantCulture)); textWriter.WriteElementString("IsDefault", category.IsDefault.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("SsaMarginRight", settings.SubtitleSettings.SsaMarginRight.ToString(CultureInfo.InvariantCulture)); foreach (var style in category.Styles)
textWriter.WriteElementString("SsaMarginTopBottom", settings.SubtitleSettings.SsaMarginTopBottom.ToString(CultureInfo.InvariantCulture)); {
textWriter.WriteElementString("AssaStyleStorage", settings.SubtitleSettings.AssaStyleStorage); 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("DCinemaFontFile", settings.SubtitleSettings.DCinemaFontFile);
textWriter.WriteElementString("DCinemaFontSize", settings.SubtitleSettings.DCinemaFontSize.ToString(CultureInfo.InvariantCulture)); textWriter.WriteElementString("DCinemaFontSize", settings.SubtitleSettings.DCinemaFontSize.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("DCinemaBottomMargin", settings.SubtitleSettings.DCinemaBottomMargin.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() public SsaStyle()
{ {
FontName = Configuration.Settings.SubtitleSettings.SsaFontName; Name = "Default";
FontSize = (float)Configuration.Settings.SubtitleSettings.SsaFontSize; FontName = "Arial";
Primary = Color.FromArgb(Configuration.Settings.SubtitleSettings.SsaFontColorArgb); FontSize = 20F;
Primary = Color.White;
Secondary = Color.Yellow; Secondary = Color.Yellow;
Outline = Color.Black; Outline = Color.Black;
Background = Color.Black; Background = Color.Black;
Alignment = "2"; Alignment = "2";
OutlineWidth = Configuration.Settings.SubtitleSettings.SsaOutline; OutlineWidth = 1M;
ShadowWidth = Configuration.Settings.SubtitleSettings.SsaShadow; ShadowWidth = 1M;
MarginLeft = 10; MarginLeft = 10;
MarginRight = 10; MarginRight = 10;
MarginVertical = 10; MarginVertical = 10;
BorderStyle = "1"; BorderStyle = "1";
if (Configuration.Settings.SubtitleSettings.SsaOpaqueBox)
{
BorderStyle = "3";
}
RawLine = string.Empty; RawLine = string.Empty;
LoadedFromHeader = false; LoadedFromHeader = false;
} }
@ -117,10 +113,6 @@ namespace Nikse.SubtitleEdit.Core.Common
{ {
sb.Append(ColorTranslator.ToWin32(Tertiary)); sb.Append(ColorTranslator.ToWin32(Tertiary));
} }
else if (f == "outlinecolour")
{
sb.Append(ColorTranslator.ToWin32(Outline));
}
else if (f == "backcolour") else if (f == "backcolour")
{ {
sb.Append(ColorTranslator.ToWin32(Background)); sb.Append(ColorTranslator.ToWin32(Background));
@ -192,7 +184,7 @@ namespace Nikse.SubtitleEdit.Core.Common
return s.Substring(0, s.Length - 1); return s.Substring(0, s.Length - 1);
} }
public string ToRawAss(string styleFormat) public string ToRawAss(string styleFormat = DefaultAssStyleFormat)
{ {
var sb = new StringBuilder(); var sb = new StringBuilder();
sb.Append("Style: "); sb.Append("Style: ");
@ -220,10 +212,6 @@ namespace Nikse.SubtitleEdit.Core.Common
{ {
sb.Append(AdvancedSubStationAlpha.GetSsaColorString(Secondary)); sb.Append(AdvancedSubStationAlpha.GetSsaColorString(Secondary));
} }
else if (f == "tertiarycolour")
{
sb.Append(AdvancedSubStationAlpha.GetSsaColorString(Tertiary));
}
else if (f == "outlinecolour") else if (f == "outlinecolour")
{ {
sb.Append(AdvancedSubStationAlpha.GetSsaColorString(Outline)); sb.Append(AdvancedSubStationAlpha.GetSsaColorString(Outline));

View File

@ -17,24 +17,25 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
{ {
get get
{ {
var borderStyle = "1"; // 1=normal, 3=opaque box string defaultStyle = string.Empty;
if (Configuration.Settings.SubtitleSettings.SsaOpaqueBox) 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 return defaultStyle;
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";
} }
} }
@ -698,6 +699,7 @@ Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text"
} }
} }
} }
return list; return list;
} }
@ -2184,7 +2186,7 @@ Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text"
var format = line.Substring(6).Split(','); var format = line.Substring(6).Split(',');
for (int i = 0; i < format.Length; i++) for (int i = 0; i < format.Length; i++)
{ {
string f = format[i].Trim().ToLowerInvariant(); string f = format[i].Trim();
if (i == nameIndex) if (i == nameIndex)
{ {
style.Name = format[i].Trim(); 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 }; return new SsaStyle { Name = styleName };
} }
} }

View File

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

View File

@ -7860,6 +7860,10 @@ namespace Nikse.SubtitleEdit.Forms
actors = new List<string>(); actors = new List<string>();
toolStripMenuItemWebVTT.Visible = false; toolStripMenuItemWebVTT.Visible = false;
var styles = AdvancedSubStationAlpha.GetStylesFromHeader(_subtitle.Header); var styles = AdvancedSubStationAlpha.GetStylesFromHeader(_subtitle.Header);
if (styles.Count == 0)
{
styles = AdvancedSubStationAlpha.GetStylesFromHeader(AdvancedSubStationAlpha.DefaultHeader);
}
setStylesForSelectedLinesToolStripMenuItem.DropDownItems.Clear(); setStylesForSelectedLinesToolStripMenuItem.DropDownItems.Clear();
foreach (var style in styles) 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 sealed partial class SubStationAlphaStyles
{ {
@ -129,6 +131,11 @@
this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader5 = ((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.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.contextMenuStripStorage = new System.Windows.Forms.ContextMenuStrip(this.components);
this.toolStripMenuItemStorageRemove = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItemStorageRemove = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemStorageRemoveAll = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItemStorageRemoveAll = new System.Windows.Forms.ToolStripMenuItem();
@ -173,8 +180,8 @@
// //
// listViewStyles // listViewStyles
// //
this.listViewStyles.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) this.listViewStyles.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.listViewStyles.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.listViewStyles.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeaderName, this.columnHeaderName,
@ -484,8 +491,8 @@
// //
// groupBoxProperties // groupBoxProperties
// //
this.groupBoxProperties.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) this.groupBoxProperties.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.groupBoxProperties.Controls.Add(this.groupBoxBorder); this.groupBoxProperties.Controls.Add(this.groupBoxBorder);
this.groupBoxProperties.Controls.Add(this.textBoxStyleName); this.groupBoxProperties.Controls.Add(this.textBoxStyleName);
@ -504,7 +511,7 @@
// //
// groupBoxBorder // groupBoxBorder
// //
this.groupBoxBorder.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) this.groupBoxBorder.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.groupBoxBorder.Controls.Add(this.radioButtonOpaqueBox); this.groupBoxBorder.Controls.Add(this.radioButtonOpaqueBox);
this.groupBoxBorder.Controls.Add(this.radioButtonOutline); this.groupBoxBorder.Controls.Add(this.radioButtonOutline);
@ -677,7 +684,7 @@
// //
// groupBoxColors // groupBoxColors
// //
this.groupBoxColors.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) this.groupBoxColors.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.groupBoxColors.Controls.Add(this.panelBackColor); this.groupBoxColors.Controls.Add(this.panelBackColor);
this.groupBoxColors.Controls.Add(this.buttonBackColor); this.groupBoxColors.Controls.Add(this.buttonBackColor);
@ -882,8 +889,8 @@
// //
// groupBoxPreview // groupBoxPreview
// //
this.groupBoxPreview.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) this.groupBoxPreview.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.groupBoxPreview.Controls.Add(this.pictureBoxPreview); this.groupBoxPreview.Controls.Add(this.pictureBoxPreview);
this.groupBoxPreview.Location = new System.Drawing.Point(7, 310); this.groupBoxPreview.Location = new System.Drawing.Point(7, 310);
@ -920,7 +927,7 @@
// //
// groupBoxFont // groupBoxFont
// //
this.groupBoxFont.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) this.groupBoxFont.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.groupBoxFont.Controls.Add(this.checkBoxFontUnderline); this.groupBoxFont.Controls.Add(this.checkBoxFontUnderline);
this.groupBoxFont.Controls.Add(this.numericUpDownFontSize); this.groupBoxFont.Controls.Add(this.numericUpDownFontSize);
@ -1042,6 +1049,11 @@
this.groupBoxStorage.Controls.Add(this.buttonStorageAdd); this.groupBoxStorage.Controls.Add(this.buttonStorageAdd);
this.groupBoxStorage.Controls.Add(this.buttonStorageRemove); this.groupBoxStorage.Controls.Add(this.buttonStorageRemove);
this.groupBoxStorage.Controls.Add(this.listViewStorage); 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.Dock = System.Windows.Forms.DockStyle.Fill;
this.groupBoxStorage.Location = new System.Drawing.Point(0, 0); this.groupBoxStorage.Location = new System.Drawing.Point(0, 0);
this.groupBoxStorage.Name = "groupBoxStorage"; this.groupBoxStorage.Name = "groupBoxStorage";
@ -1057,7 +1069,7 @@
this.buttonAddToFile.Location = new System.Drawing.Point(280, 222); this.buttonAddToFile.Location = new System.Drawing.Point(280, 222);
this.buttonAddToFile.Name = "buttonAddToFile"; this.buttonAddToFile.Name = "buttonAddToFile";
this.buttonAddToFile.Size = new System.Drawing.Size(163, 52); 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.Text = "Add to file";
this.buttonAddToFile.UseVisualStyleBackColor = true; this.buttonAddToFile.UseVisualStyleBackColor = true;
this.buttonAddToFile.Click += new System.EventHandler(this.buttonAddToFile_Click); this.buttonAddToFile.Click += new System.EventHandler(this.buttonAddToFile_Click);
@ -1069,7 +1081,7 @@
this.buttonStorageExport.Location = new System.Drawing.Point(6, 251); this.buttonStorageExport.Location = new System.Drawing.Point(6, 251);
this.buttonStorageExport.Name = "buttonStorageExport"; this.buttonStorageExport.Name = "buttonStorageExport";
this.buttonStorageExport.Size = new System.Drawing.Size(82, 23); this.buttonStorageExport.Size = new System.Drawing.Size(82, 23);
this.buttonStorageExport.TabIndex = 140; this.buttonStorageExport.TabIndex = 7;
this.buttonStorageExport.Text = "Export..."; this.buttonStorageExport.Text = "Export...";
this.buttonStorageExport.UseVisualStyleBackColor = true; this.buttonStorageExport.UseVisualStyleBackColor = true;
this.buttonStorageExport.Click += new System.EventHandler(this.buttonStorageExport_Click); this.buttonStorageExport.Click += new System.EventHandler(this.buttonStorageExport_Click);
@ -1081,7 +1093,7 @@
this.buttonStorageImport.Location = new System.Drawing.Point(6, 222); this.buttonStorageImport.Location = new System.Drawing.Point(6, 222);
this.buttonStorageImport.Name = "buttonStorageImport"; this.buttonStorageImport.Name = "buttonStorageImport";
this.buttonStorageImport.Size = new System.Drawing.Size(82, 23); this.buttonStorageImport.Size = new System.Drawing.Size(82, 23);
this.buttonStorageImport.TabIndex = 120; this.buttonStorageImport.TabIndex = 6;
this.buttonStorageImport.Text = "Import..."; this.buttonStorageImport.Text = "Import...";
this.buttonStorageImport.UseVisualStyleBackColor = true; this.buttonStorageImport.UseVisualStyleBackColor = true;
this.buttonStorageImport.Click += new System.EventHandler(this.buttonStorageImport_Click); this.buttonStorageImport.Click += new System.EventHandler(this.buttonStorageImport_Click);
@ -1093,7 +1105,7 @@
this.buttonStorageCopy.Location = new System.Drawing.Point(94, 251); this.buttonStorageCopy.Location = new System.Drawing.Point(94, 251);
this.buttonStorageCopy.Name = "buttonStorageCopy"; this.buttonStorageCopy.Name = "buttonStorageCopy";
this.buttonStorageCopy.Size = new System.Drawing.Size(82, 23); this.buttonStorageCopy.Size = new System.Drawing.Size(82, 23);
this.buttonStorageCopy.TabIndex = 150; this.buttonStorageCopy.TabIndex = 9;
this.buttonStorageCopy.Text = "Copy"; this.buttonStorageCopy.Text = "Copy";
this.buttonStorageCopy.UseVisualStyleBackColor = true; this.buttonStorageCopy.UseVisualStyleBackColor = true;
this.buttonStorageCopy.Click += new System.EventHandler(this.buttonStorageCopy_Click); this.buttonStorageCopy.Click += new System.EventHandler(this.buttonStorageCopy_Click);
@ -1105,7 +1117,7 @@
this.buttonStorageRemoveAll.Location = new System.Drawing.Point(182, 251); this.buttonStorageRemoveAll.Location = new System.Drawing.Point(182, 251);
this.buttonStorageRemoveAll.Name = "buttonStorageRemoveAll"; this.buttonStorageRemoveAll.Name = "buttonStorageRemoveAll";
this.buttonStorageRemoveAll.Size = new System.Drawing.Size(92, 23); this.buttonStorageRemoveAll.Size = new System.Drawing.Size(92, 23);
this.buttonStorageRemoveAll.TabIndex = 160; this.buttonStorageRemoveAll.TabIndex = 11;
this.buttonStorageRemoveAll.Text = "Remove all"; this.buttonStorageRemoveAll.Text = "Remove all";
this.buttonStorageRemoveAll.UseVisualStyleBackColor = true; this.buttonStorageRemoveAll.UseVisualStyleBackColor = true;
this.buttonStorageRemoveAll.Click += new System.EventHandler(this.buttonStorageRemoveAll_Click); this.buttonStorageRemoveAll.Click += new System.EventHandler(this.buttonStorageRemoveAll_Click);
@ -1117,7 +1129,7 @@
this.buttonStorageAdd.Location = new System.Drawing.Point(94, 222); this.buttonStorageAdd.Location = new System.Drawing.Point(94, 222);
this.buttonStorageAdd.Name = "buttonStorageAdd"; this.buttonStorageAdd.Name = "buttonStorageAdd";
this.buttonStorageAdd.Size = new System.Drawing.Size(82, 23); this.buttonStorageAdd.Size = new System.Drawing.Size(82, 23);
this.buttonStorageAdd.TabIndex = 125; this.buttonStorageAdd.TabIndex = 8;
this.buttonStorageAdd.Text = "New"; this.buttonStorageAdd.Text = "New";
this.buttonStorageAdd.UseVisualStyleBackColor = true; this.buttonStorageAdd.UseVisualStyleBackColor = true;
this.buttonStorageAdd.Click += new System.EventHandler(this.buttonStorageAdd_Click); this.buttonStorageAdd.Click += new System.EventHandler(this.buttonStorageAdd_Click);
@ -1129,15 +1141,15 @@
this.buttonStorageRemove.Location = new System.Drawing.Point(182, 222); this.buttonStorageRemove.Location = new System.Drawing.Point(182, 222);
this.buttonStorageRemove.Name = "buttonStorageRemove"; this.buttonStorageRemove.Name = "buttonStorageRemove";
this.buttonStorageRemove.Size = new System.Drawing.Size(92, 23); this.buttonStorageRemove.Size = new System.Drawing.Size(92, 23);
this.buttonStorageRemove.TabIndex = 130; this.buttonStorageRemove.TabIndex = 10;
this.buttonStorageRemove.Text = "Remove"; this.buttonStorageRemove.Text = "Remove";
this.buttonStorageRemove.UseVisualStyleBackColor = true; this.buttonStorageRemove.UseVisualStyleBackColor = true;
this.buttonStorageRemove.Click += new System.EventHandler(this.buttonStorageRemove_Click); this.buttonStorageRemove.Click += new System.EventHandler(this.buttonStorageRemove_Click);
// //
// listViewStorage // listViewStorage
// //
this.listViewStorage.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) this.listViewStorage.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.listViewStorage.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.listViewStorage.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1, this.columnHeader1,
@ -1149,11 +1161,11 @@
this.listViewStorage.ContextMenuStrip = this.contextMenuStripStorage; this.listViewStorage.ContextMenuStrip = this.contextMenuStripStorage;
this.listViewStorage.FullRowSelect = true; this.listViewStorage.FullRowSelect = true;
this.listViewStorage.HideSelection = false; 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.MultiSelect = false;
this.listViewStorage.Name = "listViewStorage"; this.listViewStorage.Name = "listViewStorage";
this.listViewStorage.Size = new System.Drawing.Size(545, 197); this.listViewStorage.Size = new System.Drawing.Size(545, 148);
this.listViewStorage.TabIndex = 110; this.listViewStorage.TabIndex = 5;
this.listViewStorage.UseCompatibleStateImageBehavior = false; this.listViewStorage.UseCompatibleStateImageBehavior = false;
this.listViewStorage.View = System.Windows.Forms.View.Details; this.listViewStorage.View = System.Windows.Forms.View.Details;
this.listViewStorage.SelectedIndexChanged += new System.EventHandler(this.listViewStorage_SelectedIndexChanged); this.listViewStorage.SelectedIndexChanged += new System.EventHandler(this.listViewStorage_SelectedIndexChanged);
@ -1190,6 +1202,58 @@
this.columnHeader6.Text = "Outline"; this.columnHeader6.Text = "Outline";
this.columnHeader6.Width = 55; 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 // contextMenuStripStorage
// //
this.contextMenuStripStorage.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.contextMenuStripStorage.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
@ -1321,7 +1385,7 @@
// //
// splitContainer1 // splitContainer1
// //
this.splitContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) this.splitContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left))); | System.Windows.Forms.AnchorStyles.Left)));
this.splitContainer1.Location = new System.Drawing.Point(12, 4); this.splitContainer1.Location = new System.Drawing.Point(12, 4);
this.splitContainer1.Name = "splitContainer1"; this.splitContainer1.Name = "splitContainer1";
@ -1464,6 +1528,11 @@
private System.Windows.Forms.Label labelStatus; private System.Windows.Forms.Label labelStatus;
private System.Windows.Forms.Timer timerClearStatus; private System.Windows.Forms.Timer timerClearStatus;
private System.Windows.Forms.GroupBox groupBoxStorage; 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.ListView listViewStorage;
private System.Windows.Forms.ColumnHeader columnHeader1; private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2; private System.Windows.Forms.ColumnHeader columnHeader2;

View File

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

View File

@ -43,8 +43,8 @@
// //
// listViewExportStyles // listViewExportStyles
// //
this.listViewExportStyles.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) this.listViewExportStyles.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.listViewExportStyles.CheckBoxes = true; this.listViewExportStyles.CheckBoxes = true;
this.listViewExportStyles.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.listViewExportStyles.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {

View File

@ -161,7 +161,7 @@ namespace Nikse.SubtitleEdit.Forms.Styles
toLower = toLower.Replace(" :", ":"); toLower = toLower.Replace(" :", ":");
} }
if (toLower.StartsWith("style:" + styleName.ToLowerInvariant().Trim(), StringComparison.Ordinal)) if (toLower.StartsWith("style:" + styleName.ToLowerInvariant().Trim() + ",", StringComparison.Ordinal))
{ {
sb.AppendLine(line); sb.AppendLine(line);
} }
@ -176,15 +176,20 @@ namespace Nikse.SubtitleEdit.Forms.Styles
if (content.TrimEnd().EndsWith("[Events]", StringComparison.Ordinal)) if (content.TrimEnd().EndsWith("[Events]", StringComparison.Ordinal))
{ {
content = content.Trim() + Environment.NewLine + 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 :)"; "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)) else if (!content.Contains("[Events]", StringComparison.OrdinalIgnoreCase))
{ {
content = content.Trim() + Environment.NewLine + content = content.Trim() + Environment.NewLine +
Environment.NewLine + Environment.NewLine +
"[Events]" + 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 :)"; "Dialogue: 0,0:00:31.91,0:00:33.91,Default,,0,0,0,,My Styles :)";
} }
File.WriteAllText(saveFileDialogStyle.FileName, content, Encoding.UTF8); File.WriteAllText(saveFileDialogStyle.FileName, content, Encoding.UTF8);

View File

@ -2923,7 +2923,11 @@ can edit in same subtitle file (collaboration)",
AddToFile = "Add to file", AddToFile = "Add to file",
AddToStorage = "Add to storage", AddToStorage = "Add to storage",
StyleStorage = "Style 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 PointSync = new LanguageStructure.PointSync

View File

@ -7084,6 +7084,18 @@ namespace Nikse.SubtitleEdit.Logic
case "SubStationAlphaStyles/OverwriteX": case "SubStationAlphaStyles/OverwriteX":
language.SubStationAlphaStyles.OverwriteX = reader.Value; language.SubStationAlphaStyles.OverwriteX = reader.Value;
break; 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": case "PointSync/Title":
language.PointSync.Title = reader.Value; language.PointSync.Title = reader.Value;
break; break;

View File

@ -2781,6 +2781,10 @@
public string AddToStorage { get; set; } public string AddToStorage { get; set; }
public string StyleStorage { get; set; } public string StyleStorage { get; set; }
public string OverwriteX { 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 public class PointSync