Common CustomDataSourceCommon_CustomDataSource_CSharp\CustomDataSource_CSharp\REXMLDataSource_CSharp\MapTocFunctionality.cs
// Copyright 2007 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.Collections.Generic;
using System.Text;
using ESRI.ArcGIS.ADF.Web.DataSources;
using ESRI.ArcGIS.ADF.Web;
namespace REXMLDataSource_CSharp
{
public class MapTocFunctionality : IMapTocFunctionality
{
#region private member variables
private string name = string.Empty;
private IGISResource resource = null;
private bool initialized = false;
private MapResource mapResource;
#endregion
public MapTocFunctionality(string name, MapResource resource)
{
this.name = name;
this.resource = resource;
mapResource = resource;
}
#region IMapTocFunctionality implementation
public void SetLayerVisibility(string mapFunctionalityName, object layerID, bool visible)
{
MapFunctionality mapFunc = GetMapFunctionality(mapFunctionalityName);
if (mapFunc == null)
throw new ArgumentException("mapFunctionalityName");
mapFunc.SetLayerVisibility(layerID.ToString(), visible);
}
public TocDataFrame[] GetMapContents(string mapFunctionalityName, WebImageFormat format, bool useMimeData, bool showAllDataFrames)
{
TocDataFrame[] tocDataFrames = new TocDataFrame[1];
tocDataFrames[0] = new TocDataFrame(resource.Name);
System.Web.SessionState.HttpSessionState session = null;
try
{
System.Web.HttpContext httpContext = System.Web.HttpContext.Current;
if (httpContext != null)
session = httpContext.Session;
}
catch { }
ESRI.ArcGIS.ADF.Web.Display.Swatch.SwatchInfo swatchInfo = new ESRI.ArcGIS.ADF.Web.Display.Swatch.SwatchInfo(10, 10, session);
foreach (System.Data.DataTable table in mapResource.Graphics.Tables)
{
tocDataFrames[0].Add( ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicsLayer.GetTocLayer(table as ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicsLayer, swatchInfo));
}
return tocDataFrames;
}
#endregion
#region IGISFunctionality implementation
[NonSerialized]
System.Web.UI.WebControls.WebControl _webControl;
public System.Web.UI.WebControls.WebControl WebControl
{
get { return _webControl; }
set { _webControl = value; }
}
public string Name
{
get { return name; }
set { name = value; }
}
public IGISResource Resource
{
get { return resource; }
set { resource = value; }
}
public bool Initialized
{
get { return initialized; }
}
public void LoadState() { }
public void Initialize()
{
initialized = true;
}
public void SaveState() { }
public void Dispose()
{
initialized = false;
}
public bool Supports(string operation)
{
return true;
}
#endregion
#region private methods
private MapFunctionality GetMapFunctionality(string name)
{
MapFunctionality mapFunctionality = resource.Functionalities.Find(name) as MapFunctionality;
return mapFunctionality;
}
#endregion
}
}