一:组件添加到工具栏

要在应用程序中应用OTGisX控件,首先要把所下载的OTGisX组件添加到.Net工程中。并将其添加到工具箱托盘
中。添加方式为:在工具箱上单击右键,选择“选择项”,会出现“选择工具箱项”对话框,在“COM组件”属性页,选择浏览,找到OTGisX.ocx添加到工具箱项。这时工具箱中会出现AxOTGisForm控件。在设计应
用程序界面时,可以将其拖入应用程序界面,系统会在代码中自动创建一个AxOTGisForm对象。

以管理员身份注册组件,就可以用了

二:如图

三:组件介绍

组件上有map对象,map对象上有layer对象,layer上有图元对象

四:实例

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using OTGisX;
  10.  
  11. namespace OTGisX_test
  12. {
  13. public partial class Form1 : Form
  14. {
  15. public Form1()
  16. {
  17. InitializeComponent();
  18. }
  19.  
  20. #region 事件:运行自加载,准备显示
  21. private void Form1_Load(object sender, EventArgs e)
  22. {
  23. Otg.DoOnShow();
  24. cbx_Type.SelectedIndex = ;
  25. }
  26. #endregion
  27.  
  28. #region 事件:选中一个元素触发,选中井元素,将井号赋给文本框
  29. private void axOTGisForm1_OnSelectedOneElement(object sender, AxOTGisX.IOTGisFormEvents_OnSelectedOneElementEvent e)
  30. {
  31. txt_Jname.Text = "";
  32. OTMap _OTMap = this.Otg.GetActiveMap();
  33. OTElement _OTElement = _OTMap.GetSelectedElement();
  34. OTWell _OTWell;
  35. if (_OTElement != null && _OTElement.ElementClassCodeID == ElementType.etWell)
  36. {
  37. _OTWell = (OTWell)_OTElement;
  38. txt_Jname.Text = _OTWell.TextStr.Trim();
  39. }
  40. }
  41. #endregion
  42.  
  43. #region 修改
  44. private void button1_Click(object sender, EventArgs e)
  45. {
  46.  
  47. OTMap _OTMap = this.Otg.GetActiveMap();
  48. OTElement _OTElement = _OTMap.GetSelectedElement();
  49.  
  50. if (_OTElement != null && _OTElement.ElementClassCodeID == ElementType.etWell)
  51. {
  52. OTWell aOtwell = (OTWell)_OTElement;
  53. if (txt_Jname.Text.Trim().Length > )
  54. {
  55. aOtwell.TextStr = txt_Jname.Text.Trim();
  56. OTLayer _OTLayer = aOtwell.GetParentLayer();
  57. aOtwell.UpDatePosInfo();
  58. _OTMap.UpdateAllPosition();
  59. Otg.Refresh();
  60. }
  61. else
  62. {
  63. MessageBox.Show("请输入更改的井号名!");
  64. }
  65. }
  66. }
  67. #endregion
  68.  
  69. #region 保存更改
  70. private void button2_Click(object sender, EventArgs e)
  71. {
  72. Otg.SaveCurrentFile();
  73. }
  74.  
  75. #endregion
  76.  
  77. #region 关闭
  78. private void Form1_FormClosed(object sender, FormClosedEventArgs e)
  79. {
  80. Otg.ClearUI();
  81. this.Dispose();
  82. this.Close();
  83. }
  84. #endregion
  85.  
  86. #region 添加图件
  87. private void btn_add_tj_Click(object sender, EventArgs e)
  88. {
  89. try
  90. {
  91. if (string.IsNullOrEmpty(txt_tj_mc.Text.Trim()))
  92. {
  93.  
  94. MessageBox.Show("图件名称不能为空");
  95. txt_tj_mc.Focus();
  96. return;
  97. }
  98. if (string.IsNullOrEmpty(txt_blc.Text.Trim()))
  99. {
  100. MessageBox.Show("比例尺不能为空");
  101. txt_blc.Focus();
  102. return;
  103. }
  104. if (string.IsNullOrEmpty(txt_zs_x.Text.Trim()))
  105. {
  106.  
  107. MessageBox.Show("左上X不能为空");
  108. txt_zs_x.Focus();
  109. return;
  110. }
  111. if (string.IsNullOrEmpty(txt_zs_y.Text.Trim()))
  112. {
  113.  
  114. MessageBox.Show("左上Y不能为空");
  115. txt_zs_y.Focus();
  116. return;
  117. }
  118. if (string.IsNullOrEmpty(txt_yx_x.Text.Trim()))
  119. {
  120.  
  121. MessageBox.Show("右下X不能为空");
  122. txt_yx_x.Focus();
  123. return;
  124. }
  125. if (string.IsNullOrEmpty(txt_yx_y.Text.Trim()))
  126. {
  127.  
  128. MessageBox.Show("右下Y不能为空");
  129. txt_yx_y.Focus();
  130. return;
  131. }
  132.  
  133. OTMap aOtmap = Otg.CreateNewMap();
  134. aOtmap.MapName = txt_tj_mc.Text;
  135. aOtmap.MapZoomRateX = double.Parse(txt_blc.Text);
  136. aOtmap.MapZoomRateY = double.Parse(txt_blc.Text);
  137. aOtmap.SetMapRect(double.Parse(txt_zs_x.Text), double.Parse(txt_zs_y.Text), double.Parse(txt_yx_x.Text), double.Parse(txt_yx_y.Text));//设置图件范围
  138. aOtmap.SetProjection("XA_80", TOTProjectionType.TMR, TOTCoordinateType.Projection, , , , , , , , , , , , , , , );
  139. switch (cbx_Type.SelectedIndex)
  140. {
  141. case :
  142. aOtmap.CoordinateType = TOTCoordinateType.User;
  143. break;
  144. case :
  145. aOtmap.CoordinateType = TOTCoordinateType.LonLat;
  146. break;
  147. case :
  148. aOtmap.CoordinateType = TOTCoordinateType.Projection;
  149. break;
  150. case :
  151. aOtmap.CoordinateType = TOTCoordinateType.Geodesic;
  152. break;
  153.  
  154. }
  155. aOtmap.UpdateAllPosition();
  156.  
  157. }
  158. catch (Exception ex)
  159. {
  160. MessageBox.Show(ex.ToString());
  161. }
  162. }
  163. #endregion
  164.  
  165. #region 读取图件信息
  166. private void btn_read_tj_Click(object sender, EventArgs e)
  167. {
  168. OTMap aOtmap = Otg.GetActiveMap();
  169. double zx = , zy = , yx = , yy = ;
  170. aOtmap.GetMapRect(out zx, out zy, out yx, out yy);
  171. string temp = "图件名称:" + aOtmap.MapName + Environment.NewLine;
  172. temp += "x轴比例尺是:" + aOtmap.MapZoomRateX + ",y轴比例尺是:" + aOtmap.MapZoomRateY + Environment.NewLine;
  173. temp += "图件的宽,高分别是:" + aOtmap.MapWidth.ToString() + "," + aOtmap.MapHight.ToString() + Environment.NewLine;
  174. temp += "图件坐标左边距,上边距分别是: " + aOtmap.MapLeft.ToString() + "," + aOtmap.MapHight.ToString() + Environment.NewLine;
  175. temp += "左上,右下坐标分别是:" + zx.ToString() + "," + zy.ToString() + "," + yx.ToString() + "," + yy.ToString() + Environment.NewLine;
  176. temp += "基准面列表是:" + aOtmap.GetProjectionParams();
  177. MessageBox.Show(temp);
  178. }
  179. #endregion
  180.  
  181. #region 添加图层
  182. private void btn_add_tc_Click(object sender, EventArgs e)
  183. {
  184. try
  185. {
  186. if (string.IsNullOrEmpty(txt_tc_mc.Text.Trim()))
  187. {
  188.  
  189. MessageBox.Show("图层名称不能为空");
  190. txt_tc_mc.Focus();
  191. return;
  192. }
  193.  
  194. OTMap aOtmap = Otg.GetActiveMap();
  195. MessageBox.Show("所属图件是:" + aOtmap.MapName);
  196. OTLayer aOtlayer = aOtmap.CreateNewLayer(txt_tc_mc.Text);
  197. aOtmap.UpdateAllPosition();
  198. Otg.Refresh();
  199. Otg.RefreshMapList();
  200. }
  201. catch (Exception ex)
  202. {
  203. MessageBox.Show(ex.ToString());
  204. }
  205. }
  206. #endregion
  207.  
  208. #region 添加井位图
  209. private void btn_add_ty_Click(object sender, EventArgs e)
  210. {
  211. try
  212. {
  213. OTMap aOtmap = Otg.GetActiveMap();
  214. int index = aOtmap.ActiveLayerIndex;//活动图层的索引
  215. OTLayer aOtlayer = aOtmap.GetLayer(index);
  216. MessageBox.Show("所属图层是:" + aOtlayer.LayerName);
  217. OTWell aOtwell = aOtlayer.CreateNewWellElement(, , );
  218. aOtwell.TextStr = txt_ty_mc.Text;
  219. aOtwell.TopSymID = ;
  220. aOtwell.TopSymSize = ;
  221. aOtwell.BottomSymID = ;
  222. aOtwell.BottomSymSize = ;
  223. aOtwell.TopPosX = double.Parse(txt_jkx.Text);
  224. aOtwell.TopPosY = double.Parse(txt_jky.Text);
  225. aOtwell.BottomPosX = double.Parse(txt_jdx.Text);
  226. aOtwell.BottomPosY = double.Parse(txt_jdy.Text);
  227. aOtwell.UpDatePosInfo();
  228. aOtmap.UpdateAllPosition();
  229.  
  230. }
  231. catch (Exception ex)
  232. {
  233. MessageBox.Show(ex.ToString());
  234. }
  235. }
  236. #endregion
  237. }
  238. }

刷新一口井的信息,控件和属性上的值

  1. #region 编辑一口井的图像信息
  2. public void Edit_Well(object sender, EventArgs e)
  3. {
  4. try
  5. {
  6. //10.17新增
  7. CamlBuilder cb = new CamlBuilder();
  8. cb.AddWhere(OperationSymbol.Contains, "jwty_point", ConstInfo.W_sort, ConstInfo.文本);
  9. DataSet ds = OperatePort.SearchDataList(ConstInfo.ListName_Jwty, cb.GetCamlString(), null);
  10. if (!Common.JudgeDs(ds))
  11. {
  12.  
  13. OTMap aOtmap = axOtg.GetActiveMap();
  14. OTElement _OTElement = aOtmap.GetSelectedElement();
  15. if (_OTElement != null && _OTElement.ElementClassCodeID == ElementType.etWell)
  16. {
  17. OTWell aOtwell = (OTWell)_OTElement;
  18. aOtwell.TextStr = ConstInfo.J_Number;
  19. aOtwell.TopSymID = int.Parse(ds.Tables[].Rows[]["jkfhlx_id"].ToString());//井口符号类型ID;
  20. aOtwell.TopSymSize = double.Parse(ds.Tables[].Rows[]["jkfhlxdx"].ToString());//井口符号大小;
  21. aOtwell.BottomSymID = int.Parse(ds.Tables[].Rows[]["jdfhlx_id"].ToString());//井底符号类型ID;
  22. aOtwell.BottomSymSize = double.Parse(ds.Tables[].Rows[]["jdfhdx"].ToString());//井底符号大小
  23. aOtwell.TopPosX = ConstInfo.J_jkx - ;
  24. aOtwell.TopPosY = ConstInfo.J_jky;
  25. aOtwell.BottomPosX = ConstInfo.J_jdx - ;
  26. aOtwell.BottomPosY = ConstInfo.J_jdy;
  27. aOtwell.TextHeight = ;
  28. aOtwell.UpDatePosInfo();//更新井的信息
  29. aOtmap.UpdateAllPosition();//跟新井的图像位置
  30. //axOtg.RefreshMapList();
  31. //axOtg.RefreshToolbarPosition();
  32. this.axOtg.Refresh();//刷新井的名字
  33. aOtwell.ShowProperty();//刷新属性
  34. }
  35.  
  36. }
  37. else
  38. {
  39. sh.Message("不存在该井的类别!");
  40. }
  41. }
  42. catch (Exception ex)
  43. {
  44. MessageBox.Show(ex.Message.ToString());
  45.  
  46. }
  47. }
  48. #endregion

删除某一层

  1. private void btn_Download_Click(object sender, EventArgs e)
  2. {
  3. SaveFileDialog sw = new SaveFileDialog();
  4. sw.Filter = "*.OTP|*.*";
  5. sw.FilterIndex = ;
  6. sw.Title = this.Text;
  7. sw.RestoreDirectory = true;
  8. if (sw.ShowDialog() == DialogResult.OK)
  9. {
  10. string path = sw.FileName.ToString() + ".OTP";
  11. for (int j = ; j < axOTGisForm1.Count(); j++)
  12. {
  13. OTMap fMap = axOTGisForm1.GetMap(j);
  14. for (int i = ; i < fMap.Count(); i++)
  15. {
  16. OTLayer aOtlayer = fMap.GetLayer(i);
  17. string layerN = aOtlayer.LayerName.ToString().Trim();
  18. if (j == && layerN.Length >= && layerN.Substring(, ) == "")
  19. {
  20. fMap.RemoveLayer(i);
  21. }
  22. if (cmb_imageType.Text.Trim() == "黑白图" && layerN.Length >= && layerN.Substring(, ) == "")//去彩色线
  23. {
  24. fMap.RemoveLayer(i);
  25. }
  26. if (cmb_imageType.Text.Trim() == "彩色图" && layerN.Length >= && layerN.Substring(, ) == "")//去黑白线
  27. {
  28. fMap.RemoveLayer(i);
  29. }
  30. }
  31. fMap.UpdateAllPosition();
  32. }
  33. int temp =axOTGisForm1.SaveToFile(path, );
  34. if (temp == )
  35. {
  36. MessageBox.Show("保存成功", "温馨提示");
  37. this.Close();
  38. }
  39. else
  40. {
  41. MessageBox.Show("保存异常", "温馨提示");
  42. }
  43. }
  44.  
  45. }

矢量做图组件OTGisX的使用(类似Mapbase)的更多相关文章

  1. 做一个vue轮播图组件

    根据huangyi老师的慕课网vue项目跟着做的,下面大概记录了下思路 1.轮播图的图 先不做轮播图逻辑部分,先把数据导进来,看看什么效果.在recommend组件新建一个recommends的数组, ...

  2. 使用原生js将轮播图组件化

    代码地址如下:http://www.demodashi.com/demo/11316.html   这是一个轮播图组件,这里是代码地址,需要传入容器的id和图片地址,支持Internet Explor ...

  3. WebGIS中矢量切图的初步研究

    文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/. 1.背景 在GIS领域,金字塔技术一直是一个基础性技术,WMTS规范专 ...

  4. python做图笔记

    1. 工具选择 了解了基本python,rodeo,anaconda套件这三种工具. (1)基本python,下载安装python的最新版(目前是python3.7).注意要使用安装版.安装好后,一般 ...

  5. 用 GraphScope 像 NetworkX 一样做图分析

    NetworkX 是 Python 上最常用的图分析包,GraphScoep 兼容 NetworkX 接口.本文中我们将分享如何用 GraphScope 像 NetworkX 一样在(大)图上进行分析 ...

  6. [2014.01.27]wfRadar 雷达图组件 2.5

    全新开发的雷达图组件--wfRadar,使用简单,功能强大,图像处理效果极佳. 组件支持多种图片格式,包括bmp,jpg,gif,wmf,emf,ico,png,pcx,tif,tga,pcx,dcx ...

  7. Twproject Gantt – 开源的 JavaScript 甘特图组件

    Twproject Gantt 是一款基于 jQuery 开发的甘特图组件,也可以创建其它图表,例如任务树(Task Trees).内置编辑.缩放和 CSS 皮肤等功能.更重要的是,它是免费开源的. ...

  8. 原生JS面向对象思想封装轮播图组件

    原生JS面向对象思想封装轮播图组件 在前端页面开发过程中,页面中的轮播图特效很常见,因此我就想封装一个自己的原生JS的轮播图组件.有了这个需求就开始着手准备了,代码当然是以简洁为目标,轮播图的各个功能 ...

  9. QiniuUpload- 一个方便用七牛做图床然后插入markdown的小工具

    最近一段时间有用markdown做笔记,其他都好,但是markdown插入图片挺麻烦的,特别是想截图之后直接插入的时候.需要首先把图片保存了,然后还要上传到一个地方生成链接才能插入.如果有个工具可以直 ...

随机推荐

  1. Qt 学习之路:QSortFilterProxyModel

    从本章开始,我们将逐步了解有关自定义模型的相关内容.尽管前面我们曾经介绍过 Qt 提供的几个内置模型:QStringListModel和QFileSystemModel,但对于千变万化的需求而言,这些 ...

  2. iOS开发系列之触摸事件

    基础知识 三类事件中触摸事件在iOS中是最常用的事件,这里我们首先介绍触摸事件. 在下面的例子中定义一个KCImage,它继承于UIView,在KCImage中指定一个图片作为背景.定义一个视图控制器 ...

  3. 微信小程序开发工具(0.9.092300)下载地址,分享给没有公众号的小伙伴

    目前最新的v0.9.092300,不需要填AppID就能直接开发,也不需要破解了. OSX版本.WIN64.WIN32下载地址: http://pan.baidu.com/s/1qXOdkgG

  4. bzoj 1034 (田忌赛马++)

    /* 这类题的最优策略: 自己最好的干掉对方最好的 或者 自己最差的干掉对方最差的 不能的话 用自己最差的 对阵对方最好的 这样是最优的 实现嘛 搞两个队列跑一跑 */ #include<ios ...

  5. Web.Config文件中添加数据库配置文件

    1获取所有配置文件节点的类ConfigurationManager 2数据库节点<ConnectionStrings> <add> name ="Sqlconnect ...

  6. Wpf 数据绑定简介、实例1

    简介:1.WPF绑定使用的源属性必须是依赖项属性,这是因为依赖项属性具有内置的更改通知支持,元素绑定表达式使用了Xaml扩展标记, WPF绑定一个控件是使用Binding.ElementName, 绑 ...

  7. 写一个基于NSURLSession的网络下载库

    前段时间AFNetworking 更新到3.0 ,彻底废弃NSURLConnection的API转由NSURLSession来实现,代码并没有改动很大,AF封装的很好了,读完源码感觉收获很大. 下载不 ...

  8. CocoaPods使用详细说明(转)

    一.概要 iOS开发时,项目中会引用许多第三方库,CocoaPods(https://github.com/CocoaPods/CocoaPods)可以用来方便的统一管理这些第三方库. 二.安装 由于 ...

  9. 【OpenSSL】创建证书

    [-] 1生成根证书 1 生成RSA私钥 2 生成证书请求 3 签发自签名证书 2 生成用户证书 1 生成RSA私钥 2 生成证书请求 3 签发证书   1)生成根证书 1.1) 生成RSA私钥 op ...

  10. WebService CXF调试常见报错及解决方案

    1.CXF java.lang.RuntimeException: Cannot create a secure XMLInputFactory 解决方案:从apache-cxf/lib下寻找Wood ...