最近在搭建主界面的过程中,为了界面美观大方,使用了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自带的比例尺控件(代码如下),运行程序后的显示效果如下图(不能正常显示比例尺信息):

  public FormMain()
{
InitializeComponent();
mapControlMain.OnExtentUpdated += mapControlMain_OnExtentUpdated;//鹰眼图
///比例尺控件
//Common.MapScaleCommandControl mapScaleControl = new Common.MapScaleCommandControl();
//mapScaleControl.Control = comboBoxItem_MapScale;
//mapScaleControl.OnCreate(mapControlMain);
MapScaleCommandControl mapScale = new MapScaleCommandControl();
mapScale.Control = comboBoxItem_MapScale;
mapScale.OnCreate(mapControlMain);
//进度条//首先隐藏需要时显现
this.progressBarItem.Visible = false;
Control.CheckForIllegalCrossThreadCalls = false;
}

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

 public FormMain()
{
InitializeComponent();
mapControlMain.OnExtentUpdated += mapControlMain_OnExtentUpdated;//鹰眼图
///比例尺控件
Common.MapScaleCommandControl mapScaleControl = new Common.MapScaleCommandControl();
mapScaleControl.Control = comboBoxItem_MapScale;
mapScaleControl.OnCreate(mapControlMain);
//MapScaleCommandControl mapScale = new MapScaleCommandControl();
//mapScale.Control = comboBoxItem_MapScale;
//mapScale.OnCreate(mapControlMain);
//进度条//首先隐藏需要时显现
this.progressBarItem.Visible = false;
Control.CheckForIllegalCrossThreadCalls = false;
}

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

 /// <summary>
/// 比例尺控件
/// </summary>
#region
class MapScaleCommandControl : PIE.Controls.BaseCommandControl
{
#region 成员变量
/// <summary>
/// ToolStripComboBox
/// </summary>
private DevComponents.DotNetBar.ComboBoxItem m_DotNetBarComboxItem = null;
#endregion /// <summary>
/// 构造函数
/// </summary>
public MapScaleCommandControl()
{
this.Caption = "";
this.Name = "";
this.Checked = false;
this.Enabled = false;
}
/// <summary>
/// Control
/// </summary>
public override object Control
{
get
{
return m_DotNetBarComboxItem;
}
set
{
m_DotNetBarComboxItem = value as DevComponents.DotNetBar.ComboBoxItem;
}
}
/// <summary>
/// 是否可用
/// </summary>
public override bool Enabled
{
get
{
if (m_Hook == null || m_HookHelper.ActiveView.FocusMap.LayerCount < ) return false;
return true;
}
protected set
{
base.Enabled = value;
}
}
/// <summary>
/// 创建插件对象
/// </summary>
/// <param name="hook"></param>
public override void OnCreate(object hook)
{
if (hook == null) return;
if (!(hook is PIE.Carto.IPmdContents)) return;
this.Enabled = true;
m_Hook = hook;
m_HookHelper.Hook = hook; if (m_DotNetBarComboxItem == null) return;
DevComponents.DotNetBar.ComboBoxItem comboxItem = this.m_DotNetBarComboxItem as DevComponents.DotNetBar.ComboBoxItem;
if (comboxItem == null) return; comboxItem.Items.Add("1:500");
comboxItem.Items.Add("1:1000");
comboxItem.Items.Add("1:5000");
comboxItem.Items.Add("1:10000");
comboxItem.Items.Add("1:50000");
comboxItem.Items.Add("1:100000");
comboxItem.Items.Add("1:500000");
comboxItem.Items.Add("1:1000000");
//comboxItem.KeyPress += comboxItem_KeyPress;
comboxItem.SelectedIndexChanged += comboxItem_SelectedIndexChanged;
(hook as PIE.AxControls.MapControl).OnExtentUpdated += MapScaleCommandControl_OnExtentUpdated;
}
void comboxItem_SelectedIndexChanged(object sender, EventArgs e)
{
//获取选中的比例尺
string strScale = m_DotNetBarComboxItem.Text.ToString();
int count = strScale.Length;
if (count < ) return;
string str = strScale.Substring(, count - );
double scale = Convert.ToDouble(str);
if (scale < ) return; //改变地图的比例尺并更新
m_HookHelper.ActiveView.DisplayTransformation.MapScale = scale;
m_HookHelper.ActiveView.PartialRefresh(PIE.Carto.ViewDrawPhaseType.ViewAll);
}
private void MapScaleCommandControl_OnExtentUpdated(object sender, bool sizeChanged, PIE.Geometry.IEnvelope newEnvelope)
{
string strScale = m_HookHelper.ActiveView.DisplayTransformation.MapScale.ToString();
double scale = Convert.ToDouble(strScale);
strScale = "1:" + scale.ToString("");
m_DotNetBarComboxItem.ComboBoxEx.Text = strScale;
this.m_DotNetBarComboxItem.Text = strScale;
}
/// <summary>
/// 比例尺文本变化事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void comboxItem_TextChanged(object sender, EventArgs e)
{
//获取选中的比例尺
string strScale = m_DotNetBarComboxItem.Text.ToString();
int count = strScale.Length;
if (count < ) return;
string str = strScale.Substring(, count - );
double scale = Convert.ToDouble(str);
if (scale < ) return; //改变地图的比例尺并更新
m_HookHelper.ActiveView.DisplayTransformation.MapScale = scale;
m_HookHelper.ActiveView.PartialRefresh(PIE.Carto.ViewDrawPhaseType.ViewAll);
}
/// <summary>
/// 点击事件
/// </summary>
public override void OnClick()
{
base.OnClick();
}
}
#endregion

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

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

  1. 基于存储过程的MVC开源分页控件--LYB.NET.SPPager

    摘要 现在基于ASP.NET MVC的分页控件我想大家都不陌生了,百度一下一大箩筐.其中有不少精品,陕北吴旗娃杨涛大哥做的分页控件MVCPager(http://www.webdiyer.com/)算 ...

  2. FineUI 基于 ExtJS 的专业 ASP.NET 控件库

    FineUI 基于 ExtJS 的专业 ASP.NET 控件库 http://www.fineui.com/

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

    上篇博客给大家介绍了基于Bootstrap的JQuery TreeView树形控件,数据支持json字符串.list集合(MVC5)<一>, 其中的两种方式都显得有些冗余.接着上篇博客继续 ...

  4. 百度地图API示例之添加/删除工具条、比例尺控件

    代码 <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" cont ...

  5. 基于Qt的第三方库和控件

    ====================== 基于Qt的第三方库和控件 ======================     libQxt --------   http://dev.libqxt.o ...

  6. 基于存储过程的MVC开源分页控件

    基于存储过程的MVC开源分页控件--LYB.NET.SPPager 摘要 现在基于ASP.NET MVC的分页控件我想大家都不陌生了,百度一下一大箩筐.其中有不少精品,陕北吴旗娃杨涛大哥做的分页控件M ...

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

    感谢http://www.cnblogs.com/dgrew/p/3181769.html#undefined 在Web应用程序开发领域,基于Ajax技术的JavaScript树形控件已经被广泛使用, ...

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

    .header { cursor: pointer } p { margin: 3px 6px } th { background: lightblue; width: 20% } table { t ...

  9. 【转】Appium基于安卓的各种FindElement的控件定位方法实践

    原文地址:http://blog.csdn.net/zhubaitian/article/details/39754041#t11 AppiumDriver的各种findElement方法的尝试,尝试 ...

随机推荐

  1. ubuntu 用户名配置及磁盘挂载

    创建用户 我们创建的这个用户要放到 sudo 用户组,以便于我们可以执行一些需要 root 权限的操作. sudo useradd -m -s /bin/bash username sudo user ...

  2. linux(03)基础系统优化

    Linux之基础系统优化 Linux基础系统优化 >>> https://www.cnblogs.com/pyyu/p/9355477.html Linux的网络功能相当强悍,一时之 ...

  3. idea中的插件,可以快速将类中的属性转换成Json字符串

    当我们想要测试接口的时候,难免会根据一个类,一个一个的写json数据,当属性比较少时还行,但当属性多的时候就比较麻烦了, 为了解决这个问题,我们可以安装第三方的插件来快速生成json字符串. 步骤如下 ...

  4. DNS分离解析

    实验环境: 一台内网(client)1块网卡:一台网关(dns)2块网卡:一台外网1块网卡 DNS服务器开启路由转发 [root@localhost ~]# vi /etc/sysctl.conf n ...

  5. USACO Score Inflation

    洛谷 P2722 总分 Score Inflation https://www.luogu.org/problem/P2722 JDOJ 1697: Score Inflation https://n ...

  6. 树莓派“Wlan0: Not associated”报错解决方案

    当执行 ifconfig wlan0 时,是有wlan0的网卡信息输出的. 当执行 ifconfig wlan0 up 是没问题的(即没有任何输出). 执行 iwlist wlan0 scan | g ...

  7. 从网络服务生成Apex类

    使用WSDL2Apex从网络服务生成Apex类 如果某个网络服务被定义在WSDL文件中,而Salesforce必须使用SOAP和网络服务进行通信,则这种情况在某些时候会为开发者带来很多麻烦.为了简化S ...

  8. [LeetCode] 315. Count of Smaller Numbers After Self 计算后面较小数字的个数

    You are given an integer array nums and you have to return a new counts array. The countsarray has t ...

  9. JAVA SE11环境变量配置(Windows)

    附上:03. 安装环境:Windows · IntelliJ IDEA Tutorial 附上:使用调试功能进行 Java debug 附上:Linux(Deepin)下配置java8 - L1412 ...

  10. WPF DataGrid 鼠标对表格双击导致客户端崩溃

    该问题是由于在创建DataGrid时没有设置为只读属性 解决:             <DataGrid Name="switchInfoList" MouseLeftBu ...