zoukankan      html  css  js  c++  java
  • AE基础(2)

     1  //添加图层文件
     2         private void addLayerFile()
     3         {
     4             System.Windows.Forms.OpenFileDialog openFileDialog;
     5             openFileDialog = new OpenFileDialog();
     6             openFileDialog.Title = "打开图层文件";
     7             openFileDialog.Filter = "map documents(*.lyr)|*.lyr";
     8             openFileDialog.ShowDialog();
     9             string filePath = openFileDialog.FileName;
    10             try
    11             {
    12                 axMapControl1.AddLayerFromFile(filePath);
    13             }
    14             catch (Exception e)
    15             {
    16                 MessageBox.Show("添加图层失败!!!" + e.ToString());
    17             }
    18         }
    19         //添加shape文件
    20         private void addShapeFile()
    21         {
    22             System.Windows.Forms.OpenFileDialog openFileDialog;
    23             openFileDialog = new OpenFileDialog();
    24             openFileDialog.Title = "打开图层文件";
    25             openFileDialog.Filter = "map documents(*.shp)|*.shp";
    26             openFileDialog.ShowDialog();
    27          
    28             try
    29             {   
    30                 FileInfo fileInfo = new FileInfo(openFileDialog.FileName);
    31                 string path = openFileDialog.FileName.Substring(0, openFileDialog.FileName.Length - fileInfo.Name.Length);
    32                 axMapControl1.AddShapeFile(path, fileInfo.Name);
    33             }
    34             catch (Exception e)
    35             {
    36                 MessageBox.Show("添加图层失败!!!" + e.ToString());
    37             }
    38         }
    39         //删除图层
    40         private void deleteLayer()
    41         {
    42             try
    43             {
    44                 //删除地图中所有图层
    45                 for (int i = axMapControl1.LayerCount - 1; i >= 0; i--)
    46                 {
    47                     axMapControl1.DeleteLayer(i);
    48                 }
    49             }
    50             catch (Exception e)
    51             {
    52                 MessageBox.Show("删除图层失败!!!" + e.ToString());
    53             }
    54         }
    55         //移动图层
    56         private void moveLayer()
    57         {
    58             if (axMapControl1.LayerCount > 0)
    59             {
    60                 try
    61                 {
    62                     //将最下层图层文件移动到最上层
    63                     axMapControl1.MoveLayerTo(axMapControl1.LayerCount - 1, 0);
    64                 }
    65                 catch (Exception e)
    66                 {
    67                     MessageBox.Show("移动图层失败!!!" + e.ToString());
    68                 }
    69             }
    70         }
    View Code
  • 相关阅读:
    学习链接
    【转】C#学习路线WinForm学习路线
    WPF 等待动画控件
    wpf 设置窗体在屏幕的初始位置
    WPF 添加右键菜单 自定义透明控件
    记录自己的点滴
    Linux下的mysql默认大小写敏感
    springboot+mybatis遇到BUG:自动注入失败
    springboot在阿里CentOS 7后台永久运行
    阿里云CentOS7 64位安装jdk8和mysql5.6.43及远程连接mysql
  • 原文地址:https://www.cnblogs.com/rockman/p/3320781.html
Copyright © 2011-2022 走看看