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); }
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); }
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); }