zoukankan      html  css  js  c++  java
  • AE基础(7)布局控件与地图控件关联

     1 using ESRI.ArcGIS.Carto;
     2 using ESRI.ArcGIS.Controls;
     3 using ESRI.ArcGIS.Display;
     4 using ESRI.ArcGIS.esriSystem;
     5 using System;
     6 using System.Collections.Generic;
     7 using System.ComponentModel;
     8 using System.Data;
     9 using System.Drawing;
    10 using System.Linq;
    11 using System.Text;
    12 using System.Threading.Tasks;
    13 using System.Windows.Forms;
    14 
    15 namespace Ch02Ex08
    16 {
    17     public partial class Form1 : Form
    18     {
    19         public Form1()
    20         {
    21             InitializeComponent();
    22         }
    23         //加载地图文档
    24         private void loadMapDocument()
    25         {
    26             System.Windows.Forms.OpenFileDialog openFileDialog;
    27             openFileDialog = new OpenFileDialog();
    28             openFileDialog.Title = "打开地图文档";
    29             openFileDialog.Filter = "map documents(*.mxd)|*.mxd";
    30             openFileDialog.ShowDialog();
    31             string filePath = openFileDialog.FileName;
    32             if (axMapControl1.CheckMxFile(filePath))
    33             {
    34                 axMapControl1.MousePointer =  esriControlsMousePointer.esriPointerHourglass;
    35                 axMapControl1.LoadMxFile(filePath, 0, Type.Missing);
    36                 axMapControl1.MousePointer =  esriControlsMousePointer.esriPointerDefault;
    37             }
    38             else
    39             {
    40                 MessageBox.Show(filePath + "不是有效的地图文档");
    41             }
    42         }
    43         private void copyToPageLayout()
    44         {
    45             IObjectCopy objectCopy = new ObjectCopy();
    46             object copyFromMap = axMapControl1.Map;
    47             object copyMap = objectCopy.Copy(copyFromMap);
    48             object copyToMap = axPageLayoutControl1.ActiveView.FocusMap;
    49             objectCopy.Overwrite(copyMap, ref copyToMap);
    50         }
    51 
    52         private void axMapControl1_OnMapReplaced(object sender, IMapControlEvents2_OnMapReplacedEvent e)
    53         {
    54             copyToPageLayout();
    55         }
    56 
    57         private void axMapControl1_OnAfterScreenDraw(object sender, IMapControlEvents2_OnAfterScreenDrawEvent e)
    58         {
    59             IActiveView activeView = (IActiveView)axPageLayoutControl1.ActiveView.FocusMap;
    60             IDisplayTransformation displayTransformation = activeView.ScreenDisplay.DisplayTransformation;
    61             displayTransformation.VisibleBounds = axMapControl1.Extent;
    62             axPageLayoutControl1.ActiveView.Refresh();
    63             copyToPageLayout();
    64         }
    65 
    66         private void Form1_Click(object sender, EventArgs e)
    67         {
    68             loadMapDocument();
    69         }
    70     }
    71 }
  • 相关阅读:
    MYBATIS 的parameter
    深入了解MyBatis参数
    js之onload事件的一点使用心得
    js中document.write的那点事
    MyBatis直接执行SQL查询及批量插入数据
    ng 服务
    ng json格式的序列化和反序列化
    ng 自定义过滤器的创建和使用
    ng 过滤器
    ng 双向数据绑定 实现 注册协议效果
  • 原文地址:https://www.cnblogs.com/rockman/p/3325729.html
Copyright © 2011-2022 走看看