private void pb_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            psp = new List <XYPoint>();
            psp.Clear();
            for (int i = 0; i < curves.Count; i++)
            { // malen der Punkte fuer jede Kurve
                Kurve curve = (Kurve)(curves[i]);
                if ((curve.getParser() != null) && (!(curve.isDatum)))
                { // wenn Parser vorhanden, dann Werte bestimmen fuer
                  // eingestellten x_Bereich (umweg ueber weitere Kurve)
                    for (int k = 0; k < curve.getWerte().Count; k++)
                    {
                        psp.Add(curve.getWerte()[k]);
                    }
                }
                else
                {
                    // bei DB - Werten direkt nur die
                    // importierten Daten darstellen
                    psp = curve.getWerte();
                    break;
                }
            }

            //g.setColor(curve.getKurvenfarbe());
            for (int j = 0; j < psp.Count; j++)
            { // Punkt bestimmen
                XYPoint xp = psp[j];
                if ((Math.Abs(xp.getIx() - e.X) < 4) && (Math.Abs(xp.getIy() - e.Y) < 4))
                {
                    CanGetPoint     = false;
                    MouseDownString = xp.getstr();
                    XPointValue     = xp.getX();
                    YPointValue     = xp.getY();
                    CanGetPoint     = true;
                    break;
                }
                else
                {
                    MouseDownString = "";
                }
            }
        }
        //---------------------------------------------------------------------------

        /**
         *
         * @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);
        }
Exemple #3
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();
        }
        //@Override
        //    public void paint(Graphics g0)
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            //Graphics g = CreateGraphics();

            Rectangle r = this.ClientRectangle;

            //e.Graphics.FillRectangle(new SolidBrush(Color.Blue), r);
            e.Graphics.FillRectangle(new SolidBrush(this.BackColor), r);

            e.Graphics.DrawRectangle(Pens.Gray, 0, 0, ClientSize.Width - 1, ClientSize.Height - 1);

            Kurve curve_intern = null;
            // ausprobiert - soviel, dass für doe beschriftung genug Platz
            int nRandxu = 60;
            int nRandyu = 60;



            // weitere Hilfsgroessen festlegen

            // Diagramm wird in 10 Unterabschnitte eingeteilt
            // jeweils in Breite und Hoehe
            int nDx     = (this.Width - 2 * nRandxu) / 10;
            int nRandxo = this.Width - nRandxu - 10 * nDx;
            int nWidth  = this.Width - nRandxu - nRandxo;
            int nDy     = (this.Height - 2 * nRandyu) / 10;
            int nRandyo = this.Height - nRandyu - 10 * nDy;
            int nHeight = this.Height - nRandyu - nRandyo;

            // super.paint(g);
            // der Rand wird gemalt


            //g.setColor(mp.getcRahmenfarbe());
            Pen   pe = new Pen(mp.getcRahmenfarbe());
            Brush br = new SolidBrush(Color.Red);

            //mp.setcRahmenfarbe(Color.Red);
            e.Graphics.DrawLine(pe, nRandxu, nRandyu,
                                this.Width - nRandxo, nRandyu);
            e.Graphics.DrawLine(pe, nRandxu, nRandyu, nRandxu,
                                this.Height - nRandyo);
            e.Graphics.DrawLine(pe, nRandxu, this.Height - nRandyo,
                                this.Width - nRandxo, this.Height - nRandyo);
            e.Graphics.DrawLine(pe, this.Width - nRandxo, nRandyu,
                                this.Width - nRandxo, this.Height - nRandyo);

            if (this.yRaster)
            { // yRaster auf true, dann wird 10er Unterteilung gemalt
              // Führungslinien
                for (int i = 1; i < 10; i++)
                {
                    e.Graphics.DrawLine(pe, nRandxu, nRandyu + i * nDy,
                                        this.Width - nRandxo, nRandyu + i * nDy);
                }
            }
            if (this.xRaster)
            { // xRaster auf true, dann wird 10er Unterteilung gemalt
              // Führungslinien
                for (int i = 1; i < 10; i++)
                {
                    e.Graphics.DrawLine(pe, nRandxu + i * nDx, nRandyu,
                                        nRandxu + i * nDx, this.Height - nRandyo);
                }
            }

            if ((curves.Count == 1) && ((Kurve)(curves[0])).isDatum)
            { // nur wenn Datenbank x - Feld ein Datum ist und wenn nur
              // eine Kurve naemlich die Datenbankkurve gemalt werden soll
              // Datumwerte sind eigentlich Double - Werte (sehr grosse)
              // neue Minimal und Maximalwerte bestimmen
                ((Kurve)(curves[0])).bestimmeMinMaxWerte();
                psp  = ((Kurve)(curves[0])).getWerte();
                xMin = (((Kurve)(curves[0])).getxMin());
                xMax = (((Kurve)(curves[0])).getxMax());
                yMin = ((Kurve)(curves[0])).getyMin();
                yMax = ((Kurve)(curves[0])).getyMax();;
            }
            double diffx = xMax - xMin;
            double diffy = yMax - yMin;
            // wenn Werte (x oder y) sehr gross sind, dann werden
            // statt Dezimalwertdarstellung eine Exponentendarstellung
            // gewaehlt, dazu wird die Potenz der Differenzen zwischen
            // Minimal und Maximalwert bestimmt
            int nPotx = bestimmePotenz(diffx);
            //System.out.println( "nPotx: " + nPotx );

            double w10x   = 1.0;
            int    wnPotx = nPotx;

            if (wnPotx > 0)
            {
                while (wnPotx > 0)
                {
                    w10x = 10 * w10x;
                    wnPotx--;
                }
            }
            else if (wnPotx < 0)
            {
                while (wnPotx < 0)
                {
                    w10x = w10x / 10;
                    wnPotx++;
                }
            }

            int nPoty = bestimmePotenz(diffy);
            //System.out.println( "nPoty: " + nPoty );
            double w10y   = 1.0;
            int    wnPoty = nPoty;

            if (wnPoty > 0)
            {
                while (wnPoty > 0)
                {
                    w10y = 10 * w10y;
                    wnPoty--;
                }
            }
            else if (wnPoty < 0)
            {
                while (wnPoty < 0)
                {
                    w10y = w10y / 10;
                    wnPoty++;
                }
            }
            // alten Werte merken - beachte Unterschied zu BWerten
            double xMinAlt = xMin;
            double xMaxAlt = xMax;
            double yMinAlt = yMin;
            double yMaxAlt = yMax;

            if ((nPotx < -2) || (2 < nPotx))
            {
                xMin = Math.Round((xMin / w10x) * 100) / 100.0;
                xMax = Math.Round((xMax / w10x) * 100) / 100.0;
            }
            if ((nPoty < -2) || (2 < nPoty))
            {
                yMin = Math.Round((yMin / w10y) * 100) / 100.0;
                yMax = Math.Round((yMax / w10y) * 100) / 100.0;
            }
            drawRaster(nRandxu, nRandxo, nRandyu, nRandyo, nDx, nDy, e.Graphics);

            /*
             *      if ((curves.Count == 1) && ((Kurve)(curves[0])).isDatum)
             *      { // hier wieder nur wenn Datum angezeigt
             *          xMin = xMinAlt;
             *          xMax = xMaxAlt;
             *          psp = ((Kurve)(curves[0])).getWerte();
             *          double xDatumDiff = 1.0 * (xMax - xMin) / 10;
             *
             *          if ((((Kurve)(curves[0])).getDatumart() == Datumart.NurDatum) ||
             *              (((Kurve)(curves[0])).getDatumart() == Datumart.DatumUndZeit))
             *          { // verschiedene Darstellungen des Datums wie im MainTool festgelegt
             *              for (int i = 0; i < 11; i = i + 2)
             *              { // aus Platzgruenden nur 6 Datumswerte
             *                  e.Graphics.DrawString(new DateTime((xMin + xDatumDiff * i)).ToShortDateString,
             *                      nRandxu - 30 + i * nDx, this.Height - nRandyo + 30);
             *              }
             *          }
             *          if ((((Kurve)(curves.get(0))).getDatumart() == Datumart.DatumUndZeit))
             *          {
             *              for (int i = 0; i < 11; i = i + 2)
             *              {
             *                  g.drawString(new Time(new Double(xMin + xDatumDiff * i).longValue()).toString(),
             *                      nRandxu - 30 + i * nDx, this.getHeight() - nRandyo + 45);
             *              }
             *          }
             *          if ((((Kurve)(curves.get(0))).getDatumart() == Datumart.NurZeit))
             *          {
             *              for (int i = 0; i < 11; i = i + 2)
             *              {
             *                  g.drawString(new Time(new Double(xMin + xDatumDiff * i).longValue()).toString(),
             *                      nRandxu - 30 + i * nDx, this.getHeight() - nRandyo + 30);
             *              }
             *          }
             *          for (int i = 0; i < 11; i++)
             *          { // bei der y-Achse normale Zahlendarstellung
             *            // hier die linke Achse
             *              g.drawString(NumberFormat.getInstance().
             *                  format(yMin + (yMax - yMin) / 10 * i),
             *                  nRandxu - 30, this.getHeight() - nRandyo - i * nDy);
             *          }
             *          for (int i = 0; i < 11; i++)
             *          { // Beide Achsen (hier die rechte)
             *              g.drawString(NumberFormat.getInstance().
             *                  format(yMin + (yMax - yMin) / 10 * i),
             *                  this.getWidth() - nRandxo + 20, this.getHeight() - nRandxo - i * nDy);
             *          }
             *
             *      }
             *      else
             *
             */

            // hier die normale Beschriftung (kein Datum, ..
            drawBezeichnung(xMin, xMax, yMin, yMax,
                            nRandxu, nRandxo, nRandyu, nRandyo, nDx, nDy, e.Graphics);

            if (!(String.IsNullOrEmpty(mp.getxAchse().Trim()) && String.IsNullOrEmpty(mp.getyAchse().Trim())))
            { // Achsenbeschriftung (z.B. Einheiten)
                e.Graphics.DrawString(mp.getxAchse(), this.Font, br,
                                      nRandxu + 10 * nDx - 30, this.Height - nRandyo + 45);
                e.Graphics.DrawString(mp.getyAchse(), this.Font, br,
                                      nRandxu - 55, this.Height - nRandxo - 10 * nDy - 40);
            }
            else if (curves.Count == 1)
            { // Achsenbeschriftung (z.B. Einheiten)
                Kurve curve = (Kurve)(curves[0]);
                e.Graphics.DrawString(curve.getXEinheit(), this.Font, br,
                                      nRandxu + 10 * nDx - 30, this.Height - nRandyo + 45);
                e.Graphics.DrawString(curve.getYEinheit(), this.Font, br,
                                      nRandxu - 55, this.Height - nRandxo - 10 * nDy - 40);
            }

            if ((nPoty > 2) || (nPoty < -2))
            { // nur bei Potenzialdarstellung
                e.Graphics.DrawString("* 10", this.Font, br,
                                      nRandxu - 50, nRandyu + 37);
                e.Graphics.DrawString(nPoty.ToString(), this.Font, br,
                                      nRandxu - 30, nRandyu + 27);
            }

            if (!((curves.Count == 1) && ((Kurve)(curves[0])).isDatum))
            {
                // nur bei Potenzialdarstellung (und kein Datum)
                if ((nPotx > 2) || (nPotx < -2))
                {
                    e.Graphics.DrawString("* 10", this.Font, br,
                                          nRandxu + 10 * nDx + 20, this.Height - nRandyo + 45);
                    e.Graphics.DrawString(nPotx.ToString(), this.Font, br,
                                          nRandxu + 10 * nDx + 42, this.Height - nRandyo + 35);
                }
            }

            xMin = xMinAlt;
            xMax = xMaxAlt;
            yMin = yMinAlt;
            yMax = yMaxAlt;

            for (int i = 0; i < curves.Count; i++)
            { // malen der Punkte fuer jede Kurve
                Kurve curve = (Kurve)(curves[i]);
                if ((curve.getParser() != null) && (!(curve.isDatum)))
                { // wenn Parser vorhanden, dann Werte bestimmen fuer
                  // eingestellten x_Bereich (umweg ueber weitere Kurve)
                    Parser p = curve.getParser();
                    curve_intern = p.bestimmeKurve(xMin, xMax, curve.getSteps());
                    psp          = curve_intern.getWerte();
                    curve.setWerte(psp);
                }
                else
                {
                    // bei DB - Werten direkt nur die
                    // importierten Daten darstellen
                    psp = curve.getWerte();
                }

                //g.setColor(curve.getKurvenfarbe());
                Pen       penKurvenfarbe = new Pen(curve.getKurvenfarbe());
                Punktform ka             = curve.getKurvenart();
                for (int j = 0; j < psp.Count; j++)
                { // Punkt bestimmen
                    XYPoint xp = psp[j];
                    //int nj = 0;
                    //if (j == 200)
                    //  nj++;
                    // x und y - Wert bestimmen
                    int xx = (int)((nWidth) *
                                   (xp.getX() - xMin) / (xMax - xMin));
                    int yy = (int)((nHeight) - (nHeight) *
                                   (xp.getY() - yMin) / (yMax - yMin));
                    // Falls ausserhalb des Randes, dann nicht plotten
                    if ((nRandxu + xx) > (this.Width - nRandxo))
                    {
                        continue;
                    }
                    if ((nRandxu + xx) < (nRandxu))
                    {
                        continue;
                    }
                    if ((nRandyu + yy) > (this.Height - nRandyo))
                    {
                        continue;
                    }
                    if ((nRandyu + yy) < (nRandyu))
                    {
                        continue;
                    }
                    xp.setIx(nRandxu + xx);
                    xp.setIy(nRandyu + yy);
                    // alle Werte werden angezeigt
                    male(nRandxu + xx, nRandyu + yy, e.Graphics, ka, penKurvenfarbe);
                }
                curve.setWerte(psp);
            }
            // Nur die besonderen Werte werden angezeigt
            if (ShowSpecialValues)
            {
                for (int i = 0; i < curves.Count; i++)
                { // malen der Punkte fuer jede Kurve
                    Kurve curve = (Kurve)(curves[i]);
                    if ((curve.getParser() != null) && (!(curve.isDatum)))
                    { // wenn Parser vorhanden, dann Werte bestimmen fuer
                      // eingestellten x_Bereich (umweg ueber weitere Kurve)
                        Parser p = curve.getParser();
                        curve_intern = p.bestimmeKurve(xMin, xMax, curve.getSteps());
                        psp          = curve_intern.getWerte();
                        curve.setWerte(psp);
                    }
                    else
                    {
                        // bei DB - Werten direkt nur die
                        // importierten Daten darstellen
                        psp = curve.getWerte();
                    }

                    //g.setColor(curve.getKurvenfarbe());
                    Pen       penKurvenfarbe = new Pen(curve.getKurvenfarbe());
                    Punktform ka             = curve.getKurvenart();
                    for (int j = 0; j < psp.Count; j++)
                    { // Punkt bestimmen
                        XYPoint xp = psp[j];
                        //int nj = 0;
                        //if (j == 200)
                        //  nj++;
                        // x und y - Wert bestimmen
                        int xx = (int)((nWidth) *
                                       (xp.getX() - xMin) / (xMax - xMin));
                        int yy = (int)((nHeight) - (nHeight) *
                                       (xp.getY() - yMin) / (yMax - yMin));
                        // Falls ausserhalb des Randes, dann nicht plotten
                        if ((nRandxu + xx) > (this.Width - nRandxo))
                        {
                            continue;
                        }
                        if ((nRandxu + xx) < (nRandxu))
                        {
                            continue;
                        }
                        if ((nRandyu + yy) > (this.Height - nRandyo))
                        {
                            continue;
                        }
                        if ((nRandyu + yy) < (nRandyu))
                        {
                            continue;
                        }
                        xp.setIx(nRandxu + xx);
                        xp.setIy(nRandyu + yy);
                        if (xp.getstr().Contains(ShowSpecialValuesString))
                        {
                            e.Graphics.FillRectangle(new SolidBrush(ShowSpecialValuesColor),
                                                     nRandxu + xx - 2, nRandyu + yy - 2, 5, 5);
                        }
                    }
                    curve.setWerte(psp);
                }
            }


            //Graphics2D g = (Graphics2D)g0;
            if (WithShowString)
            {
                if (bPaintmousePos)
                //            if (false)
                {
                    Font fn = new Font(FontFamily.GenericSansSerif, 12.0F, FontStyle.Bold);
                    e.Graphics.DrawString(MouseOverString, fn,
                                          new SolidBrush(this.HintColor), mx + 12, my);
                    bPaintmousePos = false;
                }
            }



            xMin = xMinB;
            xMax = xMaxB;
            yMin = yMinB;
            yMax = yMaxB;
        }
Exemple #5
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);
        }
Exemple #6
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);
        }
Exemple #7
0
        private void btnGPX_Click(object sender, EventArgs e)
        {
            grdView.Rows.Clear();


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

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


            // #######################################################

            if (!File.Exists("Landesgrenzen.gpx"))
            {
                return;
            }

            XmlReader xr = new XmlTextReader("Landesgrenzen.gpx");



            // #################################################################


            werte = new List <XYPoint>();

            string sx = "";
            string sy = "";

            while (xr.Read())
            {
                if (xr.NodeType == XmlNodeType.Element)
                {
                    if ((xr.Name == "trkpt") && (xr.AttributeCount > 0))
                    {
                        while (xr.MoveToNextAttribute())
                        {
                            if (xr.Name == "lat")
                            {
                                sy = xr.Value;
                            }
                            xr.MoveToNextAttribute();
                            if (xr.Name == "lon")
                            {
                                sx = xr.Value;
                            }


                            XYPoint p = new XYPoint();



                            sx.Replace('.', ',');
                            sy.Replace('.', ',');
                            double dx = Convert.ToDouble(sx, CultureInfo.InvariantCulture);
                            double dy = Convert.ToDouble(sy, CultureInfo.InvariantCulture);

                            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 = "";
                                grdCell[2].Value = sx;
                                grdCell[3].Value = sy;
                            }
                        }
                    }
                }
            }

            xr.Close();

            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);
             */
            curveslg = new List <Kurve>();

            curveslg.Add(curve4);
            diaglg = new Diagramm(5, 16, 47, 56, curveslg, 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();

            diaglg.setxRaster(true);
            diaglg.setyRaster(true);

            //diaght.set
            curve4.bestimmeMinMaxWerte();

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


            //diaght.WithShowString = true;

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