Ejemplo n.º 1
0
        public static HtmlString ExibirEntidadeColorCodedComNomePersonalizado(this IColorCoded entidade, string texto, string elemento = "p", string imgclass = "img-thumbnail rounded float-left")
        {
            List <KeyValuePair <string, string> > ConteudoStyles = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("border-bottom", $"3px solid {entidade.Color}")
            };

            string ConteudoStyle = CreateHTMLStyle(ConteudoStyles);
            string Conteudo      = AninharEmElemento(elemento, texto, CreateHTMLProperty("class", "card-body instituicao-title") + ConteudoStyle);
            string HrefConteudo  = AninharEmElemento("a", Conteudo);
            string Img           = string.Empty;

            if (entidade.Logo != null)
            {
                List <KeyValuePair <string, string> > ImageProperties = new List <KeyValuePair <string, string> >()
                {
                    new KeyValuePair <string, string>("class", $"{imgclass}"),
                    new KeyValuePair <string, string>("src", $"data:image;base64,{Convert.ToBase64String(entidade.Logo)}")
                };
                Img = HTMLElements.Img(CreateHTMLProperties(ImageProperties));
            }

            string     DivClasse  = CreateHTMLProperty("class", CSSCustomClassNames.InstituicaoDiv());
            string     Properties = DivClasse;
            string     Elemento   = AninharEmDiv(Img + HrefConteudo, Properties);
            HtmlString html       = new HtmlString(Elemento);

            return(html);
        }
Ejemplo n.º 2
0
        public override float Calcular()
        {
            float Media = Valores.Average();

            Passos.WriteLineAsyncCounter($"O {Titulo("Desvio padrão")} é uma medida que expressa o grau de dispersão de um conjunto de dados:");
            Passos.WriteLineAsyncCounter($" {HTMLElements.Img(Properties: "src='https://dados-agrupados-api.herokuapp.com/Imagens/desvio-padrao-1.png'")}");
            Passos.WriteLineAsyncCounter($"Obter a média aritimética dos dados (Ma) = {Media}");
            Passos.WriteLineAsyncCounter($"Obter o número de termos (N) = {Valores.Count}");
            Passos.WriteLineAsyncCounter($"(Somátorio de Xi = 1 até a posição N ({Valores.Count}) menos a média ({Media})) elevado ao quadrado{HTMLElements.Hr()}");
            int xi = 1;

            foreach (var Elemento in Valores)
            {
                //Passos.WriteLineAsync($"Termo (x{xi}) = {Elemento}");
                var operacao = (Elemento - Media) * (Elemento - Media);
                Resultado += operacao;
                Passos.WriteLineAsync($"$$ {(xi > 1 ? '+' : ' ')}(" + Elemento + " - " + Media.ToString("F2") + $")^ 2 = {operacao} ..." + Resultado + $"  $$  {HTMLElements.Hr()}");
                xi++;
            }

            Passos.WriteLineAsyncCounter($"Obter a raíz quadrada da divisão do somatório ({Resultado}) pelo numero de termos ({Valores.Count}) {HTMLElements.Hr()}");
            var operacaoFinal = (float)Math.Sqrt(Resultado / Valores.Count());

            Passos.WriteLineAsync($"\n $$ Resultado = \\sqrt {{ \\dfrac{{ {{{Resultado}}} }} {{{Valores.Count()}}}  }} = {{{operacaoFinal}}}$$");
            Resultado = operacaoFinal;
            return(Resultado);
        }
Ejemplo n.º 3
0
        public override float Calcular()
        {
            int    pos        = Math.Abs((Valores.Count / 2) - 1);
            string ValoresCSV = String.Join(",", Valores);

            Valores = Valores.ToList().OrderBy(x => x).ToList();

            Passos.WriteLineAsyncCounter($"Elementos: {ValoresCSV}");
            if (Valores.Count == 1)
            {
                Resultado = Valores[0];
            }
            else if (Valores.Count % 2 != 0)
            {
                Resultado = Valores[Valores.Count / 2];
            }
            else
            {
                Passos.WriteLineAsyncCounter($"Lista de contagem par:");
                Passos.WriteLineAsyncCounter($"Some os dois elementos do centro ({Valores[pos]} e {Valores[pos + 1]}) e divida por 2(dois):");
                Resultado = Math.Abs((Valores[pos] + Valores[pos + 1]) / 2);
                Passos.WriteLineAsync($"$$ \\dfrac{{ {{ {Valores[pos]} + {Valores[pos + 1]} }}  }} {{2}} = \\dfrac{{ {{ {Valores[pos] + Valores[pos + 1]} }}  }} {{2}} = {Resultado} $$");
            }
            Passos.WriteLineAsyncCounter($"{HTMLElements.Hr()} {Titulo("Mediana")}: Valores no centro da lista : {Resultado}");
            return(Resultado);
        }
Ejemplo n.º 4
0
        private float CalcularTamanhoIntervaloH(float Amplitude, double QuantidadeIntervalos)
        {
            var Intervalo = (float)(Amplitude / QuantidadeIntervalos);

            Passos.WriteLineAsync($"{Titulo("Calcule o Tamanho do Intervalo (H)")}: {HTMLElements.Br()} $$ H = \\dfrac{{ {{A}} }} {{K}} $$");
            Passos.WriteLineAsync($"$$ H = \\dfrac{{ {{{Amplitude}}} }} {{{QuantidadeIntervalos}}} = {Intervalo} $$");

            Intervalo = (float)((Intervalo % 1) > 0 ? Amplitude / RecalcularK() : Intervalo);

            return(Intervalo);
        }
Ejemplo n.º 5
0
        private static string CreateInput(string value, string classe, string type)
        {
            List <KeyValuePair <string, string> > InputProperties = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("class", classe),
                new KeyValuePair <string, string>("value", value),
                new KeyValuePair <string, string>("type", type)
            };
            string Propriedades = CreateHTMLProperties(InputProperties);

            return(HTMLElements.Input(Propriedades));
        }
Ejemplo n.º 6
0
        private static string CreateInputForKey <T>(PropertyInfo prop, T entity) where T : ModeloBase
        {
            string ValorAtributo = ObterValorPropriedade(prop, entity);
            List <KeyValuePair <string, string> > Properties = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("id", $"{prop.Name}"),
                new KeyValuePair <string, string>("name", $"{prop.Name}"),
                new KeyValuePair <string, string>("value", $"{ValorAtributo}"),
                new KeyValuePair <string, string>("type", $"hidden")
            };
            string Propriedades = CreateHTMLProperties(Properties);

            return(HTMLElements.Input(Propriedades));
        }
Ejemplo n.º 7
0
 public static string MontarMensagemHTML(string Mensagem, string classe = null)
 {
     Mensagem = Mensagem.Replace(HTMLPlaceholders.Div(false), HTMLElements.Div(false)).Replace(HTMLPlaceholders.Div(true), HTMLElements.Div(true));
     if (classe != null)
     {
         Mensagem = Mensagem.Replace(HTMLPlaceholders.Label(false), HTMLElements.Label(false, classe)).Replace(HTMLPlaceholders.Label(true), HTMLElements.Label(true));
         Mensagem = Mensagem.Replace(HTMLPlaceholders.P(false), HTMLElements.P(false, classe)).Replace(HTMLPlaceholders.P(true), HTMLElements.P(true));
     }
     else
     {
         Mensagem = Mensagem.Replace(HTMLPlaceholders.Label(false), HTMLElements.Label(false, "label h6-responsive")).Replace(HTMLPlaceholders.Label(true), HTMLElements.Label(true));
         Mensagem = Mensagem.Replace(HTMLPlaceholders.P(false), HTMLElements.P(false, "alteracao-p")).Replace(HTMLPlaceholders.P(true), HTMLElements.P(true));
     }
     return(Mensagem);
 }
Ejemplo n.º 8
0
        public static HtmlString MontarMensagemHTML(this IHtmlHelper helper, string Mensagem, string classe = null)
        {
            Mensagem = Mensagem.Replace(HTMLPlaceholders.Div(false), HTMLElements.Div(false)).Replace(HTMLPlaceholders.Div(true), HTMLElements.Div(true));
            if (classe != null)
            {
                Mensagem = Mensagem.Replace(HTMLPlaceholders.Label(false), HTMLElements.Label(false, classe)).Replace(HTMLPlaceholders.Label(true), HTMLElements.Label(true));
                Mensagem = Mensagem.Replace(HTMLPlaceholders.P(false), HTMLElements.P(false, classe)).Replace(HTMLPlaceholders.P(true), HTMLElements.P(true));
            }
            else
            {
                Mensagem = Mensagem.Replace(HTMLPlaceholders.Label(false), HTMLElements.Label(false, "label h6-responsive")).Replace(HTMLPlaceholders.Label(true), HTMLElements.Label(true));
                Mensagem = Mensagem.Replace(HTMLPlaceholders.P(false), HTMLElements.P(false, "alteracao-p")).Replace(HTMLPlaceholders.P(true), HTMLElements.P(true));
            }
            HtmlString html = new HtmlString(Mensagem);

            return(html);
        }
Ejemplo n.º 9
0
        public override float Calcular()
        {
            DesvioPadrao dp = new DesvioPadrao(Valores);
            Media        ma = new Media(Valores);

            dp.Calcular();
            ma.Calcular();
            Passos.WriteLineAsyncCounter($"O {Titulo("Coeficiênte de Variação")} é igual ao quociente entre o desvio padrão e a média:");
            Passos.WriteLineAsync($"$$ Dp = {dp.Resultado}$$");
            Passos.WriteLineAsync($"$$ Ma = {ma.Resultado}$$");

            var operacao = dp.Resultado / ma.Resultado;

            Passos.WriteLineAsync($"$$ \\dfrac{{ {{{dp.Resultado}}} }} {{{ma.Resultado}}} = {operacao} $$  {HTMLElements.Hr()}");

            Resultado = operacao;
            return(0f);
        }
Ejemplo n.º 10
0
        private static string CreateColorDisplay <T>(PropertyInfo prop, T entity, string divClass) where T : ModeloBase
        {
            string NomeAtributo      = ObterNomePropriedade(prop);
            string ValorAtributo     = ObterValorPropriedade(prop, entity);
            string DescricaoAtributo = ObterDescricaoPropriedade(prop);
            List <KeyValuePair <string, string> > InputProperties = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("id", $"{prop.Name}"),
                new KeyValuePair <string, string>("name", $"{prop.Name}"),
                new KeyValuePair <string, string>("class", $"form-control"),
                new KeyValuePair <string, string>("value", $"{ValorAtributo}"),
                new KeyValuePair <string, string>("placeholder", $"{NomeAtributo}"),
                new KeyValuePair <string, string>("type", $"color"),
                new KeyValuePair <string, string>("title", $"{DescricaoAtributo}")
            };
            string LabelFor          = CreateHTMLProperty("for", prop.Name);
            string InputPropriedades = CreateHTMLProperties(InputProperties);
            string InputDisplayDiv   = AninharEmDiv(string.Format(" {0}: {1} ", AninharEmLabel(NomeAtributo, LabelFor), HTMLElements.Input(InputPropriedades)));

            return(InputDisplayDiv);
        }
Ejemplo n.º 11
0
        private static string CreateInputDisplay(string NomePropriedade, string value, string Descricao, string divClass, string inputType)
        {
            List <KeyValuePair <string, string> > InputProperties = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("id", $"{NomePropriedade}"),
                new KeyValuePair <string, string>("name", $"{NomePropriedade}"),
                new KeyValuePair <string, string>("value", $"{value}"),
                new KeyValuePair <string, string>("class", $"form-control"),
                new KeyValuePair <string, string>("placeholder", $"{Descricao}"),
                new KeyValuePair <string, string>("type", $"{inputType}"),
                new KeyValuePair <string, string>("title", $"{Descricao}")
            };
            string LabelFor          = CreateHTMLProperty("for", NomePropriedade);
            string InputPropriedades = CreateHTMLProperties(InputProperties);
            string InputDisplayDiv   = AninharEmDiv(string.Format(" {0}: {1} ", AninharEmLabel(NomePropriedade, LabelFor), HTMLElements.Input(InputPropriedades)), CreateHTMLProperty("class", divClass));

            return(InputDisplayDiv);
        }
Ejemplo n.º 12
0
        private float CalcularFrequenciaRelativaAcumulada(int pos)
        {
            float resultado;

            if (pos > 0)
            {
                resultado = fr.Sum();
            }
            else
            {
                resultado = fr[pos];
            }
            Passos.WriteLineAsyncCounter($"{Titulo(ClassToHTML.AninharEmEm($"Freq. Relativa Acumu. de {ClassToHTML.AninharEmEm($"{ValoresDistintos[pos].Key}")} [x{pos + 1}] "))}: {resultado}% {HTMLElements.Hr()}");
            Passos.WriteLineAsync($"{GerarTabelaDeFrAcumulada(pos,resultado)}");

            return(resultado);
        }
Ejemplo n.º 13
0
        private void  CalcularTodosOsIntervalos()
        {
            float Abertura = ValorMinimo;

            Passos.WriteLineAsyncCounter($"{Titulo("Calcular Abertura do Intervalo")}: Começa pelo Valor Minimo = {ValorMinimo} {HTMLElements.Hr()}");
            for (int i = 0; i < QuantidadeIntervalos; i++)
            {
                try
                {
                    if (!Simples)
                    {
                        float FimIntervalo = Abertura + Intervalo;
                        intervalos.Add($"{Abertura.ToString("0.00")}|--{FimIntervalo.ToString("0.00")}");
                        Passos.WriteLineAsyncCounter($"{Titulo("Calcule o Final do Intervalo")}: Abertura + Intervalo ");
                        Passos.WriteLineAsync($"$$ {Abertura} + {Intervalo} = {Abertura + Intervalo}$$");
                        Passos.WriteLineAsyncCounter($"{Titulo("Calcule o Intervalo")}: Abertura |-- Fim ");
                        Passos.WriteLineAsync($"$${Abertura.ToString("0.00")}|--{FimIntervalo.ToString("0.00")} $$");

                        xi.Add(CalcularMediaXI(Abertura, FimIntervalo));
                        fi.Add(CalcularFrequenciaSimples(Abertura, FimIntervalo));

                        Fi.Add(CalcularFrequenciaSimplesAcumulada(i));

                        fr.Add(CalcularFrequenciaRelativa(i));
                        Fr.Add(CalcularFrequenciaRelativaAcumulada(i));

                        Abertura = FimIntervalo;
                    }
                    else
                    {
                        Passos.WriteLineAsyncCounter($"{Titulo("Freq. Simples de ")} {ClassToHTML.AninharEmEm($"{ValoresDistintos[i].Key} [x{i + 1}]")}: {ValoresDistintos[i].Value}");
                        xi.Add(ValoresDistintos[i].Key);
                        fi.Add(ValoresDistintos[i].Value);

                        Fi.Add(CalcularFrequenciaSimplesAcumulada(i));
                        fr.Add(CalcularFrequenciaRelativa(i));
                        Fr.Add(CalcularFrequenciaRelativaAcumulada(i));
                    }
                }
                catch (Exception)
                {
                    continue;
                }
            }
        }
Ejemplo n.º 14
0
 public static string AninharEmLabel(string conteudo, string propriedades = null)
 {
     conteudo = conteudo.Insert(0, HTMLElements.Label(false, propriedades));
     conteudo = conteudo.Insert(conteudo.Length, HTMLElements.Label(true));
     return(conteudo);
 }
Ejemplo n.º 15
0
        public void GerarElementoComMultiplosAtributosHTML()
        {
            List <KeyValuePair <string, string> > Styles = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("id", $"{Name}"),
                new KeyValuePair <string, string>("name", $"{Name}"),
                new KeyValuePair <string, string>("value", $"{ValorAtributo}"),
                new KeyValuePair <string, string>("class", $"form-control"),
                new KeyValuePair <string, string>("placeholder", $"{NomeAtributo}"),
                new KeyValuePair <string, string>("type", $"text")
            };
            string For          = CreateHTMLProperty("for", Name);
            string Propriedades = CreateHTMLProperties(Styles);
            string Div          = AninharEmDiv(string.Format(" {0}: {1} ", AninharEmLabel(NomeAtributo, For), HTMLElements.Input(Propriedades)), CreateHTMLProperty("class", "md-form"));

            output.WriteLine(Div);
            Assert.True(Div == MensagemEsperada);
        }
Ejemplo n.º 16
0
        public override float Calcular()
        {
            float Media = Valores.Average();

            Passos.WriteLineAsyncCounter($"{Titulo("Variância")}: A variância mede quão dispersos estão os dados na amostra. =  $$ \\sum_ {{Xi - Ma²}} \\over n $$");
            Passos.WriteLineAsyncCounter($"Calcule a média (Ma) = {Media}");
            Passos.WriteLineAsyncCounter($"Calcule o número de termos (N) = {Valores.Count} {HTMLElements.Hr()}");
            int xi = 1;

            foreach (var Elemento in Valores)
            {
                //Passos.WriteLineAsync($" $$ ( x{xi} - Ma ) ^2 $$");

                var operacao = (Elemento - Media) * (Elemento - Media);
                Resultado += operacao;
                Passos.WriteLineAsync(" $$ (" + Elemento + " - " + Media.ToString("F2") + $")^ 2 = {operacao} ..." + Resultado + $" + $$ {HTMLElements.Hr()}");
                xi++;
            }

            Passos.WriteLineAsync($"\n $$ Resultado: \\dfrac{{ {{{Resultado}}} }} {{{Valores.Count()}}} = {{{Resultado /= Valores.Count()}}} $$");

            return(Resultado);
        }
 public StringWriterDecorator() : base()
 {
     NewLine = HTMLElements.Br();
 }