コード例 #1
0
ファイル: Form1.cs プロジェクト: leleh5/grafico_funcoes
        private void tan(object sender, EventArgs e)
        {
            Funcoes funcoes = new Funcoes();

            funcoes.setTxt_1(txt_3[0].Text);
            FuncoesBLL.validadados(funcoes);

            if (Erro.getErro())
            {
                MessageBox.Show(Erro.getMens());
            }

            else
            {
                double y1;

                y1 = Math.Round(Math.Tan((float.Parse(txt_3[0].Text) * Math.PI / 180)), 4);
                float x1 = float.Parse(txt_3[0].Text);

                System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
                series1.ChartArea = "ChartArea1";
                series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
                series1.Legend    = "Legend1";
                series1.Name      = "tan(" + x1 + ") = " + y1;
                this.chart1.Series.Add(series1);

                chart1.Series[i].Points.AddXY(x1, y1);

                i = i + 1;
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: leleh5/grafico_funcoes
        private void eq2(object sender, EventArgs e)
        {
            Funcoes funcoes = new Funcoes();

            funcoes.setTxt_1(txt_2[0].Text);
            funcoes.setTxt_2(txt_2[1].Text);
            funcoes.setTxt_3(txt_2[2].Text);
            FuncoesBLL.validadados3(funcoes);

            if (Erro.getErro())
            {
                MessageBox.Show(Erro.getMens());
            }

            else
            {
                double y = 0;

                System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
                series1.ChartArea = "ChartArea1";
                series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
                series1.Legend    = "Legend1";
                series1.Name      = "y = +(" + funcoes.getTxt_1() + ") x² +(" + funcoes.getTxt_2() + ") x +(" + funcoes.getTxt_3() + ")";
                this.chart1.Series.Add(series1);

                for (int x = -10; x <= 10; x++)
                {
                    y = float.Parse(funcoes.getTxt_1()) * Math.Pow(x, 2) + float.Parse(funcoes.getTxt_2()) * x + float.Parse(funcoes.getTxt_3());
                    chart1.Series[i].Points.AddXY(x, y);
                }

                i = i + 1;
            }
        }