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

📄 polylinetool.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.Collections.Generic;
using System.Text;
using System.Web;
using ESRI.ArcGIS.ADF.Web.UI.WebControls;
using ESRI.ArcGIS.ADF.Web.UI.WebControls.Tools;
using ESRI.ArcGIS.ADF.ArcGISServer;
using ESRI.ArcGIS.ADF.Web.DataSources;
using ESRI.ArcGIS.Server;
using System.Collections;


public class PolylineTool: IMapServerToolAction
{

    #region IMapServerToolAction Members

    public void ServerAction(ToolEventArgs args)
    {
        ESRI.ArcGIS.ADF.Web.UI.WebControls.Map mapctrl;
        mapctrl = (ESRI.ArcGIS.ADF.Web.UI.WebControls.Map)args.Control;

        PolylineEventArgs peal = (PolylineEventArgs)args;
        System.Drawing.Point[] screen_points = peal.Vectors;

        ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality ags_mf = (ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality)mapctrl.GetFunctionality(0);
        //ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceLocal ags_mr = (ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceLocal)ags_mf.Resource;
        //ESRI.ArcGIS.Server.IServerContext sc = ags_mr.ServerContextInfo.ServerContext;
        ESRI.ArcGIS.ADF.ArcGISServer.MapDescription mapDescription;
        mapDescription = ags_mf.MapDescription;

        RgbColor rgb = new RgbColor();
        rgb.Red = 0;
        rgb.Green = 255;
        rgb.Blue = 0;
        rgb.AlphaValue = 255;

        PointN[] pnts1 = new PointN[screen_points.Length];

        for (int i = 0; i < screen_points.Length; i++)
        {
            PointN pnt = new PointN();
            ESRI.ArcGIS.ADF.Web.Geometry.Point mappnt = ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(screen_points[i], mapctrl.Extent, (int)mapctrl.Width.Value, (int)mapctrl.Height.Value); 
            pnt.X = mappnt.X;
            pnt.Y = mappnt.Y;
            pnts1[i] = pnt;
        }
        
        Path path1 = new Path();
        path1.PointArray = pnts1;

        Path[] paths = new Path[1];
        paths[0] = path1;

        PolylineN pline = new PolylineN();
        pline.PathArray = paths;
        pline.HasID = false;
        pline.HasM = false;
        pline.HasZ = false;
        pline.SpatialReference = mapDescription.SpatialReference;
        pline.Extent = new EnvelopeN();

        SimpleLineSymbol sls = new SimpleLineSymbol();
        sls.Color = rgb;
        sls.Style = esriSimpleLineStyle.esriSLSSolid;
        sls.Width = 2;

        LineElement le = new LineElement();
        le.Line = pline;
        le.Symbol = sls;

        if (mapDescription.CustomGraphics != null)
        {
            GraphicElement[] oldges = mapDescription.CustomGraphics;
            int cnt = oldges.Length;
            GraphicElement[] newges = new GraphicElement[cnt + 1];
            oldges.CopyTo(newges, 0);
            newges[cnt] = le;
            mapDescription.CustomGraphics = newges;
        }
        else
        {
            GraphicElement[] ges = new GraphicElement[1];
            ges[0] = le;
            mapDescription.CustomGraphics = ges;
        }
                
        mapctrl.Refresh();
    }

    #endregion
}

⌨️ 快捷键说明

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