ADFTutorials_CSharp\AccessArcIMS\App_Code\PointTool.cs
// Copyright 2011 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. // 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.Web.DataSources.IMS; using ESRI.ArcGIS.ADF.IMS.Display.AcetateElement; using ESRI.ArcGIS.ADF.IMS.Display.Symbol; using ESRI.ArcGIS.ADF.IMS.Carto; using ESRI.ArcGIS.ADF.IMS.Carto.Layer; /// <summary> /// Summary description for PointTool /// </summary> 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; MapPointEventArgs mpea = (MapPointEventArgs)args; ESRI.ArcGIS.ADF.IMS.Geometry.Point ims_map_point = (ESRI.ArcGIS.ADF.IMS.Geometry.Point) ESRI.ArcGIS.ADF.Web.DataSources.IMS.Converter.ToIMSGeometry(mpea.MapPoint); ESRI.ArcGIS.ADF.Web.DataSources.IMS.MapFunctionality mf; mf = (ESRI.ArcGIS.ADF.Web.DataSources.IMS.MapFunctionality)mapctrl.GetFunctionality("MapResourceItem0"); ESRI.ArcGIS.ADF.IMS.Carto.MapView mapview = mf.MapView; ESRI.ArcGIS.ADF.IMS.Carto.Layer.AcetateLayer alayer = (ESRI.ArcGIS.ADF.IMS.Carto.Layer.AcetateLayer)mapview.Layers.FindByName("acetate_name"); if (alayer == null) { alayer = new ESRI.ArcGIS.ADF.IMS.Carto.Layer.AcetateLayer(); alayer.Name = "acetate_name"; mapview.Layers.Add(alayer); } alayer.Visible = true; ESRI.ArcGIS.ADF.IMS.Display.AcetateElement.GeometryElement ge = new ESRI.ArcGIS.ADF.IMS.Display.AcetateElement.GeometryElement(ESRI.ArcGIS.ADF.IMS.Display.AcetateElement.AcetateUnits.Database); ge.Element = ims_map_point; ESRI.ArcGIS.ADF.IMS.Display.Symbol.SimpleMarkerSymbol sms = new ESRI.ArcGIS.ADF.IMS.Display.Symbol.SimpleMarkerSymbol(); sms.Color = System.Drawing.Color.SpringGreen; sms.Type = ESRI.ArcGIS.ADF.IMS.Display.Symbol.MarkerSymbolType.Star; sms.OutlineColor = System.Drawing.Color.Black; sms.Width = 24; ge.Symbol = sms; ESRI.ArcGIS.ADF.IMS.Display.AcetateElement.AcetateElementCollection aec = alayer.AcetateElements; aec.Add(ge); mapctrl.RefreshResource(mf.Resource.Name); } }