From 7876390ec1eea11523fd1f6235d0872e9b209719 Mon Sep 17 00:00:00 2001 From: Joseph McCausland Date: Fri, 20 Mar 2015 10:25:12 -0400 Subject: [PATCH 1/7] Upgrade ArcGIS Runtime SDK for .NET from 10.2.4 to 10.2.5 --- source/MilitaryPlanner/MilitaryPlanner.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/MilitaryPlanner/MilitaryPlanner.csproj b/source/MilitaryPlanner/MilitaryPlanner.csproj index 56d4d4d..9c19bf5 100644 --- a/source/MilitaryPlanner/MilitaryPlanner.csproj +++ b/source/MilitaryPlanner/MilitaryPlanner.csproj @@ -68,7 +68,7 @@ true - + False From b97ec127b71e954ff39654f4af1fbb9d8cc997ef Mon Sep 17 00:00:00 2001 From: Joseph McCausland Date: Fri, 20 Mar 2015 10:30:28 -0400 Subject: [PATCH 2/7] Update readme file for ArcGIS Runtime SDK 10.2.5 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 569386c..5ca3c63 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ This is an Esri ArcGIS Runtime for .NET Application Prototype Template that can ## Requirements * Visual Studio 2012 or later -* ArcGIS Runtime SDK for .NET 10.2.4 (Basic License) +* ArcGIS Runtime SDK for .NET 10.2.5 (Basic License) * [ArcGIS Runtime for .NET Requirements](https://developers.arcgis.com/net/desktop/guide/system-requirements.htm) ## Instructions @@ -43,7 +43,7 @@ This is an Esri ArcGIS Runtime for .NET Application Prototype Template that can * Run or debug from Visual Studio * To run from a stand-alone deployment * A pre-built [application folder](./application) has been provided - * You may add the runtime deployment folder (ex. `arcgisruntime10.2.4`) to this folder to quickly create a runtime deployment (ex. `./application/arcgisruntime10.2.4`) + * You may add the runtime deployment folder (ex. `arcgisruntime10.2.5`) to this folder to quickly create a runtime deployment (ex. `./application/arcgisruntime10.2.5`) * Run MilitaryPlanner.exe from the deployment folder ## Resources From 173e32d365144265fdd363272e26757ea6b1c7ae Mon Sep 17 00:00:00 2001 From: Joseph McCausland Date: Mon, 23 Mar 2015 10:56:59 -0400 Subject: [PATCH 3/7] Update OOB with loaded units on Mission Load --- source/MilitaryPlanner/ViewModels/MapViewModel.cs | 5 +++++ .../ViewModels/SymbolTreeViewModel.cs | 12 +++++++++++- source/MilitaryPlanner/data/oob/oobexample.xml | 10 ++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/source/MilitaryPlanner/ViewModels/MapViewModel.cs b/source/MilitaryPlanner/ViewModels/MapViewModel.cs index bf4d769..016c1d8 100644 --- a/source/MilitaryPlanner/ViewModels/MapViewModel.cs +++ b/source/MilitaryPlanner/ViewModels/MapViewModel.cs @@ -354,6 +354,11 @@ private void InitializeMapWithMission() Mediator.NotifyColleagues(Constants.ACTION_MISSION_LOADED, _mission); OnCurrentPhaseIndexChanged(); + + foreach (var mm in _mission.MilitaryMessages) + { + Mediator.NotifyColleagues(Constants.ACTION_ITEM_WITH_GUID_ADDED, mm.Id); + } } private void DoSaveMission(object obj) diff --git a/source/MilitaryPlanner/ViewModels/SymbolTreeViewModel.cs b/source/MilitaryPlanner/ViewModels/SymbolTreeViewModel.cs index 0ea761a..037383c 100644 --- a/source/MilitaryPlanner/ViewModels/SymbolTreeViewModel.cs +++ b/source/MilitaryPlanner/ViewModels/SymbolTreeViewModel.cs @@ -91,6 +91,9 @@ public List Children [XmlElement] public string SIC { get { return _sic; } set { _sic = value; } } + [XmlElement] + public string Id { get; set; } + internal void Save(string filename) { XmlSerializer x = new XmlSerializer(GetType()); @@ -149,7 +152,14 @@ public SymbolTreeViewModel(SymbolViewModelWrapper symbolWrapper) private SymbolTreeViewModel(SymbolViewModelWrapper symbolWrapper, SymbolTreeViewModel parent) { - _guid = Guid.NewGuid().ToString("D"); + if (String.IsNullOrWhiteSpace(symbolWrapper.Id)) + { + _guid = Guid.NewGuid().ToString("D"); + } + else + { + _guid = symbolWrapper.Id; + } _symbolWrapper = symbolWrapper; _parent = parent; diff --git a/source/MilitaryPlanner/data/oob/oobexample.xml b/source/MilitaryPlanner/data/oob/oobexample.xml index c68f935..35c6396 100644 --- a/source/MilitaryPlanner/data/oob/oobexample.xml +++ b/source/MilitaryPlanner/data/oob/oobexample.xml @@ -3,29 +3,39 @@ SFGPUCIM------- + F408D083-22F0-4951-8B91-3BFE647E7161 SFGPUCIL------- + 958BD2B2-67CD-437A-BE66-BD0666F502F0 SFGPUCIC------- + B9E4169D-4BE1-4EAC-AE09-668645757FCE SFGPUCI-------- + 2C7EFAA0-4F2D-40AE-806F-3C7132F7CF72 SFGPEVAI------- + 397AC166-5E2A-437B-A7CB-CA175B0F5FC4 SFGPUCI-------- + CC64AA4D-F571-43C8-AA44-6B811D37E16D SFGPUCI-------- + E474A494-C259-4848-85F6-66B0B767AEAE SFGPUCI-------- + 98E6B2D6-FBA1-4D04-9B44-EDB480033C20 SFGPUCI-------- + CC5E1FA5-006F-40F4-AA13-CF6667C78BC9 SFGPUCI-------- + 5F83B50C-36EA-4729-B66C-2D844233A373 \ No newline at end of file From c87cde21a71a991dc84849dafdcb50b976ff6cde Mon Sep 17 00:00:00 2001 From: Joseph McCausland Date: Tue, 24 Mar 2015 13:18:00 -0400 Subject: [PATCH 4/7] Update routing to include option for from/to address --- .../Controllers/NetworkingToolController.cs | 77 ++++++++++++++++++- source/MilitaryPlanner/Helpers/Constants.cs | 2 + .../ViewModels/NetworkingToolViewModel.cs | 39 ++++++++++ .../Views/NetworkingToolView.xaml | 34 +++++++- 4 files changed, 144 insertions(+), 8 deletions(-) diff --git a/source/MilitaryPlanner/Controllers/NetworkingToolController.cs b/source/MilitaryPlanner/Controllers/NetworkingToolController.cs index 8fe9ee7..76040b5 100644 --- a/source/MilitaryPlanner/Controllers/NetworkingToolController.cs +++ b/source/MilitaryPlanner/Controllers/NetworkingToolController.cs @@ -22,9 +22,14 @@ using Esri.ArcGISRuntime.Layers; using Esri.ArcGISRuntime.Symbology; using Esri.ArcGISRuntime.Tasks.NetworkAnalyst; +using MilitaryPlanner.Helpers; using MilitaryPlanner.ViewModels; using MilitaryPlanner.Views; using MapView = Esri.ArcGISRuntime.Controls.MapView; +using Esri.ArcGISRuntime.Tasks.Geocoding; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; namespace MilitaryPlanner.Controllers { @@ -41,6 +46,11 @@ public class NetworkingToolController private readonly GraphicsOverlay _routesOverlay; private readonly GraphicsOverlay _directionsOverlay; + private const string OnlineLocatorUrl = "http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"; + + private LocatorServiceInfo _locatorServiceInfo; + private OnlineLocatorTask _locatorTask; + public NetworkingToolController(MapView mapView, MapViewModel mapViewModel) { this._mapView = mapView; @@ -77,6 +87,11 @@ public NetworkingToolController(MapView mapView, MapViewModel mapViewModel) _directionsOverlay = mapView.GraphicsOverlays["DirectionsOverlay"]; _routeTask = new OnlineRouteTask(new Uri(OnlineRoutingService)); + + Mediator.Register(Constants.ACTION_ROUTING_GET_DIRECTIONS, DoGetDirections); + + _locatorTask = new OnlineLocatorTask(new Uri(OnlineLocatorUrl)); + _locatorTask.AutoNormalize = true; } public void Toggle() @@ -101,7 +116,7 @@ private void Reset() private void mapView_MapViewTapped(object sender, MapViewInputEventArgs e) { - if (!_networkingToolView.ViewModel.IsToolOpen) + if (!_networkingToolView.ViewModel.IsToolOpen || _networkingToolView.addressExpander.IsExpanded == true) return; try @@ -124,16 +139,21 @@ private void mapView_MapViewTapped(object sender, MapViewInputEventArgs e) private async void mapView_MapViewDoubleTapped(object sender, MapViewInputEventArgs e) { - if (!_networkingToolView.ViewModel.IsToolOpen) + if (!_networkingToolView.ViewModel.IsToolOpen || _networkingToolView.addressExpander.IsExpanded == true) return; if (_stopsOverlay.Graphics.Count() < 2) return; + e.Handled = true; + + await RunRouting(); + } + + private async Task RunRouting() + { try { - e.Handled = true; - _networkingToolView.ViewModel.PanelResultsVisibility = Visibility.Collapsed; _networkingToolView.ViewModel.ProgressVisibility = Visibility.Visible; @@ -188,6 +208,8 @@ private async void mapView_MapViewDoubleTapped(object sender, MapViewInputEventA _networkingToolView.ViewModel.PanelResultsVisibility = Visibility.Visible; } } + + return 0; } void listDirections_SelectionChanged(object sender, SelectionChangedEventArgs e) @@ -235,5 +257,52 @@ private Graphic GraphicFromRouteDirection(RouteDirection rd) return graphic; } + private async void DoGetDirections(object obj) + { + if (String.IsNullOrWhiteSpace(_networkingToolView.fromAddress.Text) || + String.IsNullOrWhiteSpace(_networkingToolView.toAddress.Text)) + { + return; + } + + // geocode from and to address + if (_locatorServiceInfo == null) + _locatorServiceInfo = await _locatorTask.GetInfoAsync(); + + Reset(); + + // geocode from address + var candidateFromResults = await _locatorTask.GeocodeAsync( + GetInputAddressFromUI(_networkingToolView.fromAddress.Text), new List { "Addr_type", "Score", "X", "Y" }, _mapView.SpatialReference, CancellationToken.None); + + // geocode to address + var candidateToResults = await _locatorTask.GeocodeAsync( + GetInputAddressFromUI(_networkingToolView.toAddress.Text), new List { "Addr_type", "Score", "X", "Y" }, _mapView.SpatialReference, CancellationToken.None); + + if (candidateFromResults.Any() && candidateToResults.Any()) + { + var fromResult = candidateFromResults.First(); + var toResult = candidateToResults.First(); + + var fromMapPoint = fromResult.Extent.GetCenter(); + var toMapPoint = toResult.Extent.GetCenter(); + + _stopsOverlay.Graphics.Add(CreateStopGraphic(new MapPoint(fromMapPoint.X, fromMapPoint.Y, _mapView.SpatialReference), 1)); + _stopsOverlay.Graphics.Add(CreateStopGraphic(new MapPoint(toMapPoint.X, toMapPoint.Y, _mapView.SpatialReference), 2)); + + await RunRouting(); + } + + } + + private System.Collections.Generic.IDictionary GetInputAddressFromUI(string singleLineAddress) + { + Dictionary address = new Dictionary(); + + address[_locatorServiceInfo.SingleLineAddressField.FieldName] = singleLineAddress; + + return address; + + } } } diff --git a/source/MilitaryPlanner/Helpers/Constants.cs b/source/MilitaryPlanner/Helpers/Constants.cs index 35e12de..0956f91 100644 --- a/source/MilitaryPlanner/Helpers/Constants.cs +++ b/source/MilitaryPlanner/Helpers/Constants.cs @@ -52,6 +52,8 @@ static public class Constants public const string ACTION_UPDATE_BASEMAP = "ActionUpdateBasemap"; + public const string ACTION_ROUTING_GET_DIRECTIONS = "ActionRoutingGetDirections"; + public const int SAVE_AS_MISSION = 1; public const int SAVE_AS_GEOMESSAGES = 2; public const string SAVE_AS_DELIMITER = "::"; diff --git a/source/MilitaryPlanner/ViewModels/NetworkingToolViewModel.cs b/source/MilitaryPlanner/ViewModels/NetworkingToolViewModel.cs index 292682d..ad4d8d1 100644 --- a/source/MilitaryPlanner/ViewModels/NetworkingToolViewModel.cs +++ b/source/MilitaryPlanner/ViewModels/NetworkingToolViewModel.cs @@ -14,6 +14,7 @@ using System; using System.Windows; using Esri.ArcGISRuntime.Layers; +using MilitaryPlanner.Helpers; namespace MilitaryPlanner.ViewModels { @@ -21,7 +22,39 @@ public class NetworkingToolViewModel : BaseToolViewModel { public NetworkingToolViewModel() { + GetDirectionsCommand = new RelayCommand(OnGetDirectionsCommand); + } + + public RelayCommand GetDirectionsCommand { get; set; } + + private bool _addressIsExpanded = false; + + public bool AddressIsExpanded + { + get { return _addressIsExpanded;} + set + { + _addressIsExpanded = value; + RaisePropertyChanged(() => AddressIsExpanded); + RaisePropertyChanged(() => PanelInstructionsVisibility); + } + } + public Visibility _panelInstructionsVisibility = Visibility.Visible; + + public Visibility PanelInstructionsVisibility + { + get + { + if (AddressIsExpanded) + { + return Visibility.Collapsed; + } + else + { + return Visibility.Visible; + } + } } private string _routeTotals = String.Empty; @@ -83,5 +116,11 @@ public Visibility ProgressVisibility RaisePropertyChanged(() => ProgressVisibility); } } + + private void OnGetDirectionsCommand(object obj) + { + Mediator.NotifyColleagues(Constants.ACTION_ROUTING_GET_DIRECTIONS, null); + } + } } diff --git a/source/MilitaryPlanner/Views/NetworkingToolView.xaml b/source/MilitaryPlanner/Views/NetworkingToolView.xaml index 0e2450f..426be03 100644 --- a/source/MilitaryPlanner/Views/NetworkingToolView.xaml +++ b/source/MilitaryPlanner/Views/NetworkingToolView.xaml @@ -32,10 +32,36 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + +