This sample demonstrates the use of the raster function templates available for an ArcGIS image service. An image service can provide an array of raster function infos. This sample service includes a list of raster function templates, custom rendering rules defined on the server and applied by a client. These raster functions can be discovered, displayed, and applied using the drop down list.
<UserControlx:Class="ArcGISWPFSDK.RasterFunctionImageService"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/client/2009"><Gridx:Name="LayoutRoot"><esri:Mapx:Name="MyMap"UseAcceleratedDisplay="True"Extent="1445440.75144509,540657.514450867,1452348.26589595,544407.514450867"><esri:ArcGISImageServiceLayerID="MyImageLayer"Url="http://sampleserver6.arcgisonline.com/arcgis/rest/services/CharlotteLAS/ImageServer"Initialized="ArcGISImageServiceLayer_Initialized"/></esri:Map><BorderBorderBrush="Black"VerticalAlignment="Top"BorderThickness="1"Margin="15"Background="White"HorizontalAlignment="Right"MinWidth="300"><Border.Effect><DropShadowEffect/></Border.Effect><StackPanelMargin="15"><TextBlockTextAlignment="Center"Text="Choose a raster function template"FontWeight="Bold"Height="16"/><ComboBoxx:Name="RasterFunctionsComboBox"Margin="5"SelectionChanged="RasterFunctionsComboBox_SelectionChanged"><ComboBox.ItemTemplate><DataTemplate><TextBlockText="{Binding Name}"/></DataTemplate></ComboBox.ItemTemplate></ComboBox></StackPanel></Border></Grid></UserControl>
using System.Windows;
using ESRI.ArcGIS.Client;
using System;
using System.Windows.Controls;
namespace ArcGISWPFSDK
{
publicpartialclass RasterFunctionImageService : UserControl
{
public RasterFunctionImageService()
{
InitializeComponent();
}
privatevoid ArcGISImageServiceLayer_Initialized(object sender, EventArgs e)
{
RasterFunctionsComboBox.ItemsSource =
(sender as ArcGISImageServiceLayer).RasterFunctionInfos;
RasterFunctionsComboBox.SelectedIndex = 0;
}
privatevoid RasterFunctionsComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
ArcGISImageServiceLayer imageLayer = MyMap.Layers["MyImageLayer"] as ArcGISImageServiceLayer;
var rasterFunction = (sender as ComboBox).SelectedItem as RasterFunctionInfo;
if (rasterFunction != null)
{
RenderingRule renderingRule = new RenderingRule() { RasterFunctionName = rasterFunction.Name };
imageLayer.RenderingRule = renderingRule;
imageLayer.Refresh();
}
}
}
}
Imports System.Windows
Imports System.Windows.Controls
Imports ESRI.ArcGIS.Client
Namespace ArcGISWPFSDK
PartialPublicClass RasterFunctionImageService
Inherits UserControl
PublicSubNew()
InitializeComponent()
EndSubPrivateSub ArcGISImageServiceLayer_Initialized(ByVal sender AsObject, ByVal e As EventArgs)
RasterFunctionsComboBox.ItemsSource = (TryCast(sender, ArcGISImageServiceLayer)).RasterFunctionInfos
RasterFunctionsComboBox.SelectedIndex = 0
EndSubPrivateSub RasterFunctionsComboBox_SelectionChanged(ByVal sender AsObject, ByVal e As SelectionChangedEventArgs)
Dim imageLayer As ArcGISImageServiceLayer = TryCast(MyMap.Layers("MyImageLayer"), ArcGISImageServiceLayer)
Dim rasterFunction = TryCast((TryCast(sender, ComboBox)).SelectedItem, RasterFunctionInfo)
If rasterFunction IsNotNothingThenDim renderingRule AsNew RenderingRule() With {.RasterFunctionName = rasterFunction.Name}
imageLayer.RenderingRule = renderingRule
imageLayer.Refresh()
EndIfEndSubEndClassEndNamespace