⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pointtool.cs

📁 arcgis server9.2 (graphicElement)图形元素操作
💻 CS
字号:
// Copyright 2006 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 use restrictions at /arcgis/developerkit/userestrictions.

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using ESRI.ArcGIS.ADF.Web.UI.WebControls.Tools;
using ESRI.ArcGIS.ADF.Web.UI.WebControls;
using ESRI.ArcGIS.ADF.ArcGISServer;
using ESRI.ArcGIS.Server;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Display;
using System.Collections;
using ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer;

public class PointTool : IMapServerToolAction
{
    public void ServerAction(ToolEventArgs args)
    {
        ESRI.ArcGIS.ADF.Web.UI.WebControls.Map mapctrl;
        mapctrl = (ESRI.ArcGIS.ADF.Web.UI.WebControls.Map) args.Control;
        
        PointEventArgs pea = (PointEventArgs)args;
        System.Drawing.Point screen_point = pea.ScreenPoint;

        MapFunctionality mf = (MapFunctionality) mapctrl.GetFunctionality(0);

        ESRI.ArcGIS.ADF.ArcGISServer.MapDescription mapDescription = mf.MapDescription;
                    
        ESRI.ArcGIS.ADF.Web.Geometry.Point adf_map_point = ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(screen_point, mapctrl.Extent, mf.DisplaySettings.ImageDescriptor.Width, mf.DisplaySettings.ImageDescriptor.Height);
        
        PointN ags_map_point = ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.FromAdfPoint(adf_map_point);

        ESRI.ArcGIS.ADF.ArcGISServer.RgbColor rgb = new ESRI.ArcGIS.ADF.ArcGISServer.RgbColor();
        rgb.Red = 0;
        rgb.Green = 255;
        rgb.Blue = 0;
        rgb.AlphaValue = 255;

        ESRI.ArcGIS.ADF.ArcGISServer.SimpleMarkerSymbol sms = new ESRI.ArcGIS.ADF.ArcGISServer.SimpleMarkerSymbol();
        sms.Style = ESRI.ArcGIS.ADF.ArcGISServer.esriSimpleMarkerStyle.esriSMSDiamond;
        sms.Color = rgb;
        sms.Size = 20.0;

        ESRI.ArcGIS.ADF.ArcGISServer.MarkerElement marker = new ESRI.ArcGIS.ADF.ArcGISServer.MarkerElement();
        marker.Symbol = sms;
        marker.Point = ags_map_point;
        
        if (mapDescription.CustomGraphics != null)
        {
            GraphicElement[] oldges = mapDescription.CustomGraphics;
            int cnt = oldges.Length;
            GraphicElement[] newges = new GraphicElement[cnt + 1];
            oldges.CopyTo(newges, 0);
            newges[cnt] = marker;
            mapDescription.CustomGraphics = newges;
        }
        else
        {
            GraphicElement[] ges = new GraphicElement[1];
            ges[0] = marker;
            mapDescription.CustomGraphics = ges;
        }
                
        mapctrl.Refresh();
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -