Пример #1
0
        /// <summary>
        /// Devuelve una cadena con la línea en formato ASS.
        /// </summary>
        public override string ToString()
        {
            var _Tipo = LineTypeInfo.LineTypeToString(Type);

            return(string.Format("{0}: {1},{2},{3},{4},{5},{6},{7},{8},{9},{10}", _Tipo, Layer, Start, End, Style, Actor, MarginLeft, MarginRight, MarginVertical, Effect, Content));
        }
Пример #2
0
        /// <summary>
        /// Inicializa una nueva instancia de la clase <see cref="Line"/> en base a una cadena.
        /// </summary>
        /// <param name="texto"></param>
        public Line(string texto)
        {
            // Obteniendo valores.
            var _tipo      = AssFilter.FilterProperty(texto, Property.Type);
            var _capa      = AssFilter.FilterProperty(texto, Property.Layer);
            var _inicio    = new Time(AssFilter.FilterProperty(texto, Property.Start));
            var _fin       = new Time(AssFilter.FilterProperty(texto, Property.End));
            var _estilo    = AssFilter.FilterProperty(texto, Property.Style);
            var _actor     = AssFilter.FilterProperty(texto, Property.Actor);
            var _margenI   = AssFilter.FilterProperty(texto, Property.MarginLeft);
            var _margenD   = AssFilter.FilterProperty(texto, Property.MarginRight);
            var _margenV   = AssFilter.FilterProperty(texto, Property.MarginVertical);
            var _efecto    = AssFilter.FilterProperty(texto, Property.Effect);
            var _contenido = AssFilter.FilterProperty(texto, Property.Content);

            // Verificando valores.

            // Tipo.
            if (_tipo != "Dialogue" && _tipo != "Comment")
            {
                return;
            }
            else
            {
                Type = LineTypeInfo.StringToLineType(_tipo);
            }

            // Capa.
            if (_capa == "")
            {
                Layer = 0;
            }
            else
            {
                Layer = int.Parse(_capa);
            }

            // Tiempos.
            if (_inicio.ToDouble() > _fin.ToDouble())
            {
                throw new InvalidOperationException("El tiempo de inicio de línea debe ser menor o igual al de fin.");
            }

            // Márgenes.
            if (_margenD == "")
            {
                MarginRight = 0;
            }
            else
            {
                MarginRight = int.Parse(_margenD);
            }

            if (_margenI == "")
            {
                MarginLeft = 0;
            }
            else
            {
                MarginLeft = int.Parse(_margenI);
            }

            if (_margenV == "")
            {
                MarginVertical = 0;
            }
            else
            {
                MarginVertical = int.Parse(_margenV);
            }

            // Ingresando demás valores.
            Start   = _inicio;
            End     = _fin;
            Style   = _estilo;
            Actor   = _actor;
            Effect  = _efecto;
            Content = _contenido;
        }