Beispiel #1
0
        public object Clone()
        {
            var newInst = new ASSEvent();

            newInst.Type    = this.Type;
            newInst.Layer   = this.Layer;
            newInst.Start   = new ASSEventTime(this.Start.ToString());
            newInst.End     = new ASSEventTime(this.End.ToString());
            newInst.Style   = this.Style;
            newInst.Name    = this.Name;
            newInst.MarginL = this.MarginL;
            newInst.MarginR = this.MarginR;
            newInst.MarginV = this.MarginV;
            newInst.Effect  = this.Effect;
            newInst.Text    = this.Text;
            return(newInst);
        }
Beispiel #2
0
        private static string FormatEvent(IList <string> eventFormat, ASSEvent evt, string spliter = ",")
        {
            var sb = new StringBuilder();

            sb.Append(evt.Type.ToString() + ": ");
            for (var i = 0; i < eventFormat.Count; i++)
            {
                var field = eventFormat[i];
                switch (field.Trim())
                {
                case "Layer": sb.Append(evt.Layer); break;

                case "Start": sb.Append(evt.Start); break;

                case "End": sb.Append(evt.End); break;

                case "Style": sb.Append(evt.Style); break;

                case "Name": sb.Append(evt.Name); break;

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

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

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

                case "Effect": sb.Append(evt.Effect); break;

                case "Text": sb.Append(evt.Text); break;

                default:
                    Trace.TraceWarning("MAPPING ERROR: Unknown field - " + field);
                    break;
                }
                if (i != eventFormat.Count - 1)
                {
                    sb.Append(spliter);
                }
            }
            return(sb.ToString());
        }
Beispiel #3
0
        private static ASSEvent MappingToEvent(string prefix, IList <string> eventFormat, IList <string> values)
        {
            var eventType = (ASSEventType)Enum.Parse(typeof(ASSEventType), prefix);
            var evt       = new ASSEvent();

            evt.Type = eventType;
            for (var i = 0; i < eventFormat.Count; i++)
            {
                var field = eventFormat[i];
                var value = values[i];
                switch (field.Trim())
                {
                case "Layer": evt.Layer = Convert.ToInt32(value); continue;

                case "Start": evt.Start = new ASSEventTime(value); continue;

                case "End": evt.End = new ASSEventTime(value); continue;

                case "Style": evt.Style = value; continue;

                case "Name": evt.Name = value; continue;

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

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

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

                case "Effect": evt.Effect = value; continue;

                case "Text": evt.Text = value; continue;

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