Common_CustomControls_CSharp\ADFWebPart\Utility.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. // namespace ADFWebPart { /// <summary> /// Internal class containing methods shared by different classes within the ADFWebPart assembly /// </summary> internal class Utility { // Adds the passed-in resource to the passed-in map resource manager internal static void AddMapResourceItemToResourceManager( ESRI.ArcGIS.ADF.Web.UI.WebControls.MapResourceManager mapResourceManager, bool insertIntoBeginning, ESRI.ArcGIS.ADF.Web.UI.WebControls.MapResourceItem mapResourceItem) { if (insertIntoBeginning) { mapResourceManager.ResourceItems.Insert(0, mapResourceItem); } else { mapResourceManager.ResourceItems.Add(mapResourceItem); } } // Creates a resource item with the passed-in name, the passed-in resource definition string, // and default settings internal static ESRI.ArcGIS.ADF.Web.UI.WebControls.MapResourceItem CreateResourceItem(string resourceName, ESRI.ArcGIS.ADF.Web.UI.WebControls.GISResourceItemDefinition gisResourceItemDefinition) { ESRI.ArcGIS.ADF.Web.UI.WebControls.MapResourceItem mapResourceItem = new ESRI.ArcGIS.ADF.Web.UI.WebControls.MapResourceItem(); mapResourceItem.Definition = gisResourceItemDefinition; mapResourceItem.Name = resourceName; mapResourceItem.DisplaySettings = new ESRI.ArcGIS.ADF.Web.DisplaySettings(); mapResourceItem.DisplaySettings.Visible = true; ESRI.ArcGIS.ADF.Web.ImageDescriptor imageDescriptor = new ESRI.ArcGIS.ADF.Web.ImageDescriptor(); imageDescriptor.ImageFormat = ESRI.ArcGIS.ADF.Web.ImageFormat.PNG8; imageDescriptor.TransparentBackground = true; imageDescriptor.TransparentColor = System.Drawing.Color.White; imageDescriptor.ReturnMimeData = true; mapResourceItem.DisplaySettings.ImageDescriptor = imageDescriptor; mapResourceItem.DisplaySettings.Transparency = 0; return mapResourceItem; } // Creates a GISResourceItemDefinition with the passed-in parameters internal static ESRI.ArcGIS.ADF.Web.UI.WebControls.GISResourceItemDefinition CreateGISResourceItemDefinition(string dataSourceDefinition, string dataSourceType, string identity, string resourceDefinition, bool dataSourceShared) { ESRI.ArcGIS.ADF.Web.UI.WebControls.GISResourceItemDefinition gisResourceItemDefinition = new ESRI.ArcGIS.ADF.Web.UI.WebControls.GISResourceItemDefinition(); gisResourceItemDefinition.DataSourceDefinition = dataSourceDefinition; gisResourceItemDefinition.Identity = (identity == null) ? string.Empty : identity; gisResourceItemDefinition.ResourceDefinition = resourceDefinition; gisResourceItemDefinition.DataSourceShared = dataSourceShared; gisResourceItemDefinition.DataSourceType = dataSourceType; return gisResourceItemDefinition; } } }