|
@@ -167,69 +167,85 @@ public static class MapControlEx
|
|
|
ctrl.ToolTipController.BeforeShow += (sender, e) =>
|
|
|
{
|
|
|
if (e.SelectedObject == null) return;
|
|
|
+ SuperToolTip superToolTip = new SuperToolTip();
|
|
|
if (e.SelectedObject.ToString() == ItemsEditorPanelAction.AddRectangle.ToString())
|
|
|
{
|
|
|
e.ToolTip = "绘制矩形";
|
|
|
return;
|
|
|
}
|
|
|
- var mapDot = e.SelectedObject as MapDot;
|
|
|
- if (mapDot == null) return;
|
|
|
- var posItem = mapDot.Tag as PosData;
|
|
|
- if (mapDot == null || posItem == null) return;
|
|
|
- SuperToolTip superToolTip = new SuperToolTip();
|
|
|
- if (posItem.ClusterCount == 1)
|
|
|
+ else if (e.SelectedObject is MapDot mapDot)
|
|
|
{
|
|
|
- var props = posItem.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public).ToList();
|
|
|
- var list = new List<(int Index, string Name, string Format, object Value)>();
|
|
|
- foreach (var prop in props)
|
|
|
+ if (mapDot == null) return;
|
|
|
+ var posItem = mapDot.Tag as PosData;
|
|
|
+ if (mapDot == null || posItem == null) return;
|
|
|
+ if (posItem.ClusterCount == 1)
|
|
|
{
|
|
|
- var attrToolTip = prop.GetCustomAttribute<ToolTipAttribute>();
|
|
|
- if (attrToolTip == null) continue;
|
|
|
- string toolTipFormat = attrToolTip.Format;
|
|
|
+ var props = posItem.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public).ToList();
|
|
|
+ var list = new List<(int Index, string Name, string Format, object Value)>();
|
|
|
+ foreach (var prop in props)
|
|
|
+ {
|
|
|
+ var attrToolTip = prop.GetCustomAttribute<ToolTipAttribute>();
|
|
|
+ if (attrToolTip == null) continue;
|
|
|
+ string toolTipFormat = attrToolTip.Format;
|
|
|
|
|
|
|
|
|
- var val = prop.GetValue(posItem);
|
|
|
+ var val = prop.GetValue(posItem);
|
|
|
|
|
|
- string displayName = prop.Name;
|
|
|
- var attrDisplay = prop.GetCustomAttribute<DisplayAttribute>();
|
|
|
- if (attrDisplay != null && !string.IsNullOrWhiteSpace(attrDisplay.Name))
|
|
|
- displayName = attrDisplay.Name;
|
|
|
-
|
|
|
- int index = attrToolTip.Index;
|
|
|
- list.Add((index, displayName, toolTipFormat, val));
|
|
|
- }
|
|
|
- list = list.OrderBy(p => p.Index).ToList();
|
|
|
- foreach ((int Index, string Name, string Format, object val) in list)
|
|
|
- {
|
|
|
- string f = null;
|
|
|
- if (val is DateTime)
|
|
|
- {
|
|
|
- f = "yyyy-MM-dd HH:mm:ss";
|
|
|
+ string displayName = prop.Name;
|
|
|
+ var attrDisplay = prop.GetCustomAttribute<DisplayAttribute>();
|
|
|
+ if (attrDisplay != null && !string.IsNullOrWhiteSpace(attrDisplay.Name))
|
|
|
+ displayName = attrDisplay.Name;
|
|
|
|
|
|
+ int index = attrToolTip.Index;
|
|
|
+ list.Add((index, displayName, toolTipFormat, val));
|
|
|
}
|
|
|
- else if (val is float || val is double || val is decimal)
|
|
|
+ list = list.OrderBy(p => p.Index).ToList();
|
|
|
+ foreach ((int Index, string Name, string Format, object val) in list)
|
|
|
{
|
|
|
- f = "f4";
|
|
|
+ string f = null;
|
|
|
+ if (val is DateTime)
|
|
|
+ {
|
|
|
+ f = "yyyy-MM-dd HH:mm:ss";
|
|
|
+
|
|
|
+ }
|
|
|
+ else if (val is float || val is double || val is decimal)
|
|
|
+ {
|
|
|
+ f = "f4";
|
|
|
+ }
|
|
|
+ if (!string.IsNullOrWhiteSpace(Format))
|
|
|
+ f = Format;
|
|
|
+ string valStr;
|
|
|
+ if (!string.IsNullOrWhiteSpace(f))
|
|
|
+ valStr = ((dynamic)val).ToString(f);
|
|
|
+ else
|
|
|
+ valStr = val.ToString();
|
|
|
+ ToolTipItem tipItem = new ToolTipItem();
|
|
|
+ tipItem.Text = $"{Name}:{valStr}";
|
|
|
+ superToolTip.Items.Add(tipItem);
|
|
|
}
|
|
|
- if (!string.IsNullOrWhiteSpace(Format))
|
|
|
- f = Format;
|
|
|
- string valStr;
|
|
|
- if (!string.IsNullOrWhiteSpace(f))
|
|
|
- valStr = ((dynamic)val).ToString(f);
|
|
|
- else
|
|
|
- valStr = val.ToString();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
ToolTipItem tipItem = new ToolTipItem();
|
|
|
- tipItem.Text = $"{Name}:{valStr}";
|
|
|
+ tipItem.Text = $"当前位置附近有{posItem.ClusterCount}个定位点,放大可查看";
|
|
|
superToolTip.Items.Add(tipItem);
|
|
|
}
|
|
|
+ e.SuperTip = superToolTip;
|
|
|
}
|
|
|
- else
|
|
|
+ else if (e.SelectedObject is MapCustomElement ele)
|
|
|
{
|
|
|
- ToolTipItem tipItem = new ToolTipItem();
|
|
|
- tipItem.Text = $"当前位置附近有{posItem.ClusterCount}个定位点,放大可查看";
|
|
|
- superToolTip.Items.Add(tipItem);
|
|
|
+ var find = innerData.mMapStorageFixed.Items.Where(p => (p is MapCustomElement pp) && p != ele && pp.Location.Equals(ele.Location));
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ sb.Append(((object[])ele.Tag)[1]);
|
|
|
+ foreach (var item in find)
|
|
|
+ {
|
|
|
+ sb.Append("\r\n");
|
|
|
+ sb.Append("-------------------");
|
|
|
+ sb.Append("\r\n");
|
|
|
+ sb.Append(((object[])item.Tag)[1]);
|
|
|
+ }
|
|
|
+ ele.ToolTipPattern = sb.ToString();
|
|
|
}
|
|
|
- e.SuperTip = superToolTip;
|
|
|
};
|
|
|
ctrl.MouseDown += (sender, e) =>
|
|
|
{
|
|
@@ -406,7 +422,7 @@ public static class MapControlEx
|
|
|
else
|
|
|
btnCustom.Visibility = BarItemVisibility.Never;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
};
|
|
|
return ctrl;
|
|
|
}
|
|
@@ -696,7 +712,7 @@ public static class MapControlEx
|
|
|
public static void DrawFixedImg(this MapControl ctrl, string tag, double imgLat, double imgLon, Image img, string toolTip = "")
|
|
|
{
|
|
|
var innerData = ctrl.Tag as InnerData;
|
|
|
- var item = new MapCustomElement() { Tag = tag };
|
|
|
+ var item = new MapCustomElement() { Tag =new object[] { tag, toolTip } };
|
|
|
item.UseAnimation = false;
|
|
|
item.BackgroundDrawingMode = ElementState.None;
|
|
|
item.Location = new GeoPoint(imgLat, imgLon);
|
|
@@ -717,7 +733,7 @@ public static class MapControlEx
|
|
|
public static void DrawFixedImg(this MapControl ctrl, string tag, double imgLat, double imgLon, SvgImage img, string toolTip = "")
|
|
|
{
|
|
|
var innerData = ctrl.Tag as InnerData;
|
|
|
- var item = new MapCustomElement() { Tag = tag };
|
|
|
+ var item = new MapCustomElement() { Tag =new object[] { tag, toolTip } };
|
|
|
item.UseAnimation = false;
|
|
|
item.BackgroundDrawingMode = ElementState.None;
|
|
|
item.Location = new GeoPoint(imgLat, imgLon);
|
|
@@ -729,7 +745,7 @@ public static class MapControlEx
|
|
|
public static void DelFixedImg(this MapControl ctrl, string tag)
|
|
|
{
|
|
|
var innerData = ctrl.Tag as InnerData;
|
|
|
- var delItems = innerData.mMapStorageFixed.Items.ToList().FindAll(p => p.Tag.ToString() == tag);
|
|
|
+ var delItems = innerData.mMapStorageFixed.Items.ToList().FindAll(p => ((object[])p.Tag)[0].ToString() == tag);
|
|
|
foreach (var item in delItems)
|
|
|
{
|
|
|
innerData.mMapStorageFixed.Items.Remove(item);
|