WPF经纬度控件

1.需求及思路

绘制一个控件,可以设置经纬度,经纬度用double类型表示,支持绑定数据,数据更改通知。错误验证,输入检校。

大致设计界面如下图:

 

2.主要代码

 主要代码在于计算,double类型转换成三个数:度数,分数,分数的小数。

  var uc = d as LonLatSetUc;
            if (uc != null && Math.Abs((decimal) e.NewValue - (decimal) e.OldValue) > 0.0000001m)
            {
                uc.DirectionSelectedIndex = uc.Value > 0 ? 0 : 1;
                uc.Deg = Math.Abs((int) uc.Value);
                var tempMin = (Math.Abs(uc.Value) - uc.Deg)*60;
                uc.Min = (int) (tempMin + 0.0000001m);
                //因decimal精度问题,需要四舍五入
                uc.MinDecimal = (int) ((tempMin - uc.Min + 0.0000001m)*1000);
            }

  

3.源码下载:

旧版本

 https://files.cnblogs.com/files/lizhijian/%E7%BB%8F%E7%BA%AC%E5%BA%A6%E6%8E%A7%E4%BB%B6.rar

 

更新:

https://files.cnblogs.com/files/chlm/%E7%BB%8F%E7%BA%AC%E5%BA%A6%E6%8E%A7%E4%BB%B6.rar

感谢阅读

转载于:https://www.cnblogs.com/chlm/p/8608537.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在于GIS相关的软件中经常要输入经纬度数值,而基于MFC Edit控件经纬度输入控件需 要创建三个Edit编辑框,来分别输入度、分、秒数值,并且需要分别进行输入范围和有效 性的检验。该基于BCGControlBar的经纬度输入控件实现了在一个输入窗口中分别按照度 、分、秒三个值域来输入经纬度数值,并同时进行了输入分有效性和输入范围的检验。经 纬度中的度、分、秒字段均通过数字键盘直接输入数值,也可通过微调按钮或者键盘的上 下键进行数字的增减,你可以通过左右键进行度、分、秒输入域的切换。该控件可以设置 度的输入范围,默认的度范围是0~89。该1.1版本修复了键盘直接输入数值的逻辑问题。 In the GIS-related software often have to enter the latitude and longitude values, and MFC Edit control based on the latitude and longitude input controls need to create three Edit edit box to enter the degrees, minutes and seconds values, and the need for input range and validity of the test. The BCGControlBar-based latitude and longitude input control realizes the input of the latitude and longitude values in degrees,minutes,and seconds in one input window, and simultaneously verifies the validity of the input points and the input range.The degrees, minutes, and seconds fields can be entered directly through the numeric keypad, also can be fine-tuning button or the keyboard up and down keys to increase or decrease the number, you can use left and right keys for degrees, minutes and seconds to switch the input field. The control can set the input range of degree, the default range is 0 ~ 89.The 1.1 version fixes the logic of keyboard input values directly.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值