Common_CustomEditorTask_VBNet\CustomEditorTask_VBNet\CustomEditor.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 Namespace CustomEditorTask_VBNet Public Class CustomEditor Inherits ESRI.ArcGIS.ADF.ArcGISServer.Editor.Editor #Region "Constructor" Public Sub New(ByVal customEditorTask As CustomEditorTask) MyBase.New(customEditorTask) ' Add handler to edtior's LayerChanged event to update the editor's current layer definition AddHandler LayerChanged, AddressOf CustomEditor_LayerChanged End Sub #End Region #Region "Event Handling" Private Sub CustomEditor_LayerChanged(ByVal featureLayer As ESRI.ArcGIS.Carto.IFeatureLayer) ' Update the CurrentLayerDefinition in state StateManager.SetProperty("CurrentLayerDefinition", CustomUtilities.GetLayerDefinition(Me)) End Sub #End Region #Region "WebControl Life Cycle Event Overrides" Protected Overrides Sub OnPreRender(ByVal e As System.EventArgs) MyBase.OnPreRender(e) If MapResource IsNot Nothing AndAlso (Not Page.ClientScript.IsClientScriptBlockRegistered("display_editorSnapTip.js")) Then ' Register stylesheet for snap tip style. Editor base class registers the explicit base ' class type when including stylesheet. As a result, classes that derive from the Editor ' must explicitly include stylesheet, if needed. Dim includeTemplate As String = "<link rel='stylesheet' text='text/css' href='{0}' />" Dim scriptLocation As String = Page.ClientScript.GetWebResourceUrl(GetType(CustomEditorTask), "CustomEditorTask_CSharp.styles.editorStyles.css") Dim include As New System.Web.UI.LiteralControl(System.String.Format(includeTemplate, scriptLocation)) CType(Page.Header, System.Web.UI.HtmlControls.HtmlHead).Controls.Add(include) End If End Sub #End Region #Region "EditorTask Panel Creation Overrides" 'add select by attributes panel to panels collection Protected Overrides Function CreateEditorPanels() As System.Collections.Generic.List(Of ESRI.ArcGIS.ADF.ArcGISServer.Editor.EditorPanel) ' Get a reference to the default panel collection Dim editorPanelList As System.Collections.Generic.List(Of ESRI.ArcGIS.ADF.ArcGISServer.Editor.EditorPanel) = MyBase.CreateEditorPanels() ' Instantiate a SearchAttributesPanel for use by the editor Dim searchAttributesPanel As ESRI.ArcGIS.ADF.ArcGISServer.Editor.EditorPanel = New SearchAttributesPanel(Me.EditorTask) ' Add the SearchAttributesPanel to the panels collection editorPanelList.Add(searchAttributesPanel) ' Uncomment the following sections to add a QueryBuilderPanel and/or a SimpleQueryPanel ' to the CustomEditorTask ' Create a SimpleQueryPanel instance for use by the editor Dim SimpleQueryPanel As ESRI.ArcGIS.ADF.ArcGISServer.Editor.EditorPanel = New SimpleQueryPanel(Me.EditorTask) 'Add the SimpleQueryPanel to the panels collection editorPanelList.Add(SimpleQueryPanel) ' Create an instance of the QueryBuilderPanel for the editor Dim QueryBuilderPanel As ESRI.ArcGIS.ADF.ArcGISServer.Editor.EditorPanel = New QueryBuilderPanel(Me.EditorTask) ' Add the QueryBuilderPanel to the panels collection editorPanelList.Add(QueryBuilderPanel) Return editorPanelList End Function ' Override to create and return the custom EditExistingFeaturePanel Protected Overrides Function CreateEditExistingFeaturePanel(ByVal editorTask As ESRI.ArcGIS.ADF.ArcGISServer.Editor.EditorTask) As ESRI.ArcGIS.ADF.ArcGISServer.Editor.EditorPanel Return New CustomEditExistingFeaturePanel(editorTask) End Function Protected Overrides Function CreateEditAttributesPanel(ByVal editorTask As ESRI.ArcGIS.ADF.ArcGISServer.Editor.EditorTask) As ESRI.ArcGIS.ADF.ArcGISServer.Editor.EditorPanel Return New CustomEditAttributesPanel(editorTask) End Function #End Region #Region "Instance Properties" ' LayerDefinition object for currently selected layer Public ReadOnly Property CurrentLayerDefinition() As ESRI.ArcGIS.ADF.Web.UI.WebControls.LayerDefinition Get ' Get the current layer definition from state Dim layerDefinition As ESRI.ArcGIS.ADF.Web.UI.WebControls.LayerDefinition = TryCast(StateManager.GetProperty("CurrentLayerDefinition"), ESRI.ArcGIS.ADF.Web.UI.WebControls.LayerDefinition) ' If no layer definition is in state, execute method to retrieve it If layerDefinition Is Nothing Then layerDefinition = CustomUtilities.GetLayerDefinition(Me) End If Return (layerDefinition) End Get End Property ' ID of currently selected polyline layer in resource being edited Friend Property PolylineLayerID() As Integer Get Dim obj As Object = Page.Session("PolylineLayerID") Return If(obj Is Nothing, -1, CInt(Fix(obj))) End Get Set(ByVal value As Integer) Page.Session("PolylineLayerID") = value End Set End Property #End Region End Class End Namespace