parent
089e2f670f
commit
5b11af6c13
BIN
ImgGPS2KML.suo
BIN
ImgGPS2KML.suo
Binary file not shown.
|
|
@ -15,17 +15,32 @@ namespace ImgGPS2KML
|
||||||
{
|
{
|
||||||
public partial class MainWin : Form
|
public partial class MainWin : Form
|
||||||
{
|
{
|
||||||
|
private string init_directory;
|
||||||
public MainWin()
|
public MainWin()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
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("Placemark");
|
||||||
writer.WriteStartElement("name");
|
writer.WriteStartElement("name");
|
||||||
writer.WriteString(name);
|
writer.WriteString(name);
|
||||||
writer.WriteEndElement();//end of name
|
writer.WriteEndElement();//end of name
|
||||||
|
addImgDescription(writer,imgPaths);
|
||||||
writer.WriteStartElement("Style");
|
writer.WriteStartElement("Style");
|
||||||
writer.WriteStartElement("IconStyle");
|
writer.WriteStartElement("IconStyle");
|
||||||
writer.WriteStartElement("Icon");
|
writer.WriteStartElement("Icon");
|
||||||
|
|
@ -143,12 +158,17 @@ namespace ImgGPS2KML
|
||||||
|
|
||||||
private void bt_add_directory(object sender, EventArgs e)
|
private void bt_add_directory(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
this.dvDirectory.Rows.Clear();
|
|
||||||
CommonOpenFileDialog dialog = new CommonOpenFileDialog();
|
CommonOpenFileDialog dialog = new CommonOpenFileDialog();
|
||||||
dialog.Multiselect = true;
|
dialog.Multiselect = true;
|
||||||
dialog.IsFolderPicker = true;
|
dialog.IsFolderPicker = true;
|
||||||
|
if (this.init_directory != "")
|
||||||
|
{
|
||||||
|
dialog.InitialDirectory = this.init_directory;
|
||||||
|
}
|
||||||
if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
|
if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
|
||||||
{
|
{
|
||||||
|
this.dvDirectory.Rows.Clear();
|
||||||
|
this.init_directory = Path.GetDirectoryName(dialog.FileNames.ToList()[0]);
|
||||||
foreach (String selectDir in dialog.FileNames)
|
foreach (String selectDir in dialog.FileNames)
|
||||||
{
|
{
|
||||||
string coordination_col_text;
|
string coordination_col_text;
|
||||||
|
|
@ -217,11 +237,13 @@ namespace ImgGPS2KML
|
||||||
}
|
}
|
||||||
double longitude;
|
double longitude;
|
||||||
double latitude;
|
double latitude;
|
||||||
|
string dirPath;
|
||||||
|
dirPath = Convert.ToString(row.Cells[0].Value);
|
||||||
string name;
|
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]);
|
longitude = Convert.ToDouble(Convert.ToString(row.Cells[1].Value).Split(',')[0]);
|
||||||
latitude = Convert.ToDouble(Convert.ToString(row.Cells[1].Value).Split(',')[1]);
|
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 Document
|
||||||
writer.WriteEndElement();//end of xml
|
writer.WriteEndElement();//end of xml
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue