最近在搭建主界面的过程中,为了界面美观大方,使用了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. hexo笔记

    目录 hexo 常用指令 站内文章跳转 hexo安装 NexT主题 默认主题 评论插件-gitalk 修改内容区宽度 添加文章阴影 文章摘要设置 一篇文章多个 categories hexo的一些配置 ...

  2. Linux安装php-mysql提示需要:libmysqlclient.so.18()(64bit)的解决办法

    Linux安装php-mysql提示需要:libmysqlclient.so.18()(64bit)的解决办法 在LNMP编译环境下安装zabbix会出现 执行:yum -y install net- ...

  3. udf文件十六进制

    如下为网上找的前辈们的UDF(以做记录) set @a = unhex('7F454C4602010100000000000000000003003E0001000000800A00000000000 ...

  4. echarts-中的事件-- demo1.on('事件类型', function (params) {}

    ECharts 支持常规的鼠标事件类型,包括 'click'.'dblclick'.'mousedown'.'mousemove'. 'mouseup'.'mouseover'.'mouseout'. ...

  5. 如何去掉任务栏的IE搜索栏

    在IE图标的位置单击鼠标右键,选择退出.

  6. mysql的创建数据库表及添加数据

    C:\Users\ceshi>mysql -u root -pEnter password: ******Welcome to the MySQL monitor. Commands end w ...

  7. Nginx日志管理(四)

    Nginx日志对于统计.系统服务排错很有用.Nginx日志主要分为两种:access_log(访问日志)和error_log(错误日志).通过访问日志我们可以得到用户的IP地址.浏览器的信息,请求的处 ...

  8. 论文阅读笔记六十四: Architectures for deep neural network based acoustic models defined over windowed speech waveforms(INTERSPEECH 2015)

    论文原址:https://pdfs.semanticscholar.org/eeb7/c037e6685923c76cafc0a14c5e4b00bcf475.pdf 摘要 本文研究了利用深度神经网络 ...

  9. windwos文件句柄数限制

    1.修改注册表,位置如下: HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Windows 2.设置 1.GDIProc ...

  10. [LeetCode] 644. Maximum Average Subarray II 子数组的最大平均值之二

    Given an array consisting of n integers, find the contiguous subarray whose length is greater than o ...