PIE SDK 基于Dot net bar实现比例尺控件

最近在搭建主界面的过程中,为了界面美观大方,使用了Dot net bar。但是,在Dot net bar的状态栏中放置PIE SDK自带的比例尺控件,运行主界面程序后,比例尺控件始终不显示比例尺信息,得不到想要的效果。如果使用Windows Form自带的状态栏,则能够正常显示比例尺信息。我猜想,可能是PIE SDK自带的比例尺控件与Dot net bar不兼容。我参考了官方博客(https://www.cnblogs.com/PIESat/p/10272779.html),利用Dot net bar拓展实现了比例尺控件。

基于Dot net bar,利用PIE SDK自带的比例尺控件(代码如下),运行程序后的显示效果如下图(不能正常显示比例尺信息):

 1  public FormMain()
 2         {
 3             InitializeComponent();
 4             mapControlMain.OnExtentUpdated += mapControlMain_OnExtentUpdated;//鹰眼图
 5             ///比例尺控件
 6             //Common.MapScaleCommandControl mapScaleControl = new Common.MapScaleCommandControl();
 7             //mapScaleControl.Control = comboBoxItem_MapScale;
 8             //mapScaleControl.OnCreate(mapControlMain);
 9             MapScaleCommandControl mapScale = new MapScaleCommandControl();
10             mapScale.Control = comboBoxItem_MapScale;
11             mapScale.OnCreate(mapControlMain);
12             //进度条//首先隐藏需要时显现
13             this.progressBarItem.Visible = false;
14             Control.CheckForIllegalCrossThreadCalls = false;
15         }

利用基于Dot net bar拓展实现的比例尺控件(代码如下),运行程序后显示的效果如下图(可正常显示比例尺信息):

 1 public FormMain()
 2         {
 3             InitializeComponent();
 4             mapControlMain.OnExtentUpdated += mapControlMain_OnExtentUpdated;//鹰眼图
 5             ///比例尺控件
 6             Common.MapScaleCommandControl mapScaleControl = new Common.MapScaleCommandControl();
 7             mapScaleControl.Control = comboBoxItem_MapScale;
 8             mapScaleControl.OnCreate(mapControlMain);
 9             //MapScaleCommandControl mapScale = new MapScaleCommandControl();
10             //mapScale.Control = comboBoxItem_MapScale;
11             //mapScale.OnCreate(mapControlMain);
12             //进度条//首先隐藏需要时显现
13             this.progressBarItem.Visible = false;
14             Control.CheckForIllegalCrossThreadCalls = false;
15         }

利用Dot net bar拓展实现的比例尺控件代码如下:

  1 /// <summary>
  2     /// 比例尺控件
  3     /// </summary>
  4     #region
  5     class MapScaleCommandControl : PIE.Controls.BaseCommandControl
  6     {
  7         #region 成员变量
  8         /// <summary>
  9         /// ToolStripComboBox
 10         /// </summary>
 11         private DevComponents.DotNetBar.ComboBoxItem m_DotNetBarComboxItem = null;
 12         #endregion
 13
 14         /// <summary>
 15         /// 构造函数
 16         /// </summary>
 17         public MapScaleCommandControl()
 18         {
 19             this.Caption = "";
 20             this.Name = "";
 21             this.Checked = false;
 22             this.Enabled = false;
 23         }
 24         /// <summary>
 25         /// Control
 26         /// </summary>
 27         public override object Control
 28         {
 29             get
 30             {
 31                 return m_DotNetBarComboxItem;
 32             }
 33             set
 34             {
 35                 m_DotNetBarComboxItem = value as DevComponents.DotNetBar.ComboBoxItem;
 36             }
 37         }
 38         /// <summary>
 39         /// 是否可用
 40         /// </summary>
 41         public override bool Enabled
 42         {
 43             get
 44             {
 45                 if (m_Hook == null || m_HookHelper.ActiveView.FocusMap.LayerCount < 1) return false;
 46                 return true;
 47             }
 48             protected set
 49             {
 50                 base.Enabled = value;
 51             }
 52         }
 53         /// <summary>
 54         /// 创建插件对象
 55         /// </summary>
 56         /// <param name="hook"></param>
 57         public override void OnCreate(object hook)
 58         {
 59             if (hook == null) return;
 60             if (!(hook is PIE.Carto.IPmdContents)) return;
 61             this.Enabled = true;
 62             m_Hook = hook;
 63             m_HookHelper.Hook = hook;
 64
 65             if (m_DotNetBarComboxItem == null) return;
 66             DevComponents.DotNetBar.ComboBoxItem comboxItem = this.m_DotNetBarComboxItem as DevComponents.DotNetBar.ComboBoxItem;
 67             if (comboxItem == null) return;
 68
 69             comboxItem.Items.Add("1:500");
 70             comboxItem.Items.Add("1:1000");
 71             comboxItem.Items.Add("1:5000");
 72             comboxItem.Items.Add("1:10000");
 73             comboxItem.Items.Add("1:50000");
 74             comboxItem.Items.Add("1:100000");
 75             comboxItem.Items.Add("1:500000");
 76             comboxItem.Items.Add("1:1000000");
 77             //comboxItem.KeyPress += comboxItem_KeyPress;
 78             comboxItem.SelectedIndexChanged += comboxItem_SelectedIndexChanged;
 79             (hook as PIE.AxControls.MapControl).OnExtentUpdated += MapScaleCommandControl_OnExtentUpdated;
 80         }
 81         void comboxItem_SelectedIndexChanged(object sender, EventArgs e)
 82         {
 83             //获取选中的比例尺
 84             string strScale = m_DotNetBarComboxItem.Text.ToString();
 85             int count = strScale.Length;
 86             if (count < 3) return;
 87             string str = strScale.Substring(2, count - 2);
 88             double scale = Convert.ToDouble(str);
 89             if (scale < 1) return;
 90
 91             //改变地图的比例尺并更新
 92             m_HookHelper.ActiveView.DisplayTransformation.MapScale = scale;
 93             m_HookHelper.ActiveView.PartialRefresh(PIE.Carto.ViewDrawPhaseType.ViewAll);
 94         }
 95         private void MapScaleCommandControl_OnExtentUpdated(object sender, bool sizeChanged, PIE.Geometry.IEnvelope newEnvelope)
 96         {
 97             string strScale = m_HookHelper.ActiveView.DisplayTransformation.MapScale.ToString();
 98             double scale = Convert.ToDouble(strScale);
 99             strScale = "1:" + scale.ToString("0");
100             m_DotNetBarComboxItem.ComboBoxEx.Text = strScale;
101             this.m_DotNetBarComboxItem.Text = strScale;
102         }
103         /// <summary>
104         /// 比例尺文本变化事件
105         /// </summary>
106         /// <param name="sender"></param>
107         /// <param name="e"></param>
108         void comboxItem_TextChanged(object sender, EventArgs e)
109         {
110             //获取选中的比例尺
111             string strScale = m_DotNetBarComboxItem.Text.ToString();
112             int count = strScale.Length;
113             if (count < 3) return;
114             string str = strScale.Substring(2, count - 2);
115             double scale = Convert.ToDouble(str);
116             if (scale < 1) return;
117
118             //改变地图的比例尺并更新
119             m_HookHelper.ActiveView.DisplayTransformation.MapScale = scale;
120             m_HookHelper.ActiveView.PartialRefresh(PIE.Carto.ViewDrawPhaseType.ViewAll);
121         }
122         /// <summary>
123         /// 点击事件
124         /// </summary>
125         public override void OnClick()
126         {
127             base.OnClick();
128         }
129     }
130 #endregion

有不对的地方,请大家批评指正。

原文地址:https://www.cnblogs.com/LW-MA/p/11417552.html

时间: 2024-07-30 13:45:10

PIE SDK 基于Dot net bar实现比例尺控件的相关文章

Web应用程序开发,基于Ajax技术的JavaScript树形控件

感谢http://www.cnblogs.com/dgrew/p/3181769.html#undefined 在Web应用程序开发领域,基于Ajax技术的JavaScript树形控件已经被广泛使用,它用来在Html页面上展现具有层次结构的数据项. 目前市场上常见的JavaScript框架及组件库中均包含自己的树形控件,例如jQuery.Dojo.YUI.Ext JS等,还有一些独立的树形控件,例如dhtmlxTree等,这些树形控件完美的解决了层次数据的展示问题. 展示离不开数据,树形控件主要

基于Qt的第三方库和控件

====================== 基于Qt的第三方库和控件 ======================     libQxt --------   http://dev.libqxt.org/libqxt/wiki/Home   按照文档中所流露的意思,libQxt实现了一些“Qt本来就应该有但实际上没有”的功能. 对应Qt相应的Module,Qxt有 QxtCore.QxtGui.QxtNetwork.QxtSql等模块作为Qt功能的 补充,此外,还提供了QxtWeb(Web S

基于浏览器的文档处理控件TX Text Control .NET Server for WP

TX Text Control .NET Server for WPF控件为用于ASP.NET服务器环境提供一个完全可编程的文字处理引擎,并且包含一个WPF客户端版本 具体功能: 合并Microsoft Word模板,生成打印就绪的PDF文件 在浏览器中以所见即所得模式编辑处理文档 从同一个文档的每一页中生成图片或meta文件 使用来自不同源的数据从零开始通过编程生成文档 在所有支持的格式之间转换文档 完全独立于 Microsoft Word, Adobe Acrobat,及其他第三方软件 一台

基于Bootstrap的JQuery TreeView树形控件,数据支持json字符串、list集合(MVC5)

BZ第一次自己写博客,心情好激动!!BZ也是小菜,本文如果有什么不对的地方,希望大神们多多指教,也希望和我一样的小菜多多学习.BZ在这里谢过各位. BZ最近看了很多博友的有关TreeView的博客,发现很多都是WebForm.JQuery的.因为BZ使用的是MVC的原因,所以决定写一写关于MVC和Bootstrap的TreeView. PS:基于Bootstrap的JQuery TreeView树形控件,JQuery版本为2.1.1(下载网上的基于Bootstrap的JQuery TreeVie

基于wince的MFC Tab Control控件的使用

1,先建立一个对话框MFC应用程序,然后在工具箱里面把Tab Control控件放到对话框中的合适位置上. 再在对话框类中,声明一个CTabCtrl变量: CTabCtrl m_tab; 变量m_tab用来与对话框中的Tab Control控件交互,为此要在DoDataExchange函数中加入DDX_Control语句: 1 //{{AFX_DATA_MAP(CTABDlg) 2 DDX_Control(pDX, IDC_TAB, m_tab); 3 //}}AFX_DATA_MAP IDC_

Stimulsoft Reports Designer.Silverlight是一个基于web的报表设计器控件

Stimulsoft Reports Designer.Silverlight是一个基于web的报表设计器控件,通过使用它您可以直接在web浏览器中更改您的报表控件.该产品使用Silverlight技术和ASP.NET开发.它不需要开发人员编写复杂的代码或很长的组件设置.您在服务器上使用的是一个简单的ASP.NET组件.Silverlight组件在客户端上运行.Stimulsoft Reports Designer.Silverlight拥有一个时尚的用户界面,加载迅速,运行速度快,并拥有丰富的

高德地图API之缩放比例尺控件+3D转换

缩放比例尺控件 首先引入控件 AMap.Scale <script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=ce3b1a3a7e67fc75810ce1ba1f83c01a&plugin=AMap.Scale"></script> 然后使用 map.addControl() 添加控件 <!DOCTYPE html>

Appium基于安卓的各种FindElement的控件定位方法实践和建议

AppiumDriver的各种findElement方法的尝试,尝试的目标应用是SDK自带的Notepad应用. 1. findElementByName 1.1 示例 el = driver.findElementByName("Add note"); assertThat(el.getText(),equalTo("Add note")); 1.2 如何获得Name 安卓设备没有找到适合的方法,尝试用Appium Inspector,但是使用了当前最新的&quo

基于Bootstrap仿淘宝分页控件实现

.header { cursor: pointer } p { margin: 3px 6px } th { background: lightblue; width: 20% } table { text-align: center; margin-top: 20px; margin-left: 10px; margin-bottom: 20px } a { cursor: pointer; text-decoration: none; color: gray } a:hover { text