添加图例、比例尺、指北针
代码中有注释,直接上
指北针
C#
代码
public
void
AddNorthArrow(IPageLayout pageLayout)
{
IGraphicsContainer container = pageLayout
as
IGraphicsContainer;
IActiveView activeView = pageLayout
as
IActiveView;
//
获得
MapFrame
IFrameElement frameElement =
container.FindFrame(activeView.FocusMap);
IMapFrame mapFrame = frameElement
as
IMapFrame;
//
根据
MapSurround
的
uid
,创建相应的
MapSurroundFrame
和
MapSurround
UID uid =
new
UIDClass();
uid.Value =
"esriCarto.MarkerNorthArrow"
;
IMapSurroundFrame mapSurroundFrame =
mapFrame.CreateSurroundFrame(uid,
null
);
//
设置
MapSurroundFrame
中指北针的点符号
IMapSurround mapSurround = mapSurroundFrame.MapSurround;
IMarkerNorthArrow markerNorthArrow = mapSurround
as
IMarkerNorthArrow;
IMarkerSymbol markerSymbol = markerNorthArrow.MarkerSymbol;
markerSymbol.Size = 18;
markerNorthArrow.MarkerSymbol = markerSymbol;
//QI
,确定
mapSurroundFrame
的位置
IElement element = mapSurroundFrame
as
IElement;
IEnvelope envelope =
new
EnvelopeClass();
envelope.PutCoords(0.2, 0.2, 5, 5);
element.Geometry = envelope;
//
使用
IGraphicsContainer
接口添加显示
container.AddElement(element, 0);
activeView.Refresh();
}
比例尺
C#
代码
public
void
AddScalebar(IPageLayout pageLayout)