private void MakeLegend(IActiveView activeView,IPageLayout pageLayout)
{
//定义图例UID对象
UID uid = new UIDClass();
uid.Value="esriCore.Legend";
//设置图例存放的坐标位置
//定义单位
pageLayout.Page.Units = esriUnits.esriCentimeters;
//得到草图容器对象
IGraphicsContainer container = pageLayout as IGraphicsContainer;
//得到当前地图的框架
IMapFrame frameElement = container.FindFrame(activeView.FocusMap) as IMapFrame;
IElement mapElement = frameElement as IElement;
IEnvelope mapEnv = mapElement.Geometry.Envelope;
IEnvelope envelope = new EnvelopeClass();
//通过当前地图框架得到相对位置
envelope.PutCoords(mapEnv.XMin, mapEnv.YMin, mapEnv.XMin + 6.5, mapEnv.YMin + 0.8);
IMapSurroundFrame frame = frameElement.CreateSurroundFrame(uid, null);
ILegend legend = frame.MapSurround as ILegend;</