Skip to content
This repository has been archived by the owner on Aug 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #56 from jmccausland/master
Browse files Browse the repository at this point in the history
Request for 10.2.5 upgrade
  • Loading branch information
Gary Sheppard committed Mar 27, 2015
2 parents 74e844b + 31f67f0 commit bdb5972
Show file tree
Hide file tree
Showing 14 changed files with 448 additions and 122 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Binary file modified application/Esri.ArcGISRuntime.dll
Binary file not shown.
212 changes: 179 additions & 33 deletions application/Esri.ArcGISRuntime.xml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions application/MilitaryPlanner.application
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
<framework targetVersion="4.5" profile="Full" supportedRuntime="4.0.30319" />
</compatibleFrameworks>
<dependency>
<dependentAssembly dependencyType="install" codebase="MilitaryPlanner.exe.manifest" size="50189">
<dependentAssembly dependencyType="install" codebase="MilitaryPlanner.exe.manifest" size="50192">
<assemblyIdentity name="MilitaryPlanner.exe" version="1.0.0.2" publicKeyToken="0000000000000000" language="neutral" processorArchitecture="x86" type="win32" />
<hash>
<dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>EMBPjPlzoXVeFky1SyVEP4NsgoCr3m+Xv+PAJDb8xcU=</dsig:DigestValue>
<dsig:DigestValue>V6nKFNl6WhF3Y+4ekYaFrC8GMzk6cLsmJl3EmqJBjVY=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>
Expand Down
Binary file modified application/MilitaryPlanner.exe
Binary file not shown.
146 changes: 73 additions & 73 deletions application/MilitaryPlanner.exe.manifest

Large diffs are not rendered by default.

74 changes: 70 additions & 4 deletions source/MilitaryPlanner/Controllers/NetworkingToolController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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;
Expand Down Expand Up @@ -77,6 +87,10 @@ 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)) {AutoNormalize = true};
}

public void Toggle()
Expand All @@ -101,7 +115,7 @@ private void Reset()

private void mapView_MapViewTapped(object sender, MapViewInputEventArgs e)
{
if (!_networkingToolView.ViewModel.IsToolOpen)
if (!_networkingToolView.ViewModel.IsToolOpen || _networkingToolView.ViewModel.AddressIsExpanded == true)
return;

try
Expand All @@ -124,16 +138,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.ViewModel.AddressIsExpanded == true)
return;

if (_stopsOverlay.Graphics.Count() < 2)
return;

e.Handled = true;

await RunRouting();
}

private async Task<int> RunRouting()
{
try
{
e.Handled = true;

_networkingToolView.ViewModel.PanelResultsVisibility = Visibility.Collapsed;
_networkingToolView.ViewModel.ProgressVisibility = Visibility.Visible;

Expand Down Expand Up @@ -188,6 +207,8 @@ private async void mapView_MapViewDoubleTapped(object sender, MapViewInputEventA
_networkingToolView.ViewModel.PanelResultsVisibility = Visibility.Visible;
}
}

return 0;
}

void listDirections_SelectionChanged(object sender, SelectionChangedEventArgs e)
Expand Down Expand Up @@ -235,5 +256,50 @@ private Graphic GraphicFromRouteDirection(RouteDirection rd)
return graphic;
}

private async void DoGetDirections(object obj)
{
if (String.IsNullOrWhiteSpace(_networkingToolView.ViewModel.FromAddress) ||
String.IsNullOrWhiteSpace(_networkingToolView.ViewModel.ToAddress))
{
return;
}

// geocode from and to address
if (_locatorServiceInfo == null)
_locatorServiceInfo = await _locatorTask.GetInfoAsync();

Reset();

// geocode from address
var candidateFromResults = await _locatorTask.GeocodeAsync(
GetInputAddressFromUI(_networkingToolView.ViewModel.FromAddress), new List<string> { "Addr_type", "Score", "X", "Y" }, _mapView.SpatialReference, CancellationToken.None);

// geocode to address
var candidateToResults = await _locatorTask.GeocodeAsync(
GetInputAddressFromUI(_networkingToolView.ViewModel.ToAddress), new List<string> { "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<string, string> GetInputAddressFromUI(string singleLineAddress)
{
Dictionary<string, string> address = new Dictionary<string, string>();

address[_locatorServiceInfo.SingleLineAddressField.FieldName] = singleLineAddress;

return address;
}
}
}
2 changes: 2 additions & 0 deletions source/MilitaryPlanner/Helpers/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "::";
Expand Down
2 changes: 1 addition & 1 deletion source/MilitaryPlanner/MilitaryPlanner.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<SignManifests>true</SignManifests>
</PropertyGroup>
<ItemGroup>
<Reference Include="Esri.ArcGISRuntime, Version=10.2.4.0, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86, processorArchitecture=MSIL" />
<Reference Include="Esri.ArcGISRuntime, Version=10.2.5.0, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86, processorArchitecture=MSIL" />
<Reference Include="Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
</Reference>
Expand Down
24 changes: 24 additions & 0 deletions source/MilitaryPlanner/ViewModels/MapViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ private enum EditState
private TimeExtent _currentTimeExtent = null;
private readonly Mission _mission = new Mission("Default Mission");
private int _currentPhaseIndex = 0;
private Geometry _beforeEditGeometry = null;

/// <summary>
/// Dictionary containing a message layer ID as the KEY and a list of military message ID's as the value
Expand Down Expand Up @@ -178,6 +179,8 @@ private async void DoEditGeometry(object obj)
UpdateCurrentMessage(tam, ges.NewGeometry);
};

_beforeEditGeometry = tam.SymbolGeometry;

var resultGeometry = await _mapView.Editor.EditGeometryAsync(tam.SymbolGeometry, null, progress);

if (resultGeometry != null)
Expand Down Expand Up @@ -354,6 +357,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)
Expand Down Expand Up @@ -1058,6 +1066,8 @@ private void DoActionCancel(object obj)
if (_mapView.Editor.Cancel.CanExecute(null))
{
_mapView.Editor.Cancel.Execute(null);

RestoreGeometry();
}
}

Expand All @@ -1067,6 +1077,20 @@ private void DoActionCancel(object obj)
}
}

private void RestoreGeometry()
{
if (_currentMessage != null && _beforeEditGeometry != null )
{
var tam = _mission.MilitaryMessages.FirstOrDefault(msg => msg.Id == _currentMessage.Id);

if (tam != null)
{
UpdateCurrentMessage(tam, _beforeEditGeometry);
_beforeEditGeometry = null;
}
}
}

private async void DoActionSymbolChanged(object param)
{
_selectedSymbol = param as SymbolViewModel;
Expand Down
42 changes: 42 additions & 0 deletions source/MilitaryPlanner/ViewModels/NetworkingToolViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,50 @@
using System;
using System.Windows;
using Esri.ArcGISRuntime.Layers;
using MilitaryPlanner.Helpers;

namespace MilitaryPlanner.ViewModels
{
public class NetworkingToolViewModel : BaseToolViewModel
{
public NetworkingToolViewModel()
{
GetDirectionsCommand = new RelayCommand(OnGetDirectionsCommand);
}

public RelayCommand GetDirectionsCommand { get; set; }

private bool _addressIsExpanded = false;

public string FromAddress { get; set; }
public string ToAddress { get; set; }

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;
Expand Down Expand Up @@ -83,5 +119,11 @@ public Visibility ProgressVisibility
RaisePropertyChanged(() => ProgressVisibility);
}
}

private void OnGetDirectionsCommand(object obj)
{
Mediator.NotifyColleagues(Constants.ACTION_ROUTING_GET_DIRECTIONS, null);
}

}
}
12 changes: 11 additions & 1 deletion source/MilitaryPlanner/ViewModels/SymbolTreeViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ public List<SymbolViewModelWrapper> 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());
Expand Down Expand Up @@ -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;

Expand Down
38 changes: 32 additions & 6 deletions source/MilitaryPlanner/Views/NetworkingToolView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,39 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Orientation="Vertical">
<Expander Header="Address input" IsExpanded="{Binding AddressIsExpanded}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="From:"/>
<TextBox Grid.Column="1" Margin="3,3,3,3" Text="{Binding FromAddress, UpdateSourceTrigger=PropertyChanged}">
<TextBox.InputBindings>
<KeyBinding Key="Enter" Command="{Binding GetDirectionsCommand}" />
</TextBox.InputBindings>
</TextBox>
<TextBlock Grid.Row="1" Text="To:"/>
<TextBox Grid.Row="1" Grid.Column="1" Margin="3,3,3,3" Text="{Binding ToAddress, UpdateSourceTrigger=PropertyChanged}">
<TextBox.InputBindings>
<KeyBinding Key="Enter" Command="{Binding GetDirectionsCommand}" />
</TextBox.InputBindings>
</TextBox>
<Button Grid.Row="2" Grid.ColumnSpan="2" Content="Get Directions" Command="{Binding GetDirectionsCommand}"/>
</Grid>
</Expander>
<TextBlock Text="Tap one or more stop locations on the map then double tap the final stop to calculate a simple route with directions."
TextWrapping="Wrap" Visibility="{Binding PanelInstructionsVisibility}"/>
</StackPanel>
<ProgressBar Grid.Row="1" IsIndeterminate="True" Visibility="{Binding ProgressVisibility}" Margin="0,12,0,0" />

<TextBlock Text="Tap one or more stop locations on the map then double tap the final stop to calculate a simple route with directions."
TextWrapping="Wrap"/>

<ProgressBar x:Name="progress" Grid.Row="1" IsIndeterminate="True" Visibility="{Binding ProgressVisibility}" Margin="0,12,0,0" />

<Grid x:Name="panelResults" Grid.Row="2" Margin="0,12,0,0" Visibility="{Binding PanelResultsVisibility}">
<Grid Grid.Row="2" Margin="0,12,0,0" Visibility="{Binding PanelResultsVisibility}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
Expand Down
Loading

0 comments on commit bdb5972

Please sign in to comment.