ArcIMS_BlueViewer_CSharp\legend.aspx.cs
// Copyright 2010 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.Configuration; namespace BlueViewer { public partial class Legend : System.Web.UI.Page { protected System.Web.UI.WebControls.Label lblTitle; [System.Diagnostics.DebuggerStepThrough()] private void InitializeComponent() { } override protected void OnInit(System.EventArgs e) { base.OnInit(e); InitializeComponent(); } override protected void OnLoad(System.EventArgs e) { base.OnLoad(e); } override protected void OnPreRender(System.EventArgs e) { base.OnPreRender(e); string legendURL = null; if ((bool)Session["VALID_USER"]) { string sServer = ConfigurationManager.AppSettings["DEFAULT_MAPSERVER"]; int iPort = System.Convert.ToInt32(ConfigurationManager.AppSettings["DEFAULT_MAPPORT"]); string sService = ConfigurationManager.AppSettings["DEFAULT_MAPSERVICE"]; int iWidth = System.Convert.ToInt32(Request.QueryString["WIDTH"]); int iHeight = System.Convert.ToInt32(Request.QueryString["HEIGHT"]); ESRI.ArcGIS.ADF.Connection.IMS.TCPConnection conArcIMS = new ESRI.ArcGIS.ADF.Connection.IMS.TCPConnection(sServer, iPort); ESRI.ArcGIS.ADF.Connection.IMS.XML.AxlRequests axlRequest = new ESRI.ArcGIS.ADF.Connection.IMS.XML.AxlRequests(); System.Xml.XmlDocument axlResponse = new System.Xml.XmlDocument(); conArcIMS.ServiceName = sService; string sAXLText = null; sAXLText = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ARCXML version=\"1.1\">"; sAXLText = sAXLText + "<REQUEST><GET_IMAGE><PROPERTIES>"; sAXLText = sAXLText + "<IMAGESIZE width=\"" + iWidth + "\" height=\"" + iHeight + "\"/>"; sAXLText = sAXLText + "<ENVELOPE minx=\"" + Request.QueryString["XMIN"] + "\" miny=\"" + Request.QueryString["YMIN"] + "\" maxx=\"" + Request.QueryString["XMAX"] + "\" maxy=\"" + Request.QueryString["YMAX"] + "\" />"; sAXLText = sAXLText + "<LEGEND display=\"true\" autoextend=\"true\" font=\"Verdana\" />"; sAXLText = sAXLText + "</PROPERTIES></GET_IMAGE></REQUEST></ARCXML>"; axlResponse.LoadXml(conArcIMS.Send(sAXLText)); if (axlResponse.GetElementsByTagName("LEGEND").Count == 1) { System.Xml.XmlNodeList nodeOutput = axlResponse.GetElementsByTagName("LEGEND"); legendURL = nodeOutput[0].Attributes["url"].Value; } imgLegend.ImageUrl = legendURL; } else { Response.Write("Error: Page Inaccessible."); } } } }