From 5b11af6c1304bb0323c3f153bc7e4af7f8864763 Mon Sep 17 00:00:00 2001 From: facat Date: Sun, 19 Jul 2020 18:18:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=9B=BE=E7=89=87=E6=8F=8F?= =?UTF-8?q?=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: facat --- ImgGPS2KML.suo | Bin 16896 -> 16896 bytes ImgGPS2KML/MainWin.cs | 30 ++++++++++++++++++++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/ImgGPS2KML.suo b/ImgGPS2KML.suo index a0c3bba34cb353598d8f0f259d0bcab794eb2d9b..d21a5f384ed9d1ab9e2a02d89920d739418a179b 100644 GIT binary patch delta 396 zcmZo@VQgq&+~C8)C^lJ*!y&-Hz#zfEz%coN zrNU$b7LLgWI9MiEu=+6aO}=TV4i<3`VA=eG)rW=S|NsC0rIFQ^aQSmGFflMNa3YI- z;R=}S!e=nKggbzPje&uI14(l87w!;d7I7qz$tC;&j3O}0HhbG zrGhBxh1YNfF)%P}1KGP-Q$(7DLx_QaK@>%e#Cc9eDFy}xeiTv33ml9L3=EPef>IY4 zx!~59NMB)MVMmdd3*ca3U|`@u7W^U?!Xkq#P$KU?*_qF9^A~x4IWVKd?g1mq!kS0z KnZL00+zD3RWLRnaMXT)h8RUa7=a(VA=eG)rW;X69WSSC$i`l zt^f`R1_lOpWWf^d0FM9v|NrMe65RZSJA|1<3`t~i34Z`156tGxU-$!<7+GN4$t6M; zID{A&7z9yt2(RJPU|?WKVqjnp*sLic&BDRYz`!7iqDJEUWM@9x$qkZ6CcAJOOfHeS zz$gwgc5{jJ6{g82Sac?r$OUjngN#Ae`$aAUA}Q}b`7n#&<}dR8a-57(3=9l>NXj;s S*garm@f4i?baRBm3Pu3`hG#1P 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