//开始查询 private void btn_Apply_Click(object sender, EventArgs e) { string caption = cbox_Layers.Text; if (caption == "") { MessageBox.Show("请先添加图层", "提示"); return; } GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(caption); if (layer == null) { return; } if (!checkBox1.Checked) { GSOFeatures features = layer.GetAllFeatures(); for (int i = 0; i < features.Length; i++) { GSOFeature newfeature = features[i]; GSOGeoPolyline3D line = newfeature.Geometry as GSOGeoPolyline3D; if (line == null) { continue; } GSOPipeLineStyle3D pipeLineStyle = line.Style as GSOPipeLineStyle3D; // 管线暂不支持依地模式 if (pipeLineStyle == null) { pipeLineStyle = new GSOPipeLineStyle3D(); } pipeLineStyle.LineColor = buttonPipelineColor.BackColor; line.Style = pipeLineStyle; } } else { string sql = "select * from " + cbox_Layers.Text.Trim(); if (textBox_WhereClause.Text != "") { sql += " where " + textBox_WhereClause.Text; try { if (layer.Dataset == null || layer.Dataset.DataSource == null || (layer.Dataset.DataSource.Type != EnumDataSourceType.SqlServer && layer.Dataset.DataSource.Type != EnumDataSourceType.Oracle)) { return; } DatabaseConnectParams connectParams = Utility.getConnectParamsByDatasourceName(globeControl1, layer.Dataset.DataSource.Name); if (connectParams == null) { return; } DataTable table = OledbHelper.QueryTable(sql, connectParams); if (table == null) { return; } for (int i = 0; i < table.Rows.Count; i++) { int id = Convert.ToInt32(table.Rows[i]["LSSYS_ID"]); GSOFeature newfeature = layer.GetFeatureByID(id); GSOGeoPolyline3D line = newfeature.Geometry as GSOGeoPolyline3D; if (line == null) { continue; } GSOPipeLineStyle3D pipeLineStyle = line.Style as GSOPipeLineStyle3D; // 管线暂不支持依地模式 if (pipeLineStyle == null) { pipeLineStyle = new GSOPipeLineStyle3D(); } pipeLineStyle.LineColor = buttonPipelineColor.BackColor; line.Style = pipeLineStyle; } } catch (Exception ex) { Log.PublishTxt(ex); MessageBox.Show(ex.Message, "提示"); return; } } } globeControl1.Refresh(); return; }