Skip to content

Commit

Permalink
Merge pull request #3 from Esri/antt0000-MilitarySymbology
Browse files Browse the repository at this point in the history
Antt0000 military symbology
  • Loading branch information
anttikajanus committed Jun 2, 2014
2 parents 8b4fd62 + e4e719e commit a0bb149
Show file tree
Hide file tree
Showing 29 changed files with 2,449 additions and 3 deletions.
2 changes: 1 addition & 1 deletion samples-data
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,15 @@
<Compile Include="Samples\Symbology\MarkerSymbols.xaml.cs">
<DependentUpon>MarkerSymbols.xaml</DependentUpon>
</Compile>
<Compile Include="Samples\Symbology\MessageProcessingSample.xaml.cs">
<DependentUpon>MessageProcessingSample.xaml</DependentUpon>
</Compile>
<Compile Include="Samples\Symbology\SimpleRendererSample.xaml.cs">
<DependentUpon>SimpleRendererSample.xaml</DependentUpon>
</Compile>
<Compile Include="Samples\Symbology\SymbolDictionarySearchSample.xaml.cs">
<DependentUpon>SymbolDictionarySearchSample.xaml</DependentUpon>
</Compile>
<Compile Include="Samples\Symbology\TextSymbols.xaml.cs">
<DependentUpon>TextSymbols.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -877,10 +883,18 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Samples\Symbology\MessageProcessingSample.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Samples\Symbology\SimpleRendererSample.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Samples\Symbology\SymbolDictionarySearchSample.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Samples\Symbology\TextSymbols.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<UserControl x:Class="ArcGISRuntimeSDKDotNet_DesktopSamples.Samples.Symbology.MessageProcessingSample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<esri:MapView x:Name="mapView">
<esri:Map>
<esri:Map.InitialExtent>
<esri:Envelope XMin="-245200" YMin="6665900" XMax="-207000" YMax="6687300">
<esri:Envelope.SpatialReference>
<esri:SpatialReference Wkid="102100"></esri:SpatialReference>
</esri:Envelope.SpatialReference>
</esri:Envelope>
</esri:Map.InitialExtent>
<esri:ArcGISTiledMapServiceLayer ID="Basemap"
ServiceUri="http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"/>
<esri:MessageLayer SymbolDictionaryType="Mil2525C" />
</esri:Map>
</esri:MapView>

<Border Background="White" BorderBrush="Black" BorderThickness="2" Margin="30"
HorizontalAlignment="Right" VerticalAlignment="Top">
<StackPanel Margin="30,20">
<TextBlock Text="Click on the button below to run the message processor. It will read simulated messages from an XML file and display military symbols on the map using Mil2525C Symbols."
FontSize="14" Width="400" TextAlignment="Left" TextWrapping="Wrap" />
<Button x:Name="processMessagesBtn"
IsEnabled="False"
Content="Process messages"
HorizontalAlignment="Center"
Margin="12,12,12,0"
Click="ProcessMessagesButton_Click"/>
</StackPanel>
</Border>
</Grid>
</UserControl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
using Esri.ArcGISRuntime;
using Esri.ArcGISRuntime.AdvancedSymbology;
using Esri.ArcGISRuntime.Layers;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Xml.Linq;

namespace ArcGISRuntimeSDKDotNet_DesktopSamples.Samples.Symbology
{
/// <summary>
/// Sample shows how to read and process Mil2525C message data from XML file.
/// </summary>
/// <title>Message Processor</title>
/// <category>Symbology</category>
/// <subcategory>Advanced</subcategory>
public partial class MessageProcessingSample : UserControl
{
private const string DATA_PATH = @"..\..\..\..\..\samples-data\symbology\Mil2525CMessages.xml";

private MessageLayer _messageLayer;

public MessageProcessingSample()
{
InitializeComponent();
mapView.ExtentChanged += mapView_ExtentChanged;
}

// Load data - enable functionality after layers are loaded.
private async void mapView_ExtentChanged(object sender, EventArgs e)
{
try
{
mapView.ExtentChanged -= mapView_ExtentChanged;

// Wait until all layers are loaded
await mapView.LayersLoadedAsync();

_messageLayer = mapView.Map.Layers.OfType<MessageLayer>().First();
processMessagesBtn.IsEnabled = true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Message Processing Sample");
}
}

private void ProcessMessagesButton_Click(object sender, RoutedEventArgs e)
{
try
{
// This function simulates real time message processing by processing a static set of messages from an XML document.
/*
* |== Example Message ==|
*
* <message>
* <_type>position_report</_type>
* <_action>update</_action>
* <_id>16986029-8295-48d1-aa6a-478f400a53c0</_id>
* <_wkid>3857</_wkid>
* <sic>GFGPOLKGS-----X</sic>
* <_control_points>-226906.99878,6679149.88998;-228500.51759,6677576.8009;-232194.67644,6675625.78198</_control_points>
* <uniquedesignation>DIRECTION OF ATTACK</uniquedesignation>
* </message>
*/

var file = new FileInfo(DATA_PATH);

// Load the XML document
XDocument xmlDocument = XDocument.Load(file.FullName, LoadOptions.None);

// Create a collection of messages
IEnumerable<XElement> messagesXml = from n in xmlDocument.Root.Elements()
where n.Name == "message"
select n;

// Iterate through the messages passing each to the ProcessMessage method on the MessageProcessor.
// The MessageGroupLayer associated with this MessageProcessor will handle the creation of any
// GraphicsLayers and Graphic objects necessary to display the message.
foreach (XElement messageXml in messagesXml)
{
Message message = new Message(from n in messageXml.Elements() select new KeyValuePair<string, string>(n.Name.ToString(), n.Value));
_messageLayer.ProcessMessage(message);
}

/*
* Alternatively you can programmatically construct the message and set the attributes.
* e.g.
*
* // Create a new message
* Message msg = new Message();
*
* // Set the ID and other parts of the message
* msg.Id = messageID;
* msg.Add("_type", "position_report");
* msg.Add("_action", "update");
* msg.Add("_control_points", X.ToString(CultureInfo.InvariantCulture) + "," + Y.ToString(CultureInfo.InvariantCulture));
* msg.Add("_wkid", "3857");
* msg.Add("sic", symbolID);
* msg.Add("uniquedesignation", "1");
*
* // Process the message using the MessageProcessor within the MessageGroupLayer
* _messageLayer.ProcessMessage(msg);
*/
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Message Processing Sample");
}
}
}
}
Loading

0 comments on commit a0bb149

Please sign in to comment.