//---------------------------------------------------------------------------

        /**
         *
         * @param xMin
         *          : Unterer Grenzwert
         * @param xMax
         *          : Oberer Grenzwert
         * @param steps
         *          : Anzahl der Zwischenwerte - 2
         * @return
         *         Bestimmt die Werte einer Funktion
         */
        public Kurve bestimmeKurve(double xMin, double xMax, int steps)
        {
            Kurve  ret   = null;
            double xStep = 0.0;

            werte.Clear();
            // Hier wird ein Array uebergeben,
            // weil sich in Java uebergebene
            // Werte nicht aendern, nur Objektwerte (brauche nur den Ersten wert
            Double[] ergebnis  = new Double[1];
            String[] errorText = new String[1];

            xStep = ((xMax - xMin) / steps);
            for (int i = 0; i <= steps; i++)
            {
                double x = xMin + xStep * i;
                try
                {
                    errorText[0] = "";
                    int error = doubleFktValue(x, ergebnis, errorText);
                    if ((error == 0) && (String.IsNullOrEmpty(errorText[0])))
                    {
                        //        XYPoint xy = new XYPoint( Math.round( x * 1000.0 ) / 1000.0, Math.round( ergebnis[0] * 1000.0 ) / 1000.0 );
                        XYPoint xy = new XYPoint(x, ergebnis[0]);
                        xy.setstr("(" + xy.getX().ToString("0.##", CultureInfo.InvariantCulture)
                                  + "," + xy.getY().ToString("0.##", CultureInfo.InvariantCulture) + ")");
                        werte.Add(xy);
                    }
                }
                catch (Exception ex)
                {
                    string str = ex.Message;
                }
            }
            // neue Kurve aus den Werte erzeugen
            ret = new Kurve(werte);
            return(ret);
        }
Beispiel #2
0
        private void maleDiagramm()
        {
            if (!chkParameter.Checked)
            {
                string err = "";
                curves.Clear();
                if (chkAktiv1.Checked)
                {
                    Parser ps = new Parser();
                    err = ps.parsen(curve1.getFktText());
                    if (err.Trim() == "")
                    {
                        ps.bestimmeKurve((double)numericUpDown1.Value,
                                         (double)numericUpDown2.Value, curve1.getSteps());
                        curve1.setParser(ps);

                        curves.Add(curve1);
                    }
                    else
                    {
                        tbCurve1.Text    += " - " + err;
                        chkAktiv1.Checked = false;
                    }
                }
                if (chkAktiv2.Checked)
                {
                    Parser ps = new Parser();
                    err = ps.parsen(curve2.getFktText());

                    if (err.Trim() == "")
                    {
                        ps.bestimmeKurve((double)numericUpDown1.Value,
                                         (double)numericUpDown2.Value, curve2.getSteps());
                        curve2.setParser(ps);
                        curves.Add(curve2);
                    }
                    else
                    {
                        tbCurve2.Text    += " - " + err;
                        chkAktiv2.Checked = false;
                    }
                }
                if (chkAktiv3.Checked)
                {
                    Parser ps = new Parser();
                    err = ps.parsen(curve3.getFktText());

                    if (err.Trim() == "")
                    {
                        ps.bestimmeKurve((double)numericUpDown1.Value,
                                         (double)numericUpDown2.Value, curve3.getSteps());
                        curve3.setParser(ps);
                        curves.Add(curve3);
                    }
                    else
                    {
                        tbCurve3.Text    += " - " + err;
                        chkAktiv3.Checked = false;
                    }
                }
            }
            else
            {
                string err = "";
                curves.Clear();
                Parser ps1 = new Parser();
                string str = curve1.getFktText();
                err = ps1.parsen(curve1.getFktText());
                if (err.Trim() != "")
                {
                    tbCurve1.Text = err;
                    return;
                }
                //curve1.setParser(ps1);

                Kurve curvea = ps1.bestimmeKurve(diag.getxMin(), diag.getxMax(), curve1.getSteps());
                err = "";
                Parser ps2 = new Parser();
                err = ps2.parsen(curve2.getFktText());
                if (err.Trim() != "")
                {
                    tbCurve2.Text = err;
                    return;
                }
                //curve2.setParser(ps2);
                Kurve curveb = ps2.bestimmeKurve(diag.getxMin(), diag.getxMax(), curve2.getSteps());

                List <XYPoint> lx1 = curvea.getWerte();
                List <XYPoint> lx2 = curveb.getWerte();
                Kurve          ka  = new Kurve();
                List <XYPoint> pk  = new List <XYPoint>();
                pk.Clear();
                for (int i = 0; i < lx1.Count; i++)
                {
                    XYPoint pxy = new XYPoint(lx1[i].getY(), lx2[i].getY());
                    pxy.setstr("(" + pxy.getX().ToString("0.##", CultureInfo.InvariantCulture) +
                               "," + pxy.getY().ToString("0.##", CultureInfo.InvariantCulture) + ")");
                    pk.Add(pxy);
                }
                ka.setParser(null);
                ka.setKurvenart(Punktform.DICKER_PUNKT);
                ka.setKurvenfarbe(Color.Yellow);
                ka.setXEinheit("");
                ka.setYEinheit("");
                ka.setFktText("");

                ka.setWerte(pk);
                curves.Add(ka);
            }

            this.Refresh();
        }
Beispiel #3
0
        private void btnPostleitzahlen_Click(object sender, EventArgs e)
        {
            grdView.Rows.Clear();

            diaght = null;
            diaglg = null;
            panRight.Controls.Clear();

            List <XYPoint> werte  = null;
            DiagParam      mp     = new DiagParam("", "");
            Kurve          curve4 = new Kurve();
            // SQLiteConnection.CreateFile("MyDatabase.sqlite");
            SQLiteConnection m_dbConnection;
            SQLiteDataReader reader = null;

            m_dbConnection = new SQLiteConnection("Data Source=meinedatenbank.db");
            m_dbConnection.Open();
            String        xf      = "select Breite, Laenge, ort  from geos order by breite";
            SQLiteCommand command = new SQLiteCommand(xf, m_dbConnection);

            try
            {
                //                command.ExecuteNonQuery();
                reader = command.ExecuteReader();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }



            String[] columnNames = new String[2];
            columnNames[0] = "Breite";
            columnNames[1] = "Laenge";
            //werte = curve.getWerte();
            //if (werte != null)
            //  werte.Clear();
            //else
            werte = new List <XYPoint>();


            while (reader.Read())
            {
                XYPoint p = new XYPoint();
                p.setstr(reader.GetString(2));
                p.setX(reader.GetDouble(1));
                p.setY(reader.GetDouble(0));
                if (!(((p.getX() < 1) || (p.getX() > 40) || (p.getY() < 40) ||
                       (p.getY() > 60))))
                {
                    werte.Add(p);

                    /*
                     * int nRow = grdView.Rows.Add();
                     * DataGridViewRow grdRow = grdView.Rows[nRow];
                     * DataGridViewCellCollection grdCell = grdRow.Cells;
                     * grdCell[0].Value = nRow.ToString();
                     * grdCell[1].Value = p.getstr();
                     * grdCell[2].Value = p.getX();
                     * grdCell[3].Value = p.getY();
                     */
                }
            }


            curve4.setParser(null);
            curve4.setKurvenart(Punktform.RECHTECK_HOHL);
            curve4.setKurvenfarbe(Color.Red);
            curve4.setXEinheit("");
            curve4.setYEinheit("");
            curve4.setFktText("");
            curve4.setWerte(werte);
            curve4.bestimmeMinMaxWerte();
            mp.setcRahmenfarbe(Color.Black);

            /*
             * if (radNurDatum.isSelected())
             *  curve4.setDatumart(Datumart.NurDatum);
             * else if (radNurZeit.isSelected())
             *  curve4.setDatumart(Datumart.NurZeit);
             * else if (radZeitDatum.isSelected())
             *  curve4.setDatumart(Datumart.DatumUndZeit);
             */
            curves = new List <Kurve>();

            curves.Add(curve4);
            diag = new Diagramm(5, 16, 47, 56, curves, mp);

            diag.ShowSpecialValuesString = "dorf";
            diag.ShowSpecialValuesColor  = Color.Blue;
            diag.ShowSpecialValues       = true;


            //pan.Refresh();

            double dxmin = curve4.getxMin();
            double dxmax = curve4.getxMax();
            double dymin = curve4.getyMin();
            double dymax = curve4.getyMin();

            diag.setxRaster(true);
            diag.setyRaster(true);
            //            curve4.bestimmeMinMaxWerte();
            diag.setxMin(curve4.getxMin());
            diag.setxMax(curve4.getxMax());
            diag.setyMin(curve4.getyMin());
            diag.setyMax(curve4.getyMax());
            diag.BackColor      = Color.LightGreen;
            diag.HintColor      = Color.Black;
            diag.WithShowString = true;

            //diag.Refresh();
            panRight.Controls.Add(diag);
        }
Beispiel #4
0
        private void btnLaendergrenzensqlite_Click(object sender, EventArgs e)
        {
            grdView.Rows.Clear();


            diag   = null;
            diaglg = null;
            panRight.Controls.Clear();
            List <XYPoint> werte = null;
            DiagParam      mp    = new DiagParam("", "");

            mp.setcRahmenfarbe(Color.Black);
            Kurve curve4 = new Kurve();

            // SQLiteConnection.CreateFile("MyDatabase.sqlite");

            if (dbKind == DatabaseKind.dbSqlite)
            {
                SQLiteConnection m_dbConnection;
                SQLiteDataReader reader = null;
                m_dbConnection = new SQLiteConnection("Data Source=SqliteLaendergrenzen.db");
                m_dbConnection.Open();
                String        xf      = "select idx,breite,laenge  from laendergrenzen order by breite";
                SQLiteCommand command = new SQLiteCommand(xf, m_dbConnection);
                try
                {
                    reader = command.ExecuteReader();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                String[] columnNames = new String[2];
                columnNames[0] = "Breite";
                columnNames[1] = "Laenge";
                werte          = new List <XYPoint>();
                while (reader.Read())
                {
                    XYPoint p     = new XYPoint();
                    int     sname = reader.GetInt32(0);
                    p.setstr(sname.ToString());
                    double dx = reader.GetDouble(2);
                    double dy = reader.GetDouble(1);

                    /*
                     * string sx = reader.GetString(2);
                     * string sy = reader.GetString(1);
                     * sx.Replace(',', '.');
                     * sy.Replace(',', '.');
                     * double dx = Convert.ToDouble(sx);
                     * double dy = Convert.ToDouble(sy);
                     */
                    p.setX(dx);
                    p.setY(dy);
                    if (!(((p.getX() < 1) || (p.getX() > 40) || (p.getY() < 40) ||
                           (p.getY() > 60))))
                    {
                        werte.Add(p);
                        int                        nRow    = grdView.Rows.Add();
                        DataGridViewRow            grdRow  = grdView.Rows[nRow];
                        DataGridViewCellCollection grdCell = grdRow.Cells;
                        grdCell[0].Value = nRow.ToString();
                        grdCell[1].Value = sname;
                        grdCell[2].Value = dx.ToString();
                        grdCell[3].Value = dy.ToString();
                    }
                }
                reader.Close();
            }
            else if (dbKind == DatabaseKind.dbAccess)
            {
                OleDbConnection con = new OleDbConnection();
                OleDbCommand    cmd = new OleDbCommand();
                OleDbDataReader reader;


                con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;" +
                                       "Data Source=Haltestellen.accdb";

                cmd.Connection  = con;
                cmd.CommandText = "SELECT name,breite,laenge  FROM D_Bahnhof_2017_09";

                try
                {
                    con.Open();

                    reader = cmd.ExecuteReader();
                    werte  = new List <XYPoint>();

                    while (reader.Read())
                    {
                        XYPoint p     = new XYPoint();
                        string  sname = reader.GetString(0);
                        p.setstr(sname);
                        double dx = reader.GetDouble(2);
                        double dy = reader.GetDouble(1);
                        //sx.Replace(',', '.');
                        //sy.Replace(',', '.');
                        //double dx = Convert.ToDouble(sx);
                        //double dy = Convert.ToDouble(sy);

                        p.setX(dx);
                        p.setY(dy);
                        if (!(((p.getX() < 1) || (p.getX() > 40) || (p.getY() < 40) ||
                               (p.getY() > 60))))
                        {
                            werte.Add(p);
                            int                        nRow    = grdView.Rows.Add();
                            DataGridViewRow            grdRow  = grdView.Rows[nRow];
                            DataGridViewCellCollection grdCell = grdRow.Cells;
                            grdCell[0].Value = nRow.ToString();
                            grdCell[1].Value = sname;
                            grdCell[2].Value = dx.ToString();
                            grdCell[3].Value = dy.ToString();;
                        }
                    }
                    reader.Close();
                    con.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }

            curve4.setParser(null);
            curve4.setKurvenart(Punktform.PUNKT);
            curve4.setKurvenfarbe(Color.Black);
            curve4.setXEinheit("Längengrade");
            curve4.setYEinheit("Breitengrade");
            curve4.setFktText("");
            curve4.setWerte(werte);
            curve4.bestimmeMinMaxWerte();


            /*
             * if (radNurDatum.isSelected())
             *  curve4.setDatumart(Datumart.NurDatum);
             * else if (radNurZeit.isSelected())
             *  curve4.setDatumart(Datumart.NurZeit);
             * else if (radZeitDatum.isSelected())
             *  curve4.setDatumart(Datumart.DatumUndZeit);
             */
            curvesht = new List <Kurve>();

            curvesht.Add(curve4);
            diaght = new Diagramm(5, 16, 47, 56, curvesht, mp);

            /*
             * diaght.ShowSpecialValuesString = "Hbf";
             * diaght.ShowSpecialValuesColor = Color.Blue;
             * diaght.ShowSpecialValues = true;
             */


            //pan.Refresh();

            double dxmin = curve4.getxMin();
            double dxmax = curve4.getxMax();
            double dymin = curve4.getyMin();
            double dymax = curve4.getyMax();

            diaght.setxRaster(true);
            diaght.setyRaster(true);

            //diaght.set
            curve4.bestimmeMinMaxWerte();

            /*
             * diaght.setxMin(0.0);
             * diaght.setxMax(20);
             * diaght.setyMin(40);
             * diaght.setyMax(70);
             */
            diaght.setxMin(curve4.getxMin());
            diaght.setxMax(curve4.getxMax());
            diaght.setyMin(curve4.getyMin());
            diaght.setyMax(curve4.getyMax());
            diaght.BackColor = Color.LightGreen;
            diaght.HintColor = Color.Black;


            diaght.WithShowString = false;

            //diag.Refresh();
            panRight.Controls.Add(diaght);
        }