Common_CustomEditorTask_CSharp\CustomEditorTask_CSharp\CustomEditor.cs
// 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. // namespace CustomEditorTask_CSharp { public class CustomEditor : ESRI.ArcGIS.ADF.ArcGISServer.Editor.Editor { #region Constructor public CustomEditor(CustomEditorTask customEditorTask) : base(customEditorTask) { // Add handler to edtior's LayerChanged event to update the editor's current layer definition this.LayerChanged += new LayerChangedHandler(CustomEditor_LayerChanged); } #endregion #region Event Handling void CustomEditor_LayerChanged(ESRI.ArcGIS.Carto.IFeatureLayer featureLayer) { // Update the CurrentLayerDefinition in state StateManager.SetProperty("CurrentLayerDefinition", CustomUtilities.GetLayerDefinition(this)); } #endregion #region WebControl Life Cycle Event Overrides protected override void OnPreRender(System.EventArgs e) { base.OnPreRender(e); if (MapResource != null && !Page.ClientScript.IsClientScriptBlockRegistered("display_editorSnapTip.js")) { // 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. string includeTemplate = "<link rel='stylesheet' text='text/css' href='{0}' />"; string scriptLocation = Page.ClientScript.GetWebResourceUrl(typeof(CustomEditorTask), "CustomEditorTask_CSharp.styles.editorStyles.css"); System.Web.UI.LiteralControl include = new System.Web.UI.LiteralControl(System.String.Format( includeTemplate, scriptLocation)); ((System.Web.UI.HtmlControls.HtmlHead)Page.Header).Controls.Add(include); } } #endregion #region EditorTask Panel Creation Overrides //add select by attributes panel to panels collection protected override System.Collections.Generic.List<ESRI.ArcGIS.ADF.ArcGISServer.Editor.EditorPanel> CreateEditorPanels() { // Get a reference to the default panel collection System.Collections.Generic.List<ESRI.ArcGIS.ADF.ArcGISServer.Editor.EditorPanel> editorPanelList = base.CreateEditorPanels(); // Instantiate a SearchAttributesPanel for use by the editor ESRI.ArcGIS.ADF.ArcGISServer.Editor.EditorPanel searchAttributesPanel = new SearchAttributesPanel(this.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 //ESRI.ArcGIS.ADF.ArcGISServer.Editor.EditorPanel simpleQueryPanel = // new SimpleQueryPanel(this.EditorTask); //// Add the SimpleQueryPanel to the panels collection //editorPanelList.Add(simpleQueryPanel); //// Create an instance of the QueryBuilderPanel for the editor //ESRI.ArcGIS.ADF.ArcGISServer.Editor.EditorPanel queryBuilderPanel = // new QueryBuilderPanel(this.EditorTask); //// Add the QueryBuilderPanel to the panels collection //editorPanelList.Add(queryBuilderPanel); return editorPanelList; } // Override to create and return the custom EditExistingFeaturePanel protected override ESRI.ArcGIS.ADF.ArcGISServer.Editor.EditorPanel CreateEditExistingFeaturePanel( ESRI.ArcGIS.ADF.ArcGISServer.Editor.EditorTask editorTask) { return new CustomEditExistingFeaturePanel(editorTask); } protected override ESRI.ArcGIS.ADF.ArcGISServer.Editor.EditorPanel CreateEditAttributesPanel( ESRI.ArcGIS.ADF.ArcGISServer.Editor.EditorTask editorTask) { return new CustomEditAttributesPanel(editorTask); } #endregion #region Instance Properties // LayerDefinition object for currently selected layer public ESRI.ArcGIS.ADF.Web.UI.WebControls.LayerDefinition CurrentLayerDefinition { get { // Get the current layer definition from state ESRI.ArcGIS.ADF.Web.UI.WebControls.LayerDefinition layerDefinition = StateManager.GetProperty("CurrentLayerDefinition") as ESRI.ArcGIS.ADF.Web.UI.WebControls.LayerDefinition; // If no layer definition is in state, execute method to retrieve it if (layerDefinition == null) { layerDefinition = CustomUtilities.GetLayerDefinition(this); } return (layerDefinition); } } // ID of currently selected polyline layer in resource being edited internal int PolylineLayerID { get { object obj = Page.Session["PolylineLayerID"]; return obj == null ? -1 : (int)obj; } set { Page.Session["PolylineLayerID"] = value; } } #endregion } }