diff --git a/ImgGPS2KML.suo b/ImgGPS2KML.suo index a0c3bba..d21a5f3 100644 Binary files a/ImgGPS2KML.suo and b/ImgGPS2KML.suo differ diff --git a/ImgGPS2KML/MainWin.cs b/ImgGPS2KML/MainWin.cs index f8b97b0..927589d 100644 --- a/ImgGPS2KML/MainWin.cs +++ b/ImgGPS2KML/MainWin.cs @@ -15,17 +15,32 @@ namespace ImgGPS2KML { public partial class MainWin : Form { + private string init_directory; public MainWin() { InitializeComponent(); + this.init_directory = ""; } - private void putPlacemark(XmlTextWriter writer,string name, double longitude, double latitude) + private void addImgDescription(XmlTextWriter writer, List imgPaths)//添加图片注释 + { + writer.WriteStartElement("description"); + string img_html=""; + foreach (string path in imgPaths) + { + img_html += string.Format(@"", path.Replace(@"\",@"/")); + } + writer.WriteCData(img_html); + writer.WriteEndElement();//end of description + } + + private void putPlacemark(XmlTextWriter writer,string name, double longitude, double latitude,List imgPaths) { writer.WriteStartElement("Placemark"); writer.WriteStartElement("name"); writer.WriteString(name); writer.WriteEndElement();//end of name + addImgDescription(writer,imgPaths); writer.WriteStartElement("Style"); writer.WriteStartElement("IconStyle"); writer.WriteStartElement("Icon"); @@ -143,12 +158,17 @@ namespace ImgGPS2KML private void bt_add_directory(object sender, EventArgs e) { - this.dvDirectory.Rows.Clear(); CommonOpenFileDialog dialog = new CommonOpenFileDialog(); dialog.Multiselect = true; dialog.IsFolderPicker = true; + if (this.init_directory != "") + { + dialog.InitialDirectory = this.init_directory; + } if (dialog.ShowDialog() == CommonFileDialogResult.Ok) { + this.dvDirectory.Rows.Clear(); + this.init_directory = Path.GetDirectoryName(dialog.FileNames.ToList()[0]); foreach (String selectDir in dialog.FileNames) { string coordination_col_text; @@ -217,11 +237,13 @@ namespace ImgGPS2KML } double longitude; double latitude; + string dirPath; + dirPath = Convert.ToString(row.Cells[0].Value); string name; - name = Path.GetFileName(Convert.ToString(row.Cells[0].Value)); + name = Path.GetFileName(dirPath); longitude = Convert.ToDouble(Convert.ToString(row.Cells[1].Value).Split(',')[0]); latitude = Convert.ToDouble(Convert.ToString(row.Cells[1].Value).Split(',')[1]); - putPlacemark(writer, name, longitude, latitude); + putPlacemark(writer, name, longitude, latitude, searchJPG(dirPath)); } writer.WriteEndElement();//end of Document writer.WriteEndElement();//end of xml