• 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 }
  • 相关阅读:
    mongodb群集
    AtoS查看iOS Crash log中的16进制代码日志
    Info.plist 的字段解释
    IOS --关于粘贴板 ,剪切板 ,UILabel的复制
    UItableView 所有内容保存为图片
    ios 工程图片清理shell
    检查项目图片是否被使用
    ios 联网 在mac机器上进行抓包
    还在为不停build 烦恼么?看这里~~
    修复OS X的Finder中文档 打开方式中重复程序的问题
  • 原文地址:https://www.cnblogs.com/rockman/p/3325729.html
Copyright © 2020-2023  润新知