Common Custom renderers
Common_CustomRenderers_VBNet\SimpleRenderer3D.aspx.vb
' Copyright 2010 ESRI
' 
' All rights reserved under the copyright laws of the United States
' and applicable international laws, treaties, and conventions.
' 
' You may freely redistribute and use this sample code, with or
' without modification, provided you include the original copyright
' notice and use restrictions.
' 
' See the use restrictions.
' 

Imports Microsoft.VisualBasic
Imports System
Public Partial Class SimpleRenderer3DPage
  Inherits System.Web.UI.Page
  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
    If (Not ScriptManager1.IsInAsyncPostBack) Then
      ' Potential inital load. Check if graphics resource has the graphics layer, and if not, create it
      Dim mapResourceItem As ESRI.ArcGIS.ADF.Web.UI.WebControls.MapResourceItem = MapResourceManager1.ResourceItems.Find("GraphicsDataSource")
      Dim graphicsMapResource As ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource = TryCast(mapResourceItem.Resource, ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource)

      If Not graphicsMapResource Is Nothing Then
        ' Check whether the map extent is null, meaning the map has not yet been initialized
        If Map1.Extent Is Nothing Then
          ' Forces earlier initialization of map and will set map extent
          Dim primaryMapResource As ESRI.ArcGIS.ADF.Web.DataSources.IMapResource = Map1.PrimaryMapResourceInstance
        End If

        ' Call helper method in App_Code which generates a random graphics layer.  In real-world situations,
        ' the random layer could be replaced with, for instance, the result of a query.  Once the layer is
        ' created, apply the renderer and add the layer to the graphics resource.

        ' First create a polygon layer...
        Dim featureGraphicsLayer As ESRI.ArcGIS.ADF.Web.Display.Graphics.FeatureGraphicsLayer = ESRI.ADF.Samples.Renderers.GenerateGraphicsHelper.CreatePolygonFeatures("polygons", Map1.Extent, 10)
        applyRendererAndAddLayer(graphicsMapResource, featureGraphicsLayer)

        ' ...then a polyline layer
        featureGraphicsLayer = ESRI.ADF.Samples.Renderers.GenerateGraphicsHelper.CreatePolylineFeatures("polylines", Map1.Extent, 10)
        applyRendererAndAddLayer(graphicsMapResource, featureGraphicsLayer)
      End If

      ' Refresh the graphics resource so the newly added layers show up
      Map1.RefreshResource("GraphicsDataSource")
    End If
  End Sub

  ' Applies the SimpleRenderer3D to the graphics layer and adds it to the resource
  Private Shared Sub applyRendererAndAddLayer(ByVal graphicsMapResource As ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource, ByVal featureGraphicsLayer As ESRI.ArcGIS.ADF.Web.Display.Graphics.FeatureGraphicsLayer)
    If Not featureGraphicsLayer Is Nothing Then
      Dim simpleRenderer3D As ESRI.ADF.Samples.Renderers.SimpleRenderer3D = New ESRI.ADF.Samples.Renderers.SimpleRenderer3D()
      simpleRenderer3D.FillColor = System.Drawing.Color.White
      simpleRenderer3D.HeightColumnName = "Height" ' Name of column which contains the extrusion height
      simpleRenderer3D.ScaleHeight = 50 ' Scale height by 50 units
            simpleRenderer3D.maxHeight_Renamed = 50 ' Limit height to a maximum of 50 pixels
      featureGraphicsLayer.Renderer = simpleRenderer3D ' Apply the renderer

      ' If a layer of the same name has already been added, remove it
      If graphicsMapResource.Graphics.Tables.Contains(featureGraphicsLayer.TableName) Then
        graphicsMapResource.Graphics.Tables.Remove(featureGraphicsLayer.TableName)
      End If

      ' Add the passed-in layer
      graphicsMapResource.Graphics.Tables.Add(featureGraphicsLayer)
    End If
  End Sub
End Class