Skip to content

Commit a0bb149

Browse files
committed
Merge pull request #3 from Esri/antt0000-MilitarySymbology
Antt0000 military symbology
2 parents 8b4fd62 + e4e719e commit a0bb149

29 files changed

+2449
-3
lines changed

samples-data

src/Desktop/ArcGISRuntimeSDKDotNet_DesktopSamples/ArcGISRuntimeSDKDotNet_DesktopSamples.csproj

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,9 +398,15 @@
398398
<Compile Include="Samples\Symbology\MarkerSymbols.xaml.cs">
399399
<DependentUpon>MarkerSymbols.xaml</DependentUpon>
400400
</Compile>
401+
<Compile Include="Samples\Symbology\MessageProcessingSample.xaml.cs">
402+
<DependentUpon>MessageProcessingSample.xaml</DependentUpon>
403+
</Compile>
401404
<Compile Include="Samples\Symbology\SimpleRendererSample.xaml.cs">
402405
<DependentUpon>SimpleRendererSample.xaml</DependentUpon>
403406
</Compile>
407+
<Compile Include="Samples\Symbology\SymbolDictionarySearchSample.xaml.cs">
408+
<DependentUpon>SymbolDictionarySearchSample.xaml</DependentUpon>
409+
</Compile>
404410
<Compile Include="Samples\Symbology\TextSymbols.xaml.cs">
405411
<DependentUpon>TextSymbols.xaml</DependentUpon>
406412
</Compile>
@@ -877,10 +883,18 @@
877883
<Generator>MSBuild:Compile</Generator>
878884
<SubType>Designer</SubType>
879885
</Page>
886+
<Page Include="Samples\Symbology\MessageProcessingSample.xaml">
887+
<Generator>MSBuild:Compile</Generator>
888+
<SubType>Designer</SubType>
889+
</Page>
880890
<Page Include="Samples\Symbology\SimpleRendererSample.xaml">
881891
<Generator>MSBuild:Compile</Generator>
882892
<SubType>Designer</SubType>
883893
</Page>
894+
<Page Include="Samples\Symbology\SymbolDictionarySearchSample.xaml">
895+
<Generator>MSBuild:Compile</Generator>
896+
<SubType>Designer</SubType>
897+
</Page>
884898
<Page Include="Samples\Symbology\TextSymbols.xaml">
885899
<Generator>MSBuild:Compile</Generator>
886900
<SubType>Designer</SubType>

src/Desktop/ArcGISRuntimeSDKDotNet_DesktopSamples/Assets/SampleDescriptions.xml

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<UserControl x:Class="ArcGISRuntimeSDKDotNet_DesktopSamples.Samples.Symbology.MessageProcessingSample"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
7+
mc:Ignorable="d"
8+
d:DesignHeight="300" d:DesignWidth="300">
9+
<Grid>
10+
<esri:MapView x:Name="mapView">
11+
<esri:Map>
12+
<esri:Map.InitialExtent>
13+
<esri:Envelope XMin="-245200" YMin="6665900" XMax="-207000" YMax="6687300">
14+
<esri:Envelope.SpatialReference>
15+
<esri:SpatialReference Wkid="102100"></esri:SpatialReference>
16+
</esri:Envelope.SpatialReference>
17+
</esri:Envelope>
18+
</esri:Map.InitialExtent>
19+
<esri:ArcGISTiledMapServiceLayer ID="Basemap"
20+
ServiceUri="http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"/>
21+
<esri:MessageLayer SymbolDictionaryType="Mil2525C" />
22+
</esri:Map>
23+
</esri:MapView>
24+
25+
<Border Background="White" BorderBrush="Black" BorderThickness="2" Margin="30"
26+
HorizontalAlignment="Right" VerticalAlignment="Top">
27+
<StackPanel Margin="30,20">
28+
<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."
29+
FontSize="14" Width="400" TextAlignment="Left" TextWrapping="Wrap" />
30+
<Button x:Name="processMessagesBtn"
31+
IsEnabled="False"
32+
Content="Process messages"
33+
HorizontalAlignment="Center"
34+
Margin="12,12,12,0"
35+
Click="ProcessMessagesButton_Click"/>
36+
</StackPanel>
37+
</Border>
38+
</Grid>
39+
</UserControl>
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
using Esri.ArcGISRuntime;
2+
using Esri.ArcGISRuntime.AdvancedSymbology;
3+
using Esri.ArcGISRuntime.Layers;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.IO;
7+
using System.Linq;
8+
using System.Windows;
9+
using System.Windows.Controls;
10+
using System.Xml.Linq;
11+
12+
namespace ArcGISRuntimeSDKDotNet_DesktopSamples.Samples.Symbology
13+
{
14+
/// <summary>
15+
/// Sample shows how to read and process Mil2525C message data from XML file.
16+
/// </summary>
17+
/// <title>Message Processor</title>
18+
/// <category>Symbology</category>
19+
/// <subcategory>Advanced</subcategory>
20+
public partial class MessageProcessingSample : UserControl
21+
{
22+
private const string DATA_PATH = @"..\..\..\..\..\samples-data\symbology\Mil2525CMessages.xml";
23+
24+
private MessageLayer _messageLayer;
25+
26+
public MessageProcessingSample()
27+
{
28+
InitializeComponent();
29+
mapView.ExtentChanged += mapView_ExtentChanged;
30+
}
31+
32+
// Load data - enable functionality after layers are loaded.
33+
private async void mapView_ExtentChanged(object sender, EventArgs e)
34+
{
35+
try
36+
{
37+
mapView.ExtentChanged -= mapView_ExtentChanged;
38+
39+
// Wait until all layers are loaded
40+
await mapView.LayersLoadedAsync();
41+
42+
_messageLayer = mapView.Map.Layers.OfType<MessageLayer>().First();
43+
processMessagesBtn.IsEnabled = true;
44+
}
45+
catch (Exception ex)
46+
{
47+
MessageBox.Show(ex.Message, "Message Processing Sample");
48+
}
49+
}
50+
51+
private void ProcessMessagesButton_Click(object sender, RoutedEventArgs e)
52+
{
53+
try
54+
{
55+
// This function simulates real time message processing by processing a static set of messages from an XML document.
56+
/*
57+
* |== Example Message ==|
58+
*
59+
* <message>
60+
* <_type>position_report</_type>
61+
* <_action>update</_action>
62+
* <_id>16986029-8295-48d1-aa6a-478f400a53c0</_id>
63+
* <_wkid>3857</_wkid>
64+
* <sic>GFGPOLKGS-----X</sic>
65+
* <_control_points>-226906.99878,6679149.88998;-228500.51759,6677576.8009;-232194.67644,6675625.78198</_control_points>
66+
* <uniquedesignation>DIRECTION OF ATTACK</uniquedesignation>
67+
* </message>
68+
*/
69+
70+
var file = new FileInfo(DATA_PATH);
71+
72+
// Load the XML document
73+
XDocument xmlDocument = XDocument.Load(file.FullName, LoadOptions.None);
74+
75+
// Create a collection of messages
76+
IEnumerable<XElement> messagesXml = from n in xmlDocument.Root.Elements()
77+
where n.Name == "message"
78+
select n;
79+
80+
// Iterate through the messages passing each to the ProcessMessage method on the MessageProcessor.
81+
// The MessageGroupLayer associated with this MessageProcessor will handle the creation of any
82+
// GraphicsLayers and Graphic objects necessary to display the message.
83+
foreach (XElement messageXml in messagesXml)
84+
{
85+
Message message = new Message(from n in messageXml.Elements() select new KeyValuePair<string, string>(n.Name.ToString(), n.Value));
86+
_messageLayer.ProcessMessage(message);
87+
}
88+
89+
/*
90+
* Alternatively you can programmatically construct the message and set the attributes.
91+
* e.g.
92+
*
93+
* // Create a new message
94+
* Message msg = new Message();
95+
*
96+
* // Set the ID and other parts of the message
97+
* msg.Id = messageID;
98+
* msg.Add("_type", "position_report");
99+
* msg.Add("_action", "update");
100+
* msg.Add("_control_points", X.ToString(CultureInfo.InvariantCulture) + "," + Y.ToString(CultureInfo.InvariantCulture));
101+
* msg.Add("_wkid", "3857");
102+
* msg.Add("sic", symbolID);
103+
* msg.Add("uniquedesignation", "1");
104+
*
105+
* // Process the message using the MessageProcessor within the MessageGroupLayer
106+
* _messageLayer.ProcessMessage(msg);
107+
*/
108+
}
109+
catch (Exception ex)
110+
{
111+
MessageBox.Show(ex.Message, "Message Processing Sample");
112+
}
113+
}
114+
}
115+
}

0 commit comments

Comments
 (0)