diff --git a/README.md b/README.md index 4838807..86fee67 100644 --- a/README.md +++ b/README.md @@ -23,17 +23,22 @@ Coordinate Conversion allows analysts to input and quickly convert coordinates b ## Requirements -### Devs +### Build Requirements * Visual Studio 2015 + * Important Note: Visual Studio 2013 is required if building on ArcGIS 10.3.1 +* ArcGIS for Desktop + * ArcMap 10.3.1+ + * ArcGIS Pro 2.1+ * ArcGIS Desktop SDK for .NET 10.3.1+ * [ArcGIS Desktop for .NET Requirements](https://desktop.arcgis.com/en/desktop/latest/get-started/system-requirements/arcobjects-sdk-system-requirements.htm) -* ArcGIS Pro 2.1+ SDK +* [ArcGIS Pro SDK](http://pro.arcgis.com/en/pro-app/sdk/) 2.1+ -### Users +### Run Requirements -* ArcGIS Desktop 10.3.1 - 10.6.1 -* ArcGIS Pro 2.1 - 2.2 +* ArcGIS for Desktop + * ArcMap 10.3.1+ + * ArcGIS Pro 2.1+ ## Instructions @@ -65,10 +70,9 @@ Coordinate Conversion allows analysts to input and quickly convert coordinates b * [Coordinate Conversion online documentation](http://solutions.arcgis.com/defense/help/coordinate-conversion/) * [Military Tools for ArcGIS](https://esri.github.io/military-tools-desktop-addins/) * [Military Tools for ArcGIS Solutions Pages](http://solutions.arcgis.com/defense/help/military-tools/) -* [ArcGIS for Defense Solutions Website](http://solutions.arcgis.com/defense) * [ArcGIS for Defense Downloads](http://appsforms.esri.com/products/download/#ArcGIS_for_Defense) * [ArcGIS Blog](http://blogs.esri.com/esri/arcgis/) -* [ArcGIS Solutions Website](http://solutions.arcgis.com/military/) +* [ArcGIS Solutions Website](http://solutions.arcgis.com/) ## Issues @@ -78,28 +82,17 @@ Find a bug or want to request a new feature? Please let us know by submitting a Anyone and everyone is welcome to contribute. Please see our [guidelines for contributing](https://github.com/esri/contributing). -### Repository Points of Contact - -#### Repository Owner: [Kevin](https://github.com/kgonzago) - -* Merge Pull Requests -* Creates Releases and Tags -* Manages Milestones -* Manages and Assigns Issues - -#### Secondary: [Lyle](https://github.com/topowright) - -* Backup when the owner is away +## Repository Points of Contact +Contact the [Military Tools team](mailto:defensesolutions@esri.com) ## Licensing - -Copyright 2015-2017 Esri +Copyright 2018 Esri Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. -You may obtain a copy of the License at +You may obtain a copy of the License at: - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -107,4 +100,5 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -A copy of the license is available in the repository's [license.txt](license.txt) file. +A copy of the license is available in the repository's [license.txt](./License.txt) file. + diff --git a/source/CoordinateConversion/ArcMapAddinCoordinateConversion/MainViewModel.cs b/source/CoordinateConversion/ArcMapAddinCoordinateConversion/MainViewModel.cs index 003bc73..64a094b 100644 --- a/source/CoordinateConversion/ArcMapAddinCoordinateConversion/MainViewModel.cs +++ b/source/CoordinateConversion/ArcMapAddinCoordinateConversion/MainViewModel.cs @@ -34,28 +34,5 @@ public MainViewModel() public CCConvertTabView ConvertTabView { get; set; } - object selectedTab = null; - public object SelectedTab - { - get { return selectedTab; } - set - { - if (selectedTab == value) - return; - - selectedTab = value; - var tabItem = selectedTab as TabItem; - if ((tabItem == null) || ((tabItem.Content == null) || - (tabItem.Content as UserControl).Content == null)) - return; - - Mediator.NotifyColleagues(Constants.TAB_ITEM_SELECTED, ((tabItem.Content as UserControl).Content as UserControl).DataContext); - //TODO let the other viewmodels determine what to do when tab selection changes - if (tabItem.Header.ToString() == CoordinateConversionLibrary.Properties.Resources.HeaderCollect) - Mediator.NotifyColleagues(CoordinateConversionLibrary.Constants.SetToolMode, MapPointToolMode.Collect); - else - Mediator.NotifyColleagues(CoordinateConversionLibrary.Constants.SetToolMode, MapPointToolMode.Convert); - } - } } } diff --git a/source/CoordinateConversion/ArcMapAddinCoordinateConversion/ViewModels/CollectTabViewModel.cs b/source/CoordinateConversion/ArcMapAddinCoordinateConversion/ViewModels/CollectTabViewModel.cs index cd14e7f..03b7ab8 100644 --- a/source/CoordinateConversion/ArcMapAddinCoordinateConversion/ViewModels/CollectTabViewModel.cs +++ b/source/CoordinateConversion/ArcMapAddinCoordinateConversion/ViewModels/CollectTabViewModel.cs @@ -377,13 +377,13 @@ private string PromptSaveFileDialog(string ext, string filter, string title) sfDlg = new SaveFileDialog(); sfDlg.AddExtension = true; sfDlg.CheckPathExists = true; - sfDlg.DefaultExt = ext; - sfDlg.Filter = filter; sfDlg.OverwritePrompt = true; - sfDlg.Title = title; - } + sfDlg.FileName = ""; + sfDlg.DefaultExt = ext; + sfDlg.Filter = filter; + sfDlg.Title = title; if (sfDlg.ShowDialog() == DialogResult.OK) { @@ -596,6 +596,8 @@ private void OnPasteCommand(object obj) var coordinates = new List(); foreach (var item in lines) { + if (item.Trim() == "") + continue; var sb = new StringBuilder(); sb.Append(item.Trim()); coordinates.Add(sb.ToString()); diff --git a/source/CoordinateConversion/CoordinateConversionLibrary/Helpers/Constants.cs b/source/CoordinateConversion/CoordinateConversionLibrary/Helpers/Constants.cs index 4cd7300..56f1f44 100644 --- a/source/CoordinateConversion/CoordinateConversionLibrary/Helpers/Constants.cs +++ b/source/CoordinateConversion/CoordinateConversionLibrary/Helpers/Constants.cs @@ -32,10 +32,8 @@ public class Constants public const string SetListBoxItemAddInPoint = "SET_LISTBOX_ITEM_ADDINPOINT"; public const string NewMapPointSelection = "NEW_MAP_POINT_SELECTION"; public const string SetCoordinateGetter = "SET_COORDINATE_GETTER"; - public const string SetToolMode = "SET_TOOL_MODE"; public const string NEW_MAP_POINT = "NEW_MAP_POINT"; public const string MOUSE_MOVE_POINT = "MOUSE_MOVE_POINT"; - public const string TAB_ITEM_SELECTED = "TAB_ITEM_SELECTED"; public const string IMPORT_COORDINATES = "IMPORT_COORDINATES"; public const string CollectListHasItems = "COLLECT_LIST_HAS_ITEMS"; } diff --git a/source/CoordinateConversion/CoordinateConversionLibrary/Helpers/ImportCSV.cs b/source/CoordinateConversion/CoordinateConversionLibrary/Helpers/ImportCSV.cs index cdca86e..356ae96 100644 --- a/source/CoordinateConversion/CoordinateConversionLibrary/Helpers/ImportCSV.cs +++ b/source/CoordinateConversion/CoordinateConversionLibrary/Helpers/ImportCSV.cs @@ -77,7 +77,7 @@ public static IEnumerable Import(Stream stream, string[] fieldNames) where List list = new List(); using (StreamReader reader = new StreamReader(stream)) { - string line = reader.ReadLine(); + string line = reader.ReadLine().Trim(); if (line.Contains("sep=")) line = reader.ReadLine(); if (string.IsNullOrEmpty(line)) diff --git a/source/CoordinateConversion/CoordinateConversionLibrary/Models/CoordinateBase.cs b/source/CoordinateConversion/CoordinateConversionLibrary/Models/CoordinateBase.cs index 81b0476..2dd808a 100644 --- a/source/CoordinateConversion/CoordinateConversionLibrary/Models/CoordinateBase.cs +++ b/source/CoordinateConversion/CoordinateConversionLibrary/Models/CoordinateBase.cs @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - ******************************************************************************/ + ******************************************************************************/ using CoordinateConversionLibrary.Views; using System; @@ -87,5 +87,42 @@ public virtual string ToString(string format, IFormatProvider formatProvider) return string.Empty; } + + public delegate void delShowAmbiguousEventHandler(object sender, AmbiguousEventArgs e); + public static event delShowAmbiguousEventHandler ShowAmbiguousEventHandler; + public static bool IsEventAttached { get; set; } + + public static void ShowAmbiguousEvent() + { + var handler = ShowAmbiguousEventHandler; + if (handler != null) + { + var eventArgs = new AmbiguousEventArgs() { IsEventHandled = true }; + handler(typeof(CoordinateBase), eventArgs); + IsEventAttached = true; + } + else + { + IsEventAttached = false; + } + } + + public static void ShowAmbiguousDialog() + { + CoordinateDD.ShowAmbiguousEvent(); + if (!CoordinateDD.IsEventAttached) + ambiguousCoordsViewDlg.ShowDialog(); + } + + } + public class AmbiguousEventArgs : EventArgs + { + private bool _isEventHandled; + + public bool IsEventHandled + { + get { return _isEventHandled; } + set { _isEventHandled = value; } + } } } diff --git a/source/CoordinateConversion/CoordinateConversionLibrary/Models/CoordinateDD.cs b/source/CoordinateConversion/CoordinateConversionLibrary/Models/CoordinateDD.cs index 6783eb9..e11b264 100644 --- a/source/CoordinateConversion/CoordinateConversionLibrary/Models/CoordinateDD.cs +++ b/source/CoordinateConversion/CoordinateConversionLibrary/Models/CoordinateDD.cs @@ -1,17 +1,17 @@ -/******************************************************************************* - * Copyright 2015 Esri - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. +/******************************************************************************* + * Copyright 2015 Esri + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. ******************************************************************************/ using CoordinateConversionLibrary.Views; @@ -114,10 +114,9 @@ public static bool TryParse(string input, out CoordinateDD coord, bool displayAm return false; if (latValue < 90 && longValue < 90) - ambiguousCoordsViewDlg.ShowDialog(); + ShowAmbiguousDialog(); } - - blnMatchDDLat = ambiguousCoordsViewDlg.CheckedLatLon; + blnMatchDDLat = CoordinateConversionLibraryConfig.AddInConfig.DisplayAmbiguousCoordsDlg; } // Lat/Lon diff --git a/source/CoordinateConversion/CoordinateConversionLibrary/Models/CoordinateDDM.cs b/source/CoordinateConversion/CoordinateConversionLibrary/Models/CoordinateDDM.cs index be45be1..7d9c679 100644 --- a/source/CoordinateConversion/CoordinateConversionLibrary/Models/CoordinateDDM.cs +++ b/source/CoordinateConversion/CoordinateConversionLibrary/Models/CoordinateDDM.cs @@ -101,7 +101,7 @@ public static bool TryParse(string input, out CoordinateDDM ddm, bool displayAmb return false; if (latValue < 90 && longValue < 90) - ambiguousCoordsViewDlg.ShowDialog(); + ShowAmbiguousDialog(); } blnMatchDDMLat = ambiguousCoordsViewDlg.CheckedLatLon; diff --git a/source/CoordinateConversion/CoordinateConversionLibrary/Models/CoordinateDMS.cs b/source/CoordinateConversion/CoordinateConversionLibrary/Models/CoordinateDMS.cs index 82b65be..c6b4181 100644 --- a/source/CoordinateConversion/CoordinateConversionLibrary/Models/CoordinateDMS.cs +++ b/source/CoordinateConversion/CoordinateConversionLibrary/Models/CoordinateDMS.cs @@ -12,103 +12,103 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - ******************************************************************************/ - -using CoordinateConversionLibrary.Views; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Text; -using System.Text.RegularExpressions; - -namespace CoordinateConversionLibrary.Models -{ - public class CoordinateDMS : CoordinateBase - { - public CoordinateDMS() { LatDegrees = 40; LatMinutes = 7; LatSeconds = 22.68; LonDegrees = -78; LonMinutes = 27; LonSeconds = 21.27; } - - public CoordinateDMS(int latd, int latm, double lats, int lond, int lonm, double lons) - { - LatDegrees = latd; - LatMinutes = latm; - LatSeconds = lats; - LonDegrees = lond; - LonMinutes = lonm; - LonSeconds = lons; - } - - public CoordinateDMS(CoordinateDD dd) - { - LatDegrees = (int)Math.Truncate(dd.Lat); - double latm = Math.Abs(dd.Lat - Math.Truncate(dd.Lat)) * 60.0; - LatMinutes = (int)Math.Truncate(latm); - LatSeconds = (latm - LatMinutes) * 60.0; - - LonDegrees = (int)Math.Truncate(dd.Lon); - double lonm = Math.Abs(dd.Lon - Math.Truncate(dd.Lon)) * 60.0; - LonMinutes = (int)Math.Truncate(lonm); - LonSeconds = (lonm - LonMinutes) * 60.0; - } - - #region Properties - - public int LatDegrees { get; set; } - - public int LatMinutes - { - get; - set; - } - - public double LatSeconds - { - get; - set; - } - public int LonDegrees - { - get; - set; - } - - public int LonMinutes - { - get; - set; - } - - public double LonSeconds - { - get; - set; - } - - #endregion Properties - - public static bool TryParse(string input, out CoordinateDMS dms, bool displayAmbiguousCoordsDlg = false) - { - dms = new CoordinateDMS(); - - if (string.IsNullOrWhiteSpace(input)) - return false; - - input = input.Trim(); - string numSep = System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator; - input = numSep != "." ? input.Replace(".", numSep) : input; - - Regex regexDMSLat = new Regex(@"^((?[\+\-NnSs])?(?[0-8]?\d|90)[°˚º^~*\s\-_]+(?[0-5]?\d|\d)['′\s\-_]+(?([0-5]?\d|\d)([.,:]\d*)?)[\u0022\u00A8\u02DD\s_]*(?[\+\-NnSs])?)([,:;\s|\/\\]+)((?[\+\-EeWw])?(?[0]?\d?\d|1[0-7]\d|180)[°˚º^~*\s\-_]+(?[0-5]\d|\d)['′\s\-_]+(?([0-5]?\d|\d)([.,:]\d*)?)[\u0022\u00A8\u02DD\s_]*(?[\+\-EeWw])?)[\s]*$"); - Regex regexDMSLon = new Regex(@"^((?[\+\-EeWw])?(?[0]?\d?\d|1[0-7]\d|180)[°˚º^~*\s\-_]+(?[0-5]\d|\d)['′\s\-_]+(?([0-5]?\d|\d)([.,:]\d*)?)[\u0022\u00A8\u02DD\s_]*(?[\+\-EeWw])?)([,:;\s|\/\\]+)((?[\+\-NnSs])?(?[0-8]?\d|90)[°˚º^~*\s\-_]+(?[0-5]?\d|\d)['′\s\-_]+(?([0-5]?\d|\d)([.,:]\d*)?)[\u0022\u00A8\u02DD\s_]*(?[\+\-NnSs])?)[\s]*$"); - - var matchDMSLat = regexDMSLat.Match(input); - var matchDMSLon = regexDMSLon.Match(input); - - bool blnMatchDMSLat = matchDMSLat.Success; - int LatDegrees = -1, LonDegrees = -1, LatMinutes = -1, LonMinutes = -1; - double LatSeconds = -1, LonSeconds = -1; - Group firstPrefix = null, firstSuffix = null, lastPrefix = null, lastSuffix = null; - - // Ambiguous coordinate, could be both lat/lon && lon/lat - if (matchDMSLat.Success && matchDMSLat.Length == input.Length && matchDMSLon.Success && matchDMSLon.Length == input.Length) + ******************************************************************************/ + +using CoordinateConversionLibrary.Views; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Text; +using System.Text.RegularExpressions; + +namespace CoordinateConversionLibrary.Models +{ + public class CoordinateDMS : CoordinateBase + { + public CoordinateDMS() { LatDegrees = 40; LatMinutes = 7; LatSeconds = 22.68; LonDegrees = -78; LonMinutes = 27; LonSeconds = 21.27; } + + public CoordinateDMS(int latd, int latm, double lats, int lond, int lonm, double lons) + { + LatDegrees = latd; + LatMinutes = latm; + LatSeconds = lats; + LonDegrees = lond; + LonMinutes = lonm; + LonSeconds = lons; + } + + public CoordinateDMS(CoordinateDD dd) + { + LatDegrees = (int)Math.Truncate(dd.Lat); + double latm = Math.Abs(dd.Lat - Math.Truncate(dd.Lat)) * 60.0; + LatMinutes = (int)Math.Truncate(latm); + LatSeconds = (latm - LatMinutes) * 60.0; + + LonDegrees = (int)Math.Truncate(dd.Lon); + double lonm = Math.Abs(dd.Lon - Math.Truncate(dd.Lon)) * 60.0; + LonMinutes = (int)Math.Truncate(lonm); + LonSeconds = (lonm - LonMinutes) * 60.0; + } + + #region Properties + + public int LatDegrees { get; set; } + + public int LatMinutes + { + get; + set; + } + + public double LatSeconds + { + get; + set; + } + public int LonDegrees + { + get; + set; + } + + public int LonMinutes + { + get; + set; + } + + public double LonSeconds + { + get; + set; + } + + #endregion Properties + + public static bool TryParse(string input, out CoordinateDMS dms, bool displayAmbiguousCoordsDlg = false) + { + dms = new CoordinateDMS(); + + if (string.IsNullOrWhiteSpace(input)) + return false; + + input = input.Trim(); + string numSep = System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator; + input = numSep != "." ? input.Replace(".", numSep) : input; + + Regex regexDMSLat = new Regex(@"^((?[\+\-NnSs])?(?[0-8]?\d|90)[°˚º^~*\s\-_]+(?[0-5]?\d|\d)['′\s\-_]+(?([0-5]?\d|\d)([.,:]\d*)?)[\u0022\u00A8\u02DD\s_]*(?[\+\-NnSs])?)([,:;\s|\/\\]+)((?[\+\-EeWw])?(?[0]?\d?\d|1[0-7]\d|180)[°˚º^~*\s\-_]+(?[0-5]\d|\d)['′\s\-_]+(?([0-5]?\d|\d)([.,:]\d*)?)[\u0022\u00A8\u02DD\s_]*(?[\+\-EeWw])?)[\s]*$"); + Regex regexDMSLon = new Regex(@"^((?[\+\-EeWw])?(?[0]?\d?\d|1[0-7]\d|180)[°˚º^~*\s\-_]+(?[0-5]\d|\d)['′\s\-_]+(?([0-5]?\d|\d)([.,:]\d*)?)[\u0022\u00A8\u02DD\s_]*(?[\+\-EeWw])?)([,:;\s|\/\\]+)((?[\+\-NnSs])?(?[0-8]?\d|90)[°˚º^~*\s\-_]+(?[0-5]?\d|\d)['′\s\-_]+(?([0-5]?\d|\d)([.,:]\d*)?)[\u0022\u00A8\u02DD\s_]*(?[\+\-NnSs])?)[\s]*$"); + + var matchDMSLat = regexDMSLat.Match(input); + var matchDMSLon = regexDMSLon.Match(input); + + bool blnMatchDMSLat = matchDMSLat.Success; + int LatDegrees = -1, LonDegrees = -1, LatMinutes = -1, LonMinutes = -1; + double LatSeconds = -1, LonSeconds = -1; + Group firstPrefix = null, firstSuffix = null, lastPrefix = null, lastSuffix = null; + + // Ambiguous coordinate, could be both lat/lon && lon/lat + if (matchDMSLat.Success && matchDMSLat.Length == input.Length && matchDMSLon.Success && matchDMSLon.Length == input.Length) { if (CoordinateConversionLibraryConfig.AddInConfig.DisplayAmbiguousCoordsDlg && displayAmbiguousCoordsDlg) { @@ -133,243 +133,243 @@ public static bool TryParse(string input, out CoordinateDMS dms, bool displayAmb return false; if (latValue < 90 && longValue < 90) - ambiguousCoordsViewDlg.ShowDialog(); - } - - blnMatchDMSLat = ambiguousCoordsViewDlg.CheckedLatLon; - } - - // Lat/Lon - if (matchDMSLat.Success && matchDMSLat.Length == input.Length && blnMatchDMSLat) - { - if (ValidateNumericCoordinateMatch(matchDMSLat, new string[] { "latitudeD", "latitudeM", "latitudeS", "longitudeD", "longitudeM", "longitudeS" })) - { - LatDegrees = int.Parse(matchDMSLat.Groups["latitudeD"].Value); - LatMinutes = int.Parse(matchDMSLat.Groups["latitudeM"].Value); - LatSeconds = double.Parse(matchDMSLat.Groups["latitudeS"].Value); - LonDegrees = int.Parse(matchDMSLat.Groups["longitudeD"].Value); - LonMinutes = int.Parse(matchDMSLat.Groups["longitudeM"].Value); - LonSeconds = double.Parse(matchDMSLat.Groups["longitudeS"].Value); - firstPrefix = matchDMSLat.Groups["firstPrefix"]; - firstSuffix = matchDMSLat.Groups["firstSuffix"]; - lastPrefix = matchDMSLat.Groups["lastPrefix"]; - lastSuffix = matchDMSLat.Groups["lastSuffix"]; - - blnMatchDMSLat = true; - } - else - return false; - } - // Lon/Lat - else if (matchDMSLon.Success && matchDMSLon.Length == input.Length) - { - if (ValidateNumericCoordinateMatch(matchDMSLon, new string[] { "latitudeD", "latitudeM", "latitudeS", "longitudeD", "longitudeM", "longitudeS" })) - { - LatDegrees = int.Parse(matchDMSLon.Groups["latitudeD"].Value); - LatMinutes = int.Parse(matchDMSLon.Groups["latitudeM"].Value); - LatSeconds = double.Parse(matchDMSLon.Groups["latitudeS"].Value); - LonDegrees = int.Parse(matchDMSLon.Groups["longitudeD"].Value); - LonMinutes = int.Parse(matchDMSLon.Groups["longitudeM"].Value); - LonSeconds = double.Parse(matchDMSLon.Groups["longitudeS"].Value); - firstPrefix = matchDMSLon.Groups["firstPrefix"]; - firstSuffix = matchDMSLon.Groups["firstSuffix"]; - lastPrefix = matchDMSLon.Groups["lastPrefix"]; - lastSuffix = matchDMSLon.Groups["lastSuffix"]; - } - else - return false; - } - else - return false; - - // Don't allow both prefix and suffix for lat or lon - if (firstPrefix.Success && firstSuffix.Success) - { - return false; - } - - if (lastPrefix.Success && lastSuffix.Success) - { - return false; - } - - if ((firstSuffix.Success || firstPrefix.Success) && (firstSuffix.Value.ToUpper().Equals("S") || firstPrefix.Value.ToUpper().Equals("S")) || - (lastSuffix.Success || lastPrefix.Success) && (lastSuffix.Value.ToUpper().Equals("S") || lastPrefix.Value.ToUpper().Equals("S"))) - { - LatDegrees = Math.Abs(LatDegrees) * -1; - } - - if ((firstSuffix.Success || firstPrefix.Success) && (firstSuffix.Value.ToUpper().Equals("W") || firstPrefix.Value.ToUpper().Equals("W")) || - (lastSuffix.Success || lastPrefix.Success) && (lastSuffix.Value.ToUpper().Equals("W") || lastPrefix.Value.ToUpper().Equals("W"))) - { - LonDegrees = Math.Abs(LonDegrees) * -1; - } - - if ((firstSuffix.Success || firstPrefix.Success) && (firstSuffix.Value.ToUpper().Equals("-") || firstPrefix.Value.ToUpper().Equals("-"))) - { - if (blnMatchDMSLat) - LatDegrees = Math.Abs(LatDegrees) * -1; - else - LonDegrees = Math.Abs(LonDegrees) * -1; - } - - if ((lastSuffix.Success || lastPrefix.Success) && (lastSuffix.Value.ToUpper().Equals("-") || lastPrefix.Value.ToUpper().Equals("-"))) - { - if (blnMatchDMSLat) - LonDegrees = Math.Abs(LonDegrees) * -1; - else - LatDegrees = Math.Abs(LatDegrees) * -1; - } - - dms = new CoordinateDMS(LatDegrees, LatMinutes, LatSeconds, LonDegrees, LonMinutes, LonSeconds); - - return true; - } - - public override string ToString(string format, IFormatProvider formatProvider) - { - var temp = base.ToString(format, formatProvider); - - if (!string.IsNullOrWhiteSpace(temp)) - return temp; - - var sb = new StringBuilder(); - - if (format == null) - format = "DMS"; - - NumberFormatInfo fi = NumberFormatInfo.InvariantInfo; - - switch (format.ToUpper()) - { - case "": - case "DMS": - sb.AppendFormat(fi, "{0}° {1}\' {2:#}\" {3}", Math.Abs(this.LatDegrees), this.LatMinutes, this.LatSeconds, this.LatDegrees < 0 ? "S" : "N"); - sb.AppendFormat(fi, " {0}° {1}\' {2:#}\" {3}", Math.Abs(this.LonDegrees), this.LonMinutes, this.LonSeconds, this.LonDegrees < 0 ? "W" : "E"); - break; - default: - throw new Exception("CoordinateDMS.ToString(): Invalid formatting string."); - } - - return sb.ToString(); - } - - } - - public class CoordinateDMSFormatter : CoordinateFormatterBase - { - public override string Format(string format, object arg, IFormatProvider formatProvider) - { - if (arg is CoordinateDMS) - { - if (string.IsNullOrWhiteSpace(format)) - { - return this.Format("A0°B0'C0.00\"N X0°Y0'Z0.00\"E", arg, this); - } - else - { - var coord = arg as CoordinateDMS; - double cnum = coord.LatDegrees; - var sb = new StringBuilder(); - var olist = new List(); - bool startIndexNeeded = false; - bool endIndexNeeded = false; - int currentIndex = 0; - - foreach (char c in format) - { - if (startIndexNeeded && (c == '#' || c == '.' || c == '0')) - { - // add {: - sb.AppendFormat("{{{0}:", currentIndex++); - startIndexNeeded = false; - endIndexNeeded = true; - } - - if (endIndexNeeded && (c != '#' && c != '.' && c != '0')) - { - sb.Append("}"); - endIndexNeeded = false; - } - - switch (c) - { - case 'A': - cnum = coord.LatDegrees; - olist.Add(Math.Abs(cnum)); - startIndexNeeded = true; - break; - case 'B': - cnum = coord.LatMinutes; - olist.Add(Math.Abs(cnum)); - startIndexNeeded = true; - break; - case 'C': - cnum = coord.LatSeconds; - olist.Add(Math.Abs(cnum)); - startIndexNeeded = true; - break; - case 'X': - cnum = coord.LonDegrees; - olist.Add(Math.Abs(cnum)); - startIndexNeeded = true; - break; - case 'Y': - cnum = coord.LonMinutes; - olist.Add(Math.Abs(cnum)); - startIndexNeeded = true; - break; - case 'Z': - cnum = coord.LonSeconds; - olist.Add(Math.Abs(cnum)); - startIndexNeeded = true; - break; - case '+': // show + or - - if (cnum > 0.0) - sb.Append("+"); - break; - case '-': - if (cnum < 0.0) - sb.Append("-"); - break; - case 'N': // N or S - case 'S': - if (coord.LatDegrees > 0) - sb.Append("N"); // do we always want UPPER - else - sb.Append("S"); - break; - case 'E': // E or W - case 'W': - if (coord.LonDegrees > 0) - sb.Append("E"); - else - sb.Append("W"); - break; - default: - sb.Append(c); - break; - } - } - - if (endIndexNeeded) - { - sb.Append("}"); - } - - return String.Format(sb.ToString(), olist.ToArray()); - - } - } - - if (arg is IFormattable) - { - return ((IFormattable)arg).ToString(format, formatProvider); - } - else - { - return arg.ToString(); - } - } - } -} + ShowAmbiguousDialog(); + } + + blnMatchDMSLat = ambiguousCoordsViewDlg.CheckedLatLon; + } + + // Lat/Lon + if (matchDMSLat.Success && matchDMSLat.Length == input.Length && blnMatchDMSLat) + { + if (ValidateNumericCoordinateMatch(matchDMSLat, new string[] { "latitudeD", "latitudeM", "latitudeS", "longitudeD", "longitudeM", "longitudeS" })) + { + LatDegrees = int.Parse(matchDMSLat.Groups["latitudeD"].Value); + LatMinutes = int.Parse(matchDMSLat.Groups["latitudeM"].Value); + LatSeconds = double.Parse(matchDMSLat.Groups["latitudeS"].Value); + LonDegrees = int.Parse(matchDMSLat.Groups["longitudeD"].Value); + LonMinutes = int.Parse(matchDMSLat.Groups["longitudeM"].Value); + LonSeconds = double.Parse(matchDMSLat.Groups["longitudeS"].Value); + firstPrefix = matchDMSLat.Groups["firstPrefix"]; + firstSuffix = matchDMSLat.Groups["firstSuffix"]; + lastPrefix = matchDMSLat.Groups["lastPrefix"]; + lastSuffix = matchDMSLat.Groups["lastSuffix"]; + + blnMatchDMSLat = true; + } + else + return false; + } + // Lon/Lat + else if (matchDMSLon.Success && matchDMSLon.Length == input.Length) + { + if (ValidateNumericCoordinateMatch(matchDMSLon, new string[] { "latitudeD", "latitudeM", "latitudeS", "longitudeD", "longitudeM", "longitudeS" })) + { + LatDegrees = int.Parse(matchDMSLon.Groups["latitudeD"].Value); + LatMinutes = int.Parse(matchDMSLon.Groups["latitudeM"].Value); + LatSeconds = double.Parse(matchDMSLon.Groups["latitudeS"].Value); + LonDegrees = int.Parse(matchDMSLon.Groups["longitudeD"].Value); + LonMinutes = int.Parse(matchDMSLon.Groups["longitudeM"].Value); + LonSeconds = double.Parse(matchDMSLon.Groups["longitudeS"].Value); + firstPrefix = matchDMSLon.Groups["firstPrefix"]; + firstSuffix = matchDMSLon.Groups["firstSuffix"]; + lastPrefix = matchDMSLon.Groups["lastPrefix"]; + lastSuffix = matchDMSLon.Groups["lastSuffix"]; + } + else + return false; + } + else + return false; + + // Don't allow both prefix and suffix for lat or lon + if (firstPrefix.Success && firstSuffix.Success) + { + return false; + } + + if (lastPrefix.Success && lastSuffix.Success) + { + return false; + } + + if ((firstSuffix.Success || firstPrefix.Success) && (firstSuffix.Value.ToUpper().Equals("S") || firstPrefix.Value.ToUpper().Equals("S")) || + (lastSuffix.Success || lastPrefix.Success) && (lastSuffix.Value.ToUpper().Equals("S") || lastPrefix.Value.ToUpper().Equals("S"))) + { + LatDegrees = Math.Abs(LatDegrees) * -1; + } + + if ((firstSuffix.Success || firstPrefix.Success) && (firstSuffix.Value.ToUpper().Equals("W") || firstPrefix.Value.ToUpper().Equals("W")) || + (lastSuffix.Success || lastPrefix.Success) && (lastSuffix.Value.ToUpper().Equals("W") || lastPrefix.Value.ToUpper().Equals("W"))) + { + LonDegrees = Math.Abs(LonDegrees) * -1; + } + + if ((firstSuffix.Success || firstPrefix.Success) && (firstSuffix.Value.ToUpper().Equals("-") || firstPrefix.Value.ToUpper().Equals("-"))) + { + if (blnMatchDMSLat) + LatDegrees = Math.Abs(LatDegrees) * -1; + else + LonDegrees = Math.Abs(LonDegrees) * -1; + } + + if ((lastSuffix.Success || lastPrefix.Success) && (lastSuffix.Value.ToUpper().Equals("-") || lastPrefix.Value.ToUpper().Equals("-"))) + { + if (blnMatchDMSLat) + LonDegrees = Math.Abs(LonDegrees) * -1; + else + LatDegrees = Math.Abs(LatDegrees) * -1; + } + + dms = new CoordinateDMS(LatDegrees, LatMinutes, LatSeconds, LonDegrees, LonMinutes, LonSeconds); + + return true; + } + + public override string ToString(string format, IFormatProvider formatProvider) + { + var temp = base.ToString(format, formatProvider); + + if (!string.IsNullOrWhiteSpace(temp)) + return temp; + + var sb = new StringBuilder(); + + if (format == null) + format = "DMS"; + + NumberFormatInfo fi = NumberFormatInfo.InvariantInfo; + + switch (format.ToUpper()) + { + case "": + case "DMS": + sb.AppendFormat(fi, "{0}° {1}\' {2:#}\" {3}", Math.Abs(this.LatDegrees), this.LatMinutes, this.LatSeconds, this.LatDegrees < 0 ? "S" : "N"); + sb.AppendFormat(fi, " {0}° {1}\' {2:#}\" {3}", Math.Abs(this.LonDegrees), this.LonMinutes, this.LonSeconds, this.LonDegrees < 0 ? "W" : "E"); + break; + default: + throw new Exception("CoordinateDMS.ToString(): Invalid formatting string."); + } + + return sb.ToString(); + } + + } + + public class CoordinateDMSFormatter : CoordinateFormatterBase + { + public override string Format(string format, object arg, IFormatProvider formatProvider) + { + if (arg is CoordinateDMS) + { + if (string.IsNullOrWhiteSpace(format)) + { + return this.Format("A0°B0'C0.00\"N X0°Y0'Z0.00\"E", arg, this); + } + else + { + var coord = arg as CoordinateDMS; + double cnum = coord.LatDegrees; + var sb = new StringBuilder(); + var olist = new List(); + bool startIndexNeeded = false; + bool endIndexNeeded = false; + int currentIndex = 0; + + foreach (char c in format) + { + if (startIndexNeeded && (c == '#' || c == '.' || c == '0')) + { + // add {: + sb.AppendFormat("{{{0}:", currentIndex++); + startIndexNeeded = false; + endIndexNeeded = true; + } + + if (endIndexNeeded && (c != '#' && c != '.' && c != '0')) + { + sb.Append("}"); + endIndexNeeded = false; + } + + switch (c) + { + case 'A': + cnum = coord.LatDegrees; + olist.Add(Math.Abs(cnum)); + startIndexNeeded = true; + break; + case 'B': + cnum = coord.LatMinutes; + olist.Add(Math.Abs(cnum)); + startIndexNeeded = true; + break; + case 'C': + cnum = coord.LatSeconds; + olist.Add(Math.Abs(cnum)); + startIndexNeeded = true; + break; + case 'X': + cnum = coord.LonDegrees; + olist.Add(Math.Abs(cnum)); + startIndexNeeded = true; + break; + case 'Y': + cnum = coord.LonMinutes; + olist.Add(Math.Abs(cnum)); + startIndexNeeded = true; + break; + case 'Z': + cnum = coord.LonSeconds; + olist.Add(Math.Abs(cnum)); + startIndexNeeded = true; + break; + case '+': // show + or - + if (cnum > 0.0) + sb.Append("+"); + break; + case '-': + if (cnum < 0.0) + sb.Append("-"); + break; + case 'N': // N or S + case 'S': + if (coord.LatDegrees > 0) + sb.Append("N"); // do we always want UPPER + else + sb.Append("S"); + break; + case 'E': // E or W + case 'W': + if (coord.LonDegrees > 0) + sb.Append("E"); + else + sb.Append("W"); + break; + default: + sb.Append(c); + break; + } + } + + if (endIndexNeeded) + { + sb.Append("}"); + } + + return String.Format(sb.ToString(), olist.ToArray()); + + } + } + + if (arg is IFormattable) + { + return ((IFormattable)arg).ToString(format, formatProvider); + } + else + { + return arg.ToString(); + } + } + } +} diff --git a/source/CoordinateConversion/CoordinateConversionLibrary/Properties/Resources.Designer.cs b/source/CoordinateConversion/CoordinateConversionLibrary/Properties/Resources.Designer.cs index 76fc9bd..d16d960 100644 --- a/source/CoordinateConversion/CoordinateConversionLibrary/Properties/Resources.Designer.cs +++ b/source/CoordinateConversion/CoordinateConversionLibrary/Properties/Resources.Designer.cs @@ -591,6 +591,15 @@ public class Resources { } } + /// + /// Looks up a localized string similar to Please wait while map loads.... + /// + public static string LoadMapMsg { + get { + return ResourceManager.GetString("LoadMapMsg", resourceCulture); + } + } + /// /// Looks up a localized string similar to Copy. /// @@ -627,6 +636,15 @@ public class Resources { } } + /// + /// Looks up a localized string similar to No data found.. + /// + public static string MsgNoDataFound { + get { + return ResourceManager.GetString("MsgNoDataFound", resourceCulture); + } + } + /// /// Looks up a localized string similar to You've selected a feature class that already exists. Do you wish to replace it?. /// diff --git a/source/CoordinateConversion/CoordinateConversionLibrary/Properties/Resources.resx b/source/CoordinateConversion/CoordinateConversionLibrary/Properties/Resources.resx index 9c0b96d..c236352 100644 --- a/source/CoordinateConversion/CoordinateConversionLibrary/Properties/Resources.resx +++ b/source/CoordinateConversion/CoordinateConversionLibrary/Properties/Resources.resx @@ -375,4 +375,10 @@ Choose location to create KMZ file + + Please wait while map loads... + + + No data found. + \ No newline at end of file diff --git a/source/CoordinateConversion/CoordinateConversionLibrary/ViewModels/TabBaseViewModel.cs b/source/CoordinateConversion/CoordinateConversionLibrary/ViewModels/TabBaseViewModel.cs index 7ba629c..4a68e69 100644 --- a/source/CoordinateConversion/CoordinateConversionLibrary/ViewModels/TabBaseViewModel.cs +++ b/source/CoordinateConversion/CoordinateConversionLibrary/ViewModels/TabBaseViewModel.cs @@ -31,7 +31,6 @@ public TabBaseViewModel() HasInputError = false; IsHistoryUpdate = true; IsToolGenerated = false; - ToolMode = MapPointToolMode.Unknown; // commands EditPropertiesDialogCommand = new RelayCommand(OnEditPropertiesDialogCommand); @@ -39,13 +38,6 @@ public TabBaseViewModel() Mediator.Register(CoordinateConversionLibrary.Constants.NEW_MAP_POINT, OnNewMapPointInternal); Mediator.Register(CoordinateConversionLibrary.Constants.MOUSE_MOVE_POINT, OnMouseMoveInternal); - Mediator.Register(CoordinateConversionLibrary.Constants.TAB_ITEM_SELECTED, OnTabItemSelected); - Mediator.Register(CoordinateConversionLibrary.Constants.SetToolMode, (mode) => - { - MapPointToolMode eMode = MapPointToolMode.Unknown; - Enum.TryParse(mode.ToString(), out eMode); - ToolMode = eMode; - }); configObserver = new PropertyObserver(CoordinateConversionLibraryConfig.AddInConfig) .RegisterHandler(n => n.DisplayCoordinateType, OnDisplayCoordinateTypeChanged); @@ -70,26 +62,6 @@ public bool HasInputError } } - public MapPointToolMode ToolMode { get; set; } - - private bool isActiveTab = true; - /// - /// Property to keep track of which tab/viewmodel is the active item - /// - public bool IsActiveTab - { - get - { - return isActiveTab; - } - set - { - //TODO do we need a reset? - //Reset(true); - isActiveTab = value; - RaisePropertyChanged(() => IsActiveTab); - } - } private string _inputCoordinate; public string InputCoordinate { @@ -137,16 +109,16 @@ public virtual void OnEditPropertiesDialogCommand(object obj) { if (e.Message.ToLower() == CoordinateConversionLibrary.Properties.Resources.CoordsOutOfBoundsMsg.ToLower()) { - System.Windows.Forms.MessageBox.Show(e.Message + System.Environment.NewLine + CoordinateConversionLibrary.Properties.Resources.CoordsOutOfBoundsAddlMsg, + System.Windows.Forms.MessageBox.Show(e.Message + System.Environment.NewLine + CoordinateConversionLibrary.Properties.Resources.CoordsOutOfBoundsAddlMsg, CoordinateConversionLibrary.Properties.Resources.CoordsoutOfBoundsCaption); } else { System.Windows.Forms.MessageBox.Show(e.Message); } - + } - + } public virtual void OnImportCSVFileCommand(object obj) @@ -167,13 +139,21 @@ public virtual void OnImportCSVFileCommand(object obj) using (Stream s = new FileStream(fileDialog.FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { var headers = ImportCSV.GetHeaders(s); - foreach (var header in headers) + if (headers != null) { - fieldVM.AvailableFields.Add(header); - System.Diagnostics.Debug.WriteLine("header : {0}", header); - } + foreach (var header in headers) + { + fieldVM.AvailableFields.Add(header); + System.Diagnostics.Debug.WriteLine("header : {0}", header); + } - dlg.DataContext = fieldVM; + dlg.DataContext = fieldVM; + } + else + { + System.Windows.Forms.MessageBox.Show(CoordinateConversionLibrary.Properties.Resources.MsgNoDataFound); + return; + } } if (dlg.ShowDialog() == true) { @@ -207,7 +187,7 @@ private void OnNewMapPointInternal(object obj) public virtual bool OnNewMapPoint(object obj) { - return IsActiveTab; + return true; } private void OnMouseMoveInternal(object obj) @@ -217,21 +197,9 @@ private void OnMouseMoveInternal(object obj) public virtual bool OnMouseMove(object obj) { - return IsActiveTab; + return true; } - /// - /// Handler for the tab item selected event - /// Helps keep track of which tab item/viewmodel is active - /// - /// bool if selected or not - private void OnTabItemSelected(object obj) - { - if (obj == null) - return; - - IsActiveTab = (obj == this); - } } public class ImportCoordinatesList diff --git a/source/CoordinateConversion/ProAppCoordConversionModule/CoordinateConversionDockpaneViewModel.cs b/source/CoordinateConversion/ProAppCoordConversionModule/CoordinateConversionDockpaneViewModel.cs index e1d1098..ea77f30 100644 --- a/source/CoordinateConversion/ProAppCoordConversionModule/CoordinateConversionDockpaneViewModel.cs +++ b/source/CoordinateConversion/ProAppCoordConversionModule/CoordinateConversionDockpaneViewModel.cs @@ -45,9 +45,6 @@ protected CoordinateConversionDockpaneViewModel() ConvertTabView = new CCConvertTabView(); ConvertTabView.DataContext = new ProConvertTabViewModel(); - CollectTabView = new CCCollectTabView(); - CollectTabView.DataContext = new ProCollectTabViewModel(); - MapSelectionChangedEvent.Subscribe(OnSelectionChanged); } @@ -59,28 +56,6 @@ protected CoordinateConversionDockpaneViewModel() private const string _dockPaneID = "ProAppCoordConversionModule_CoordinateConversionDockpane"; public CCConvertTabView ConvertTabView { get; set; } - public CCCollectTabView CollectTabView { get; set; } - - object selectedTab = null; - public object SelectedTab - { - get { return selectedTab; } - set - { - if (selectedTab == value) - return; - - selectedTab = value; - var tabItem = selectedTab as TabItem; - if(tabItem != null && tabItem.Content != null && ((tabItem.Content as UserControl).Content != null)) - Mediator.NotifyColleagues(CoordinateConversionLibrary.Constants.TAB_ITEM_SELECTED, ((tabItem.Content as UserControl).Content as UserControl).DataContext); - //TODO let the other viewmodels determine what to do when tab selection changes - if (tabItem.Header.ToString() == CoordinateConversionLibrary.Properties.Resources.HeaderCollect) - Mediator.NotifyColleagues(CoordinateConversionLibrary.Constants.SetToolMode, MapPointToolMode.Collect); - else - Mediator.NotifyColleagues(CoordinateConversionLibrary.Constants.SetToolMode, MapPointToolMode.Convert); - } - } /// /// Show the DockPane. diff --git a/source/CoordinateConversion/ProAppCoordConversionModule/ProAppCoordConversionModule.csproj b/source/CoordinateConversion/ProAppCoordConversionModule/ProAppCoordConversionModule.csproj index f2e7dd0..f7c397a 100644 --- a/source/CoordinateConversion/ProAppCoordConversionModule/ProAppCoordConversionModule.csproj +++ b/source/CoordinateConversion/ProAppCoordConversionModule/ProAppCoordConversionModule.csproj @@ -145,11 +145,15 @@ FlashEmbeddedControl.xaml + + + ProAmbiguousCoordsView.xaml + ProEditOutputCoordinateView.xaml @@ -183,6 +187,10 @@ Designer MSBuild:Compile + + MSBuild:Compile + Designer + Designer MSBuild:Compile @@ -251,12 +259,12 @@ - diff --git a/source/CoordinateConversion/ProAppCoordConversionModule/ViewModels/ProAmbiguousCoordsViewModel.cs b/source/CoordinateConversion/ProAppCoordConversionModule/ViewModels/ProAmbiguousCoordsViewModel.cs new file mode 100644 index 0000000..9bf8b87 --- /dev/null +++ b/source/CoordinateConversion/ProAppCoordConversionModule/ViewModels/ProAmbiguousCoordsViewModel.cs @@ -0,0 +1,61 @@ +using CoordinateConversionLibrary; +using CoordinateConversionLibrary.Helpers; +using CoordinateConversionLibrary.Models; +using CoordinateConversionLibrary.ViewModels; + +namespace ProAppCoordConversionModule.ViewModels +{ + public partial class ProAmbiguousCoordsViewModel : BaseViewModel + { + public ProAmbiguousCoordsViewModel() + { + SelectedCoordinateType = CoordinateConversionLibraryConfig.AddInConfig.DisplayCoordinateType; + DisplayAmbiguousCoordsDlg = CoordinateConversionLibraryConfig.AddInConfig.DisplayAmbiguousCoordsDlg; + CheckedLatLon = true; + OKButtonPressedCommand = new RelayCommand(OnOkButtonPressedCommand); + DontShowAgainCommand = new RelayCommand(OnDontShowAgainCommand); + } + + #region Properties + public CoordinateTypes SelectedCoordinateType { get; set; } + public bool DisplayAmbiguousCoordsDlg { get; set; } + public RelayCommand OKButtonPressedCommand { get; set; } + public RelayCommand DontShowAgainCommand { get; set; } + public bool IsDontShowAgainChecked { get; set; } + private bool? dialogResult = null; + public bool? DialogResult + { + get { return dialogResult; } + set + { + dialogResult = value; + RaisePropertyChanged(() => DialogResult); + } + } + private bool _checkedLatLon; + + public bool CheckedLatLon + { + get { return _checkedLatLon; } + set + { + _checkedLatLon = value; + RaisePropertyChanged(() => CheckedLatLon); + } + } + + #endregion + + #region Commands + private void OnOkButtonPressedCommand(object obj) + { + DialogResult = true; + } + + private void OnDontShowAgainCommand(object obj) + { + CoordinateConversionLibraryConfig.AddInConfig.DisplayAmbiguousCoordsDlg = !IsDontShowAgainChecked; + } + #endregion + } +} diff --git a/source/CoordinateConversion/ProAppCoordConversionModule/ViewModels/ProCollectTabViewModel.cs b/source/CoordinateConversion/ProAppCoordConversionModule/ViewModels/ProCollectTabViewModel.cs index 8cfa19a..c2bc0ca 100644 --- a/source/CoordinateConversion/ProAppCoordConversionModule/ViewModels/ProCollectTabViewModel.cs +++ b/source/CoordinateConversion/ProAppCoordConversionModule/ViewModels/ProCollectTabViewModel.cs @@ -409,6 +409,8 @@ private void OnPasteCommand(object obj) var coordinates = new List(); foreach (var item in lines) { + if (item.Trim() == "") + continue; var sb = new StringBuilder(); sb.Append(item.Trim()); coordinates.Add(sb.ToString()); @@ -421,6 +423,12 @@ private void OnPasteCommand(object obj) internal override void OnFlashPointCommandAsync(object obj) { + if (MapView.Active == null) + { + System.Windows.Forms.MessageBox.Show(CoordinateConversionLibrary.Properties.Resources.LoadMapMsg); + return; + } + if (ListBoxItemAddInPoint != null) { var geometry = ListBoxItemAddInPoint.Point; diff --git a/source/CoordinateConversion/ProAppCoordConversionModule/ViewModels/ProConvertTabViewModel.cs b/source/CoordinateConversion/ProAppCoordConversionModule/ViewModels/ProConvertTabViewModel.cs index b59d390..d6193e5 100644 --- a/source/CoordinateConversion/ProAppCoordConversionModule/ViewModels/ProConvertTabViewModel.cs +++ b/source/CoordinateConversion/ProAppCoordConversionModule/ViewModels/ProConvertTabViewModel.cs @@ -38,8 +38,6 @@ public ProConvertTabViewModel() CollectTabView.DataContext = new ProCollectTabViewModel(); InputCoordinateHistoryList = new ObservableCollection(); - - IsActiveTab = true; } public InputCoordinateConversionView InputCCView { get; set; } @@ -76,6 +74,12 @@ public override bool OnNewMapPoint(object obj) internal override async void OnFlashPointCommandAsync(object obj) { + if (MapView.Active == null) + { + System.Windows.Forms.MessageBox.Show(CoordinateConversionLibrary.Properties.Resources.LoadMapMsg); + return; + } + // Don't allow updating of the inputs or outputs while flashpoint is happening CoordinateMapTool.AllowUpdates = false; diff --git a/source/CoordinateConversion/ProAppCoordConversionModule/ViewModels/ProTabBaseViewModel.cs b/source/CoordinateConversion/ProAppCoordConversionModule/ViewModels/ProTabBaseViewModel.cs index 03fe532..2cf4c59 100644 --- a/source/CoordinateConversion/ProAppCoordConversionModule/ViewModels/ProTabBaseViewModel.cs +++ b/source/CoordinateConversion/ProAppCoordConversionModule/ViewModels/ProTabBaseViewModel.cs @@ -30,6 +30,7 @@ using System.IO; using System.Text; using System.Linq; +using ProAppCoordConversionModule.Views; namespace ProAppCoordConversionModule.ViewModels { @@ -326,13 +327,21 @@ public override void OnImportCSVFileCommand(object obj) using (Stream s = new FileStream(fileDialog.FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { var headers = ImportCSV.GetHeaders(s); - foreach (var header in headers) + if (headers != null) { - fieldVM.AvailableFields.Add(header); - System.Diagnostics.Debug.WriteLine("header : {0}", header); - } + foreach (var header in headers) + { + fieldVM.AvailableFields.Add(header); + System.Diagnostics.Debug.WriteLine("header : {0}", header); + } - dlg.DataContext = fieldVM; + dlg.DataContext = fieldVM; + } + else + { + System.Windows.Forms.MessageBox.Show(CoordinateConversionLibrary.Properties.Resources.MsgNoDataFound); + return; + } } if (dlg.ShowDialog() == true) { @@ -646,6 +655,7 @@ private async Task GetCoordinateType(string input) // DD CoordinateDD dd; + CoordinateDD.ShowAmbiguousEventHandler += ShowAmbiguousEventHandler; if (CoordinateDD.TryParse(input, out dd, true)) { if (dd.Lat > 90 || dd.Lat < -90 || dd.Lon > 180 || dd.Lon < -180) @@ -785,6 +795,16 @@ private async Task GetCoordinateType(string input) return new CCCoordinate() { Type = CoordinateType.Unknown, Point = null }; } + public static void ShowAmbiguousEventHandler(object sender, AmbiguousEventArgs e) + { + if (e.IsEventHandled) + { + var ambiguous = new ProAmbiguousCoordsView(); + ambiguous.DataContext = new ProAmbiguousCoordsViewModel(); + ambiguous.ShowDialog(); + e.IsEventHandled = false; + } + } #endregion Private Methods } diff --git a/source/CoordinateConversion/ProAppCoordConversionModule/Views/ProAmbiguousCoordsView.xaml b/source/CoordinateConversion/ProAppCoordConversionModule/Views/ProAmbiguousCoordsView.xaml new file mode 100644 index 0000000..05c8bcb --- /dev/null +++ b/source/CoordinateConversion/ProAppCoordConversionModule/Views/ProAmbiguousCoordsView.xaml @@ -0,0 +1,46 @@ + + + + + + + + + + +