예제 #1
0
        public static string Imprimir(List <FormaGeometrica> figuras, int idioma)
        {
            Idioma.SetIdioma(idioma);
            var sb = new StringBuilder();

            if (!figuras.Any())
            {
                sb.Append(Strings.SinFiguras);
            }
            else
            {
                var figura_total = figuras.GroupBy(a => a.GetType().Name).Select(ab => new Resultado
                {
                    figura    = ab.Key,
                    cantidad  = ab.Count(),
                    perimetro = ab.Sum(a => a.Perimetro),
                    area      = ab.Sum(a => a.Area)
                });
                // HEADER
                sb.Append(Strings.Titulo);
                //Shapes report
                foreach (Resultado _row in figura_total)
                {
                    sb.Append(_row.cantidad + " "
                              + Obtener_Plural(_row.cantidad, _row.figura)
                              + " | "
                              + Strings.Area + " " + String.Format("{0:0.##}", _row.area) + " | "
                              + Strings.Perimetro + " " + String.Format("{0:0.##}", _row.perimetro)
                              + " <br/>");
                }
                //// FOOTER
                sb.Append(Strings.TituloResultado);
                var figuras_totales = figuras.GroupBy(a => "Totales").Select(ab => new Resultado_Total
                {
                    cantidad  = ab.Count(),
                    perimetro = ab.Sum(a => a.Perimetro),
                    area      = ab.Sum(a => a.Area)
                });
                foreach (Resultado_Total _row in figuras_totales)
                {
                    sb.Append(_row.cantidad + " " + Strings.Figuras + " "
                              + Strings.Perimetro + " " + String.Format("{0:0.##}", _row.perimetro) + " "
                              + Strings.Area + " " + String.Format("{0:0.##}", _row.area));
                }
            }
            Console.WriteLine(sb.ToString());
            return(sb.ToString());
        }