From 089e2f670fd7d5616433c899e44565e98d5fb54e Mon Sep 17 00:00:00 2001 From: facat Date: Sun, 19 Jul 2020 10:21:16 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E4=B8=80=E6=AC=A1=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E3=80=82=E5=AE=8C=E6=88=90=E5=9F=BA=E6=9C=AC=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 5 + ImgGPS2KML.sln | 20 ++ ImgGPS2KML.suo | Bin 0 -> 16896 bytes ImgGPS2KML/ImgGPS2KML.csproj | 101 +++++++++ ImgGPS2KML/MainWin.Designer.cs | 155 +++++++++++++ ImgGPS2KML/MainWin.cs | 237 ++++++++++++++++++++ ImgGPS2KML/MainWin.resx | 141 ++++++++++++ ImgGPS2KML/Program.cs | 21 ++ ImgGPS2KML/Properties/AssemblyInfo.cs | 36 +++ ImgGPS2KML/Properties/Resources.Designer.cs | 71 ++++++ ImgGPS2KML/Properties/Resources.resx | 117 ++++++++++ ImgGPS2KML/Properties/Settings.Designer.cs | 30 +++ ImgGPS2KML/Properties/Settings.settings | 7 + 13 files changed, 941 insertions(+) create mode 100644 .gitignore create mode 100644 ImgGPS2KML.sln create mode 100644 ImgGPS2KML.suo create mode 100644 ImgGPS2KML/ImgGPS2KML.csproj create mode 100644 ImgGPS2KML/MainWin.Designer.cs create mode 100644 ImgGPS2KML/MainWin.cs create mode 100644 ImgGPS2KML/MainWin.resx create mode 100644 ImgGPS2KML/Program.cs create mode 100644 ImgGPS2KML/Properties/AssemblyInfo.cs create mode 100644 ImgGPS2KML/Properties/Resources.Designer.cs create mode 100644 ImgGPS2KML/Properties/Resources.resx create mode 100644 ImgGPS2KML/Properties/Settings.Designer.cs create mode 100644 ImgGPS2KML/Properties/Settings.settings diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8d87b71 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +bin +Packages +Windows API Code Pack 1.1 +obj +Windows API Code Pack 1.1.zip \ No newline at end of file diff --git a/ImgGPS2KML.sln b/ImgGPS2KML.sln new file mode 100644 index 0000000..42589b1 --- /dev/null +++ b/ImgGPS2KML.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImgGPS2KML", "ImgGPS2KML\ImgGPS2KML.csproj", "{1494F446-2E9D-4A5B-86B8-F0C140AE0169}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1494F446-2E9D-4A5B-86B8-F0C140AE0169}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1494F446-2E9D-4A5B-86B8-F0C140AE0169}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1494F446-2E9D-4A5B-86B8-F0C140AE0169}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1494F446-2E9D-4A5B-86B8-F0C140AE0169}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/ImgGPS2KML.suo b/ImgGPS2KML.suo new file mode 100644 index 0000000000000000000000000000000000000000..a0c3bba34cb353598d8f0f259d0bcab794eb2d9b GIT binary patch literal 16896 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 HMgj%^gXIQn literal 0 HcmV?d00001 diff --git a/ImgGPS2KML/ImgGPS2KML.csproj b/ImgGPS2KML/ImgGPS2KML.csproj new file mode 100644 index 0000000..d10a570 --- /dev/null +++ b/ImgGPS2KML/ImgGPS2KML.csproj @@ -0,0 +1,101 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {1494F446-2E9D-4A5B-86B8-F0C140AE0169} + WinExe + Properties + ImgGPS2KML + ImgGPS2KML + v3.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + False + ..\Packages\ExifLib\lib\net20\ExifLib.dll + + + False + Windows API Code Pack 1.1\binaries\Microsoft.WindowsAPICodePack.dll + + + False + Windows API Code Pack 1.1\binaries\Microsoft.WindowsAPICodePack.Shell.dll + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + Form + + + MainWin.cs + + + + + MainWin.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + \ No newline at end of file diff --git a/ImgGPS2KML/MainWin.Designer.cs b/ImgGPS2KML/MainWin.Designer.cs new file mode 100644 index 0000000..655995d --- /dev/null +++ b/ImgGPS2KML/MainWin.Designer.cs @@ -0,0 +1,155 @@ +namespace ImgGPS2KML +{ + partial class MainWin + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.btAddDirectory = new System.Windows.Forms.Button(); + this.btExportKML = new System.Windows.Forms.Button(); + this.dvDirectory = new System.Windows.Forms.DataGridView(); + this.directory = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.coordination = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.canExport = new System.Windows.Forms.DataGridViewCheckBoxColumn(); + this.menuStrip1 = new System.Windows.Forms.MenuStrip(); + this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.individuallyWritenBy杜孟远20207ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + ((System.ComponentModel.ISupportInitialize)(this.dvDirectory)).BeginInit(); + this.menuStrip1.SuspendLayout(); + this.SuspendLayout(); + // + // btAddDirectory + // + this.btAddDirectory.Location = new System.Drawing.Point(675, 27); + this.btAddDirectory.Name = "btAddDirectory"; + this.btAddDirectory.Size = new System.Drawing.Size(112, 23); + this.btAddDirectory.TabIndex = 0; + this.btAddDirectory.Text = "添加目录"; + this.btAddDirectory.UseVisualStyleBackColor = true; + this.btAddDirectory.Click += new System.EventHandler(this.bt_add_directory); + // + // btExportKML + // + this.btExportKML.Location = new System.Drawing.Point(675, 82); + this.btExportKML.Name = "btExportKML"; + this.btExportKML.Size = new System.Drawing.Size(112, 23); + this.btExportKML.TabIndex = 2; + this.btExportKML.Text = "导出kml"; + this.btExportKML.UseVisualStyleBackColor = true; + this.btExportKML.Click += new System.EventHandler(this.btExportKML_Click); + // + // dvDirectory + // + this.dvDirectory.AllowUserToAddRows = false; + this.dvDirectory.AllowUserToDeleteRows = false; + this.dvDirectory.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dvDirectory.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.directory, + this.coordination, + this.canExport}); + this.dvDirectory.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically; + this.dvDirectory.Location = new System.Drawing.Point(12, 27); + this.dvDirectory.Name = "dvDirectory"; + this.dvDirectory.RowTemplate.Height = 23; + this.dvDirectory.Size = new System.Drawing.Size(657, 492); + this.dvDirectory.TabIndex = 3; + // + // directory + // + this.directory.HeaderText = "文件夹"; + this.directory.Name = "directory"; + this.directory.Width = 450; + // + // coordination + // + this.coordination.HeaderText = "标签中心坐标"; + this.coordination.Name = "coordination"; + // + // canExport + // + this.canExport.HeaderText = "可导出"; + this.canExport.Name = "canExport"; + this.canExport.TrueValue = "1"; + this.canExport.Width = 50; + // + // menuStrip1 + // + this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.aboutToolStripMenuItem}); + this.menuStrip1.Location = new System.Drawing.Point(0, 0); + this.menuStrip1.Name = "menuStrip1"; + this.menuStrip1.Size = new System.Drawing.Size(820, 25); + this.menuStrip1.TabIndex = 4; + this.menuStrip1.Text = "menuStrip1"; + // + // aboutToolStripMenuItem + // + this.aboutToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.individuallyWritenBy杜孟远20207ToolStripMenuItem}); + this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem"; + this.aboutToolStripMenuItem.Size = new System.Drawing.Size(55, 21); + this.aboutToolStripMenuItem.Text = "About"; + // + // individuallyWritenBy杜孟远20207ToolStripMenuItem + // + this.individuallyWritenBy杜孟远20207ToolStripMenuItem.Name = "individuallyWritenBy杜孟远20207ToolStripMenuItem"; + this.individuallyWritenBy杜孟远20207ToolStripMenuItem.Size = new System.Drawing.Size(283, 22); + this.individuallyWritenBy杜孟远20207ToolStripMenuItem.Text = "Individually Writen By 杜孟远 2020.7"; + // + // MainWin + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(820, 562); + this.Controls.Add(this.dvDirectory); + this.Controls.Add(this.btExportKML); + this.Controls.Add(this.btAddDirectory); + this.Controls.Add(this.menuStrip1); + this.MainMenuStrip = this.menuStrip1; + this.Name = "MainWin"; + this.Text = "ImgGPS2KML"; + ((System.ComponentModel.ISupportInitialize)(this.dvDirectory)).EndInit(); + this.menuStrip1.ResumeLayout(false); + this.menuStrip1.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button btAddDirectory; + private System.Windows.Forms.Button btExportKML; + private System.Windows.Forms.DataGridView dvDirectory; + private System.Windows.Forms.DataGridViewTextBoxColumn directory; + private System.Windows.Forms.DataGridViewTextBoxColumn coordination; + private System.Windows.Forms.DataGridViewCheckBoxColumn canExport; + private System.Windows.Forms.MenuStrip menuStrip1; + private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem individuallyWritenBy杜孟远20207ToolStripMenuItem; + } +} + diff --git a/ImgGPS2KML/MainWin.cs b/ImgGPS2KML/MainWin.cs new file mode 100644 index 0000000..f8b97b0 --- /dev/null +++ b/ImgGPS2KML/MainWin.cs @@ -0,0 +1,237 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using System.Diagnostics; +using ExifLib; +using System.Xml; +using Microsoft.WindowsAPICodePack.Dialogs; +using System.IO; +namespace ImgGPS2KML +{ + public partial class MainWin : Form + { + public MainWin() + { + InitializeComponent(); + } + + private void putPlacemark(XmlTextWriter writer,string name, double longitude, double latitude) + { + writer.WriteStartElement("Placemark"); + writer.WriteStartElement("name"); + writer.WriteString(name); + writer.WriteEndElement();//end of name + writer.WriteStartElement("Style"); + writer.WriteStartElement("IconStyle"); + writer.WriteStartElement("Icon"); + writer.WriteStartElement("href"); + writer.WriteString("http://maps.google.com/mapfiles/kml/paddle/blu-blank.png"); + writer.WriteEndElement();//end of href + writer.WriteEndElement();//end of Icon + writer.WriteStartElement("color"); + writer.WriteString("ffffffff"); + writer.WriteEndElement();//end of color + writer.WriteStartElement("scale"); + writer.WriteString("1.0"); + writer.WriteEndElement();//end of scale + writer.WriteEndElement();//end of IconStyle + writer.WriteEndElement();//end of Style + writer.WriteStartElement("Point"); + writer.WriteStartElement("coordinates"); + writer.WriteString(String.Format("{0},{1},0", longitude, latitude)); + writer.WriteEndElement();//end of coordinates + writer.WriteEndElement();//end of Point + writer.WriteEndElement();//end of Placemark + } + + private double toDecimalUnit(double degree, double minute, double second)//把2度2分3秒这样的数据转换成2.3212这样的数据。 + { + return degree + minute / 60 + second / 3600; + } + + //private double distanceByLongNLat(double long1, double lat1, double long2, double lat2)//计算经纬度两点间距离 + //{ + // double a, b, R; + // R = 6378137;//地球半径 + // lat1 = lat1 * Math.PI / 180.0; + // lat2 = lat2 * Math.PI / 180.0; + // a = lat1 - lat2; + // b = (long1 - long2) * Math.PI / 180.0; + // double d; + // double sa2, sb2; + // sa2 = Math.sin(a / 2.0); + // sb2 = Math.sin(b / 2.0); + // d = 2 * R * Math.asin(Math.sqrt(sa2 * sa2 + Math.cos(lat1) * Math.cos(lat2) * sb2 * sb2)); + // return d; + //} + + private List extractCordinattionFromImg(List imgPaths)//获得所有图片的坐标 + { + List longitudNLatitude = new List();//第一个是经度,第二个是纬度 + foreach (string path in imgPaths) + { + try + { + using (ExifReader reader = new ExifReader(path)) + { + double[] longitude;//经度 + double[] latitude;//纬度 + reader.GetTagValue(ExifTags.GPSLongitude, out longitude); + reader.GetTagValue(ExifTags.GPSLatitude, out latitude); + if (longitude == null || latitude == null) + { + continue; + } + double decimalLongtitude; + decimalLongtitude = toDecimalUnit(longitude[0], longitude[1], longitude[2]); + double decimalLatitude; + decimalLatitude = toDecimalUnit(latitude[0], latitude[1], latitude[2]); + longitudNLatitude.Add(new double[] { decimalLongtitude, decimalLatitude }); + } + } + catch + { + + } + } + return longitudNLatitude; + + } + + double[] get_centroid(List cluster) + { + double x; + double y; + double z; + x = 0; + y = 0; + z = 0; + int coord_num = cluster.Count; + foreach (double[] coord in cluster) + { + double lon = coord[0] / 180 * Math.PI; + double lat = coord[1] / 180 * Math.PI; + x += Math.Cos(lat) * Math.Cos(lon); + y += Math.Cos(lat) * Math.Sin(lon); + z += Math.Sin(lat); + } + x /= coord_num; + y /= coord_num; + z /= coord_num; + return new double[] { Math.Atan2(y, x) * 180 / Math.PI, Math.Atan2(z, Math.Sqrt(x * x + y * y)) * 180 / Math.PI }; + } + + private List searchJPG(string sourceDir) + { + string[] allFiles = Directory.GetFiles(sourceDir); + List jpgFiles = new List(); + foreach (string file in allFiles) + { + if (Path.GetExtension(file).ToLower() == ".jpg") + { + jpgFiles.Add(file); + } + } + return jpgFiles; + + } + + private void bt_add_directory(object sender, EventArgs e) + { + this.dvDirectory.Rows.Clear(); + CommonOpenFileDialog dialog = new CommonOpenFileDialog(); + dialog.Multiselect = true; + dialog.IsFolderPicker = true; + if (dialog.ShowDialog() == CommonFileDialogResult.Ok) + { + foreach (String selectDir in dialog.FileNames) + { + string coordination_col_text; + bool canExport; + canExport = true; + List imgPaths = searchJPG(selectDir); + if (imgPaths.Count > 0) + { + List coordinationOfImg; + coordinationOfImg = extractCordinattionFromImg(imgPaths); + if (coordinationOfImg.Count > 0) + { + double[] centroid; + centroid = get_centroid(coordinationOfImg);//计算所有图片坐标的中心 + coordination_col_text = string.Format("{0},{1}", centroid[0], centroid[1]); + } + else + { + coordination_col_text = "图片中未找到坐标。"; + canExport = false; + } + } + else + { + coordination_col_text="未找到图片。"; + canExport = false; + } + this.dvDirectory.Rows.Add(new object[]{selectDir,coordination_col_text,canExport}); + + } + } + } + + private void btExportKML_Click(object sender, EventArgs e) + { + SaveFileDialog dialog = new SaveFileDialog(); + dialog.Filter = "kml file (*.kml)|*.kml"; + if (dialog.ShowDialog() == DialogResult.OK) + { + using (XmlTextWriter writer = new XmlTextWriter(dialog.FileName, Encoding.UTF8)) + { + writer.Formatting = Formatting.Indented; + writer.WriteStartDocument(); + writer.WriteStartElement("kml"); + writer.WriteStartAttribute("xmlns"); + writer.WriteString("http://www.opengis.net/kml/2.2"); + writer.WriteEndAttribute(); + writer.WriteStartAttribute("xmlns:gx"); + writer.WriteString("http://www.google.com/kml/ext/2.2"); + writer.WriteEndAttribute(); + writer.WriteStartAttribute("xmlns:atom"); + writer.WriteString("http://www.w3.org/2005/Atom"); + writer.WriteEndAttribute(); + writer.WriteStartElement("Document"); + writer.WriteStartElement("name"); + writer.WriteString("照片导出坐标"); + writer.WriteEndElement();//end of name + foreach (DataGridViewRow row in this.dvDirectory.Rows) + { + Int32 canExport; + DataGridViewCheckBoxCell checkBoxColum=row.Cells[2] as DataGridViewCheckBoxCell; + canExport =Convert.ToInt32(checkBoxColum.Value); + if (canExport !=1) + { + continue; + } + double longitude; + double latitude; + string name; + name = Path.GetFileName(Convert.ToString(row.Cells[0].Value)); + 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); + } + writer.WriteEndElement();//end of Document + writer.WriteEndElement();//end of xml + writer.WriteEndDocument(); + + } + MessageBox.Show("已导出"); + } + + + } + } +} diff --git a/ImgGPS2KML/MainWin.resx b/ImgGPS2KML/MainWin.resx new file mode 100644 index 0000000..2dfee3d --- /dev/null +++ b/ImgGPS2KML/MainWin.resx @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + True + + + True + + + True + + + True + + + 17, 17 + + \ No newline at end of file diff --git a/ImgGPS2KML/Program.cs b/ImgGPS2KML/Program.cs new file mode 100644 index 0000000..a618b95 --- /dev/null +++ b/ImgGPS2KML/Program.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Windows.Forms; + +namespace ImgGPS2KML +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new MainWin()); + } + } +} diff --git a/ImgGPS2KML/Properties/AssemblyInfo.cs b/ImgGPS2KML/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..be1da4a --- /dev/null +++ b/ImgGPS2KML/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ImgGPS2KML")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ImgGPS2KML")] +[assembly: AssemblyCopyright("Copyright © 2020")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("cf014ee2-c398-4d20-a317-4d89b74c3842")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/ImgGPS2KML/Properties/Resources.Designer.cs b/ImgGPS2KML/Properties/Resources.Designer.cs new file mode 100644 index 0000000..eb7653b --- /dev/null +++ b/ImgGPS2KML/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.8689 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace ImgGPS2KML.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ImgGPS2KML.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/ImgGPS2KML/Properties/Resources.resx b/ImgGPS2KML/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/ImgGPS2KML/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ImgGPS2KML/Properties/Settings.Designer.cs b/ImgGPS2KML/Properties/Settings.Designer.cs new file mode 100644 index 0000000..8941d58 --- /dev/null +++ b/ImgGPS2KML/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.8689 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace ImgGPS2KML.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/ImgGPS2KML/Properties/Settings.settings b/ImgGPS2KML/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/ImgGPS2KML/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + +