2010年8月09日_周一_Toc control

/*******************************************************************************/

//web controls

//Toc control

//2010年8月8日

/******************************************************************************/

Language

C#

Show All



The table of contents, or Toc, control lists the layers on the map and shows what the features represent.  A toc is buddied with a map control.  As a result, checking a layer on in the toc control will draw it in the map control.  Each resource associated with a map control may contain one or more layers. The toc control represents each resource as a group layer, which is a layer that contains layers.
Toc控件是一个内容列表,她列出了在地图控件中的包含的图层以及图层所代表的要素。Toc控件和一个map控件(ˇˍˇ) (ˇˍˇ) 相绑。 结果,在Toc控件中选中一个图层,那么这个图层就将在地图控件中绘制。和地图控件相关联的的每一个资源都包含一个或者多个图层。Toc控件把每一个资源都当做一个图层组,它又是一个可以包含其他图层的图层。


The Toc control inherits from the TreeViewPlus control, which is a Web ADF control that allows you to display data in a tree-type control with expandable nodes. TreeViewPlus is also used in the TaskResults control. It is possible to programmatically alter(改变) the nodes in the Toc by adding, moving or deleting nodes. However, keep in mind that the typical use of the Toc and Web ADF involves(包含、牵涉、涉及) client callbacks rather than full page postbacks, so that server-side methods to modify the Toc cannot ordinarily(平常的、普通的) be done after startup in the browser.
toc控件继承于TreeViewPlus控件,TreeViewPlus控件是一个web ADF控件,它允许你使用展开的节点以树状形式来展示数据。TreeViewPlus控件也有在TaskResults控件中使用 。通过编程的方式是可以改变节点的,比如:添加、移动或者删除节点等等。 不过,一定要记住的是:TOC控件以及WebResults的典型应用是涉及到客户端的回调而不是整个页面的回发。因此,服务器端方法对TOC控件的重新定义,当TOC控件在浏览器中启动后,是不能或者不能正常的去完成。


Assembly: ESRI.ArcGIS.ADF.Web.UI.WebControls.dll
Class: ESRI.ArcGIS.ADF.Web.UI.WebControls.Toc

Using the Toc control

TOC控件引用,以及其的命名空间

Add supporting controls to the page
In order to use the 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 zoom/pan controls (users can also zoom/pan using mouse/keyboard combinations).

向页面中添加支持的控件

为了使用TOC控件,一系列支持的控件必须是可以获得的。启动一个含有MapResourcemanager控件和Map控件的页面,其他的控件是可以选择性的添加。 比如:用来提供进行平移或者缩放工具ToolBar控件(用户也可以结合使用鼠标和键盘来对地图进行平移、缩放等操作)。

Add the Toc control to the page
Drag a Toc control onto the page. Your page should resemble the following (this layout is using a table, so your arrangement may differ):
向页面中添加TOC控件

向页面中拖放一个TOC控件,你的页面应该和下面的类似(这个布局使用来一个表格,所以这个和你的安排可能有所不同)

 

Set the properties for the Toc control 
设置TOC控件的属性
In design mode, click on the Toc control to select it. The Properties window displays the properties for the control:
在设计视图模式下,单击TOC控件,并选择他,属性页面将会展示TOC控件的属性


The only property that you must set for the Toc control is the Map property. Click the drop-down list for its value and choose the Map control added previously.

Members

唯一的一个必须为TOC控件设置的属性是地图属性。单击下拉列表选择值并选择在上一步添加的Map控件。
Properties
属性
The following table provides a list of properties of interest.  For complete reference information, see the Toc control in the library reference section.

Property Name

 Type

Description

BuddyControl

string

The Map control ID to which the Toc will be buddied to.

DisabledColor

Color

Color to display disabled nodes, such as nodes for layers that are not visible at the current scale.

ExpandDepth

int

Levels of the Toc's tree view to display on startup. For example, to display all layer names and legend swatches on startup, set ExpandDepth to 2. ExpandDepth is not automatically preserved if a full page postback occurs.

PageSize

int

Number of layers to display per page of the Toc. When the number of layers exceeds PageSize, links are displayed at the top of the Toc to display additional Toc pages.

RenderOnDemand

bool

Defers rendering of legend swatches until the layer is expanded to display the swatches. Useful when the Toc contains numerous or complex layers, or when users rarely expand the Toc to view legend swatches.

ShowLayerCheckBoxes

bool

Displays checkboxes for each layer, enabling the user to turn layers on and off.

ShowResourceCheckBoxes

bool

Displays a checkbox at the level of the resource (map service), enabling users to turn all layers in the service on or off. Useful when multiple services are added to the map.

SwatchPageSize

int

Maximum number of swatches to display per layer before using paging within the layer swatches. If the number of categories within the layer exceed this value, only this number are displayed at a time, and links are displayed at the top of the layer legend to display additional groups of swatches for the layer.

TocType

TocType

The default is SwatchList, which includes legend swatches, which represent layer symbology, in the Toc. The other option is LayerList, which displays only layer names, without legend swatches.

Discussion

Modifying Toc content at runtime

讨论

在运行的状态下改变TOC控件的内容
By default, if a Toc is buddied with a Map, map resources can be used to populate nodes with content that includes layer names, renderer classifications, and legend swatches.  Nodes within a Toc are populated during the initial call to PreRender, and on any call to the Refresh or RenderLegendHtml methods.   The Toc maintains an OnNodesPopulated event which is triggered after the nodes are populated.   You can handle this event and modify Toc content before it is rendered on the client.   This enables you to add, modify or remove content from the Toc.   Changes made in the handler must be applied each time the nodes are populated because the structure of the Toc is regenerated.  As a result, you need to explicitly track and manage changes you make to Toc content.   The following code provides a brief example of custom nodes being added to a Toc using a NodesPopulated event handler.
默认情况下,如果一个toc控件和一个地图绑定,地图资源就使用内容填充节点,内容包括:图层的名称,渲染的分类, legend swatches。 TOC控件中节点的初始化是发生在初始化的调用,以及任何刷新的调用或者RenderLegendHtml方法调用。TOC控件包含一个OnNodesPopulated事件,她是在节点创建完成后触发的。 你可以处理这个事件并在它显示在客户端之前重新定义TOC控件的内容。这个能够让你添加、重定义、删除来自TOC控件中的内容。 每次节点重绘的时候,发生在handle里面的变化就要被应用,这是因为,TOC结构是重载的。 结果,你需要明确的追踪和管理你改变的TOC内容。
下面的代码提供来一个简单例子,使用一个NodesPopulated事件的处理方法添加一个自定义的node到TOC控件里面


[C#]

void Toc1_NodesPopulated(object sender, EventArgs e)

{

       TreeViewPlusNode ParentNode = new TreeViewPlusNode("commserver", "Community Incidents");

       TreeViewPlusNode ChildNode1 = new TreeViewPlusNode("incidents", "Crime");

       TreeViewPlusNode ChildNode2 = new TreeViewPlusNode("b&e", "Breaking and Entering");

       TreeViewPlusNode ChildNode3 = new TreeViewPlusNode("trespass", "Trespassing");

       ChildNode1.Nodes.Add(ChildNode2);

       ChildNode1.Nodes.Add(ChildNode3);

       ParentNode.Nodes.Add(ChildNode1);

       Toc1.Nodes.Insert(0, ParentNode);

}

                                  
Runtime view:
运行状态下的视图


You can listen for other events on the Toc control (e.g. NodeChecked, NodeClicked, etc.) to manage interaction with the custom content.  
你可以侦听发生在TOC控件中的其他控件的事件来管理和自定义内容的交互。

Setting Toc tree headings
设置TOC控件标题


When you add resources (map services) to the MapResourceManager control, you can assign a value to the Name property for each resource. The Name value is used in the Toc control as the heading label for the resource (service). You should give resources names that describe their content or purpose, such as the name of the map service.

当你向TOC控件中添加MapResourceManager控件,你可以为每一个资源的Name属性设置一个值。 这个Name属性将会在TOC控件中作为资源(属性)的标题使用。你可以将Name属性设置为对资源内容或者目的的描述,比如:地图服务的名称。

原文地址:https://www.cnblogs.com/xingchen/p/1795406.html