123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- using DevExpress.XtraEditors;
- using DevExpress.XtraEditors.DXErrorProvider;
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ExtensionsDev
- {
- public static class BaseEditExtension
- {
- public static void UseDoubleClickToSelectAll(this BaseEdit ctrl)
- {
- ctrl.DoubleClick += Ctrl_DoubleClick;
- }
- private static void Ctrl_DoubleClick(object sender, EventArgs e)
- {
- var ctrl= (BaseEdit)sender;
- ctrl.SelectAll();
- }
- public static (bool,string) CheckLonLat(this TextEdit @this, string msg)
- {
- if (string.IsNullOrWhiteSpace(@this.Text.Trim()))
- {
-
- return (false, $"{msg}经纬度不能为空!");
- }
- var context = @this.Text.Split(',');
- if (context.Length != 2)
- {
-
- return (false,$"{msg}经度纬度之间用英文逗号隔开!");
- }
- double lon;
- bool isDoubleLon = Double.TryParse(context[0], out lon);
- if (!isDoubleLon || lon > 180 || lon < -180)
- {
- return (false, $"{msg}经度范围[180,-180]!");
- }
- double lat;
- bool isDoubleLat = Double.TryParse(context[1], out lat);
- if (!isDoubleLat || lat > 90 || lat < -90)
- {
- return (false, $"{msg}纬度范围[90,-90]!");
- }
- return (true,"");
- }
- }
- }
|