添加图片描述

Signed-off-by: facat <facat@facat.com>
This commit is contained in:
facat 2020-07-19 18:18:16 +08:00
parent 089e2f670f
commit 5b11af6c13
2 changed files with 26 additions and 4 deletions

Binary file not shown.

View File

@ -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<string> imgPaths)//添加图片注释
{
writer.WriteStartElement("description");
string img_html="";
foreach (string path in imgPaths)
{
img_html += string.Format(@"<img style='max-width:500px;' src='file:///{0}'>", path.Replace(@"\",@"/"));
}
writer.WriteCData(img_html);
writer.WriteEndElement();//end of description
}
private void putPlacemark(XmlTextWriter writer,string name, double longitude, double latitude,List<string> 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