Provides access to members that control the reading and writing of map document files.(提供访问的成员,控制读写地图文档文件)
1:MapDocumentClass Class
The MapDocument coclass is used to read and write map document files.(地图文档组件类是用于读写地图文档文件。)实现了IMapDocument接口。
m_MapDocument = new MapDocumentClass();
2:Open Method
[C#]public void Open (string sDocument,string bsPassword);
[C++]HRESULT Open( BSTR sDocument, BSTR bsPassword);
The MapDocument will be cached so no other users will be able to access the MapDocument until it has been closed.(MapDocument将会被缓存,所以没有其他用户可以访问MapDocument,除非它已被关闭。)Before using the Open methods check whether the specified document
IsPresent,
IsRestricted,
IsMapDocument and
IsPasswordProtected. If the MapDocument is password protected, specify the password in the Open method.
3:MapCount Property
The number of Map objects contained within the map document
// 使用IMapDocument打开文档
IMapDocument m_MapDocument;
private void LoadMapDoc()
{
m_MapDocument = new MapDocumentClass();
try
{
//打开文档对话框选择MXD文件
System.Windows.Forms. OpenFileDialog openFileDialog2;
openFileDialog2 = new OpenFileDialog();
openFileDialog2.Title = "Open Map Document";
openFileDialog2.Filter = "Map Documents (*.mxd)|*.mxd";
openFileDialog2.ShowDialog();
string sFilePath = openFileDialog2.FileName;
//将数据加载到pMapDocument并与MapControl联系起来
m_MapDocument.Open(sFilePath, "");
int i;
int sum = m_MapDocument.MapCount ;
for (i = 0; i <sum; i++)
{
// 一个IMapDocument对象中可能包含很多Map对象,遍历map对象
axMapControl1.Map = m_MapDocument.get_Map(i);
}
// 刷新地图控件
axMapControl1.Refresh();
}
catch ( Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
4:Map Property
[C#]public IMap get_Map (int mapIndex);
[C++]HRESULT get_Map(long mapIndex, IMap** ppMap);
5:IsReadOnly Property
[C#]public bool get_IsReadOnly (string sDocument);
[C++]HRESULT get_IsReadOnly( BSTR sDocument, VARIANT_BOOL* IsReadOnly);
Determines whether the specified file is read only. The
Save method cannot overwrite a read-only MapDocument, use the
SaveAs to write to a new document.(保存方法不能覆盖只读的地图文件,使用另存为)
6:Save Method
[C#]public void Save (bool bUseRelativePaths, bool bCreateThumnbail);
[C#]
Optional Values
bUseRelativePaths Supply true as a default value.(true代码默认值)
bCreateThumnbail Supply true as a default value.
[C++]HRESULT Save(VARIANT_BOOL bUseRelativePaths,VARIANT_BOOL bCreateThumnbail);
7:UsesRelativePaths Property
[C#]public
boolUsesRelativePaths {get;}
[C++]HRESULT get_UsesRelativePaths(VARIANT_BOOL* bUsesRelativePaths);文件是
Indicates if the data in the map document is referenced using relative paths.
(表明如果数据在地图文件是使用相对路径引用。)
// 使用IMapDocument保存文档
private void SaveDocument()
{
// 判断文档是否为只读
if (m_MapDocument.get_IsReadOnly(m_MapDocument.DocumentFilename))
{
MessageBox.Show( "This map document is read only!");
return;
}
//用当前的文件路径设置保存文件
m_MapDocument.Save(m_MapDocument.UsesRelativePaths, true);
MessageBox.Show( "Changes saved successfully!");
}
8:SaveAs Method
Save the contents of the map document to the specified file name.
[C#]public void SaveAs (string sDocument, bool bUseRelativePaths, boolbCreateThumnbail);
Optional Values
bUseRelativePaths Supply true as a default value.
bCreateThumnbail Supply true as a default value.
// 地图文档另存为
private void SaveAsDocument ()
{
//Open a file dialog for saving map documents
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.Title = "Save Map Document As";
saveFileDialog1.Filter = "Map Documents (*.mxd)|*.mxd";
saveFileDialog1.ShowDialog();
//Exit if no map document is selected
string sFilePath = saveFileDialog1.FileName;
if (sFilePath == "")
{
return;
}
if (sFilePath == m_MapDocument.DocumentFilename)
{
// 当选择文件和当前文件相同时,保存即可
SaveDocument();
}
else
{
//SaveAs a new document with relative paths
m_MapDocument.SaveAs(sFilePath, true, true);
//Open document
MessageBox.Show( "Document saved successfully!");
}
}
- angular2系列教程(七)Injectable、Promise、Interface、使用服务
今天我们要讲的ng2的service这个概念,和ng1一样,service通常用于发送http请求,但其实你可以在里面封装任何你想封装的方法,有时候控制器之间的通讯也是依靠service来完成的,让我 ...
- 接口--interface
“interface”(接口)关键字使抽象的概念更深入了一层.我们可将其想象为一个“纯”抽象类.它允许创建者规定一个类的基本形式:方法名.自变量列表以及返回类型,但不规定方法主体.接口也包含了基本数据 ...
- Configure a bridge interface over a VLAN tagged bonded interface
SOLUTION VERIFIED February 5 2014 KB340153 Environment Red Hat Enterprise Linux 6 (All Versions) Red ...
- Create a bridge using a tagged vlan (8021.q) interface
SOLUTION VERIFIED April 27 2013 KB26727 Environment Red Hat Enterprise Linux 5 Red Hat Enterprise Li ...
- Configure a bridged network interface for KVM using RHEL 5.4 or later?
environment Red Hat Enterprise Linux 5.4 or later Red Hat Enterprise Linux 6.0 or later KVM virtual ...
- Set up VLAN (802.1q) tagging on a network interface?
SOLUTION VERIFIED October 13 2015 KB39674 KB741413 environment Red Hat Enterprise Linux 4 Red Hat En ...
- 谨慎使用Marker Interface
之所以写这篇文章,源自于组内的一些技术讨论.实际上,Effective Java的Item 37已经详细地讨论了Marker Interface.但是从整个Item的角度来看,其对于Marker In ...
- 浅析Go语言的Interface机制
前几日一朋友在学GO,问了我一些interface机制的问题.试着解释发现自己也不是太清楚,所以今天下午特意查了资料和阅读GO的源码(基于go1.4),整理出了此文.如果有错误的地方还望指正. GO语 ...
- 如何设计一门语言(七)——闭包、lambda和interface
人们都很喜欢讨论闭包这个概念.其实这个概念对于写代码来讲一点用都没有,写代码只需要掌握好lambda表达式和class+interface的语义就行了.基本上只有在写编译器和虚拟机的时候才需要管什么是 ...
- mongodb在win7下的安装和使用
1.下载mongodb的windows版本,有32位和64位版本,根据系统情况下载,下载地址:http://www.mongodb.org/downloads 2.解压缩至额E:/mongodb即可 ...
- Architecture of a Highly Scalable NIO-Based Server
一. thread-per-connection The thread-per-connection approach uses an exclusive worker thread for each ...
- 转:VS2010调试NUnit测试项目 (Running or debugging NUnit tests from Visual Studio without any extensions)
If you write unit tests and use NUnit test framework this may be helpful. I decided to write this si ...
- Gulp自动化工具之图片压缩
一.安装node https://nodejs.org/download/ 根据需要选择对应的版本 安装好了之后可以通过node -v参看一下版本 node -v 二.安装gulp npm insta ...
- ArcGIS中如何导出单个矢量要素图形
原文:ArcGIS中如何导出单个矢量要素图形 在ARCGIS中载入了一张含有省界的中国地图,是SHP文件.现在我只想要其中一块地区的,实现方法如下: 加入到ArcGIS后,右击图层,打开属性表(att ...
- LeetCode Maximal Square
原题链接在这里:https://leetcode.com/problems/maximal-square/ 这是一道DP题,存储历史信息是到当前点能有的最大square, 用二维数组dp存储. 更新方 ...
- 注册表操作命令和自定义cmd窗口
REM @echo offREM clsREM echo Microsoft Windows 7REM echo ------------------------REM echo Welcome to ...
- Buffer too small
在项目中用到了CString,后来发现在Format的时候会报Buffer too small的错误,在网上查资料发现时这样的 CString output ; int size = m_NicInf ...
- eclipse打开jar包出现乱码问题解决方法
今天做项目时候,用eclipse打开.class文件出现乱码问题.jar编码和本地编辑器编码格式不对造成的错误. 首先我们打开eclipse,点击菜单下的window-->preferences ...
- RabbitMQ学习总结 第二篇:快速入门HelloWorld
目录 RabbitMQ学习总结 第一篇:理论篇 RabbitMQ学习总结 第二篇:快速入门HelloWorld RabbitMQ学习总结 第三篇:工作队列Work Queue RabbitMQ学习总结 ...