Ejemplo n.º 1
0
        public ASCIIImage(ConstructorArguments e)
        {
            if (e.value == null)
            {
                throw new ArgumentNullException("ASCIIImage.ConstructorArguments.value");
            }

            var s = new StringReader(e.value);

            var lines = new List <string>();

            var loop = true;

            while (loop)
            {
                var x = s.ReadLine();

                if (x == null)
                {
                    loop = false;
                }
                else
                {
                    lines.Add(x);
                }
            }

            var a = new List <string>();

            this.Height = 0;

            for (int i = 0; i < lines.Count;)
            {
                var v = lines[i];

                if (e.IsComment(v))
                {
                    i++;
                }
                else
                {
                    var n = "";

                    for (int j = 0; j < v.Length; j += 1 + e.skipx)
                    {
                        for (int mj = 0; mj < e.MultiplyX; mj++)
                        {
                            n += v.Substring(j, 1);
                        }
                    }

                    for (int mi = 0; mi < e.MultiplyY; mi++)
                    {
                        a.Add(n);
                    }

                    i += 1 + e.skipy;
                }
            }

            this.Lines = a.ToArray();

            this.Height = this.Lines.Length;

            if (Height > 0)
            {
                this.Width = this.Lines.Max(k => k.Length);
            }
        }