Merge pull request #904 from ivandrofly/patch-4

Use copy constructor instead re-calling GetSsaStyle()
This commit is contained in:
Nikolaj Olsson 2015-06-21 20:16:12 +02:00
commit f66a785ee0
2 changed files with 32 additions and 3 deletions

View File

@ -625,7 +625,7 @@ namespace Nikse.SubtitleEdit.Forms.Styles
{
string styleName = listViewStyles.SelectedItems[0].Text;
SsaStyle oldStyle = GetSsaStyle(styleName);
SsaStyle style = GetSsaStyle(styleName);
SsaStyle style = new SsaStyle(oldStyle); // Copy contructor
style.Name = string.Format(Configuration.Settings.Language.SubStationAlphaStyles.CopyOfY, styleName);
if (GetSsaStyle(style.Name).LoadedFromHeader)
@ -1295,4 +1295,4 @@ namespace Nikse.SubtitleEdit.Forms.Styles
}
}
}
}

View File

@ -49,6 +49,35 @@ namespace Nikse.SubtitleEdit.Logic
LoadedFromHeader = false;
}
public SsaStyle(SsaStyle ssaStyle)
{
Name = ssaStyle.Name;
FontName = ssaStyle.FontName;
FontSize = ssaStyle.FontSize;
Italic = ssaStyle.Italic;
Bold = ssaStyle.Bold;
Underline = ssaStyle.Underline;
Primary = ssaStyle.Primary;
Secondary = ssaStyle.Secondary;
Tertiary = ssaStyle.Tertiary;
Outline = ssaStyle.Outline;
Background = ssaStyle.Background;
ShadowWidth = ssaStyle.ShadowWidth;
OutlineWidth = ssaStyle.OutlineWidth;
Alignment = ssaStyle.Alignment;
MarginLeft = ssaStyle.MarginLeft;
MarginRight = ssaStyle.MarginRight;
MarginVertical = ssaStyle.MarginVertical;
BorderStyle = ssaStyle.BorderStyle;
RawLine = ssaStyle.RawLine;
LoadedFromHeader = ssaStyle.LoadedFromHeader;
}
internal string ToRawSsa(string styleFormat)
{
var sb = new StringBuilder();
@ -173,4 +202,4 @@ namespace Nikse.SubtitleEdit.Logic
return s.Substring(0, s.Length - 1);
}
}
}
}