• 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
  • 相关阅读:
    HashMap,Hash优化与高效散列
    Dubbo Overview
    模板引擎 引自 《PHP核心技术与最佳实践》
    使用 phpStorm 开发
    使用 Zend_Studio 开发
    Symfony 2.0 认识Request, Response, Session, Cookie
    Symfony 建立一个Bundle
    Symfony 从路由认识它
    信鸽推送.net 服务端代码
    c#输出json,其中包含子json (可以含 无限级 子json)的方法思路
  • 原文地址:https://www.cnblogs.com/rockman/p/3320781.html
Copyright © 2020-2023  润新知