呼,有一阵子没写博客(daun zi)了,这段时间忙于一个AE开发的项目,魔鬼产品催得紧啊,
完全没有时间,终于告一段落了, 总结一下,跟大家做一个分享。
今天来分享地图整饰。
话不多说,进入正题
地图漫游
首先分享对地图漫游的相关系列操作,包括放大缩小、全图展示、平移、编辑等。
相关代码如下:
//Zoom in
private void btnFixedZoomIn_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
ControlsPageZoomInFixedCommand zoominfixed = new ControlsPageZoomInFixedCommand();
zoominfixed.OnCreate(axPageLayoutControl1.Object);
zoominfixed.OnClick();
}
//Zoom out
private void FixedZoomOut_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
ControlsPageZoomOutFixedCommand zoomoutfixed = new ControlsPageZoomOutFixedCommand();
zoomoutfixed.OnCreate(axPageLayoutControl1.Object);
zoomoutfixed.OnClick();
}
//全图展示
private void btnZoom2WholePage_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
ControlsPageZoomWholePageCommand wholeTool = new ControlsPageZoomWholePageCommand();
wholeTool.OnCreate(axPageLayoutControl1.Object);
wholeTool.OnClick();
}
//平移地图
private void btnLayoutPan_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
ControlsPagePanTool PanTool = new ControlsPagePanToolClass();
PanTool.OnCreate(axPageLayoutControl1.Object);
axPageLayoutControl1.CurrentTool = PanTool as ITool;
}
//鼠标切换为编辑模式
private void btneditmouse_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
ControlsSelectTool Cmd = new ControlsSelectTool();
Cmd.OnCreate(this.axPageLayoutControl1.Object);
this.axPageLayoutControl1.CurrentTool = Cmd as ITool;
}
地图要素
一张完整的地图当然不能缺少地图要素(当时上学的时候也因为丢三落四没少被老师骂),所以!图例、指北针、比例尺、标题、文字、格网,代码都在下面了,老铁子们按需取货吧,走你。
//图例
private void btn_legend_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
FrmLegend frmLegend = new FrmLegend(axPageLayoutControl1);
frmLegend.OnQueryLenendItems += pLegend => m_Legend = pLegend;
frmLegend.OnQueryColumnCount += pColumnCount => m_ColumnCount = pColumnCount;
//窗体位置在屏幕中间
frmLegend.StartPosition = FormStartPosition.CenterScreen;
frmLegend.ShowDialog();
axPageLayoutControl1.CurrentTool = null;
axPageLayoutControl1.MousePointer = esriControlsMousePointer.esriPointerCrosshair;
operation = "添加图例";
}
//指北针
private void btn_compass_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
FrmNorthArrow frmNorthArrow = new FrmNorthArrow();
frmNorthArrow.OnQueryNorthArrow += pNorthArrow => m_NorthArrrow = pNorthArrow;
//窗体位置在屏幕中间
frmNorthArrow.StartPosition = FormStartPosition.CenterScreen;
frmNorthArrow.ShowDialog();
axPageLayoutControl1.CurrentTool = null;
axPageLayoutControl1.MousePointer = esriControlsMousePointer.esriPointerCrosshair;
operation = "添加指北针"