矢量做图组件OTGisX的使用(类似Mapbase)
一:组件添加到工具栏
要在应用程序中应用OTGisX控件,首先要把所下载的OTGisX组件添加到.Net工程中。并将其添加到工具箱托盘
中。添加方式为:在工具箱上单击右键,选择“选择项”,会出现“选择工具箱项”对话框,在“COM组件”属性页,选择浏览,找到OTGisX.ocx添加到工具箱项。这时工具箱中会出现AxOTGisForm控件。在设计应
用程序界面时,可以将其拖入应用程序界面,系统会在代码中自动创建一个AxOTGisForm对象。
以管理员身份注册组件,就可以用了
二:如图
三:组件介绍
组件上有map对象,map对象上有layer对象,layer上有图元对象
四:实例
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using OTGisX;
- namespace OTGisX_test
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- #region 事件:运行自加载,准备显示
- private void Form1_Load(object sender, EventArgs e)
- {
- Otg.DoOnShow();
- cbx_Type.SelectedIndex = ;
- }
- #endregion
- #region 事件:选中一个元素触发,选中井元素,将井号赋给文本框
- private void axOTGisForm1_OnSelectedOneElement(object sender, AxOTGisX.IOTGisFormEvents_OnSelectedOneElementEvent e)
- {
- txt_Jname.Text = "";
- OTMap _OTMap = this.Otg.GetActiveMap();
- OTElement _OTElement = _OTMap.GetSelectedElement();
- OTWell _OTWell;
- if (_OTElement != null && _OTElement.ElementClassCodeID == ElementType.etWell)
- {
- _OTWell = (OTWell)_OTElement;
- txt_Jname.Text = _OTWell.TextStr.Trim();
- }
- }
- #endregion
- #region 修改
- private void button1_Click(object sender, EventArgs e)
- {
- OTMap _OTMap = this.Otg.GetActiveMap();
- OTElement _OTElement = _OTMap.GetSelectedElement();
- if (_OTElement != null && _OTElement.ElementClassCodeID == ElementType.etWell)
- {
- OTWell aOtwell = (OTWell)_OTElement;
- if (txt_Jname.Text.Trim().Length > )
- {
- aOtwell.TextStr = txt_Jname.Text.Trim();
- OTLayer _OTLayer = aOtwell.GetParentLayer();
- aOtwell.UpDatePosInfo();
- _OTMap.UpdateAllPosition();
- Otg.Refresh();
- }
- else
- {
- MessageBox.Show("请输入更改的井号名!");
- }
- }
- }
- #endregion
- #region 保存更改
- private void button2_Click(object sender, EventArgs e)
- {
- Otg.SaveCurrentFile();
- }
- #endregion
- #region 关闭
- private void Form1_FormClosed(object sender, FormClosedEventArgs e)
- {
- Otg.ClearUI();
- this.Dispose();
- this.Close();
- }
- #endregion
- #region 添加图件
- private void btn_add_tj_Click(object sender, EventArgs e)
- {
- try
- {
- if (string.IsNullOrEmpty(txt_tj_mc.Text.Trim()))
- {
- MessageBox.Show("图件名称不能为空");
- txt_tj_mc.Focus();
- return;
- }
- if (string.IsNullOrEmpty(txt_blc.Text.Trim()))
- {
- MessageBox.Show("比例尺不能为空");
- txt_blc.Focus();
- return;
- }
- if (string.IsNullOrEmpty(txt_zs_x.Text.Trim()))
- {
- MessageBox.Show("左上X不能为空");
- txt_zs_x.Focus();
- return;
- }
- if (string.IsNullOrEmpty(txt_zs_y.Text.Trim()))
- {
- MessageBox.Show("左上Y不能为空");
- txt_zs_y.Focus();
- return;
- }
- if (string.IsNullOrEmpty(txt_yx_x.Text.Trim()))
- {
- MessageBox.Show("右下X不能为空");
- txt_yx_x.Focus();
- return;
- }
- if (string.IsNullOrEmpty(txt_yx_y.Text.Trim()))
- {
- MessageBox.Show("右下Y不能为空");
- txt_yx_y.Focus();
- return;
- }
- OTMap aOtmap = Otg.CreateNewMap();
- aOtmap.MapName = txt_tj_mc.Text;
- aOtmap.MapZoomRateX = double.Parse(txt_blc.Text);
- aOtmap.MapZoomRateY = double.Parse(txt_blc.Text);
- 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));//设置图件范围
- aOtmap.SetProjection("XA_80", TOTProjectionType.TMR, TOTCoordinateType.Projection, , , , , , , , , , , , , , , );
- switch (cbx_Type.SelectedIndex)
- {
- case :
- aOtmap.CoordinateType = TOTCoordinateType.User;
- break;
- case :
- aOtmap.CoordinateType = TOTCoordinateType.LonLat;
- break;
- case :
- aOtmap.CoordinateType = TOTCoordinateType.Projection;
- break;
- case :
- aOtmap.CoordinateType = TOTCoordinateType.Geodesic;
- break;
- }
- aOtmap.UpdateAllPosition();
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.ToString());
- }
- }
- #endregion
- #region 读取图件信息
- private void btn_read_tj_Click(object sender, EventArgs e)
- {
- OTMap aOtmap = Otg.GetActiveMap();
- double zx = , zy = , yx = , yy = ;
- aOtmap.GetMapRect(out zx, out zy, out yx, out yy);
- string temp = "图件名称:" + aOtmap.MapName + Environment.NewLine;
- temp += "x轴比例尺是:" + aOtmap.MapZoomRateX + ",y轴比例尺是:" + aOtmap.MapZoomRateY + Environment.NewLine;
- temp += "图件的宽,高分别是:" + aOtmap.MapWidth.ToString() + "," + aOtmap.MapHight.ToString() + Environment.NewLine;
- temp += "图件坐标左边距,上边距分别是: " + aOtmap.MapLeft.ToString() + "," + aOtmap.MapHight.ToString() + Environment.NewLine;
- temp += "左上,右下坐标分别是:" + zx.ToString() + "," + zy.ToString() + "," + yx.ToString() + "," + yy.ToString() + Environment.NewLine;
- temp += "基准面列表是:" + aOtmap.GetProjectionParams();
- MessageBox.Show(temp);
- }
- #endregion
- #region 添加图层
- private void btn_add_tc_Click(object sender, EventArgs e)
- {
- try
- {
- if (string.IsNullOrEmpty(txt_tc_mc.Text.Trim()))
- {
- MessageBox.Show("图层名称不能为空");
- txt_tc_mc.Focus();
- return;
- }
- OTMap aOtmap = Otg.GetActiveMap();
- MessageBox.Show("所属图件是:" + aOtmap.MapName);
- OTLayer aOtlayer = aOtmap.CreateNewLayer(txt_tc_mc.Text);
- aOtmap.UpdateAllPosition();
- Otg.Refresh();
- Otg.RefreshMapList();
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.ToString());
- }
- }
- #endregion
- #region 添加井位图
- private void btn_add_ty_Click(object sender, EventArgs e)
- {
- try
- {
- OTMap aOtmap = Otg.GetActiveMap();
- int index = aOtmap.ActiveLayerIndex;//活动图层的索引
- OTLayer aOtlayer = aOtmap.GetLayer(index);
- MessageBox.Show("所属图层是:" + aOtlayer.LayerName);
- OTWell aOtwell = aOtlayer.CreateNewWellElement(, , );
- aOtwell.TextStr = txt_ty_mc.Text;
- aOtwell.TopSymID = ;
- aOtwell.TopSymSize = ;
- aOtwell.BottomSymID = ;
- aOtwell.BottomSymSize = ;
- aOtwell.TopPosX = double.Parse(txt_jkx.Text);
- aOtwell.TopPosY = double.Parse(txt_jky.Text);
- aOtwell.BottomPosX = double.Parse(txt_jdx.Text);
- aOtwell.BottomPosY = double.Parse(txt_jdy.Text);
- aOtwell.UpDatePosInfo();
- aOtmap.UpdateAllPosition();
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.ToString());
- }
- }
- #endregion
- }
- }
刷新一口井的信息,控件和属性上的值
- #region 编辑一口井的图像信息
- public void Edit_Well(object sender, EventArgs e)
- {
- try
- {
- //10.17新增
- CamlBuilder cb = new CamlBuilder();
- cb.AddWhere(OperationSymbol.Contains, "jwty_point", ConstInfo.W_sort, ConstInfo.文本);
- DataSet ds = OperatePort.SearchDataList(ConstInfo.ListName_Jwty, cb.GetCamlString(), null);
- if (!Common.JudgeDs(ds))
- {
- OTMap aOtmap = axOtg.GetActiveMap();
- OTElement _OTElement = aOtmap.GetSelectedElement();
- if (_OTElement != null && _OTElement.ElementClassCodeID == ElementType.etWell)
- {
- OTWell aOtwell = (OTWell)_OTElement;
- aOtwell.TextStr = ConstInfo.J_Number;
- aOtwell.TopSymID = int.Parse(ds.Tables[].Rows[]["jkfhlx_id"].ToString());//井口符号类型ID;
- aOtwell.TopSymSize = double.Parse(ds.Tables[].Rows[]["jkfhlxdx"].ToString());//井口符号大小;
- aOtwell.BottomSymID = int.Parse(ds.Tables[].Rows[]["jdfhlx_id"].ToString());//井底符号类型ID;
- aOtwell.BottomSymSize = double.Parse(ds.Tables[].Rows[]["jdfhdx"].ToString());//井底符号大小
- aOtwell.TopPosX = ConstInfo.J_jkx - ;
- aOtwell.TopPosY = ConstInfo.J_jky;
- aOtwell.BottomPosX = ConstInfo.J_jdx - ;
- aOtwell.BottomPosY = ConstInfo.J_jdy;
- aOtwell.TextHeight = ;
- aOtwell.UpDatePosInfo();//更新井的信息
- aOtmap.UpdateAllPosition();//跟新井的图像位置
- //axOtg.RefreshMapList();
- //axOtg.RefreshToolbarPosition();
- this.axOtg.Refresh();//刷新井的名字
- aOtwell.ShowProperty();//刷新属性
- }
- }
- else
- {
- sh.Message("不存在该井的类别!");
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message.ToString());
- }
- }
- #endregion
删除某一层
- private void btn_Download_Click(object sender, EventArgs e)
- {
- SaveFileDialog sw = new SaveFileDialog();
- sw.Filter = "*.OTP|*.*";
- sw.FilterIndex = ;
- sw.Title = this.Text;
- sw.RestoreDirectory = true;
- if (sw.ShowDialog() == DialogResult.OK)
- {
- string path = sw.FileName.ToString() + ".OTP";
- for (int j = ; j < axOTGisForm1.Count(); j++)
- {
- OTMap fMap = axOTGisForm1.GetMap(j);
- for (int i = ; i < fMap.Count(); i++)
- {
- OTLayer aOtlayer = fMap.GetLayer(i);
- string layerN = aOtlayer.LayerName.ToString().Trim();
- if (j == && layerN.Length >= && layerN.Substring(, ) == "")
- {
- fMap.RemoveLayer(i);
- }
- if (cmb_imageType.Text.Trim() == "黑白图" && layerN.Length >= && layerN.Substring(, ) == "")//去彩色线
- {
- fMap.RemoveLayer(i);
- }
- if (cmb_imageType.Text.Trim() == "彩色图" && layerN.Length >= && layerN.Substring(, ) == "")//去黑白线
- {
- fMap.RemoveLayer(i);
- }
- }
- fMap.UpdateAllPosition();
- }
- int temp =axOTGisForm1.SaveToFile(path, );
- if (temp == )
- {
- MessageBox.Show("保存成功", "温馨提示");
- this.Close();
- }
- else
- {
- MessageBox.Show("保存异常", "温馨提示");
- }
- }
- }
矢量做图组件OTGisX的使用(类似Mapbase)的更多相关文章
- 做一个vue轮播图组件
根据huangyi老师的慕课网vue项目跟着做的,下面大概记录了下思路 1.轮播图的图 先不做轮播图逻辑部分,先把数据导进来,看看什么效果.在recommend组件新建一个recommends的数组, ...
- 使用原生js将轮播图组件化
代码地址如下:http://www.demodashi.com/demo/11316.html 这是一个轮播图组件,这里是代码地址,需要传入容器的id和图片地址,支持Internet Explor ...
- WebGIS中矢量切图的初步研究
文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/. 1.背景 在GIS领域,金字塔技术一直是一个基础性技术,WMTS规范专 ...
- python做图笔记
1. 工具选择 了解了基本python,rodeo,anaconda套件这三种工具. (1)基本python,下载安装python的最新版(目前是python3.7).注意要使用安装版.安装好后,一般 ...
- 用 GraphScope 像 NetworkX 一样做图分析
NetworkX 是 Python 上最常用的图分析包,GraphScoep 兼容 NetworkX 接口.本文中我们将分享如何用 GraphScope 像 NetworkX 一样在(大)图上进行分析 ...
- [2014.01.27]wfRadar 雷达图组件 2.5
全新开发的雷达图组件--wfRadar,使用简单,功能强大,图像处理效果极佳. 组件支持多种图片格式,包括bmp,jpg,gif,wmf,emf,ico,png,pcx,tif,tga,pcx,dcx ...
- Twproject Gantt – 开源的 JavaScript 甘特图组件
Twproject Gantt 是一款基于 jQuery 开发的甘特图组件,也可以创建其它图表,例如任务树(Task Trees).内置编辑.缩放和 CSS 皮肤等功能.更重要的是,它是免费开源的. ...
- 原生JS面向对象思想封装轮播图组件
原生JS面向对象思想封装轮播图组件 在前端页面开发过程中,页面中的轮播图特效很常见,因此我就想封装一个自己的原生JS的轮播图组件.有了这个需求就开始着手准备了,代码当然是以简洁为目标,轮播图的各个功能 ...
- QiniuUpload- 一个方便用七牛做图床然后插入markdown的小工具
最近一段时间有用markdown做笔记,其他都好,但是markdown插入图片挺麻烦的,特别是想截图之后直接插入的时候.需要首先把图片保存了,然后还要上传到一个地方生成链接才能插入.如果有个工具可以直 ...
随机推荐
- Qt 学习之路:QSortFilterProxyModel
从本章开始,我们将逐步了解有关自定义模型的相关内容.尽管前面我们曾经介绍过 Qt 提供的几个内置模型:QStringListModel和QFileSystemModel,但对于千变万化的需求而言,这些 ...
- iOS开发系列之触摸事件
基础知识 三类事件中触摸事件在iOS中是最常用的事件,这里我们首先介绍触摸事件. 在下面的例子中定义一个KCImage,它继承于UIView,在KCImage中指定一个图片作为背景.定义一个视图控制器 ...
- 微信小程序开发工具(0.9.092300)下载地址,分享给没有公众号的小伙伴
目前最新的v0.9.092300,不需要填AppID就能直接开发,也不需要破解了. OSX版本.WIN64.WIN32下载地址: http://pan.baidu.com/s/1qXOdkgG
- bzoj 1034 (田忌赛马++)
/* 这类题的最优策略: 自己最好的干掉对方最好的 或者 自己最差的干掉对方最差的 不能的话 用自己最差的 对阵对方最好的 这样是最优的 实现嘛 搞两个队列跑一跑 */ #include<ios ...
- Web.Config文件中添加数据库配置文件
1获取所有配置文件节点的类ConfigurationManager 2数据库节点<ConnectionStrings> <add> name ="Sqlconnect ...
- Wpf 数据绑定简介、实例1
简介:1.WPF绑定使用的源属性必须是依赖项属性,这是因为依赖项属性具有内置的更改通知支持,元素绑定表达式使用了Xaml扩展标记, WPF绑定一个控件是使用Binding.ElementName, 绑 ...
- 写一个基于NSURLSession的网络下载库
前段时间AFNetworking 更新到3.0 ,彻底废弃NSURLConnection的API转由NSURLSession来实现,代码并没有改动很大,AF封装的很好了,读完源码感觉收获很大. 下载不 ...
- CocoaPods使用详细说明(转)
一.概要 iOS开发时,项目中会引用许多第三方库,CocoaPods(https://github.com/CocoaPods/CocoaPods)可以用来方便的统一管理这些第三方库. 二.安装 由于 ...
- 【OpenSSL】创建证书
[-] 1生成根证书 1 生成RSA私钥 2 生成证书请求 3 签发自签名证书 2 生成用户证书 1 生成RSA私钥 2 生成证书请求 3 签发证书 1)生成根证书 1.1) 生成RSA私钥 op ...
- WebService CXF调试常见报错及解决方案
1.CXF java.lang.RuntimeException: Cannot create a secure XMLInputFactory 解决方案:从apache-cxf/lib下寻找Wood ...