|
|
@@ -1,11 +1,14 @@
|
|
|
using DataSimulation.Repostory;
|
|
|
+using DataSimulation.Repostory.EFContext;
|
|
|
using DevExpress.Export.Xl;
|
|
|
using DevExpress.Map;
|
|
|
using DevExpress.Map.Native;
|
|
|
using DevExpress.Utils;
|
|
|
+using DevExpress.Utils.Filtering;
|
|
|
using DevExpress.Utils.Svg;
|
|
|
using DevExpress.XtraBars;
|
|
|
using DevExpress.XtraEditors;
|
|
|
+using DevExpress.XtraEditors.Popup;
|
|
|
using DevExpress.XtraGrid;
|
|
|
using DevExpress.XtraGrid.Columns;
|
|
|
using DevExpress.XtraGrid.Views.Grid;
|
|
|
@@ -14,6 +17,7 @@ using DevExpress.XtraMap.ItemEditor;
|
|
|
using DevExpress.XtraPrinting;
|
|
|
using DxHelper;
|
|
|
using System;
|
|
|
+using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
using System.Data.Common;
|
|
|
@@ -78,7 +82,7 @@ public static class MapControlEx
|
|
|
/// 航迹线
|
|
|
/// </summary>
|
|
|
internal MapSpline flightpath;
|
|
|
- internal Dictionary<string, FlightInfo> _flightCache = new Dictionary<string, FlightInfo>();
|
|
|
+ internal List<FlightInfo> _flightCache = new List<FlightInfo>();
|
|
|
internal MapDot hoverPoint;
|
|
|
internal ToolTipControllerShowEventArgs hoverTip;
|
|
|
internal ToolTipController mapToolTip;
|
|
|
@@ -403,7 +407,7 @@ public static class MapControlEx
|
|
|
/// <param name="img"></param>
|
|
|
/// <param name="action">一个回调,参数为选中的定位点</param>
|
|
|
/// <returns></returns>
|
|
|
- public static MapControl AddPosMenu<T>(this MapControl ctrl, string caption, SvgImage img, Action<T> action, Func<T, bool> showCondition = null) where T : PosData, new()
|
|
|
+ public static MapControl AddMenu<T>(this MapControl ctrl, string caption, SvgImage img, Action<T> action, Func<T, bool> showCondition = null) where T : FlightInfo, new()
|
|
|
{
|
|
|
var btnCustom = new BarButtonItem() { Caption = caption };
|
|
|
btnCustom.ImageOptions.SvgImage = img;
|
|
|
@@ -470,14 +474,14 @@ public static class MapControlEx
|
|
|
/// <param name="img"></param>
|
|
|
/// <param name="action">一个回调,参数为框选的定位点</param>
|
|
|
/// <returns></returns>
|
|
|
- public static MapControl AddRectMenu<T>(this MapControl ctrl, string caption, SvgImage img, Action<IEnumerable<T>> action) where T : PosData, new()
|
|
|
+ public static MapControl AddRectMenu<T>(this MapControl ctrl, string caption, SvgImage img, Action<IEnumerable<T>> action) where T : FlightInfo, new()
|
|
|
{
|
|
|
var btnCustom = new BarButtonItem() { Caption = caption };
|
|
|
btnCustom.ImageOptions.SvgImage = img;
|
|
|
btnCustom.Tag = ctrl;
|
|
|
btnCustom.ItemClick += (sender, e) =>
|
|
|
{
|
|
|
- var data = ctrl.GetRectPosItem<T>();
|
|
|
+ var data = ctrl.GetRectItem<T>();
|
|
|
action(data);
|
|
|
};
|
|
|
var innerData = ctrl.Tag as InnerData;
|
|
|
@@ -560,7 +564,7 @@ public static class MapControlEx
|
|
|
/// </summary>
|
|
|
/// <param name="ctrl"></param>
|
|
|
/// <returns></returns>
|
|
|
- public static IEnumerable<T> GetRectPosItem<T>(this MapControl ctrl) where T : PosData, new()
|
|
|
+ public static IEnumerable<T> GetRectItem<T>(this MapControl ctrl) where T : FlightInfo, new()
|
|
|
{
|
|
|
var innerData = ctrl.Tag as InnerData;
|
|
|
if (innerData.CurrentRect == default) return new List<T>();
|
|
|
@@ -569,7 +573,7 @@ public static class MapControlEx
|
|
|
double startLat = rect.startLat;
|
|
|
double endLon = rect.endLon;
|
|
|
double endLat = rect.endLat;
|
|
|
- var temp = innerData._dataCache.Keys.Where(p => p.InRectangle(startLon, startLat, endLon, endLat));
|
|
|
+ var temp = innerData._flightCache.Where(p => p.InRectangle(startLon, startLat, endLon, endLat));
|
|
|
var res = temp.Select(p => (T)p);
|
|
|
return res;
|
|
|
}
|
|
|
@@ -592,7 +596,7 @@ public static class MapControlEx
|
|
|
return ctrl;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
/// <summary>
|
|
|
/// 为地图添加右键测距功能
|
|
|
@@ -625,21 +629,19 @@ public static class MapControlEx
|
|
|
var innerData = ctrl.Tag as InnerData;
|
|
|
btnFlight.ItemClick += (sender, e) =>
|
|
|
{
|
|
|
- var flights = innerData._flightCache.Keys.ToList();
|
|
|
- var frm = new MapFlightLineView(flights);
|
|
|
+ var flights = innerData._flightCache.GroupBy(m => m.FlightName);
|
|
|
+ var frm = new MapFlightLineView(flights.Select(f => f.Key).ToList());
|
|
|
frm.onClick = (reslut) =>
|
|
|
{
|
|
|
- (bool isOk, string caption, double speed) = reslut;
|
|
|
+ (bool isOk, string fligthName, double speed) = reslut;
|
|
|
|
|
|
ShowPopup?.Invoke((false, frm));
|
|
|
if (!isOk)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
- var filghtInfo = new FlightInfo(caption, speed);
|
|
|
- innerData._flightCache.Add(filghtInfo.FlightName, filghtInfo);
|
|
|
|
|
|
- string filghtName = $"DrawFlightLine{caption}";
|
|
|
+ string filghtName = $"DrawFlightLine_{fligthName}_{speed}";
|
|
|
ctrl.MapEditor.SetEditMode();
|
|
|
var items = innerData.flightStorge.Items.ToArray();
|
|
|
innerData.flightpath = new MapSpline()
|
|
|
@@ -709,10 +711,8 @@ public static class MapControlEx
|
|
|
{
|
|
|
innerData.distinctPath.Points.Clear();
|
|
|
}
|
|
|
- var filghtInfo = new FlightInfo(fligthName, speed);
|
|
|
- innerData._flightCache.Add(filghtInfo.FlightName, filghtInfo);
|
|
|
|
|
|
- string filghtName = $"DrawFlightLine{fligthName}";
|
|
|
+ string filghtName = $"DrawFlightLine_{fligthName}_{speed}";
|
|
|
ctrl.MapEditor.SetEditMode();
|
|
|
innerData.flightpath = new MapSpline()
|
|
|
{
|
|
|
@@ -760,7 +760,7 @@ public static class MapControlEx
|
|
|
public static IEnumerable<T> GetFlightLine<T>(this MapControl ctrl) where T : FlightInfo
|
|
|
{
|
|
|
var innerData = ctrl.Tag as InnerData;
|
|
|
- return innerData._flightCache.Select(m => (T)m.Value);
|
|
|
+ return innerData._flightCache.Select(m => (T)m);
|
|
|
}
|
|
|
|
|
|
private static void AddFlightPoint(object sender, MouseEventArgs e)
|
|
|
@@ -769,14 +769,16 @@ public static class MapControlEx
|
|
|
var ctrl = sender as MapControl;
|
|
|
|
|
|
var location = ctrl.ScreenPointToCoordPoint(e.Location);
|
|
|
- string Name = innerData.flightpath.Tag.ToString().Replace("DrawFlightLine", "");
|
|
|
+ var strs = innerData.flightpath.Tag.ToString().Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
+ string name = strs[1];
|
|
|
+ double speed = Convert.ToDouble(strs[2]);
|
|
|
double lon = Math.Round(location.GetX(), 3);
|
|
|
double lat = Math.Round(location.GetY(), 3);
|
|
|
innerData.hoverPoint = new MapDot()
|
|
|
{
|
|
|
CanResize = false,
|
|
|
CanMove = false,
|
|
|
- ToolTipPattern = $"航迹:{Name}\r\n{lon},{lat}°",
|
|
|
+ ToolTipPattern = $"航迹:{name}\r\n{lon},{lat}°",
|
|
|
Tag = innerData.flightpath.Tag,
|
|
|
Size = 8
|
|
|
};
|
|
|
@@ -784,9 +786,9 @@ public static class MapControlEx
|
|
|
innerData.hoverPoint.Fill = ColorHelper.GetColor(innerData.hoverPoint.Tag.ToString());
|
|
|
innerData.flightStorge.Items.Add(innerData.hoverPoint);
|
|
|
innerData.flightpath.Points.Add(innerData.hoverPoint.Location);
|
|
|
- if (!innerData._flightCache[Name].flights.Any(m => m.FlightLon == lon && m.FlightLat == lat))
|
|
|
+ if (!innerData._flightCache.Any(m => m.FlightLon == lon && m.FlightName == name && m.Speed == speed && m.FlightLat == lat))
|
|
|
{
|
|
|
- innerData._flightCache[Name].flights.Add(new FlightData(lon, lat));
|
|
|
+ innerData._flightCache.Add(new FlightInfo(name, speed, lon, lat));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -805,19 +807,20 @@ public static class MapControlEx
|
|
|
ctrl.Refresh();
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
- for (int i = 0; i < items.Count(); i++)
|
|
|
+ var group = items.GroupBy(m => m.FlightName);
|
|
|
+ foreach (var item in group)
|
|
|
{
|
|
|
- var f = items.ElementAt(i);
|
|
|
+ var f = item.ToList();
|
|
|
ctrl.ShowFlightLine(innerData, f);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
- private static void ShowFlightLine(this MapControl ctrl, InnerData innerData, FlightInfo flight)
|
|
|
+ private static void ShowFlightLine<T>(this MapControl ctrl, InnerData innerData, List<T> points) where T : FlightInfo, new()
|
|
|
{
|
|
|
- string filghtName = $"DrawFlightLine{flight.FlightName}";
|
|
|
+ var first = points.First();
|
|
|
+ string filghtName = $"DrawFlightLine_{first.FlightName}_{first.Speed}";
|
|
|
var flightpath = new MapSpline()
|
|
|
{
|
|
|
Stroke = Color.FromArgb(127, 255, 0, 199),
|
|
|
@@ -834,14 +837,15 @@ public static class MapControlEx
|
|
|
var hoverPoint = new MapDot() { CanResize = false, CanMove = false, Tag = filghtName, Size = 8 };
|
|
|
hoverPoint.Fill = ColorHelper.GetColor(hoverPoint.Tag.ToString());
|
|
|
innerData.flightStorge.Items.Add(hoverPoint);
|
|
|
- if (flight.flights.Count > 0)
|
|
|
+ if (points.Count > 0)
|
|
|
{
|
|
|
- var center = new GeoPoint(flight.flights.First().FlightLat, flight.flights.First().FlightLon);
|
|
|
+
|
|
|
+ var center = new GeoPoint(first.FlightLat, first.FlightLon);
|
|
|
ctrl.SetCenterPoint(center, true);
|
|
|
}
|
|
|
Task.Run(() =>
|
|
|
{
|
|
|
- flight.flights.ForEach((finfo) =>
|
|
|
+ points.ForEach((finfo) =>
|
|
|
{
|
|
|
var location = new GeoPoint(finfo.FlightLat, finfo.FlightLon);
|
|
|
|
|
|
@@ -849,7 +853,7 @@ public static class MapControlEx
|
|
|
{
|
|
|
CanResize = false,
|
|
|
CanMove = false,
|
|
|
- ToolTipPattern = $"航迹:{flight.FlightName}\r\n{finfo.FlightLon},{finfo.FlightLat}°",
|
|
|
+ ToolTipPattern = $"航迹:{finfo.FlightName}\r\n{finfo.FlightLon},{finfo.FlightLat}°",
|
|
|
Tag = flightpath.Tag,
|
|
|
Size = 8
|
|
|
};
|
|
|
@@ -861,7 +865,7 @@ public static class MapControlEx
|
|
|
});
|
|
|
|
|
|
});
|
|
|
- innerData._flightCache.Add(flight.FlightName, flight);
|
|
|
+ innerData._flightCache.AddRange(points);
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -874,15 +878,7 @@ public static class MapControlEx
|
|
|
btnExportFlightLine.ItemClick += (sender, e) =>
|
|
|
{
|
|
|
if (!innerData._flightCache.Any()) return;
|
|
|
- List<FightDataCsv> list = new List<FightDataCsv>();
|
|
|
- foreach (var item in innerData._flightCache.Values)
|
|
|
- {
|
|
|
- foreach (var fitem in item.flights)
|
|
|
- {
|
|
|
- list.Add(new FightDataCsv(item.FlightName, item.Speed, fitem.FlightLon, fitem.FlightLat));
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
+ List<FlightInfo> list = innerData._flightCache;
|
|
|
Dictionary<string, string> cellFormats = new Dictionary<string, string>();//单元格的format
|
|
|
var props = list.First().GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
|
|
|
List<(int ColumnIndex, PropertyInfo Prop, string Header)> listPorps = new List<(int, PropertyInfo, string)>();
|
|
|
@@ -1383,7 +1379,7 @@ public static class MapControlEx
|
|
|
if (recCallback)
|
|
|
innerData.mOnRectChanged?.Invoke(ctrl.GetCurrentRect());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static void ClearRect(this MapControl ctrl)
|
|
|
{
|
|
|
var innerDate = ctrl.Tag as InnerData;
|