|
@@ -24,6 +24,7 @@ using System.Linq;
|
|
|
using System.Reflection;
|
|
|
using System.Text;
|
|
|
using System.Threading;
|
|
|
+using System.Threading.Tasks;
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
public enum GoogleMapType
|
|
@@ -899,10 +900,10 @@ public static class MapControlEx
|
|
|
/// </summary>
|
|
|
/// <param name="ctrl"></param>
|
|
|
/// <returns></returns>
|
|
|
- public static IEnumerable<FlightInfo> GetFlightLine(this MapControl ctrl)
|
|
|
+ public static IEnumerable<T> GetFlightLine<T>(this MapControl ctrl) where T : FlightInfo
|
|
|
{
|
|
|
var innerData = ctrl.Tag as InnerData;
|
|
|
- return innerData._flightCache.Select(m => m.Value);
|
|
|
+ return innerData._flightCache.Select(m => (T)m.Value);
|
|
|
}
|
|
|
|
|
|
private static void AddFlightPoint(object sender, MouseEventArgs e)
|
|
@@ -926,10 +927,78 @@ public static class MapControlEx
|
|
|
innerData.hoverPoint.Fill = ColorHelper.GetColor(innerData.hoverPoint.Tag.ToString());
|
|
|
innerData.mMapStorage.Items.Add(innerData.hoverPoint);
|
|
|
innerData.flightpath.Points.Add(innerData.hoverPoint.Location);
|
|
|
- if (!innerData._flightCache[Name].flights.Any(m => m.FlightLon == lon && m.FlightLat == lat))
|
|
|
+ innerData._flightCache[Name].flights.Add(new FlightData(lon, lat));
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void SetFlightLine<T>(this MapControl ctrl, IEnumerable<T> items, bool clearDrawLayer = true) where T : FlightInfo, new()
|
|
|
+ {
|
|
|
+ var innerData = ctrl.Tag as InnerData;
|
|
|
+ innerData._flightCache.Clear();
|
|
|
+ if (clearDrawLayer)
|
|
|
+ ctrl.ClearDrawObj();
|
|
|
+ if (items == null || !items.Any())
|
|
|
{
|
|
|
- innerData._flightCache[Name].flights.Add(new FlightData(lon, lat));
|
|
|
+ ctrl.Refresh();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int i = 0; i < items.Count(); i++)
|
|
|
+ {
|
|
|
+ var f = items.ElementAt(i);
|
|
|
+ ctrl.ShowFlightLine(innerData, f);
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ private static void ShowFlightLine(this MapControl ctrl, InnerData innerData, FlightInfo flight)
|
|
|
+ {
|
|
|
+ string filghtName = $"DrawFlightLine{flight.FlightName}";
|
|
|
+ var flightpath = new MapSpline()
|
|
|
+ {
|
|
|
+ Stroke = Color.FromArgb(127, 255, 0, 199),
|
|
|
+ StrokeWidth = 2,
|
|
|
+ CanResize = true,
|
|
|
+ CanEdit = true,
|
|
|
+ CanRotate = true,
|
|
|
+ IsHitTestVisible = false,
|
|
|
+ CanMove = true,
|
|
|
+ Tag = filghtName
|
|
|
+
|
|
|
+ };
|
|
|
+ innerData.mMapStorage.Items.Add(flightpath);
|
|
|
+ var hoverPoint = new MapDot() { CanResize = false, CanMove = false, Tag = filghtName, Size = 8 };
|
|
|
+ hoverPoint.Fill = ColorHelper.GetColor(hoverPoint.Tag.ToString());
|
|
|
+ innerData.mMapStorage.Items.Add(hoverPoint);
|
|
|
+ if (flight.flights.Count > 0)
|
|
|
+ {
|
|
|
+ var center = new GeoPoint(flight.flights.First().FlightLat, flight.flights.First().FlightLon);
|
|
|
+ ctrl.SetCenterPoint(center, true);
|
|
|
+ }
|
|
|
+ Task.Run(() =>
|
|
|
+ {
|
|
|
+ flight.flights.ForEach((finfo) =>
|
|
|
+ {
|
|
|
+ var location = new GeoPoint(finfo.FlightLat, finfo.FlightLon);
|
|
|
+
|
|
|
+ var hoverPointj = new MapDot()
|
|
|
+ {
|
|
|
+ CanResize = false,
|
|
|
+ CanMove = false,
|
|
|
+ ToolTipPattern = $"航迹:{flight.FlightName}\r\n{finfo.FlightLon},{finfo.FlightLat}°",
|
|
|
+ Tag = flightpath.Tag,
|
|
|
+ Size = 8
|
|
|
+ };
|
|
|
+ hoverPointj.Location = location;
|
|
|
+ hoverPointj.Fill = ColorHelper.GetColor(hoverPointj.Tag.ToString());
|
|
|
+ innerData.mMapStorage.Items.Add(hoverPointj);
|
|
|
+ flightpath.Points.Add(hoverPointj.Location);
|
|
|
+ Thread.Sleep(1000);
|
|
|
+ });
|
|
|
+
|
|
|
+ });
|
|
|
+ innerData._flightCache.Add(flight.FlightName, flight);
|
|
|
+
|
|
|
}
|
|
|
#endregion
|
|
|
/// <summary>
|