using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using GeoScene.Globe; using GeoScene.Data; using GeoScene.Engine; namespace WorldGIS { public partial class changeModelPathDlg : Form { private GSOLayer layer; private string startStr = null; public changeModelPathDlg(GSOLayer _layer) { InitializeComponent(); this.layer = _layer; GSOFeatures fs = _layer.GetAllFeatures(); for (int i = 0; i < fs.Length; i++) { GSOFeature f = fs[i]; if (f != null && f.Geometry != null && f.Geometry.Type == EnumGeometryType.GeoModel) { GSOGeoModel model = f.Geometry as GSOGeoModel; //model.FilePath string[] strs = model.FilePath.Split(new char[] { '/' }); if (strs.Length == 1) { strs = model.FilePath.Split(new char[] { '\\' }); } string fName = strs[strs.Length - 1]; startStr = fName.Split( '-' )[0]; continue; } } if (startStr == null) { MessageBox.Show("图层不符合要求!"); this.Close(); } textBox1.Text = startStr; } private void button1_Click(object sender, EventArgs e) { GSOFeatures fs = layer.GetAllFeatures(); for (int i = 0; i < fs.Length; i++) { GSOFeature f = fs[i]; if (f != null && f.Geometry != null && f.Geometry.Type == EnumGeometryType.GeoModel) { GSOGeoModel model = f.Geometry as GSOGeoModel; //model.FilePath string[] strs = model.FilePath.Split(new char[] { '/' }); if (strs.Length == 1) { strs = model.FilePath.Split(new char[] { '\\' }); } string fName = strs[strs.Length - 1]; // startStr = fName.Split('-')[0]; //fName.Replace(textBox1.Text, textBox2.Text); string fn = ""; for (int j = 0; j < strs.Length - 1; j++) { fn += strs[j]; } fn += fName.Replace(textBox1.Text, textBox2.Text); model.FilePath = fn; } } this.Close(); } private void button2_Click(object sender, EventArgs e) { this.Close(); } } }