private void ApplyButton_Click(object sender, RoutedEventArgs e)
{
try
{
ArcGISImageServiceLayer imageLayer = MyMap.Layers["ImageServiceLayer"] as ArcGISImageServiceLayer;
RenderingRule renderingRule = new RenderingRule();
Dictionary<string, object> rasterParams = new Dictionary<string, object>();
if (SRRadioButton.IsChecked.Value)
{
renderingRule.RasterFunctionName = "ShadedRelief";
renderingRule.VariableName = "Raster";
rasterParams.Add("Azimuth", string.IsNullOrEmpty(AzimuthTextBox.Text) ? 0 : double.Parse(AzimuthTextBox.Text));
rasterParams.Add("Altitude", string.IsNullOrEmpty(AltitudeTextBox.Text) ? 0 : double.Parse(AltitudeTextBox.Text));
rasterParams.Add("ZFactor", string.IsNullOrEmpty(ZFactorTextBox.Text) ? 0 : double.Parse(ZFactorTextBox.Text));
if (ColormapCheckBox.IsChecked.Value)
rasterParams.Add("Colormap", CreateColorMap());
else
{
renderingRule.RasterFunctionName = "Hillshade";
renderingRule.VariableName = "DEM";
}
renderingRule.RasterFunctionArguments = rasterParams;
}
else
{
renderingRule.RasterFunctionName = "Slope";
renderingRule.VariableName = "DEM";
rasterParams.Add("ZFactor", string.IsNullOrEmpty(ZFactorTextBox.Text) ? 0 : double.Parse(ZFactorTextBox.Text));
renderingRule.RasterFunctionArguments = rasterParams;
}
imageLayer.RenderingRule = renderingRule;
imageLayer.Refresh();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}