ArcGIS Server EditorTask control

The EditorTask control provides a suite of tools for Web-based editing of feature layers in ArcGIS Server map services. The runtime dialog provides tools to modify, add, and remove feature geometry and attributes.  The EditorTask can also be customized and extended to filter attributes, manage tools, handle events during the editing process, and manage panels.  See the discussion section below for more details.

The following set of requirements apply to the EditorTask capabilities:  

*                               The EditorTask requires an ArcGIS Server Local map service.  

*                               The ArcGIS Server map service can be either pooled or non-pooled.

*                               Both versioned and non-versioned layers can be edited in non-pooled services, while only non-versioned layers can be edited in pooled services.

*                               At runtime, the Editor panel contains a set of sub panels which contain different items depending on the purpose and feature type being edited.  Editing non-versioned data will change the availability of some commands on the Editor panel.  When using non-versioned data with a pooled service, the Editor panel will not contain a Undo, Redo, or Save button for pooled services.   When using non-versioned data with non-pooled service, the Undo and Redo button will not be available.   Undo and Redo are capabilities of a versioned geodatabase.  The Save option is a capability defined by a non-pooled service.     

*                               While the map service can contain many different data types, editable layers for the EditorTask must be ArcSDE enterprise or workgroup layers. 

*                               Shapefiles and personal geodatabases cannot be edited with the EditorTask, but they can be used for other operations such as snapping. 

*                               The data frame in the map service that contains an editable layer cannot be projected on the fly by the Web ADF or projected within the mxd.  

*                               If more than one feature layer share the same name in a map service, only one is editable.  It is recommended that each editable layer in a map service have a unique layer name.

Assembly: ESRI.ArcGIS.ADF.ArcGISServer.Editor.dll

Class: ESRI.ArcGIS.ADF.ArcGISServer.EditorTask

JavaScript libraries: display_common.js, display_dotnetadf.js, display_editortask.js, display_editorSnapTip.js, display_contextmenu.js, display_floatingpanel.js, display_task.js, display_toolbar.js

Using the EditorTask control

1.                              Add supporting controls to the page

2.                               In order to take use the EditorTask control, a number of supporting controls must be available.  Set up a Web application with, at minimum, a  MapResourceManager control and a Map control using their discussion topics as a guide. Other controls may optionally be added, such as a Toolbar control for zooming and panning operations.

3.                               Add the EditorTask control to the page

4.                               Drag an EditorTask control onto the page. For the purposes of this example, the EditorTask does not need to be contained within a TaskManager control. If using the Web Mapping Application template, a TaskManager is used to handle the opening of the task from the left-hand console list of tasks. The page does not need a TaskResults control, since the EditorTask does not actually create results output. The EditorTask inherits from FloatingPanel, so that it will automatically appear in a floating window at run time.

5.                               Your page should resemble the following in Visual Studio:

6.                              

7.                               Set the properties for the EditorTask control

8.                               You must set a few of the properties of the EditorTask in order for it to work properly. You may access the required properties from the "smart tag" which you can open by hovering over the right side of the EditorTask control. Click the arrow to expand the smart tag menu.

9.                               Alternatively, you can set the properties using the Properties window for the control:

10.                          

11.                           a. Select Resource to Edit: Click this item in the smart tag list of tasks, or in the Properties window, click the ellipsis button for the MapResource property. This displays the Select Map Resource Editor dialog:

12.                          

13.                           In the resource editor, click the drop-down list to select the Map control added earlier. Select a service from the Resource drop-down list. If no services appear in this list, check that an ArcGIS Server Local resource is present in the MapResourceManager, and that the resource is a non-pooled service.

14.                           b. Select Editable Layers: Click this item in the smart tag list of tasks in the EditorTask control, or in the Properties window, click the details button for the EditableLayers property. This displays the Select Editable Layers Editor dialog. It may take some time for the dialog to find the editable layers, during which time the dialog is grayed out. Once the available layers are found, the dialog should appear similar to the following:

15.                          

16.                           If no layers appear in the list, check that the map service is using ArcSDE layers. If multiple ArcSDE databases have been added to the map service, use the Database drop-down list to select the one you want to use. Also, if a versioned geodatabase is used in the map service, you may select either to edit as versioned or as unversioned. If you select unversioned, only layers not set as versioned may be enabled for editing.

17.                           The left-hand column, labeled "Layers not available for editing", lists layers that you can enable for editing by users. Click a layer to highlight it, and click the >> button to move it to the list of Editable Layers on the right side of the dialog. Only layers in the Editable Layers list will be available for users to edit.

18.                           c. Select Editable Versions : You need to set this item if using a versioned ArcSDE database. If editing an unversioned database, this option is not available. To select versions, click the Select Editable Versions item in the smart tag list, or in the Properties window, click the details button for the VersionIDs property. This displays the Select Editable Versions Editor:

19.                          

20.                           Available versions are listed in the left hand side of the dialog. To make versions available to users, click a version in the left side, then click the >> button to move it to the right side list of Editable Versions. Only versions appearing in the right-hand list are available to users.

21.                           d. Set Snapping Rules: By default, no snapping is used when editing. Snapping forces a click near an existing feature to be set exactly at a part of the nearby feature. This allows features to exactly coincide along their borders. To add snapping to the application, click the Set Snapping Rules item in the smart tag list, or in the Properties window, click the details button for the Snapping property. This displays the Set Layer Snapping Editor:

22.                          

23.                           This dialog displays all layers that may be enabled for editing, even if the layers have not been actually added to the editable layers list. This is because snapping can occur across layers. For example, if you enable snapping to a parcels layer and are adding a new building feature, new vertices may be snapped to a parcel within the snapping tolerance.

24.                           Three snapping types are available: edge, where snapping can occur anywhere along a feature; vertex, where snapping occurs to x,y points defining the shape of a feature; and end , where snapping occurs to the endpoints of a feature. For more information on snapping types, consult the ArcGIS Desktop Help.

25.                           e. Optional: Change other properties for editing

26.                           Other properties for editing may be set in the Properties window for the Editor Task.  Refer to the Properties section below to change EditorTask properties at design-time.

27.                            

28.                           Add an ArcGIS Identity

29.                           Applications using an ArcGIS Server Local resource must contain an ArcGIS identity to enable use of the resource. To add an identity, right-click on the Web application in the Solution Explorer, and click Add ArcGIS Identity. A dialog displays where you can enter the user name, password, and domain or machine name. Click OK to insert the identity, which is stored in the web.config file of the application.

30.                           If an appropriate identity is not added to the application, the user may see an error when starting the Web application, such as one saying that "an object reference is not set to an instance of an object."

31.                           Using the EditorTask at runtime

32.                           For details about using the editor task, see the Help system for the Web Mapping Application, under the page "Editing Data". You can obtain a copy of this Help by creating a new website from the Visual Studio menu under File-New-Website, and choosing the "Web Mapping Application" template. You can also generate a new website from the ArcGIS Server Manager or ArcIMS Web Manager. In either case, a Help folder will be included in the website. The editor task help may be brought up from the main Help page (default.htm), or it can be viewed directly at the EditorTask.htm page.

Members

Properties

  The following tables provide a list of properties and events of interest.  For complete reference information, see the EditorTask control in the library reference section.

Property Name

 Type

Description

ConflictLevel

ConflictLevel

How conflicts are defined. Either when a second user edits the same feature (Row), or only when editing the same attributes of a feature (Column).

Conflict Resolution

ConflictResolution

Whether conflicting features are replaced by their representations in the target version or the current edit session.

CreateNewFeatureTitle

string 

Text title for the section for creating new features.

EditableLayers

 

A list of the layer IDs for all layers that will be editable by the editor

EditAttributesTitle

string

Text title for the section for editing feature attributes.

EditExistingFeatureTitle

string

Text title for the section for modifying the geometry and position of features.

EditorSettingsTitle

string

Text title displayed in the section for changing edit settings for snapping and feature selection.

EnableChangeSettings

bool

Whether to allow the user to change edit settings for snapping and feature selection.

EnableEditAttributes

bool

Whether to allow the user to change attributes of features.

EnableEditExistingFeature

bool

Whether to allow the user to modify the geometry or position of existing features.

EnableNewFeatureCreation

bool

Whether to allow the user to add new features.

FeatureHighlightColor

Color

The color to use for highlighting the feature selected for attribute editing.

FeatureSelectionColor

Color

Color to highlight features when selected by the user.

FeatureSelectionMode

FeatureSelectionMode

How features are to be selected with the SelectFeature tool.

MapResource

string

The map resource to be edited.

NotifyOnConflicts

bool

Whether to display a notification message when conflicts are detected and resolved while saving edits.

SelectionLimit

int

Maximum number of features selectable by the user.

SelectionTolerance

int

When selecting, features within this number of pixels of a click will be selected.

ShowFeatureHighlight

bool

Indicates if the feature whose attributes are shown in the attribute editor panel should be highlighted.

ShowSnapCircle

bool

Whether to display a circle around the cursor that indicates the snapping distance.

Snapping

StringList

The snapping rules to use while editing.

SnapTipColor

Color

When the user is using a tool with snapping enabled, and presses the 's' key, a marker will be displayed with this color at the location that will be snapped to.

SnapTolerance

int

Pixel distance within which snapping to a feature will occur.

TaskResultsContainers

BuddyControlCollection

The controls in which results from this task are displayed.

Title

string

Text displayed in the main title of the editor task window.

VersionIDs

StringList

A list of all of the versions that will be editable by the editor. If the editable layers are non-versioned, then this property is ignored.

VertexColor

Color

Color of vertices when displayed by the user.

Events

Event Type 

Description

EditorPanelsCreated

Occurs when the editor panels (create feature, edit feature, edit attribute) are created.   Can be used to add a custom panel to the main EditorTask panel. 

PanelCollapsed

Occurs when any panel in the EditorTask is collapsed.

PanelExpanded

Occurs when any panel in the EditorTask is expanded.

PostAttributeEdit

This event is fired when an attribute edit has completed.

PostCommandExecute

An Editor command completed execution of its server action.

PostToolExecute

An Editor tool completed execution of its server action.

PreAttributeEdit

This event is fired when an attribute edit is about to be made.  It may be used for input validation or cancellation of the edit.

PreCommandExecute 

An Editor command is about to execute its server action.

PreToolExecute

An Editor tool is about to execute its server action.  This would allow developers to target specific edits and possibly abort based on their own criteria or add their own logging.

SettingsPanelsCreated 

Occurs when the settings panel is created (when the Settings link in the main EditorTask panel is clicked).   Can be used to add a custom panel to the Settings panel.

SetVersion

Fired when the end-user selects a version from the version list.  The version of the layers in the workspace being edited are set to the selected version.

ToolsCreated

Occurs when the tools in an existing toolbar, in an Editor panel, are created.  Can be used to add a custom tool to an existing toolbar.

Event Arguments

Event Argument Type 

Description

EditorPanelsCreatedEventArgs

Created when the EditorPanelsCreated event occurs.  Provides access to the existing panels on the main EditorTask panel.

PostAttributeEditEventArgs

Created when the PostAttributeEdit event occurs.  Provides access to the feature and dataset that was edited.

PostCommandExecuteEventArgs

Created when the PostCommandExecute event occurs.  Provides access to the editable feature layer and server context.

PostToolExecuteEventArgs

Created when the PostToolExecute event occurs.  Provides access to the editable feature layer and server context.

PreAttributeEditEventArgs

Created when the PreAttributeEdit event occurs.  Provides access to the feature and dataset being edited.

PreCommandExecuteEventArgs

Created when the PreCommandExecute event occurs.  Provides access to the editable feature layer and server context.

PreToolExecuteEventArgs

Created when the PreToolExecute event occurs.  Provides access to the editable feature layer and server context.

ToolsCreatedEventArgs

Created when the ToolsCreated event occurs.  Provides access to the toolbars in the EditorTask.

Discussion

*                               Panel Structure and Naming

*                               If an editable layer is versioned, the Set Version panel will be displayed when the EditorTask is initialized at runtime. 

*                              

*                               The Editor panel contains a set of sub panels which contain different items depending on the purpose and feature type being edited.  Note that editing non-versioned data will change the availability of some commands on the Editor panel.  When using non-versioned data with a pooled service, the Editor panel will not contain a Undo, Redo, or Save button for pooled services.  When using non-versioned data with non-pooled service, the Undo and Redo button will not be available.  

*                                

*                               The Settings panel compliments actions on the Editor panel.  It exposes the ability to change snapping rules and selection behavior when editing data.

*                              

*                               Attribute Filtering 

*                               The EditorTask can be customized to filter attributes available for editing at runtime.  The EditorTask has a property named AttributeDisplay which is a collection of AttributeDisplayInfo objects.  The AttributeDisplayInfo class allows you to define how attributes are displayed for a specific layer using the DisplayMode enumeration.  DisplayMode is defined as follows:

*                               [C#]

*                                             public enum AttributeDisplayMode

*                                         {

*                                             /// <summary>

*                                             /// The attribute is displayed and editable.

*                                             /// </summary>

*                                             Editable,

*                                             /// <summary>

*                                             /// The attribute is shown as read-only.

*                                             /// </summary>

*                                             ReadOnly,

*                                             

*                                             /// <summary>

*                                             /// The attribute is not shown.

*                                             /// </summary>

*                                             Hidden

*                                         }

*                                                                          

The AttributeDisplayInfo class enables you to do two things:

1) Specify how attributes are displayed by default.

2) Define how specific fields that are to be displayed using the Add method.

If you only want to display a few attributes, you can set the default display mode to ?Hidden? (via the constructor or DefaultDisplayMode property) and explictly list the fields you want to display. Conversely, if you have many attributes and only want to hide a few, set DefaultDisplayMode to ?Editable? or "ReadOnly" and then turn off the fields you want to hide.   Here is a sample code snippet to illustrate filtering attributes on a layer using AttributeDisplayInfo:

[C#]

    protected void Page_Load(object sender, EventArgs e)

    {

        if (!Page.IsPostBack)

            FilterAttributes();

    }

    private void FilterAttributes()

    {

        AttributeDisplayInfo adi = new AttributeDisplayInfo(5, AttributeDisplayMode.Hidden);

        adi.Overrides.Add(new AttributeDisplayOverride("STATE_NAME", AttributeDisplayMode.ReadOnly));

        adi.Overrides.Add(new AttributeDisplayOverride("STATE_FIPS", AttributeDisplayMode.ReadOnly));

        adi.Overrides.Add(new AttributeDisplayOverride("SUB_REGION", AttributeDisplayMode.ReadOnly));

        adi.Overrides.Add(new AttributeDisplayOverride("POP1990", AttributeDisplayMode.ReadOnly));

        adi.Overrides.Add(new AttributeDisplayOverride("POP1999", AttributeDisplayMode.Editable));

        adi.Overrides.Add(new AttributeDisplayOverride("AVG_SALE87", AttributeDisplayMode.Editable));

        EditorTask1.AttributeDisplay.AttributeDisplayInfos.Add(adi);

    }

Using the code above, here are the before and after screenshots of the EditorTask illustrating the changes in the attribute panel:

*                               Customizing Toolbars and Tools

*                               The ToolsCreated event on the EditorTask control gives you access to a list of toolbars and the parent that contains the toolbars. You can use the parent property to determine which EditorPanel has created its child toolbars, or possibly if it is the main EditorTask common tools toolbar in which case the parent will be the Editor itself, and then you can manipulate the toolbar collection to add, remove or reorder toolbars and/or tools within toolbars. The main Editor panel contains EditorPanels with toolbars: NewFeatureCreator, ExistingFeatureEditor, and AttributesEditor.

*                                                       Reorder Existing Tools

*                                                       Implement the ToolsCreated event handler as follows:

*                                                       [C#]

*                                         protected void EditorTask1_ToolsCreated(object sender, ToolsCreatedEventArgs e)

*                                         {

*                                             if (e.Parent == EditorTask1.Editor.ExistingFeatureEditor)

*                                             {

*                                                 // Remove the first toolbar

*                                                 Toolbar toolbar0 = e.Toolbars[0];

*                                                 Toolbar toolbar1 = e.Toolbars[1];

*                                                 e.Toolbars.Remove(toolbar0);

*                                                 // Add the delete tool from first toolbar to second toolbar

*                                                 ToolbarItem deleteTool = toolbar0.ToolbarItems.Find("DeleteFeature");

*                                                 toolbar1.ToolbarItems.Add(deleteTool);

*                                                 // Widen toolbar to accommodate additional tool

*                                                 toolbar1.Width = new Unit(toolbar1.Width.Value + 35, UnitType.Pixel);

*                                             }

*                                         }

Here are before and after images of the EditorTask. Notice that the delete tool from the top row of tools has been moved to the bottom toolbar and the top toolbar has been removed.

*                                                       Adding Custom Tools, Commands, and Toolbars

*                                                       The ToolsCreated event can also be used to add custom tools and commands.  When creating custom tools, command and toolbars, you can use the EditorTool, EditorCommand, and EditorTooblar classes in the ESRI.ArcGIS.ADF.ArcGISServer.Editor.dll assembly.  These classes extend standard tools, commands and toolbars defined in the ESRI.ArcGIS.ADF.Web.UI.WebControls.dll assembly.   The classes that implement the server action for the EditorTool and EditorCommand objects must derive from EditorServerToolAction and EditorServerCommandAction, respectively. This will enable EditorTask specific actions to occur and be handled.  For example, custom editor tools and commands have the ability to handle the pre and post tool/command execute events and hide the AJAX indicator image when the server action completes.  In addition, there are Start, Stop and AbortEditOperation methods that must be used when performing edits (depending on editable layer and service properties) and methods for refreshing the EditorTask and map.    

*                                                                               EditorCommand

*                                                                               The EditorCommand constructor defines the following signature:

*                                     public EditorCommand(string name, ToolGeometry geometryType, int minSelectedFeatures)

The geometryType parameter specifies the type(s) of geometry the EditorCommand can work with. For instance, the ClearSelection EditorCommand is valid for all geometry types, while the ShowVertex EditorCommand is only valid for polyline and polygon geometries (both commands are included with the EditorTask).   When the geometry type of the current edit layer is incompatible with the geometry type that the EditorCommand can work with, the EditorCommand is hidden.   EditorCommands also specify their minimum selection count requirement.   For example, the ShowVertex EditorCommand is usable if at least one feature is selected, while the MergePolygon EditorCommand is usable if at least two features are selected.  If the number of selected features is less than the minimum selection count, then the EditorCommand is automatically disabled until the number of selected features satisfies this requirement.

*                                                                               EditorTool

*                                                                               The EditorTool constructor defines the following signature:

*                                     public EditorTool(string name, string mapID, bool useSnapping, ToolGeometry geometryType, int minSelectedFeatures)

The EditorTool constructor shares the same parameters as the EditorCommand plus two additional parameters: mapID and useSnapping.  The mapID is the client ID of the map being used by the EditorTask.  The useSnapping parameter specifies if the tool works with snapping.  If this is set to ?true? then when the EditorTool is active, snap tips will be enabled and the snapping circle will be displayed if the ?show snap circle? setting is enabled.

*                                                                               EditorToolbar

*                                                                               You can also use an EditorToolbar to contain the tools and commands.  The EditorToolbar updates EditorTools and EditorCommands based on properties of the edit session - such as current edit layer geometry and number of selected features.  The following event handler implementation will add a tool to the common tool area of the EditorTask, and add a new Toolbar to the geometry editing panel.

*                                                                               Example: Using the ToolsCreated event to add custom editor tools, commands, and toolbars

*                                                                               The following example illustrates how to programatically add a new EditorCommand to an existing toolbar in the EditorTask and add a new EditorToolbar with a new EditorTool.  The event argument type ToolsCreatedEventArgs provides access to panels within the EditorTask so you can locate the panel or toolbar you want to modify.   Note, the ToolsCreated event is handled in the page that contains the EditorTask.

*                                                                                

*                                                                               [C#]

*                                     protected void EditorTask1_ToolsCreated(object sender, ToolsCreatedEventArgs e)

*                                     {

*                                         // Add tool to main toolbar area

*                                         if (e.Parent == EditorTask1.Editor)

*                                         {

*                                             Toolbar toolbar = e.Toolbars[0];

*                                             // Create a command

*                                             EditorCommand command = new EditorCommand("MyCommand", ToolGeometry.All, 0);

*                                             command.DefaultImage = "~/images/tool1.gif";

*                                             command.HoverImage = "~/images/tool1_hover.gif";

*                                             command.SelectedImage = "~/images/tool1_selected.gif";

*                                             command.ServerActionAssembly = "App_Code";

*                                             command.ServerActionClass = "MyCommand";

*                                             command.ToolTip = "MyCommand";

*                                             toolbar.ToolbarItems.Add(command);

*                                             

*                                             // Widen toolbar to accomodate additional tool

*                                             toolbar.Width = new Unit(toolbar.Width.Value + 35, UnitType.Pixel);

*                                         }

*                                         else if (e.Parent == EditorTask1.Editor.ExistingFeatureEditor)

*                                         {

*                                             // Create a new toolbar

*                                             EditorToolbar toolbar = new EditorToolbar();

*                                             toolbar.ID = "MyToolbar";

*                                             toolbar.BuddyControlType = BuddyControlType.Map;

*                                             toolbar.BuddyControls.Add(new BuddyControl("Map1"));

*                                             toolbar.ToolbarStyle = ToolbarStyle.ImageOnly;

*                                             // Create some tools

*                                             EditorTool tool = new EditorTool("MyTool2", Map1.ClientID, true, ToolGeometry.Polygon, 1);

*                                             tool.ClientAction = "Line";

*                                             tool.DefaultImage = "~/images/tool2.gif";

*                                             tool.HoverImage = "~/images/tools2_hover.gif";

*                                             tool.SelectedImage = "~/images/tools2_selected.gif";

*                                             tool.ServerActionAssembly = "App_Code";

*                                             tool.ServerActionClass = "MyTool2";

*                                             tool.ToolTip = "MyTool2";

*                                             toolbar.ToolbarItems.Add(tool);

*                                             // Add more tools like above

*                                            

*                                             // Add toolbar to toolbar collection

*                                             toolbar.Width = new Unit(toolbar.ToolbarItems.Count * 35, UnitType.Pixel);

*                                             e.Toolbars.Add(toolbar);

*                                         }

*                                         }

Below are the before and after images of the EditorTask.

*                                                                               Example: Custom EditorTool Implementation

*                                                                               The following example will create a custom EditorTool that will clip the selected features to the input envelope. The first step is to implement the server action that will actually perform the clipping. In the code, the EditorServerAction method has access to the input envelope which will be converted to map coordinates behind the scenes before the EditorServerAction method is called. Also available from the base class is the Editor instance and LayerDescription for the current layer. Notice that the clipped feature IDs are stored in a property. This is because PostToolExecute event handlers will have access to this object so you can expose this information to the handler.

*                                                                               [C#]

*                                     public class ClipFeatures : EditorServerToolAction

*                                     {

*                                         private List<int> features = new List<int>();

*                                         public List<int> Features

*                                         {

*                                             get { return features; }

*                                         }

*                                         protected override bool Init(Editor editor)

*                                         {

*                                             features.Clear();

*                                             return base.Init(editor);

*                                         }

*                                         

*                                         protected override void EditorServerAction()

*                                         {

*                                             IEnvelope env = Geometry as IEnvelope;

*                                             MapDescription mapDesc = Editor.MapFunctionality.MapDescription;

*                                             int[] fidSet = LayerDescription.SelectionFeatures;

*                                             if (fidSet != null && fidSet.Length > 0)

*                                             {

*                                                 ITopologicalOperator3 topo3 = null;

*                                                 IFeature feature = null;

*                                                 try

*                                                 {

*                                                     StartEditOperation();

*                                                     IFeatureCursor cursor = FeatureLayer.FeatureClass.GetFeatures(fidSet, false);

*                                                     feature = cursor.NextFeature();

*                                                     while (feature != null)

*                                                     {

*                                                         topo3 = (ITopologicalOperator3)feature.ShapeCopy;

*                                                         topo3.Clip(env);

*                                                         IGeometry geometry = (IGeometry)topo3;

*                                                         if (!geometry.IsEmpty)

*                                                         {

*                                                             feature.Shape = geometry;

*                                                             feature.Store();

*                                                             // Keep track of the clipped features

*                                                             features.Add(feature.OID);

*                                                         }

*                                                         feature = cursor.NextFeature();

*                                                     }

*                                                     StopEditOperation();

*                                                 }

*                                                 catch (Exception e)

*                                                 {

*                                                     AbortEditOperation(e);

*                                                 }

*                                                 if (features.Count > 0)

*                                                 {

*                                                     // Refresh the Editor, Map, vertices, etc. with the new selection set

*                                                     Refresh(features, true);

*                                                 }

*                                             }

*                                         }

*                                     }

Now that the server action is complete, we need to associate it with a tool. This can be done in the ToolsCreated event handler. We need to specify that this tool works on line and polygon geometry and that at least one feature must be selected. Also, snapping will not be used by this tool.

[C#]

    protected void EditorTask1_ToolsCreated(object sender, ToolsCreatedEventArgs e)

    {

        if (e.Parent == EditorTask1.Editor.ExistingFeatureEditor)

        {

            // Add tool to the second standard toolbar in the EditorPanel

            EditorTool clip = new EditorTool("Clip", Map1.ClientID, false, ToolGeometry.Line | ToolGeometry.Polygon, 1);

            clip.ClientAction = "DragRectangle";

            clip.DefaultImage = "~/images/clip.gif";

            clip.SelectedImage = "~/images/clip_on.gif";

            clip.HoverImage = "~/images/clip_over.gif";

            clip.ToolTip = "Clip Feature(s)";

            clip.ServerActionAssembly = "App_Code";

            clip.ServerActionClass = "ClipFeatures";

            e.Toolbars[0].ToolbarItems.Add(clip);

            double oldWidth = e.Toolbars[0].Width.Value;

            e.Toolbars[0].Width = new Unit(oldWidth + 35, UnitType.Pixel);

        }

    }

For more information on implementing custom tools and commands in the Web ADF, see the discussion section of the Toolbar control.

*                                                       Adding Custom Editor Panels

*                                                       The EditorPanelsCreated and SettingsPanelsCreated events can be handled to modify the panels shown in the main Editor panel and also in the associated Settings panel. Panels may be added, removed and reordered. To add a panel, create a subclass of EditorPanel or TooledEditorPanel and add it to the collection exposed in the event argument. TooledEditorPanel has a collection of toolbar items which can be populated by overriding the CreateToolbars() method. This class will fire the ToolsCreated on the EditorTask after this method returns. Here is a very simple example of a custom EditorPanel.

*                                                       [C#]

*                                     public class MyPanel : EditorPanel

*                                     {

*                                         public MyPanel(string title, EditorTask task, string ID) : base(title, task, ID) { }

*                                         protected override void RenderContents(HtmlTextWriter writer)

*                                         {

*                                             writer.Write("This is my custom panel");

*                                         }

*                                     }

By adding this class to the App_Code folder of the EditorTask web application, the custom panel can be added to the EditorTask with the following EditorPanelsCreated event handler code:

[C#]

    protected void EditorTask1_EditorPanelsCreated(object sender, EditorPanelsCreatedEventArgs e)

    {

        MyPanel panel = new MyPanel("My Custom Panel", EditorTask1, "myPanelID");

        e.EditorPanels.Insert(0, panel);

    }

At runtime, the custom panel will appear as follows. Notice that in the code above the custom panel was inserted into the first position in the EditorPanel collection (index 0) so that the custom panel is displayed above the other standard EditorPanel panels.

Similarly, a custom panel can be added to the Editor Settings panel (displayed when clicking the "Settings" link at the bottom of the EditorTask) by handling the SettingsPanelsCreated event like follows:

[C#]

    protected void EditorTask1_SettingsPanelsCreated(object sender, EditorPanelsCreatedEventArgs e)

    {

        MyPanel panel = new MyPanel("My Custom Settings Panel", EditorTask1, "mySettingsPanelID");

        e.EditorPanels.Insert(1, panel);

    }

At runtime, the custom panel will appear as follows. Notice this time that in the code above the custom panel was inserted into the second position in the EditorPanel collection (index 1) so that the custom panel is displayed between the other standard EditorPanel panels.

 

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值