wyq 1 year ago
parent
commit
b369e8a60f

+ 2 - 2
DataSimulation.Forms/EditForms/FlightEditor.cs

@@ -106,12 +106,12 @@ namespace DataSimulation.Forms.EditForms
             double speed;
             if (!double.TryParse(txtSpeed.Text, out speed))
             {
-                dxErrorProvider.SetError(txtSpeed, "请设置正确的航迹速度(Km/s)");
+                dxErrorProvider.SetError(txtSpeed, "请设置正确的航迹速度(m/s)");
                 return false;
             }
             if (speed <= 0)
             {
-                dxErrorProvider.SetError(txtSpeed, "航迹速度范围不能小于等于0Km/s");
+                dxErrorProvider.SetError(txtSpeed, "航迹速度范围不能小于等于0(m/s)");
                 return false;
             }
             return true;

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

@@ -2,6 +2,7 @@
 using DataSimulation.Repostory.EFContext;
 using DataSimulation.Repostory.Model;
 using DevExpress.Utils.About;
+using DevExpress.XtraEditors;
 using DevExpress.XtraEditors.Controls;
 using DxHelper;
 using ExtensionsDev;
@@ -38,7 +39,7 @@ namespace DataSimulation.Forms.EditForms
             this.radioSimulationType.Properties.Items.AddRange(radioGroups.ToArray());
             this.radioSimulationType.SelectedIndex = 0;
 
-          
+
         }
 
         public TaskEditor(TaskInfo info)
@@ -57,14 +58,26 @@ namespace DataSimulation.Forms.EditForms
             .UseExportImg()
             .UseExportXlsx()
             .UseExportCsv()
-            .UseFlightLine()
+            .UseFlightLine(res =>
+            {
+                (bool isShowPopup, XtraUserControl frm) = res;
+                if (isShowPopup)
+                {
+                    DxHelper.PopupHelper.ShowPopup(frm, mapControl, 400);
+                }
+                else
+                {
+
+                    DxHelper.PopupHelper.HidePopup(frm);
+                }
+            })
             .SetMapLayerType(null)
             .UseDrawRect(rect =>
             {
                 (double startLon, double startLat, double centerLon, double centerLat, double endLon, double endLat, double lonRange, double latRange) = rect;
             });
 
-            var hjList =await SimulationCache.GetAllAsync();
+            var hjList = await SimulationCache.GetAllAsync();
             this.txtHj.UseDefault().SetData(hjList, nameof(SimulationInfo.SimulationName)).UseDoubleClickToSelectAll();
 
             using (SimulationContext db = new SimulationContext())

+ 30 - 20
DataSimulation.Forms/ExtensionsDev/MapControlEx.cs

@@ -5,6 +5,7 @@ using DevExpress.Map.Native;
 using DevExpress.Utils;
 using DevExpress.Utils.Svg;
 using DevExpress.XtraBars;
+using DevExpress.XtraEditors;
 using DevExpress.XtraGrid;
 using DevExpress.XtraGrid.Columns;
 using DevExpress.XtraGrid.Views.Grid;
@@ -832,7 +833,7 @@ public static class MapControlEx
     /// </summary>
     /// <param name="ctrl"></param>
     /// <returns></returns>
-    public static MapControl UseFlightLine(this MapControl ctrl)
+    public static MapControl UseFlightLine(this MapControl ctrl, Action<(bool, XtraUserControl)> ShowPopup)
     {
         var btnFlight = new BarButtonItem() { Caption = "航迹线" };
         btnFlight.ImageOptions.SvgImage = SvgHelper.CreateDistanceLine();
@@ -841,14 +842,20 @@ public static class MapControlEx
         btnFlight.ItemClick += (sender, e) =>
         {
             var flights = innerData._flightCache.Keys.ToList();
-            using (var frm = new MapFlightLineView(flights))
+            var frm = new MapFlightLineView(flights);
+            frm.onClick = (reslut) =>
             {
-                if (frm.ShowDialog() != DialogResult.OK) return;
+                (bool isOk, string caption, double speed) = reslut;
 
-                var filghtInfo = new FlightInfo(frm.Caption, frm.Speed);
+                ShowPopup?.Invoke((false, frm));
+                if (!isOk)
+                {
+                    return;
+                }
+                var filghtInfo = new FlightInfo(caption, speed);
                 innerData._flightCache.Add(filghtInfo.FlightName, filghtInfo);
 
-                string filghtName = $"DrawFlightLine{frm.Caption}";
+                string filghtName = $"DrawFlightLine{caption}";
                 ctrl.MapEditor.SetEditMode();
                 var items = innerData.mMapStorage.Items.ToArray();
                 innerData.flightpath = new MapSpline()
@@ -886,7 +893,9 @@ public static class MapControlEx
                     ctrl.MouseEnter -= MapControl_MouseEnter;
                     ctrl.MouseMove -= MovingDistinct;
                 };
-            }
+
+            };
+            ShowPopup?.Invoke((true, frm));
         };
 
         innerData.barM.BeginInit();
@@ -895,7 +904,13 @@ public static class MapControlEx
         innerData.barM.EndInit();
         return ctrl;
     }
-
+    /// <summary>
+    /// 
+    /// </summary>
+    /// <param name="ctrl"></param>
+    /// <param name="fligthName"></param>
+    /// <param name="speed">速度 m/s</param>
+    /// <returns></returns>
     public static MapControl DrawFlightLine(this MapControl ctrl, string fligthName, double speed)
     {
 
@@ -2490,7 +2505,7 @@ public static class MapControlEx
     }
     #endregion
     #region 航迹名称
-    class MapFlightLineView : DevExpress.XtraEditors.XtraForm
+    class MapFlightLineView : DevExpress.XtraEditors.XtraUserControl
     {
         private System.ComponentModel.IContainer components = null;
         private DevExpress.XtraLayout.LayoutControl layoutControl1;
@@ -2586,7 +2601,7 @@ public static class MapControlEx
             this.txtSpeed.Properties.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Near;
             this.txtSpeed.Properties.AutoHeight = false;
             this.txtSpeed.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
-            new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Glyph, "km/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)});
+            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.Size = new System.Drawing.Size(248, 22);
             this.txtSpeed.StyleController = this.layoutControl1;
             this.txtSpeed.TabIndex = 4;
@@ -2709,12 +2724,6 @@ public static class MapControlEx
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(272, 208);
             this.Controls.Add(this.layoutControl1);
-            this.IconOptions.ShowIcon = false;
-            this.MaximizeBox = false;
-            this.MinimizeBox = false;
-            this.Name = "MapFlightLineView";
-            this.ShowInTaskbar = false;
-            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
             this.Text = "航迹";
             ((System.ComponentModel.ISupportInitialize)(this.layoutControl1)).EndInit();
             this.layoutControl1.ResumeLayout(false);
@@ -2757,12 +2766,12 @@ public static class MapControlEx
             double speed;
             if (!double.TryParse(txtSpeed.Text, out speed))
             {
-                dxErrorProvider1.SetError(txtSpeed, "请设置正确的航迹速度(Km/s)");
+                dxErrorProvider1.SetError(txtSpeed, "请设置正确的航迹速度(m/s)");
                 return;
             }
             if (speed <= 0)
             {
-                dxErrorProvider1.SetError(txtSpeed, "航迹速度范围不能小于等于0Km/s");
+                dxErrorProvider1.SetError(txtSpeed, "航迹速度范围不能小于等于0(m/s)");
                 return;
             }
             dxErrorProvider1.SetError(txtSpeed, string.Empty);
@@ -2785,6 +2794,8 @@ public static class MapControlEx
         }
 
         private List<string> Names;
+
+        public Action<(bool isOk, string caption, double speed)> onClick;
         public string Caption
         {
             get
@@ -2835,13 +2846,12 @@ public static class MapControlEx
                 dxErrorProvider1.SetError(txtSpeed, "航迹速度范围不能小于等于0Km/s");
                 return;
             }
-
-            this.DialogResult = DialogResult.OK;
+            this.onClick?.Invoke((true, Caption, Speed));
         }
 
         private void btnCancel_Click(object sender, EventArgs e)
         {
-            this.DialogResult = DialogResult.Cancel;
+            this.onClick?.Invoke((false, "", 0));
         }
     }
     #endregion

+ 15 - 3
DataSimulation.Forms/UserControl/CtrlHome.cs

@@ -5,6 +5,7 @@ using DataSimulation.Repostory.Model;
 using DevExpress.Utils;
 using DevExpress.Utils.About;
 using DevExpress.XtraBars.Customization;
+using DevExpress.XtraEditors;
 using DevExpress.XtraEditors.ButtonsPanelControl;
 using DevExpress.XtraMap;
 using DxHelper;
@@ -45,8 +46,19 @@ namespace DataSimulation.Forms.UserControl
           .UseDrawRect(rect =>
           {
               (double startLon, double startLat, double centerLon, double centerLat, double endLon, double endLat, double lonRange, double latRange) = rect;
-          }).UseFlightLine()
-         ;
+          }).UseFlightLine(res =>
+          {
+              (bool isShowPopup, XtraUserControl frm) = res;
+              if (isShowPopup)
+              {
+                  DxHelper.PopupHelper.ShowPopup(frm, mapControl, 400);
+              }
+              else
+              {
+
+                  DxHelper.PopupHelper.HidePopup(frm);
+              }
+          });
 
         }
 
@@ -90,7 +102,7 @@ namespace DataSimulation.Forms.UserControl
 
         private async void layoutControlGroup_CustomButtonClick(object sender, DevExpress.XtraBars.Docking2010.BaseButtonEventArgs e)
         {
-           
+
             var txt = (e.Button as GroupBoxButton).Caption;
             if (txt == "新建任务")
             {

+ 1 - 1
DataSimulation.Repostory/Model/SimulationInfo.cs

@@ -18,7 +18,7 @@ namespace DataSimulation.Repostory.Model
         [Display(Name = "仿真名称")]
         public string SimulationName { get; set; }
 
-        [Display(Name = "仿真速度(Km/s)")]
+        [Display(Name = "仿真速度(m/s)")]
         public double SimulationSpeed { get; set; }
     }
 }

+ 3 - 0
DataSimulation.Repostory/PosData.cs

@@ -184,6 +184,9 @@ namespace DataSimulation.Repostory
         }
         public string FlightName { get; set; }
 
+        /// <summary>
+        /// 速度m/s
+        /// </summary>
         public double Speed { get; set; }
 
         public List<FlightData> flights { get; set; }