diff --git a/ExtLibs/Utilities/srtm.cs b/ExtLibs/Utilities/srtm.cs index 36cab57a54..378c57cb35 100644 --- a/ExtLibs/Utilities/srtm.cs +++ b/ExtLibs/Utilities/srtm.cs @@ -9,6 +9,7 @@ using System.Net.Http; using System.Threading.Tasks; using log4net; +using GMap.NET; namespace MissionPlanner.Utilities { @@ -388,16 +389,18 @@ public static altresponce getAltitude(double lat, double lng, double zoom = 16) if (!Directory.Exists(datadirectory)) Directory.CreateDirectory(datadirectory); - lock (objlock) + if (GMaps.Instance.Mode != AccessMode.CacheOnly) { - if (!queue.Contains(filename)) + lock (objlock) { - log.Info("Getting " + filename); - queue.Add(filename); - requestSemaphore.Release(); + if (!queue.Contains(filename)) + { + log.Info("Getting " + filename); + queue.Add(filename); + requestSemaphore.Release(); + } } } - } } } diff --git a/GCSViews/ConfigurationView/ConfigPlanner.Designer.cs b/GCSViews/ConfigurationView/ConfigPlanner.Designer.cs index 73944d11d8..95b1e50c50 100644 --- a/GCSViews/ConfigurationView/ConfigPlanner.Designer.cs +++ b/GCSViews/ConfigurationView/ConfigPlanner.Designer.cs @@ -119,6 +119,9 @@ private void InitializeComponent() this.num_linelength = new System.Windows.Forms.NumericUpDown(); this.label11 = new System.Windows.Forms.Label(); this.chk_displaytooltip = new System.Windows.Forms.CheckBox(); + this.CMB_mapCache = new System.Windows.Forms.ComboBox(); + this.label13 = new System.Windows.Forms.Label(); + this.BUT_mapCacheDir = new MissionPlanner.Controls.MyButton(); ((System.ComponentModel.ISupportInitialize)(this.NUM_tracklength)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.num_gcsid)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.num_linelength)).BeginInit(); @@ -859,6 +862,26 @@ private void InitializeComponent() this.chk_displaytooltip.UseVisualStyleBackColor = true; this.chk_displaytooltip.CheckedChanged += new System.EventHandler(this.chk_displaytooltip_CheckedChanged); // + // CMB_mapCache + // + this.CMB_mapCache.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.CMB_mapCache.FormattingEnabled = true; + resources.ApplyResources(this.CMB_mapCache, "CMB_mapCache"); + this.CMB_mapCache.Name = "CMB_mapCache"; + this.CMB_mapCache.SelectedIndexChanged += new System.EventHandler(this.CMB_mapCache_SelectedIndexChanged); + // + // label13 + // + resources.ApplyResources(this.label13, "label13"); + this.label13.Name = "label13"; + // + // BUT_mapCacheDir + // + resources.ApplyResources(this.BUT_mapCacheDir, "BUT_mapCacheDir"); + this.BUT_mapCacheDir.Name = "BUT_mapCacheDir"; + this.BUT_mapCacheDir.UseVisualStyleBackColor = true; + this.BUT_mapCacheDir.Click += new System.EventHandler(this.BUT_mapCacheDir_Click); + // // ConfigPlanner // resources.ApplyResources(this, "$this"); @@ -952,6 +975,9 @@ private void InitializeComponent() this.Controls.Add(this.BUT_Joystick); this.Controls.Add(this.BUT_videostop); this.Controls.Add(this.BUT_videostart); + this.Controls.Add(this.label13); + this.Controls.Add(this.CMB_mapCache); + this.Controls.Add(this.BUT_mapCacheDir); this.Name = "ConfigPlanner"; this.Load += new System.EventHandler(this.ConfigPlanner_Load); ((System.ComponentModel.ISupportInitialize)(this.NUM_tracklength)).EndInit(); @@ -1054,5 +1080,8 @@ private void InitializeComponent() private System.Windows.Forms.NumericUpDown num_linelength; private System.Windows.Forms.Label label11; private System.Windows.Forms.CheckBox chk_displaytooltip; + private System.Windows.Forms.Label label13; + public System.Windows.Forms.ComboBox CMB_mapCache; + private Controls.MyButton BUT_mapCacheDir; } } diff --git a/GCSViews/ConfigurationView/ConfigPlanner.cs b/GCSViews/ConfigurationView/ConfigPlanner.cs index c0f2f23694..4e94adec6b 100644 --- a/GCSViews/ConfigurationView/ConfigPlanner.cs +++ b/GCSViews/ConfigurationView/ConfigPlanner.cs @@ -1,9 +1,11 @@ using DirectShowLib; using MissionPlanner.Controls; using MissionPlanner.Joystick; +using MissionPlanner.Maps; using MissionPlanner.Utilities; using System; using System.Collections.Generic; +using System.Diagnostics; using System.Drawing; using System.Globalization; using System.IO; @@ -240,6 +242,15 @@ public void Activate() chk_displaytooltip.Checked = Settings.Instance.GetString("mapicondesc", "") != ""; num_linelength.Value = Settings.Instance.GetInt32("GMapMarkerBase_Length", 500); + CMB_mapCache.DataSource = Enum.GetNames(typeof(GMap.NET.AccessMode)); + try + { + CMB_mapCache.SelectedIndex = CMB_mapCache.Items.IndexOf(Settings.Instance["mapCache"] ?? GMap.NET.GMaps.Instance.Mode.ToString()); + } + catch + { + } + startup = false; } @@ -1125,5 +1136,38 @@ private void cmb_secondarydisplaystyle_SelectedIndexChanged(object sender, Event Maps.GMapMarkerBase.InactiveDisplayStyle = Maps.GMapMarkerBase.InactiveDisplayStyleEnum.Normal; } } + + private void CMB_mapCache_SelectedIndexChanged(object sender, EventArgs e) + { + if (startup) + return; + Settings.Instance["mapCache"] = CMB_mapCache.Text; + GMap.NET.GMaps.Instance.Mode = (GMap.NET.AccessMode)Enum.Parse(typeof(GMap.NET.AccessMode), Settings.Instance["mapCache"].ToString()); + } + + private void BUT_mapCacheDir_Click(object sender, EventArgs e) + { + try + { + string folderPath = MyImageCache.Instance.CacheLocation; + if (Directory.Exists(folderPath)) + { + ProcessStartInfo startInfo = new ProcessStartInfo + { + Arguments = folderPath, + FileName = "explorer.exe" + }; + + Process.Start(startInfo); + } + else + { + MessageBox.Show(string.Format("{0} Directory does not exist!", folderPath)); + } + } + catch (Exception) + { + } + } } } \ No newline at end of file diff --git a/GCSViews/ConfigurationView/ConfigPlanner.resx b/GCSViews/ConfigurationView/ConfigPlanner.resx index 35cdefd52e..14d68da1d4 100644 --- a/GCSViews/ConfigurationView/ConfigPlanner.resx +++ b/GCSViews/ConfigurationView/ConfigPlanner.resx @@ -256,7 +256,7 @@ NOTE: Set the low level of SEVERITY to speak - 949, 643 + 949, 693 50 @@ -2835,11 +2835,86 @@ 0 + + + 107, 653 + + + 138, 21 + + + 127 + + + CMB_mapCache + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 80 + + + True + + + NoControl + + + 9, 656 + + + 96, 13 + + + 50 + + + Map Access Mode + + + label13 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 79 + + + NoControl + + + 251, 653 + + + 94, 21 + + + 95 + + + Open Map Cache + + + BUT_mapCacheDir + + + MissionPlanner.Controls.MyButton, MissionPlanner.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + $this + + + 81 True - - zh-TW - diff --git a/Program.cs b/Program.cs index d8d4dc6127..b1fdfd988e 100644 --- a/Program.cs +++ b/Program.cs @@ -316,6 +316,11 @@ public static void Start(string[] args) Console.WriteLine("Setup GMaps 1"); // set the cache provider to my custom version GMap.NET.GMaps.Instance.PrimaryCache = new Maps.MyImageCache(); + if (Settings.Instance["mapCache"] != null) + { + GMap.NET.GMaps.Instance.Mode = (GMap.NET.AccessMode)Enum.Parse(typeof(GMap.NET.AccessMode), Settings.Instance["mapCache"].ToString()); + log.Info("Map access mode set to : " + GMap.NET.GMaps.Instance.Mode.ToString()); + } Console.WriteLine("Setup GMaps 2"); // add my custom map providers GMap.NET.MapProviders.GMapProviders.List.Add(Maps.WMSProvider.Instance);