gongqiuhong 1 سال پیش
والد
کامیت
77342622d7

+ 1 - 1
DataSimulation.Forms/DataSimulation.Forms.csproj

@@ -203,6 +203,7 @@
     <Compile Include="MainForm.Designer.cs">
       <DependentUpon>MainForm.cs</DependentUpon>
     </Compile>
+    <Compile Include="Model\FlightImportInfo.cs" />
     <Compile Include="Program.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="UserControl\CtrlHistoryTask.cs">
@@ -268,7 +269,6 @@
     <EmbeddedResource Include="MainForm.resx">
       <DependentUpon>MainForm.cs</DependentUpon>
     </EmbeddedResource>
-    <EmbeddedResource Include="Properties\licenses.licx" />
     <EmbeddedResource Include="Properties\Resources.resx">
       <Generator>ResXFileCodeGenerator</Generator>
       <LastGenOutput>Resources.Designer.cs</LastGenOutput>

+ 16 - 5
DataSimulation.Forms/EditForms/FlightEditor.cs

@@ -4,6 +4,7 @@ using DataSimulation.Repostory.Model;
 using DevExpress.Utils.About;
 using DevExpress.XtraEditors.Controls;
 using DevExpress.XtraEditors.DXErrorProvider;
+using DevExpress.XtraMap;
 using DxHelper;
 using ExtensionsDev;
 using System;
@@ -49,7 +50,11 @@ namespace DataSimulation.Forms.EditForms
            .UseExportXlsx()
            .UseExportCsv()
            .UseExportFlightLine()
-           .SetMapLayerType(null);
+           .SetMapLayerType(null)
+           .UseDrawRect(rect =>
+              {
+                  (double startLon, double startLat, double centerLon, double centerLat, double endLon, double endLat, double lonRange, double latRange) = rect;
+              });
             txtFlightName.EditValueChanged += TxtFlightName_EditValueChanged;
             txtSpeed.EditValueChanged += TxtSpeed_EditValueChanged;
 
@@ -58,9 +63,15 @@ namespace DataSimulation.Forms.EditForms
                 this.txtFlightName.Text = info.SimulationName;
                 this.txtSpeed.Text = $"{info.SimulationSpeed}";
                 var points = await SimulationCache.GetAllByIDAsync(info.ID, info.CreateTime);
-                var flinfo = new FlightInfo(info.SimulationName, info.SimulationSpeed);
-                points.ForEach(m => flinfo.flights.Add(new FlightData(m.SimulationLon, m.SimulationLat)));
-                mapControl.SetFlightLine(new FlightInfo[1] { flinfo });
+                List<FlightInfo> flights = new List<FlightInfo>();
+                points.ForEach(m => flights.Add(new FlightInfo(info.SimulationName, info.SimulationSpeed, m.SimulationLon, m.SimulationLat)));
+                mapControl.SetFlightLine(flights);
+                mapControl.AddRectMenu<FlightInfo>("删除航迹点", SvgHelper.CreateClose(), items =>
+                {
+                    var flightInfos = mapControl.GetRectItem<FlightInfo>();
+                    mapControl.DelFlightItem(flightInfos);
+
+                });
                 layoutControlItem12.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                 layoutControlItem2.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
             }
@@ -146,7 +157,7 @@ namespace DataSimulation.Forms.EditForms
                     var sinfo = db.SimulationInfos.Add(info);
 
                     await db.SaveChangesAsync();
-                    var points = fligth.flights.Select(f => new SimulationPonit()
+                    var points = fligths.Select(f => new SimulationPonit()
                     {
                         SimulationId = sinfo.ID,
                         SimulationLon = f.FlightLon,

+ 53 - 124
DataSimulation.Forms/EditForms/FlightImport.Designer.cs

@@ -29,56 +29,41 @@
         private void InitializeComponent()
         {
             this.components = new System.ComponentModel.Container();
-            DevExpress.XtraEditors.Controls.EditorButtonImageOptions editorButtonImageOptions1 = new DevExpress.XtraEditors.Controls.EditorButtonImageOptions();
-            DevExpress.Utils.SerializableAppearanceObject serializableAppearanceObject1 = new DevExpress.Utils.SerializableAppearanceObject();
-            DevExpress.Utils.SerializableAppearanceObject serializableAppearanceObject2 = new DevExpress.Utils.SerializableAppearanceObject();
-            DevExpress.Utils.SerializableAppearanceObject serializableAppearanceObject3 = new DevExpress.Utils.SerializableAppearanceObject();
-            DevExpress.Utils.SerializableAppearanceObject serializableAppearanceObject4 = new DevExpress.Utils.SerializableAppearanceObject();
             this.layoutControl1 = new DevExpress.XtraLayout.LayoutControl();
-            this.cbAll = new DevExpress.XtraEditors.ComboBoxEdit();
             this.btnImport = new DevExpress.XtraEditors.SimpleButton();
             this.mapControl = new DevExpress.XtraMap.MapControl();
             this.btnSave = new DevExpress.XtraEditors.SimpleButton();
-            this.txtSpeed = new DevExpress.XtraEditors.ButtonEdit();
-            this.txtFlightName = new DevExpress.XtraEditors.TextEdit();
             this.Root = new DevExpress.XtraLayout.LayoutControlGroup();
-            this.layoutControlItem1 = new DevExpress.XtraLayout.LayoutControlItem();
             this.layoutControlItem13 = new DevExpress.XtraLayout.LayoutControlItem();
-            this.layoutControlItem10 = new DevExpress.XtraLayout.LayoutControlItem();
             this.splitterItem1 = new DevExpress.XtraLayout.SplitterItem();
             this.emptySpaceItem1 = new DevExpress.XtraLayout.EmptySpaceItem();
-            this.emptySpaceItem2 = new DevExpress.XtraLayout.EmptySpaceItem();
             this.layoutControlItem12 = new DevExpress.XtraLayout.LayoutControlItem();
             this.layoutControlItem2 = new DevExpress.XtraLayout.LayoutControlItem();
-            this.所有航迹 = new DevExpress.XtraLayout.LayoutControlItem();
             this.dxErrorProvider = new DevExpress.XtraEditors.DXErrorProvider.DXErrorProvider(this.components);
+            this.gridImprot = new DevExpress.XtraGrid.GridControl();
+            this.gridView1 = new DevExpress.XtraGrid.Views.Grid.GridView();
+            this.layoutControlItem1 = new DevExpress.XtraLayout.LayoutControlItem();
             ((System.ComponentModel.ISupportInitialize)(this.layoutControl1)).BeginInit();
             this.layoutControl1.SuspendLayout();
-            ((System.ComponentModel.ISupportInitialize)(this.cbAll.Properties)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.mapControl)).BeginInit();
-            ((System.ComponentModel.ISupportInitialize)(this.txtSpeed.Properties)).BeginInit();
-            ((System.ComponentModel.ISupportInitialize)(this.txtFlightName.Properties)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.Root)).BeginInit();
-            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem1)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem13)).BeginInit();
-            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem10)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.splitterItem1)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem1)).BeginInit();
-            ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem2)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem12)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem2)).BeginInit();
-            ((System.ComponentModel.ISupportInitialize)(this.所有航迹)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.dxErrorProvider)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.gridImprot)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.gridView1)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem1)).BeginInit();
             this.SuspendLayout();
             // 
             // layoutControl1
             // 
-            this.layoutControl1.Controls.Add(this.cbAll);
+            this.layoutControl1.Controls.Add(this.gridImprot);
             this.layoutControl1.Controls.Add(this.btnImport);
             this.layoutControl1.Controls.Add(this.mapControl);
             this.layoutControl1.Controls.Add(this.btnSave);
-            this.layoutControl1.Controls.Add(this.txtSpeed);
-            this.layoutControl1.Controls.Add(this.txtFlightName);
             this.layoutControl1.Dock = System.Windows.Forms.DockStyle.Fill;
             this.layoutControl1.Location = new System.Drawing.Point(0, 0);
             this.layoutControl1.Name = "layoutControl1";
@@ -87,22 +72,11 @@
             this.layoutControl1.TabIndex = 0;
             this.layoutControl1.Text = "layoutControl1";
             // 
-            // cbAll
-            // 
-            this.cbAll.Location = new System.Drawing.Point(12, 29);
-            this.cbAll.Name = "cbAll";
-            this.cbAll.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
-            new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
-            this.cbAll.Size = new System.Drawing.Size(278, 20);
-            this.cbAll.StyleController = this.layoutControl1;
-            this.cbAll.TabIndex = 18;
-            this.cbAll.SelectedValueChanged += new System.EventHandler(this.cbAll_SelectedValueChanged);
-            // 
             // btnImport
             // 
-            this.btnImport.Location = new System.Drawing.Point(154, 475);
+            this.btnImport.Location = new System.Drawing.Point(217, 475);
             this.btnImport.Name = "btnImport";
-            this.btnImport.Size = new System.Drawing.Size(60, 22);
+            this.btnImport.Size = new System.Drawing.Size(72, 22);
             this.btnImport.StyleController = this.layoutControl1;
             this.btnImport.TabIndex = 17;
             this.btnImport.Text = "导入航迹";
@@ -110,14 +84,14 @@
             // 
             // mapControl
             // 
-            this.mapControl.Location = new System.Drawing.Point(304, 12);
+            this.mapControl.Location = new System.Drawing.Point(379, 12);
             this.mapControl.Name = "mapControl";
-            this.mapControl.Size = new System.Drawing.Size(873, 485);
+            this.mapControl.Size = new System.Drawing.Size(798, 485);
             this.mapControl.TabIndex = 16;
             // 
             // btnSave
             // 
-            this.btnSave.Location = new System.Drawing.Point(218, 475);
+            this.btnSave.Location = new System.Drawing.Point(293, 475);
             this.btnSave.Name = "btnSave";
             this.btnSave.Size = new System.Drawing.Size(72, 22);
             this.btnSave.StyleController = this.layoutControl1;
@@ -125,81 +99,34 @@
             this.btnSave.Text = "保存";
             this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
             // 
-            // txtSpeed
-            // 
-            this.txtSpeed.Location = new System.Drawing.Point(12, 111);
-            this.txtSpeed.MaximumSize = new System.Drawing.Size(0, 20);
-            this.txtSpeed.MinimumSize = new System.Drawing.Size(0, 20);
-            this.txtSpeed.Name = "txtSpeed";
-            this.txtSpeed.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
-            new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Glyph, "m/s", -1, false, true, false, editorButtonImageOptions1, new DevExpress.Utils.KeyShortcut(System.Windows.Forms.Keys.None), serializableAppearanceObject1, serializableAppearanceObject2, serializableAppearanceObject3, serializableAppearanceObject4, "", null, null, DevExpress.Utils.ToolTipAnchor.Default)});
-            this.txtSpeed.Properties.MaskSettings.Set("MaskManagerType", typeof(DevExpress.Data.Mask.NumericMaskManager));
-            this.txtSpeed.Properties.MaskSettings.Set("mask", "f3");
-            this.txtSpeed.Properties.MaxLength = 10;
-            this.txtSpeed.Size = new System.Drawing.Size(278, 20);
-            this.txtSpeed.StyleController = this.layoutControl1;
-            this.txtSpeed.TabIndex = 13;
-            // 
-            // txtFlightName
-            // 
-            this.txtFlightName.Location = new System.Drawing.Point(12, 70);
-            this.txtFlightName.Name = "txtFlightName";
-            this.txtFlightName.Properties.MaxLength = 12;
-            this.txtFlightName.Size = new System.Drawing.Size(278, 20);
-            this.txtFlightName.StyleController = this.layoutControl1;
-            this.txtFlightName.TabIndex = 4;
-            // 
             // Root
             // 
             this.Root.EnableIndentsWithoutBorders = DevExpress.Utils.DefaultBoolean.True;
             this.Root.GroupBordersVisible = false;
             this.Root.Items.AddRange(new DevExpress.XtraLayout.BaseLayoutItem[] {
-            this.layoutControlItem1,
             this.layoutControlItem13,
-            this.layoutControlItem10,
             this.splitterItem1,
             this.emptySpaceItem1,
-            this.emptySpaceItem2,
             this.layoutControlItem12,
             this.layoutControlItem2,
-            this.所有航迹});
+            this.layoutControlItem1});
             this.Root.Name = "Root";
             this.Root.Size = new System.Drawing.Size(1189, 509);
             this.Root.TextVisible = false;
             // 
-            // layoutControlItem1
-            // 
-            this.layoutControlItem1.Control = this.txtFlightName;
-            this.layoutControlItem1.Location = new System.Drawing.Point(0, 41);
-            this.layoutControlItem1.Name = "layoutControlItem1";
-            this.layoutControlItem1.Size = new System.Drawing.Size(282, 41);
-            this.layoutControlItem1.Text = "航迹名称";
-            this.layoutControlItem1.TextLocation = DevExpress.Utils.Locations.Top;
-            this.layoutControlItem1.TextSize = new System.Drawing.Size(48, 14);
-            // 
             // layoutControlItem13
             // 
             this.layoutControlItem13.Control = this.mapControl;
-            this.layoutControlItem13.Location = new System.Drawing.Point(292, 0);
+            this.layoutControlItem13.Location = new System.Drawing.Point(367, 0);
             this.layoutControlItem13.Name = "layoutControlItem13";
-            this.layoutControlItem13.Size = new System.Drawing.Size(877, 489);
+            this.layoutControlItem13.Size = new System.Drawing.Size(802, 489);
             this.layoutControlItem13.TextSize = new System.Drawing.Size(0, 0);
             this.layoutControlItem13.TextVisible = false;
             // 
-            // layoutControlItem10
-            // 
-            this.layoutControlItem10.Control = this.txtSpeed;
-            this.layoutControlItem10.Location = new System.Drawing.Point(0, 82);
-            this.layoutControlItem10.Name = "layoutControlItem10";
-            this.layoutControlItem10.Size = new System.Drawing.Size(282, 44);
-            this.layoutControlItem10.Text = "速度";
-            this.layoutControlItem10.TextLocation = DevExpress.Utils.Locations.Top;
-            this.layoutControlItem10.TextSize = new System.Drawing.Size(48, 14);
-            // 
             // splitterItem1
             // 
             this.splitterItem1.AllowHotTrack = true;
-            this.splitterItem1.Location = new System.Drawing.Point(282, 0);
+            this.splitterItem1.Location = new System.Drawing.Point(357, 0);
             this.splitterItem1.Name = "splitterItem1";
             this.splitterItem1.Size = new System.Drawing.Size(10, 489);
             // 
@@ -208,21 +135,13 @@
             this.emptySpaceItem1.AllowHotTrack = false;
             this.emptySpaceItem1.Location = new System.Drawing.Point(0, 463);
             this.emptySpaceItem1.Name = "emptySpaceItem1";
-            this.emptySpaceItem1.Size = new System.Drawing.Size(142, 26);
+            this.emptySpaceItem1.Size = new System.Drawing.Size(205, 26);
             this.emptySpaceItem1.TextSize = new System.Drawing.Size(0, 0);
             // 
-            // emptySpaceItem2
-            // 
-            this.emptySpaceItem2.AllowHotTrack = false;
-            this.emptySpaceItem2.Location = new System.Drawing.Point(0, 126);
-            this.emptySpaceItem2.Name = "emptySpaceItem2";
-            this.emptySpaceItem2.Size = new System.Drawing.Size(282, 337);
-            this.emptySpaceItem2.TextSize = new System.Drawing.Size(0, 0);
-            // 
             // layoutControlItem12
             // 
             this.layoutControlItem12.Control = this.btnSave;
-            this.layoutControlItem12.Location = new System.Drawing.Point(206, 463);
+            this.layoutControlItem12.Location = new System.Drawing.Point(281, 463);
             this.layoutControlItem12.MaxSize = new System.Drawing.Size(76, 26);
             this.layoutControlItem12.MinSize = new System.Drawing.Size(76, 26);
             this.layoutControlItem12.Name = "layoutControlItem12";
@@ -234,25 +153,43 @@
             // layoutControlItem2
             // 
             this.layoutControlItem2.Control = this.btnImport;
-            this.layoutControlItem2.Location = new System.Drawing.Point(142, 463);
+            this.layoutControlItem2.Location = new System.Drawing.Point(205, 463);
+            this.layoutControlItem2.MaxSize = new System.Drawing.Size(76, 26);
+            this.layoutControlItem2.MinSize = new System.Drawing.Size(76, 26);
             this.layoutControlItem2.Name = "layoutControlItem2";
-            this.layoutControlItem2.Size = new System.Drawing.Size(64, 26);
+            this.layoutControlItem2.Size = new System.Drawing.Size(76, 26);
+            this.layoutControlItem2.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom;
             this.layoutControlItem2.TextSize = new System.Drawing.Size(0, 0);
             this.layoutControlItem2.TextVisible = false;
             // 
-            // 所有航迹
-            // 
-            this.所有航迹.Control = this.cbAll;
-            this.所有航迹.Location = new System.Drawing.Point(0, 0);
-            this.所有航迹.Name = "所有航迹";
-            this.所有航迹.Size = new System.Drawing.Size(282, 41);
-            this.所有航迹.TextLocation = DevExpress.Utils.Locations.Top;
-            this.所有航迹.TextSize = new System.Drawing.Size(48, 14);
-            // 
             // dxErrorProvider
             // 
             this.dxErrorProvider.ContainerControl = this;
             // 
+            // gridImprot
+            // 
+            this.gridImprot.Location = new System.Drawing.Point(12, 12);
+            this.gridImprot.MainView = this.gridView1;
+            this.gridImprot.Name = "gridImprot";
+            this.gridImprot.Size = new System.Drawing.Size(353, 459);
+            this.gridImprot.TabIndex = 18;
+            this.gridImprot.ViewCollection.AddRange(new DevExpress.XtraGrid.Views.Base.BaseView[] {
+            this.gridView1});
+            // 
+            // gridView1
+            // 
+            this.gridView1.GridControl = this.gridImprot;
+            this.gridView1.Name = "gridView1";
+            // 
+            // layoutControlItem1
+            // 
+            this.layoutControlItem1.Control = this.gridImprot;
+            this.layoutControlItem1.Location = new System.Drawing.Point(0, 0);
+            this.layoutControlItem1.Name = "layoutControlItem1";
+            this.layoutControlItem1.Size = new System.Drawing.Size(357, 463);
+            this.layoutControlItem1.TextSize = new System.Drawing.Size(0, 0);
+            this.layoutControlItem1.TextVisible = false;
+            // 
             // FlightImport
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F);
@@ -265,21 +202,17 @@
             this.Load += new System.EventHandler(this.Editor_Load);
             ((System.ComponentModel.ISupportInitialize)(this.layoutControl1)).EndInit();
             this.layoutControl1.ResumeLayout(false);
-            ((System.ComponentModel.ISupportInitialize)(this.cbAll.Properties)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.mapControl)).EndInit();
-            ((System.ComponentModel.ISupportInitialize)(this.txtSpeed.Properties)).EndInit();
-            ((System.ComponentModel.ISupportInitialize)(this.txtFlightName.Properties)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.Root)).EndInit();
-            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem1)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem13)).EndInit();
-            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem10)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.splitterItem1)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem1)).EndInit();
-            ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem2)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem12)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem2)).EndInit();
-            ((System.ComponentModel.ISupportInitialize)(this.所有航迹)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.dxErrorProvider)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.gridImprot)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.gridView1)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem1)).EndInit();
             this.ResumeLayout(false);
 
         }
@@ -288,13 +221,8 @@
 
         private DevExpress.XtraLayout.LayoutControl layoutControl1;
         private DevExpress.XtraLayout.LayoutControlGroup Root;
-        private DevExpress.XtraEditors.TextEdit txtFlightName;
-        private DevExpress.XtraLayout.LayoutControlItem layoutControlItem1;
-        private DevExpress.XtraEditors.ButtonEdit txtSpeed;
-        private DevExpress.XtraLayout.LayoutControlItem layoutControlItem10;
         private DevExpress.XtraEditors.SimpleButton btnSave;
         private DevExpress.XtraLayout.LayoutControlItem layoutControlItem12;
-        private DevExpress.XtraLayout.EmptySpaceItem emptySpaceItem2;
         private DevExpress.XtraEditors.DXErrorProvider.DXErrorProvider dxErrorProvider;
         private DevExpress.XtraMap.MapControl mapControl;
         private DevExpress.XtraLayout.LayoutControlItem layoutControlItem13;
@@ -302,7 +230,8 @@
         private DevExpress.XtraLayout.EmptySpaceItem emptySpaceItem1;
         private DevExpress.XtraEditors.SimpleButton btnImport;
         private DevExpress.XtraLayout.LayoutControlItem layoutControlItem2;
-        private DevExpress.XtraEditors.ComboBoxEdit cbAll;
-        private DevExpress.XtraLayout.LayoutControlItem 所有航迹;
+        private DevExpress.XtraGrid.GridControl gridImprot;
+        private DevExpress.XtraGrid.Views.Grid.GridView gridView1;
+        private DevExpress.XtraLayout.LayoutControlItem layoutControlItem1;
     }
 }

+ 52 - 53
DataSimulation.Forms/EditForms/FlightImport.cs

@@ -1,13 +1,17 @@
-using DataSimulation.Repostory;
+using DataSimulation.Forms.Model;
+using DataSimulation.Repostory;
 using DataSimulation.Repostory.EFContext;
 using DataSimulation.Repostory.Model;
 using DevExpress.Utils.About;
+using DevExpress.Utils.Extensions;
 using DevExpress.XtraEditors;
 using DevExpress.XtraEditors.Controls;
 using DevExpress.XtraEditors.DXErrorProvider;
+using DevExpress.XtraGrid.Views.Grid;
 using DxHelper;
 using ExtensionsDev;
 using System;
+using System.Collections;
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.Data;
@@ -19,6 +23,7 @@ using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 using System.Windows.Forms;
+using System.Xml.Linq;
 
 namespace DataSimulation.Forms.EditForms
 {
@@ -26,11 +31,11 @@ namespace DataSimulation.Forms.EditForms
     {
         public List<SimulationInfo> Addinfo;
         private List<SimulationInfo> simulationInfos;
-        private List<FlightInfo> flightInfos;
+        private List<FlightImportInfo> flightInfos = new List<FlightImportInfo>();
         public FlightImport(List<SimulationInfo> simulationInfos)
         {
             InitializeComponent();
-            this.Text = "导入航迹";
+            this.Text = "航迹导入";
             this.simulationInfos = simulationInfos;
             this.StartPosition = FormStartPosition.CenterParent;
         }
@@ -46,19 +51,38 @@ namespace DataSimulation.Forms.EditForms
            .UseExportXlsx()
            .UseExportCsv()
            .UseExportFlightLine()
-           .SetMapLayerType(null);
+           .SetMapLayerType(null)
+             .UseDrawRect(rect =>
+              {
+                  (double startLon, double startLat, double centerLon, double centerLat, double endLon, double endLat, double lonRange, double latRange) = rect;
+              });
+            gridView1.SelectionChanged += GridView1_SelectionChanged;
+            gridImprot.Init<FlightImportInfo>().UseSort().UseFilter().UseMultiSelect().UseRowNumber();
+            gridView1.OptionsSelection.MultiSelectMode = GridMultiSelectMode.CheckBoxRowSelect;
+            gridImprot.DataSource = flightInfos;
+            gridView1.RefreshData();
         }
 
+        private void GridView1_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e)
+        {
+            var ids = gridView1.GetSelectedRows();
+            List<FlightImportInfo> selects = new List<FlightImportInfo>();
+            foreach (var id in ids)
+            {
+                var item = gridView1.GetRow(id) as FlightImportInfo;
+                selects.Add(item);
+            }
+            mapControl.SetFlightLine(selects.SelectMany(m => m.flights));
+        }
 
         private async void btnSave_Click(object sender, EventArgs e)
         {
             try
             {
                 var fligths = mapControl.GetFlightLine<FlightInfo>();
-               
+                var group = fligths.GroupBy(m => new { m.FlightName, m.Speed });
                 Addinfo = new List<SimulationInfo>();
-
-                var sims = fligths.Select(f => new SimulationInfo() { SimulationName = f.FlightName, SimulationSpeed = f.Speed });
+                var sims = group.Select(f => new SimulationInfo() { SimulationName = f.Key.FlightName, SimulationSpeed = f.Key.Speed });
                 Addinfo.AddRange(sims);
 
                 using (SimulationPartContext db = SimulationPartContext.GetContext(sims.First().CreateTime))
@@ -69,8 +93,8 @@ namespace DataSimulation.Forms.EditForms
                     List<SimulationPonit> ponits = new List<SimulationPonit>();
                     foreach (var sinfo in sinfos)
                     {
-                        var flight = fligths.FirstOrDefault(s => s.FlightName == sinfo.SimulationName);
-                        var fpoints = flight.flights.Select(f => new SimulationPonit()
+                        var flight = group.First(m => m.Key.FlightName == sinfo.SimulationName).ToList();
+                        var fpoints = flight.Select(f => new SimulationPonit()
                         {
                             SimulationId = sinfo.ID,
                             SimulationLon = f.FlightLon,
@@ -96,11 +120,10 @@ namespace DataSimulation.Forms.EditForms
         private List<FlightInfo> AnalysisFlight(string filePath)
         {
 
-            List<FlightInfo> flightInfos = new List<FlightInfo>();
+            List<FlightInfo> fights = new List<FlightInfo>();
             try
             {
 
-                List<FightDataCsv> fights = new List<FightDataCsv>();
                 var allLines = File.ReadAllLines(filePath);
                 int count = 0;
                 foreach (var item in allLines)
@@ -112,28 +135,19 @@ namespace DataSimulation.Forms.EditForms
                     {
                         throw new Exception("格式错误");
                     }
-                    FightDataCsv fight = new FightDataCsv();
+                    FlightInfo fight = new FlightInfo();
                     int i = 0;
                     fight.FlightName = strs[i++];
+                    if (simulationInfos.Any(m => m.SimulationName == fight.FlightName))
+                    {
+                        fight.FlightName = $"{fight.FlightName}{DateTime.Now:yyyyMMddHHmmss}";
+                    }
                     fight.Speed = Convert.ToDouble(strs[i++]);
                     fight.FlightLon = Convert.ToDouble(strs[i++]);
                     fight.FlightLat = Convert.ToDouble(strs[i++]);
                     fights.Add(fight);
                 }
-                var groupfilghts = fights.GroupBy(f => f.FlightName);
-                foreach (var flight in groupfilghts)
-                {
-                    string name = flight.Key;
-                    if (simulationInfos.Any(m => m.SimulationName == name))
-                    {
-                        name = $"{name}{DateTime.Now:yyyyMMddHHmmss}";
-                    }
-                    double speed = flight.First().Speed;
-                    var fligths = flight.Select(f => new FlightData(f.FlightLon, f.FlightLat)).ToList();
-                    FlightInfo flightInfo = new FlightInfo(name, speed);
-                    flightInfo.flights.AddRange(fligths);
-                    flightInfos.Add(flightInfo);
-                }
+
             }
             catch (Exception ex)
             {
@@ -141,47 +155,32 @@ namespace DataSimulation.Forms.EditForms
                 DxHelper.MsgBoxHelper.ShowError($"导入航迹解析异常:{ex.Message}");
             }
 
-            return flightInfos;
+            return fights;
 
         }
 
         private void btnFlight_Click(object sender, EventArgs e)
         {
-            flightInfos = new List<FlightInfo>();
+            flightInfos.Clear();
             XtraOpenFileDialog xtraOpenFileDialog1 = new XtraOpenFileDialog();
             xtraOpenFileDialog1.Multiselect = false;
             xtraOpenFileDialog1.Filter = "CSV文件|*.csv";
             if (xtraOpenFileDialog1.ShowDialog() == DialogResult.OK)
             {
                 string filePath = xtraOpenFileDialog1.FileName;
-                flightInfos = AnalysisFlight(filePath);
-            }
-            try
-            {
-                cbAll.Properties.Items.AddRange(flightInfos.Select(m => m.FlightName).ToList());
-                if (flightInfos.Count > 0)
+                var ff = AnalysisFlight(filePath);
+
+                var group = ff.GroupBy(m => new { m.FlightName, m.Speed });
+                foreach (var item in group)
                 {
-                    cbAll.SelectedIndex = 0;
-                    mapControl.SetFlightLine(flightInfos);
+                    var fi = new FlightImportInfo(item.Key.FlightName, item.Key.Speed);
+                    fi.flights.AddRange(item.ToList());
+                    flightInfos.Add(fi);
                 }
             }
-            catch (Exception ex)
-            {
-                Serilog.Log.Error(ex, $"导入航迹异常:{ex.Message}");
-                DxHelper.MsgBoxHelper.ShowError($"导入航迹异常:{ex.Message}");
-            }
-
-        }
-
-        private void cbAll_SelectedValueChanged(object sender, EventArgs e)
-        {
-            if (flightInfos != null && flightInfos.Count > 0)
-            {
-                var name = cbAll.SelectedItem.ToString();
-                var firstFlight = flightInfos.First(f => f.FlightName == name);
-                this.txtFlightName.Text = firstFlight.FlightName;
-                this.txtSpeed.Text = $"{firstFlight.Speed}";
-            }
+            gridView1.RefreshData();
+            gridView1.SelectAll();
+            mapControl.SetFlightLine(flightInfos.SelectMany(m => m.flights));
 
         }
     }

+ 3 - 4
DataSimulation.Forms/EditForms/TaskEditor.cs

@@ -234,10 +234,9 @@ namespace DataSimulation.Forms.EditForms
                 foreach (var item in selectedValue)
                 {
                     var simulationPonitInfo = SimulationCache.GetAllByIDAsync(item.ID, item.CreateTime).Result;
-                    var flinfo = new FlightInfo(item.SimulationName, item.SimulationSpeed);
-                    var fpoinits = simulationPonitInfo.Select(s => new FlightData(s.SimulationLon, s.SimulationLat));
-                    flinfo.flights.AddRange(fpoinits);
-                    flightInfos.Add(flinfo);
+                    var fpoinits = simulationPonitInfo.Select(s => new FlightInfo(item.SimulationName, item.SimulationSpeed, s.SimulationLon, s.SimulationLat));
+
+                    flightInfos.AddRange(fpoinits);
                 }
                 mapControl.SetFlightLine(flightInfos);
             }

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 245 - 674
DataSimulation.Forms/ExtensionsDev/MapControlEx.cs


+ 31 - 0
DataSimulation.Forms/Model/FlightImportInfo.cs

@@ -0,0 +1,31 @@
+using DataSimulation.Repostory;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DataSimulation.Forms.Model
+{
+    public class FlightImportInfo
+    {
+        public FlightImportInfo(string name,double speed)
+        {
+            FlightName = name;
+            Speed = speed;
+            flights = new List<FlightInfo>();
+        }
+
+        [Display(Name = "航迹名称")]
+        public string FlightName { get; set; }
+
+        /// <summary>
+        /// 速度m/s
+        /// </summary>
+        [Display(Name = "航迹速度(m/s)")]
+        public double Speed { get; set; }
+
+        public List<FlightInfo> flights { get; set; }
+    }
+}

+ 0 - 6
DataSimulation.Forms/Properties/licenses.licx

@@ -1,6 +0,0 @@
-DevExpress.XtraEditors.ImageComboBoxEdit, DevExpress.XtraEditors.v23.2, Version=23.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
-DevExpress.XtraEditors.TextEdit, DevExpress.XtraEditors.v23.2, Version=23.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
-DevExpress.XtraLayout.LayoutControl, DevExpress.XtraLayout.v23.2, Version=23.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
-DevExpress.XtraEditors.SearchLookUpEdit, DevExpress.XtraGrid.v23.2, Version=23.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
-DevExpress.XtraEditors.ButtonEdit, DevExpress.XtraEditors.v23.2, Version=23.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
-DevExpress.XtraMap.MapControl, DevExpress.XtraMap.v23.2, Version=23.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a

+ 1 - 1
DataSimulation.Repostory/DataSimulation.Repostory.csproj

@@ -95,7 +95,7 @@
     <Compile Include="Model\TaskInfo.cs" />
     <Compile Include="Model\TaskSimulation.cs" />
     <Compile Include="Model\XlInfo.cs" />
-    <Compile Include="PosData.cs" />
+    <Compile Include="FlightInfo.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="SimulationCache.cs" />
     <Compile Include="TaskCache.cs" />

+ 141 - 0
DataSimulation.Repostory/FlightInfo.cs

@@ -0,0 +1,141 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+
+namespace DataSimulation.Repostory
+{
+    /// <summary>
+    /// 指示某个属性需要导出
+    /// </summary>
+    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
+    public class ExportCellAttribute : Attribute
+    {
+        /// <summary>
+        /// 指示某个属性需要导出
+        /// </summary>
+        public ExportCellAttribute()
+        {
+        }
+
+        /// <summary>
+        /// 指示某个属性需要导出
+        /// </summary>
+        /// <param name="format">浮点数(默认f4)、时间(默认yyyy-MM-dd HH:mm:ss)等导出时的格式化字符串</param>
+        public ExportCellAttribute(string format)
+        {
+            this.Format = format;
+        }
+        /// <summary>
+        /// 浮点数(默认f4)、时间(默认yyyy-MM-dd HH:mm:ss)等导出时的格式化字符串
+        /// </summary>
+        public string Format { get; set; }
+
+        /// <summary>
+        /// 列的排列顺序,未指定的ColumnIndex的按照属性顺序排在之后
+        /// </summary>
+        public int ColumnIndex { get; set; } = -1;
+
+    }
+
+
+    /// <summary>
+    /// 指示某个属性在ToolTip中显示
+    /// </summary>
+    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
+    public class ToolTipAttribute : Attribute
+    {
+        /// <summary>
+        /// 指示某个属性在ToolTip中显示
+        /// </summary>
+        public ToolTipAttribute()
+        {
+        }
+
+        /// <summary>
+        /// 指示某个属性在ToolTip中显示
+        /// </summary>
+        /// <param name="format">浮点数(默认f4)、时间(默认yyyy-MM-dd HH:mm:ss)等导出时的格式化字符串</param>
+        public ToolTipAttribute(string format)
+        {
+            this.Format = format;
+        }
+        /// <summary>
+        /// 浮点数(默认f4)、时间(默认yyyy-MM-dd HH:mm:ss)等导出时的格式化字符串
+        /// </summary>
+        public string Format { get; set; }
+
+        /// <summary>
+        /// ToolTip从上到下的排列顺序,未指定的Index将按照属性顺序排在之后
+        /// </summary>
+        public int Index { get; set; } = 10000;
+    }
+
+
+    [Serializable]
+    public class FlightInfo
+    {
+        public FlightInfo()
+        {
+        }
+
+        public FlightInfo(string name, double speed, double lon, double lat)
+        {
+            FlightName = name;
+            Speed = speed;
+            FlightLon = lon;
+            FlightLat = lat;
+        }
+        [Display(Name = "航迹名称")]
+        [ExportCell("")]
+        public string FlightName { get; set; }
+
+        /// <summary>
+        /// 速度m/s
+        /// </summary>
+        [Display(Name = "航迹速度(m/s)")]
+        [ExportCell("f3")]
+        public double Speed { get; set; }
+
+
+        [Display(Name = "航迹经度(°)", AutoGenerateField = false)]
+        [ExportCell("f3")]
+        public double FlightLon { get; set; }
+
+        [Display(Name = "航迹纬度(°)", AutoGenerateField = false)]
+        [ExportCell("f3")]
+        public double FlightLat { get; set; }
+
+        [Display(Name = "是否选中", AutoGenerateField = false)]
+        [NotMapped]
+        public bool Selected { get; set; }
+
+
+        public override string ToString()
+        {
+            return $"航迹:{FlightName}\r\n{FlightLon},{FlightLat}°";
+        }
+        public string GetFilghtName()
+        {
+           return $"DrawFlightLine_{FlightName}_{Speed}";
+        }
+
+        /// <summary>
+        /// 判断定位点是否在一个框选的矩形区域内
+        /// </summary>
+        /// <param name="startLon"></param>
+        /// <param name="startLat"></param>
+        /// <param name="endLon"></param>
+        /// <param name="endLat"></param>
+        /// <returns></returns>
+        public bool InRectangle(double startLon, double startLat, double endLon, double endLat)
+        {
+            return FlightLon >= startLon && FlightLon <= endLon && FlightLat >= startLat && FlightLat <= endLat;
+        }
+
+        public bool EqualFlight(FlightInfo flight)
+        {
+            return FlightName == flight.FlightName && Speed <= flight.Speed && FlightLon >= flight.FlightLon && FlightLat <= flight.FlightLat;
+        }
+    }
+}

+ 0 - 248
DataSimulation.Repostory/PosData.cs

@@ -1,248 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-using System.ComponentModel.DataAnnotations.Schema;
-using System.Data.Entity.Core.Common.CommandTrees.ExpressionBuilder.Spatial;
-
-namespace DataSimulation.Repostory
-{
-    /// <summary>
-    /// 指示某个属性需要导出
-    /// </summary>
-    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
-    public class ExportCellAttribute : Attribute
-    {
-        /// <summary>
-        /// 指示某个属性需要导出
-        /// </summary>
-        public ExportCellAttribute()
-        {
-        }
-
-        /// <summary>
-        /// 指示某个属性需要导出
-        /// </summary>
-        /// <param name="format">浮点数(默认f4)、时间(默认yyyy-MM-dd HH:mm:ss)等导出时的格式化字符串</param>
-        public ExportCellAttribute(string format)
-        {
-            this.Format = format;
-        }
-        /// <summary>
-        /// 浮点数(默认f4)、时间(默认yyyy-MM-dd HH:mm:ss)等导出时的格式化字符串
-        /// </summary>
-        public string Format { get; set; }
-
-        /// <summary>
-        /// 列的排列顺序,未指定的ColumnIndex的按照属性顺序排在之后
-        /// </summary>
-        public int ColumnIndex { get; set; } = -1;
-
-    }
-
-
-    /// <summary>
-    /// 指示某个属性在ToolTip中显示
-    /// </summary>
-    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
-    public class ToolTipAttribute : Attribute
-    {
-        /// <summary>
-        /// 指示某个属性在ToolTip中显示
-        /// </summary>
-        public ToolTipAttribute()
-        {
-        }
-
-        /// <summary>
-        /// 指示某个属性在ToolTip中显示
-        /// </summary>
-        /// <param name="format">浮点数(默认f4)、时间(默认yyyy-MM-dd HH:mm:ss)等导出时的格式化字符串</param>
-        public ToolTipAttribute(string format)
-        {
-            this.Format = format;
-        }
-        /// <summary>
-        /// 浮点数(默认f4)、时间(默认yyyy-MM-dd HH:mm:ss)等导出时的格式化字符串
-        /// </summary>
-        public string Format { get; set; }
-
-        /// <summary>
-        /// ToolTip从上到下的排列顺序,未指定的Index将按照属性顺序排在之后
-        /// </summary>
-        public int Index { get; set; } = 10000;
-    }
-
-    /// <summary>
-    /// 定位点绑定到地图的对象
-    /// </summary>
-    public class PosData : BaseModel<long>
-    {
-        /// <summary>
-        /// 信号时刻
-        /// </summary>
-        [Display(Name = "信号时刻")]
-        [DisplayFormat(DataFormatString = "yyyy-MM-dd HH:mm:ss.fff")]
-        [ExportCell(ColumnIndex = 0)]//如果导出了SigTime,则内部会自动按照SigTime降序排列后再导出
-        [ToolTip(Index = 0)]
-        public DateTime SigTime { get; set; }
-
-        /// <summary>
-        /// 定位经度
-        /// </summary>
-        [Display(Name = "定位经度", AutoGenerateField = false)]
-        [ExportCell("f4")]
-        [ToolTip("f4")]
-        public double PosLon { get; set; }
-
-        /// <summary>
-        /// 定位纬度
-        /// </summary>
-        [Display(Name = "定位纬度", AutoGenerateField = false)]
-        [ExportCell("f4")]
-        [ToolTip("f4")]
-        public double PosLat { get; set; }
-
-
-        /// <summary>
-        /// 定位经度
-        /// </summary>
-        [Display(Name = "镜像经度", AutoGenerateField = false)]
-        [ExportCell("f4")]
-        [ToolTip("f4")]
-        public double MirrLon { get; set; }
-
-        /// <summary>
-        /// 定位纬度
-        /// </summary>
-        [Display(Name = "镜像纬度", AutoGenerateField = false)]
-        [ExportCell("f4")]
-        [ToolTip("f4")]
-        public double MirrLat { get; set; }
-
-        /// <summary>
-        /// 当前点是否被选中(默认false)
-        /// </summary>
-        [Display(Name = "是否选中", AutoGenerateField = false)]
-        [NotMapped]
-        public bool Selected { get; set; }
-
-        /// <summary>
-        /// 当前点是否可见(默认true)
-        /// </summary>
-        [Display(Name = "是否可见", AutoGenerateField = false)]
-        [NotMapped]
-        public bool Visible { get; set; } = true;
-
-        /// <summary>
-        /// 用于生成颜色的一个key,相同的key具有相同的颜色,当ColorKey为html颜色时则使用此颜色(如#A1B2FF),默认红色#CC3333
-        /// </summary>、
-        [Display(Name = "颜色标记", AutoGenerateField = false)]
-        [NotMapped]
-        public string ColorKey { get; set; } = "#CC3333";
-
-        /// <summary>
-        /// 判断定位点是否在一个框选的矩形区域内
-        /// </summary>
-        /// <param name="startLon"></param>
-        /// <param name="startLat"></param>
-        /// <param name="endLon"></param>
-        /// <param name="endLat"></param>
-        /// <returns></returns>
-        public bool InRectangle(double startLon, double startLat, double endLon, double endLat)
-        {
-            return PosLon >= startLon && PosLon <= endLon && PosLat >= startLat && PosLat <= endLat;
-        }
-
-        /// <summary>
-        /// 内部调用的属性
-        /// </summary>
-        [Display(AutoGenerateField = false)]
-        [NotMapped]
-        public int ClusterCount { get; set; } = 1;
-
-        /// <summary>
-        /// 内部调用的属性
-        /// </summary>
-        [Display(AutoGenerateField = false)]
-        [NotMapped]
-        public int ClusterKey { get; set; } = int.MinValue;
-    }
-
-    public class FlightInfo
-    {
-        public FlightInfo()
-        {
-        }
-        public FlightInfo(string name, double Speed)
-        {
-            this.FlightName = name;
-            this.Speed = Speed;
-            flights = new List<FlightData>();
-
-        }
-        [Display(Name = "航迹名称")]
-        public string FlightName { get; set; }
-
-        /// <summary>
-        /// 速度m/s
-        /// </summary>
-        [Display(Name = "航迹速度(m/s)")]
-        public double Speed { get; set; }
-
-        /// <summary>
-        /// 航迹数据点
-        /// </summary>
-        [Display(Name = "航迹数据点")]
-        [ExportCell()]
-        public List<FlightData> flights { get; set; }
-
-    }
-    public class FlightData
-    {
-        public FlightData(double lon, double lat)
-        {
-            this.FlightLon = lon;
-            this.FlightLat = lat;
-        }
-        [Display(Name = "航迹经度")]
-        public double FlightLon { get; set; }
-
-        [Display(Name = "航迹纬度")]
-        public double FlightLat { get; set; }
-
-    }
-
-    public class FightDataCsv
-    {
-        public FightDataCsv()
-        { }
-
-        public FightDataCsv(string name, double speed, double lon, double lat)
-        {
-            FlightName = name;
-            Speed = speed;
-            FlightLon = lon;
-            FlightLat = lat;
-        }
-
-        [Display(Name = "航迹名称")]
-        [ExportCell("")]
-        public string FlightName { get; set; }
-
-        /// <summary>
-        /// 速度m/s
-        /// </summary>
-        [Display(Name = "航迹速度(m/s)")]
-        [ExportCell("f3")]
-        public double Speed { get; set; }
-
-        [Display(Name = "航迹经度(°)")]
-        [ExportCell("f3")]
-        public double FlightLon { get; set; }
-
-        [Display(Name = "航迹纬度(°)")]
-        [ExportCell("f3")]
-        public double FlightLat { get; set; }
-
-    }
-}

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است