Exemple #1
0
        private static string FormatStyle(IList <string> v4pStyleFormat, ASSStyle style, string spliter = ",")
        {
            var sb = new StringBuilder();

            sb.Append("Style: ");
            for (var i = 0; i < v4pStyleFormat.Count; i++)
            {
                var field = v4pStyleFormat[i];
                switch (field.Trim())
                {
                case "Name": sb.Append(style.Name); break;

                case "Fontname": sb.Append(style.Fontname); break;

                case "Fontsize": sb.Append(style.Fontsize); break;

                case "PrimaryColour": sb.Append(style.PrimaryColour); break;

                case "SecondaryColour": sb.Append(style.SecondaryColour); break;

                case "OutlineColour": sb.Append(style.OutlineColour); break;

                case "BackColour": sb.Append(style.BackColour); break;

                case "Bold": sb.Append(style.Bold ? "-1" : "0"); break;

                case "Italic": sb.Append(style.Italic ? "-1" : "0"); break;

                case "Underline": sb.Append(style.Underline ? "-1" : "0"); break;

                case "StrikeOut": sb.Append(style.StrikeOut ? "-1" : "0"); break;

                case "ScaleX": sb.Append(style.ScaleX); break;

                case "ScaleY": sb.Append(style.ScaleY); break;

                case "Spacing": sb.Append(style.Spacing); break;

                case "Angle": sb.Append(style.Angle); break;

                case "BorderStyle": sb.Append((int)style.BorderStyle); break;

                case "Outline": sb.Append(style.Outline); break;

                case "Shadow": sb.Append(style.Shadow); break;

                case "Alignment": sb.Append((int)style.Alignment); break;

                case "MarginL": sb.Append(style.MarginL); break;

                case "MarginR": sb.Append(style.MarginR); break;

                case "MarginV": sb.Append(style.MarginV); break;

                case "Encoding": sb.Append(style.Encoding); break;

                default:
                    Trace.TraceWarning("MAPPING ERROR: Unknown field - " + field);
                    break;
                }
                if (i != v4pStyleFormat.Count - 1)
                {
                    sb.Append(spliter);
                }
            }
            return(sb.ToString());
        }
Exemple #2
0
        private static ASSStyle MappingToStyle(IList <string> v4pStyleFormat, IList <string> values)
        {
            var style = new ASSStyle();

            for (var i = 0; i < v4pStyleFormat.Count; i++)
            {
                var field = v4pStyleFormat[i];
                var value = values[i];
                switch (field.Trim())
                {
                case "Name": style.Name = value; continue;

                case "Fontname": style.Fontname = value; continue;

                case "Fontsize": style.Fontsize = Convert.ToDouble(value); continue;

                case "PrimaryColour": style.PrimaryColour = value; continue;

                case "SecondaryColour": style.SecondaryColour = value; continue;

                case "OutlineColour": style.OutlineColour = value; continue;

                case "BackColour": style.BackColour = value; continue;

                case "Bold": style.Bold = Convert.ToInt16(value) == -1; continue;

                case "Italic": style.Italic = Convert.ToInt16(value) == -1; continue;

                case "Underline": style.Underline = Convert.ToInt16(value) == -1; continue;

                case "StrikeOut": style.StrikeOut = Convert.ToInt16(value) == -1; continue;

                case "ScaleX": style.ScaleX = Convert.ToDouble(value); continue;

                case "ScaleY": style.ScaleY = Convert.ToDouble(value); continue;

                case "Spacing": style.Spacing = Convert.ToInt32(value); continue;

                case "Angle": style.Angle = Convert.ToDouble(value); continue;

                case "BorderStyle": style.BorderStyle = (V4pStyleBorderStyle)Convert.ToInt16(value); continue;

                case "Outline": style.Outline = Convert.ToInt32(value); continue;

                case "Shadow": style.Shadow = Convert.ToInt32(value); continue;

                case "Alignment": style.Alignment = (V4pStyleAlignment)Convert.ToInt16(value); continue;

                case "MarginL": style.MarginL = Convert.ToInt32(value); continue;

                case "MarginR": style.MarginR = Convert.ToInt32(value); continue;

                case "MarginV": style.MarginV = Convert.ToInt32(value); continue;

                case "Encoding": style.Encoding = Convert.ToInt32(value); continue;

                default:
                    Trace.TraceWarning("MAPPING ERROR: Unknown field - " + field);
                    continue;
                }
            }
            return(style);
        }