Maps类的代码
Maps这个类也许是所有读者最关心的问题,也许我的确忘记交代了,可是在5-11图中,读者完全应该能看出该类的原理。为了不让大家继续困扰,特给出代码,更简单:
public class Maps : IMaps, IDisposable
{
private IList<IMap> _mapList = null;
#region class constructor
public Maps()
{
_mapList = new List<IMap>();
}
#endregion
#region IDisposable Members
/// <summary>
/// 释放集合对象
/// </summary>
public void Dispose()
{
if (_mapList != null)
{
_mapList.Clear();
_mapList = null;
}
}
#endregion
#region IMaps Members
/// <summary>
/// 移除指定的地图
/// </summary>
/// <param name="Index"></param>
public void RemoveAt(int Index)
{
if (Index > _mapList.Count || Index < 0)
throw new Exception("Maps::RemoveAt:\r\n索引越界!");
_mapList.RemoveAt(Index);
}
/// <summary>
/// 清除所有Map
/// </summary>
public void Reset()
{
_mapList.Clear();
}
/// <summary>
/// 返回Map集合中Map数量
/// </summary>
public int Count
{
get
{
return _mapList.Count;
}
}
/// <summary>
/// 返回指定的Map对象
/// </summary>
/// <param name="Index"></param>
/// <returns></returns>
public IMap get_Item(int Index)
{
if (Index > _mapList.Count || Index < 0)
throw new Exception("Maps::get_Item:\r\n索引值越界!");
return _mapList[Index];
}
/// <summary>
/// 删除一个指定的Map对象
/// </summary>
/// <param name="Map"></param>
public void Remove(IMap Map)
{
_mapList.Remove(Map);
}
/// <summary>
/// 产生一个新地图并将其添加到Map集合中
/// </summary>
/// <returns></returns>
public IMap Create()
{
IMap newMap = new MapClass();
_mapList.Add(newMap);
return newMap;
}
/// <summary>
/// 将一个Map添加到集合中
/// </summary>
/// <param name="Map"></param>
public void Add(IMap Map)
{
if (Map == null)
throw new Exception("Maps::Add:\r\n新地图没有初始化!");
_mapList.Add(Map);
}
#endregion
}
Related Items
Comments
帮助文件中是有啊,可很多人不看帮助啊![]()
if(m_pageLayeroutControl==null||m_mapControl==null)
throw new Exception("ControlsSynchronize::BindControls:\r\nMapControl或PageLayoutControl没有初始化!");
不知为什么会出现这样的错误 ,我的代码按书上的,自己也推敲了,觉得应该能从maingis类中初始化了。
请问这是什么原因啊?
(插件式。。。那本书学习中遇到的问题)
显然,你的m_pageLayeroutControl和m_mapControl均未赋值
public int Count报错:
Maps类不实现接口成员 ESRI.ArcGIS.Carto.IMaps.Count
请问这是怎么回事?
谢谢请解释一下。
Maps类实现了IMaps接口,其中的每一个产生和方法都需要自己来实现
22 于 2009-6-25 22:27:04 回复我完全是按照上面的代码敲进去的,其中count的代码我也录入了,其他代码都没问题,就是这一个不知道是怎么回事?一直报错:Maps类不实现接口成员 ESRI.ArcGIS.Carto.IMaps.Count
谢谢,请解释 一下,已经困扰我好几天了。
我完全是按照上面的代码敲进去的,其中count的代码我也录入了,其他代码都没问题,就是这一个不知道是怎么回事?一直报错:Maps类不实现接口成员 ESRI.ArcGIS.Carto.IMaps.Count
谢谢,请解释 一下,已经困扰我好几天了。
我用的是vs2008,这个Map一直有上述问题,请lz给解释一下。谢谢。
ls的不知道你所说的List<IMap>是怎么用的呀?是只改一行代码,还是全部都改?不太懂。谢谢你的回复
你不会是用了.NET3.5吧??
//产生一个地图容器IMaps对象
IMaps maps = new Maps();
找不到类型或命名空间名称“Maps”(是否缺少 using 指令或程序集引用?)
这是怎么回事????
Maps是一个实现了IMaps的集合类,需要你自己写
Leave a comment
Or, take a look at Archives and Categories
帮助文件中就有