wyq 1 year ago
parent
commit
631559064e

+ 8 - 0
DataSimulation.Forms/DataSimulation.Forms.csproj

@@ -226,6 +226,14 @@
       <Name>DataSimulation.Repostory</Name>
     </ProjectReference>
   </ItemGroup>
+  <ItemGroup>
+    <Content Include="Images\Cancel.svg">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="Images\Ok.svg">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
     <PropertyGroup>

+ 83 - 43
DataSimulation.Forms/EditForms/AntEditor.Designer.cs

@@ -28,21 +28,23 @@
         /// </summary>
         private void InitializeComponent()
         {
+            this.components = new System.ComponentModel.Container();
+            DevExpress.XtraEditors.Controls.EditorButtonImageOptions editorButtonImageOptions3 = new DevExpress.XtraEditors.Controls.EditorButtonImageOptions();
+            DevExpress.Utils.SerializableAppearanceObject serializableAppearanceObject9 = new DevExpress.Utils.SerializableAppearanceObject();
+            DevExpress.Utils.SerializableAppearanceObject serializableAppearanceObject10 = new DevExpress.Utils.SerializableAppearanceObject();
+            DevExpress.Utils.SerializableAppearanceObject serializableAppearanceObject11 = new DevExpress.Utils.SerializableAppearanceObject();
+            DevExpress.Utils.SerializableAppearanceObject serializableAppearanceObject12 = new DevExpress.Utils.SerializableAppearanceObject();
             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();
-            DevExpress.XtraEditors.Controls.EditorButtonImageOptions editorButtonImageOptions2 = new DevExpress.XtraEditors.Controls.EditorButtonImageOptions();
-            DevExpress.Utils.SerializableAppearanceObject serializableAppearanceObject5 = new DevExpress.Utils.SerializableAppearanceObject();
-            DevExpress.Utils.SerializableAppearanceObject serializableAppearanceObject6 = new DevExpress.Utils.SerializableAppearanceObject();
-            DevExpress.Utils.SerializableAppearanceObject serializableAppearanceObject7 = new DevExpress.Utils.SerializableAppearanceObject();
-            DevExpress.Utils.SerializableAppearanceObject serializableAppearanceObject8 = new DevExpress.Utils.SerializableAppearanceObject();
             this.layoutControl1 = new DevExpress.XtraLayout.LayoutControl();
             this.btnOk = new DevExpress.XtraEditors.SimpleButton();
             this.btnCancel = new DevExpress.XtraEditors.SimpleButton();
             this.txtAntLon = new DevExpress.XtraEditors.ButtonEdit();
             this.txtAntName = new DevExpress.XtraEditors.TextEdit();
+            this.txtAntLat = new DevExpress.XtraEditors.ButtonEdit();
             this.Root = new DevExpress.XtraLayout.LayoutControlGroup();
             this.emptySpaceItem1 = new DevExpress.XtraLayout.EmptySpaceItem();
             this.layoutControlItem2 = new DevExpress.XtraLayout.LayoutControlItem();
@@ -50,12 +52,15 @@
             this.layoutControlItem4 = new DevExpress.XtraLayout.LayoutControlItem();
             this.layoutControlItem5 = new DevExpress.XtraLayout.LayoutControlItem();
             this.emptySpaceItem2 = new DevExpress.XtraLayout.EmptySpaceItem();
-            this.txtAntLat = new DevExpress.XtraEditors.ButtonEdit();
             this.layoutControlItem1 = new DevExpress.XtraLayout.LayoutControlItem();
+            this.emptySpaceItem3 = new DevExpress.XtraLayout.EmptySpaceItem();
+            this.dxErrorProvider = new DevExpress.XtraEditors.DXErrorProvider.DXErrorProvider(this.components);
+            this.emptySpaceItem4 = new DevExpress.XtraLayout.EmptySpaceItem();
             ((System.ComponentModel.ISupportInitialize)(this.layoutControl1)).BeginInit();
             this.layoutControl1.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.txtAntLon.Properties)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.txtAntName.Properties)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.txtAntLat.Properties)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.Root)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem1)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem2)).BeginInit();
@@ -63,8 +68,10 @@
             ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem4)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem5)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem2)).BeginInit();
-            ((System.ComponentModel.ISupportInitialize)(this.txtAntLat.Properties)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem1)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem3)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.dxErrorProvider)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem4)).BeginInit();
             this.SuspendLayout();
             // 
             // layoutControl1
@@ -79,15 +86,15 @@
             this.layoutControl1.Name = "layoutControl1";
             this.layoutControl1.OptionsCustomizationForm.DesignTimeCustomizationFormPositionAndSize = new System.Drawing.Rectangle(831, 101, 650, 400);
             this.layoutControl1.Root = this.Root;
-            this.layoutControl1.Size = new System.Drawing.Size(258, 295);
+            this.layoutControl1.Size = new System.Drawing.Size(371, 295);
             this.layoutControl1.TabIndex = 0;
             this.layoutControl1.Text = "layoutControl1";
             // 
             // btnOk
             // 
-            this.btnOk.Location = new System.Drawing.Point(131, 202);
+            this.btnOk.Location = new System.Drawing.Point(276, 202);
             this.btnOk.Name = "btnOk";
-            this.btnOk.Size = new System.Drawing.Size(105, 22);
+            this.btnOk.Size = new System.Drawing.Size(73, 22);
             this.btnOk.StyleController = this.layoutControl1;
             this.btnOk.TabIndex = 8;
             this.btnOk.Text = "确定";
@@ -95,9 +102,9 @@
             // 
             // btnCancel
             // 
-            this.btnCancel.Location = new System.Drawing.Point(22, 202);
+            this.btnCancel.Location = new System.Drawing.Point(181, 202);
             this.btnCancel.Name = "btnCancel";
-            this.btnCancel.Size = new System.Drawing.Size(105, 22);
+            this.btnCancel.Size = new System.Drawing.Size(81, 22);
             this.btnCancel.StyleController = this.layoutControl1;
             this.btnCancel.TabIndex = 7;
             this.btnCancel.Text = "取消";
@@ -108,12 +115,12 @@
             this.txtAntLon.Location = new System.Drawing.Point(22, 103);
             this.txtAntLon.Name = "txtAntLon";
             this.txtAntLon.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
-            new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Glyph, "°", -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, "°", -1, false, true, false, editorButtonImageOptions3, new DevExpress.Utils.KeyShortcut(System.Windows.Forms.Keys.None), serializableAppearanceObject9, serializableAppearanceObject10, serializableAppearanceObject11, serializableAppearanceObject12, "", null, null, DevExpress.Utils.ToolTipAnchor.Default)});
             this.txtAntLon.Properties.MaskSettings.Set("MaskManagerType", typeof(DevExpress.Data.Mask.NumericMaskManager));
             this.txtAntLon.Properties.MaskSettings.Set("mask", "f");
             this.txtAntLon.Properties.MaxLength = 10;
-            this.txtAntLon.Properties.NullValuePrompt = "必需";
-            this.txtAntLon.Size = new System.Drawing.Size(214, 23);
+            this.txtAntLon.Properties.NullValuePrompt = "必需";
+            this.txtAntLon.Size = new System.Drawing.Size(327, 23);
             this.txtAntLon.StyleController = this.layoutControl1;
             this.txtAntLon.TabIndex = 6;
             // 
@@ -122,10 +129,24 @@
             this.txtAntName.Location = new System.Drawing.Point(22, 49);
             this.txtAntName.Name = "txtAntName";
             this.txtAntName.Properties.AutoHeight = false;
-            this.txtAntName.Size = new System.Drawing.Size(214, 23);
+            this.txtAntName.Size = new System.Drawing.Size(327, 23);
             this.txtAntName.StyleController = this.layoutControl1;
             this.txtAntName.TabIndex = 5;
             // 
+            // txtAntLat
+            // 
+            this.txtAntLat.Location = new System.Drawing.Point(22, 154);
+            this.txtAntLat.Name = "txtAntLat";
+            this.txtAntLat.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
+            new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Glyph, "°", -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.txtAntLat.Properties.MaskSettings.Set("MaskManagerType", typeof(DevExpress.Data.Mask.NumericMaskManager));
+            this.txtAntLat.Properties.MaskSettings.Set("mask", "f");
+            this.txtAntLat.Properties.MaxLength = 10;
+            this.txtAntLat.Properties.NullValuePrompt = "必需";
+            this.txtAntLat.Size = new System.Drawing.Size(327, 23);
+            this.txtAntLat.StyleController = this.layoutControl1;
+            this.txtAntLat.TabIndex = 6;
+            // 
             // Root
             // 
             this.Root.EnableIndentsWithoutBorders = DevExpress.Utils.DefaultBoolean.True;
@@ -137,10 +158,12 @@
             this.layoutControlItem4,
             this.layoutControlItem5,
             this.emptySpaceItem2,
-            this.layoutControlItem1});
+            this.layoutControlItem1,
+            this.emptySpaceItem3,
+            this.emptySpaceItem4});
             this.Root.Name = "Root";
             this.Root.Padding = new DevExpress.XtraLayout.Utils.Padding(20, 20, 20, 20);
-            this.Root.Size = new System.Drawing.Size(258, 295);
+            this.Root.Size = new System.Drawing.Size(371, 295);
             this.Root.TextVisible = false;
             // 
             // emptySpaceItem1
@@ -148,7 +171,7 @@
             this.emptySpaceItem1.AllowHotTrack = false;
             this.emptySpaceItem1.Location = new System.Drawing.Point(0, 206);
             this.emptySpaceItem1.Name = "emptySpaceItem1";
-            this.emptySpaceItem1.Size = new System.Drawing.Size(218, 49);
+            this.emptySpaceItem1.Size = new System.Drawing.Size(331, 49);
             this.emptySpaceItem1.TextSize = new System.Drawing.Size(0, 0);
             // 
             // layoutControlItem2
@@ -159,7 +182,7 @@
             this.layoutControlItem2.MinSize = new System.Drawing.Size(54, 54);
             this.layoutControlItem2.Name = "layoutControlItem2";
             this.layoutControlItem2.Padding = new DevExpress.XtraLayout.Utils.Padding(2, 2, 12, 2);
-            this.layoutControlItem2.Size = new System.Drawing.Size(218, 54);
+            this.layoutControlItem2.Size = new System.Drawing.Size(331, 54);
             this.layoutControlItem2.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom;
             this.layoutControlItem2.Text = "天线名称";
             this.layoutControlItem2.TextLocation = DevExpress.Utils.Locations.Top;
@@ -173,7 +196,7 @@
             this.layoutControlItem3.MinSize = new System.Drawing.Size(54, 51);
             this.layoutControlItem3.Name = "layoutControlItem3";
             this.layoutControlItem3.Padding = new DevExpress.XtraLayout.Utils.Padding(2, 2, 12, 2);
-            this.layoutControlItem3.Size = new System.Drawing.Size(218, 51);
+            this.layoutControlItem3.Size = new System.Drawing.Size(331, 51);
             this.layoutControlItem3.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom;
             this.layoutControlItem3.Text = "天线经度";
             this.layoutControlItem3.TextLocation = DevExpress.Utils.Locations.Top;
@@ -182,18 +205,23 @@
             // layoutControlItem4
             // 
             this.layoutControlItem4.Control = this.btnCancel;
-            this.layoutControlItem4.Location = new System.Drawing.Point(0, 180);
+            this.layoutControlItem4.Location = new System.Drawing.Point(159, 180);
+            this.layoutControlItem4.MinSize = new System.Drawing.Size(35, 26);
             this.layoutControlItem4.Name = "layoutControlItem4";
-            this.layoutControlItem4.Size = new System.Drawing.Size(109, 26);
+            this.layoutControlItem4.Size = new System.Drawing.Size(85, 26);
+            this.layoutControlItem4.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom;
             this.layoutControlItem4.TextSize = new System.Drawing.Size(0, 0);
             this.layoutControlItem4.TextVisible = false;
             // 
             // layoutControlItem5
             // 
             this.layoutControlItem5.Control = this.btnOk;
-            this.layoutControlItem5.Location = new System.Drawing.Point(109, 180);
+            this.layoutControlItem5.Location = new System.Drawing.Point(254, 180);
+            this.layoutControlItem5.MaxSize = new System.Drawing.Size(77, 26);
+            this.layoutControlItem5.MinSize = new System.Drawing.Size(77, 26);
             this.layoutControlItem5.Name = "layoutControlItem5";
-            this.layoutControlItem5.Size = new System.Drawing.Size(109, 26);
+            this.layoutControlItem5.Size = new System.Drawing.Size(77, 26);
+            this.layoutControlItem5.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom;
             this.layoutControlItem5.TextSize = new System.Drawing.Size(0, 0);
             this.layoutControlItem5.TextVisible = false;
             // 
@@ -204,24 +232,10 @@
             this.emptySpaceItem2.MaxSize = new System.Drawing.Size(0, 24);
             this.emptySpaceItem2.MinSize = new System.Drawing.Size(104, 24);
             this.emptySpaceItem2.Name = "emptySpaceItem2";
-            this.emptySpaceItem2.Size = new System.Drawing.Size(218, 24);
+            this.emptySpaceItem2.Size = new System.Drawing.Size(331, 24);
             this.emptySpaceItem2.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom;
             this.emptySpaceItem2.TextSize = new System.Drawing.Size(0, 0);
             // 
-            // txtAntLat
-            // 
-            this.txtAntLat.Location = new System.Drawing.Point(22, 154);
-            this.txtAntLat.Name = "txtAntLat";
-            this.txtAntLat.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
-            new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Glyph, "°", -1, false, true, false, editorButtonImageOptions2, new DevExpress.Utils.KeyShortcut(System.Windows.Forms.Keys.None), serializableAppearanceObject5, serializableAppearanceObject6, serializableAppearanceObject7, serializableAppearanceObject8, "", null, null, DevExpress.Utils.ToolTipAnchor.Default)});
-            this.txtAntLat.Properties.MaskSettings.Set("MaskManagerType", typeof(DevExpress.Data.Mask.NumericMaskManager));
-            this.txtAntLat.Properties.MaskSettings.Set("mask", "f");
-            this.txtAntLat.Properties.MaxLength = 10;
-            this.txtAntLat.Properties.NullValuePrompt = "非必需";
-            this.txtAntLat.Size = new System.Drawing.Size(214, 23);
-            this.txtAntLat.StyleController = this.layoutControl1;
-            this.txtAntLat.TabIndex = 6;
-            // 
             // layoutControlItem1
             // 
             this.layoutControlItem1.Control = this.txtAntLat;
@@ -232,17 +246,37 @@
             this.layoutControlItem1.MinSize = new System.Drawing.Size(54, 51);
             this.layoutControlItem1.Name = "layoutControlItem1";
             this.layoutControlItem1.Padding = new DevExpress.XtraLayout.Utils.Padding(2, 2, 12, 2);
-            this.layoutControlItem1.Size = new System.Drawing.Size(218, 51);
+            this.layoutControlItem1.Size = new System.Drawing.Size(331, 51);
             this.layoutControlItem1.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom;
             this.layoutControlItem1.Text = "天线纬度";
             this.layoutControlItem1.TextLocation = DevExpress.Utils.Locations.Top;
             this.layoutControlItem1.TextSize = new System.Drawing.Size(48, 14);
             // 
+            // emptySpaceItem3
+            // 
+            this.emptySpaceItem3.AllowHotTrack = false;
+            this.emptySpaceItem3.Location = new System.Drawing.Point(0, 180);
+            this.emptySpaceItem3.Name = "emptySpaceItem3";
+            this.emptySpaceItem3.Size = new System.Drawing.Size(159, 26);
+            this.emptySpaceItem3.TextSize = new System.Drawing.Size(0, 0);
+            // 
+            // dxErrorProvider
+            // 
+            this.dxErrorProvider.ContainerControl = this;
+            // 
+            // emptySpaceItem4
+            // 
+            this.emptySpaceItem4.AllowHotTrack = false;
+            this.emptySpaceItem4.Location = new System.Drawing.Point(244, 180);
+            this.emptySpaceItem4.Name = "emptySpaceItem4";
+            this.emptySpaceItem4.Size = new System.Drawing.Size(10, 26);
+            this.emptySpaceItem4.TextSize = new System.Drawing.Size(0, 0);
+            // 
             // AntEditor
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(258, 295);
+            this.ClientSize = new System.Drawing.Size(371, 295);
             this.Controls.Add(this.layoutControl1);
             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
             this.Name = "AntEditor";
@@ -252,6 +286,7 @@
             this.layoutControl1.ResumeLayout(false);
             ((System.ComponentModel.ISupportInitialize)(this.txtAntLon.Properties)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.txtAntName.Properties)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.txtAntLat.Properties)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.Root)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem1)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem2)).EndInit();
@@ -259,8 +294,10 @@
             ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem4)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem5)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem2)).EndInit();
-            ((System.ComponentModel.ISupportInitialize)(this.txtAntLat.Properties)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem1)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem3)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.dxErrorProvider)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem4)).EndInit();
             this.ResumeLayout(false);
 
         }
@@ -281,5 +318,8 @@
         private DevExpress.XtraLayout.EmptySpaceItem emptySpaceItem2;
         private DevExpress.XtraEditors.ButtonEdit txtAntLat;
         private DevExpress.XtraLayout.LayoutControlItem layoutControlItem1;
+        private DevExpress.XtraEditors.DXErrorProvider.DXErrorProvider dxErrorProvider;
+        private DevExpress.XtraLayout.EmptySpaceItem emptySpaceItem3;
+        private DevExpress.XtraLayout.EmptySpaceItem emptySpaceItem4;
     }
 }

+ 55 - 2
DataSimulation.Forms/EditForms/AntEditor.cs

@@ -11,6 +11,7 @@ using System.Windows.Forms;
 using DataSimulation.Repostory;
 using DataSimulation.Repostory.EFContext;
 using DataSimulation.Repostory.Model;
+using DxHelper;
 
 namespace DataSimulation.Forms.EditForms
 {
@@ -24,7 +25,25 @@ namespace DataSimulation.Forms.EditForms
             this.Text = "添加天线";
             info = new AntInfo();
             this.StartPosition = FormStartPosition.CenterParent;
+            btnOk.ImageOptions.SvgImage = SvgHelper.LoadFromFile("Images\\Ok.svg");
+            btnOk.ImageOptions.SvgImageSize = new Size(20, 20);
+
+            btnCancel.ImageOptions.SvgImage = SvgHelper.LoadFromFile("Images\\Cancel.svg");
+            btnCancel.ImageOptions.SvgImageSize = new Size(20, 20);
+            txtAntLon.EditValueChanged += TxtAntLon_EditValueChanged;
+            txtAntLat.EditValueChanged += TxtAntLat_EditValueChanged;
+        }
+
+        private void TxtAntLat_EditValueChanged(object sender, EventArgs e)
+        {
+            txtAntLat.CheckLat(dxErrorProvider, "天线");
         }
+
+        private void TxtAntLon_EditValueChanged(object sender, EventArgs e)
+        {
+            txtAntLon.CheckLon(dxErrorProvider, "天线");
+        }
+
         public AntEditor(AntInfo info)
             : this()
         {
@@ -45,14 +64,48 @@ namespace DataSimulation.Forms.EditForms
         {
             this.DialogResult = DialogResult.Cancel;
         }
-        private void btnOk_Click(object sender, EventArgs e)
+        private async void btnOk_Click(object sender, EventArgs e)
         {
-
+            if (!txtAntLon.CheckLon(dxErrorProvider, "天线") || !txtAntLat.CheckLat(dxErrorProvider, "天线"))
+            {
+                return;
+            }
             try
             {
                 info.AntName = txtAntName.Text.Trim();
                 info.AntLon = Convert.ToDouble(txtAntLon.Text);
                 info.AntLat = Convert.ToDouble(txtAntLat.Text);
+                if (this.Text == "添加天线")
+                {
+                    using (SimulationContext db = new SimulationContext())
+                    {
+                        bool isAny = db.AntInfos.Any(s => s.AntName == info.AntName && s.AntLon == info.AntLon && s.AntLat == info.AntLat);
+                        if (isAny)
+                        {
+                            DxHelper.MsgBoxHelper.ShowError($"添加天线信息失败,已经存在卫星:{info.Ant}");
+                            return;
+                        }
+                        db.AntInfos.Add(info);
+                        await db.SaveChangesAsync();
+                    }
+                }
+                else
+                {
+                    using (SimulationContext db = new SimulationContext())
+                    {
+                        bool isAny = db.AntInfos.Any(s => s.ID != info.ID && s.AntName == info.AntName && s.AntLon == info.AntLon && s.AntLat == info.AntLat);
+                        if (isAny)
+                        {
+                            DxHelper.MsgBoxHelper.ShowError($"编辑卫星信息失败,已经存在卫星:{info.Ant}");
+                            return;
+                        }
+                        var find = await db.AntInfos.Where(p => p.ID == info.ID).FirstOrDefaultAsync();
+                        find.AntName = info.AntName;
+                        find.AntLon = info.AntLon;
+                        find.AntLat = info.AntLat;
+                        await db.SaveChangesAsync();
+                    }
+                }
                 this.DialogResult = DialogResult.OK;
             }
             catch (Exception ex)

+ 3 - 0
DataSimulation.Forms/EditForms/AntEditor.resx

@@ -117,4 +117,7 @@
   <resheader name="writer">
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
+  <metadata name="dxErrorProvider.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>17, 17</value>
+  </metadata>
 </root>

+ 10 - 1
DataSimulation.Forms/EditForms/SatEditor.Designer.cs

@@ -28,6 +28,7 @@
         /// </summary>
         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();
@@ -48,6 +49,7 @@
             this.layoutControlItem4 = new DevExpress.XtraLayout.LayoutControlItem();
             this.layoutControlItem5 = new DevExpress.XtraLayout.LayoutControlItem();
             this.emptySpaceItem2 = new DevExpress.XtraLayout.EmptySpaceItem();
+            this.dxErrorProvider = new DevExpress.XtraEditors.DXErrorProvider.DXErrorProvider(this.components);
             ((System.ComponentModel.ISupportInitialize)(this.layoutControl1)).BeginInit();
             this.layoutControl1.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.txtSatLon.Properties)).BeginInit();
@@ -62,6 +64,7 @@
             ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem4)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem5)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem2)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.dxErrorProvider)).BeginInit();
             this.SuspendLayout();
             // 
             // layoutControl1
@@ -109,7 +112,7 @@
             this.txtSatLon.Properties.MaskSettings.Set("MaskManagerType", typeof(DevExpress.Data.Mask.NumericMaskManager));
             this.txtSatLon.Properties.MaskSettings.Set("mask", "f");
             this.txtSatLon.Properties.MaxLength = 10;
-            this.txtSatLon.Properties.NullValuePrompt = "必需";
+            this.txtSatLon.Properties.NullValuePrompt = "必需";
             this.txtSatLon.Size = new System.Drawing.Size(214, 23);
             this.txtSatLon.StyleController = this.layoutControl1;
             this.txtSatLon.TabIndex = 6;
@@ -238,6 +241,10 @@
             this.emptySpaceItem2.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom;
             this.emptySpaceItem2.TextSize = new System.Drawing.Size(0, 0);
             // 
+            // dxErrorProvider
+            // 
+            this.dxErrorProvider.ContainerControl = this;
+            // 
             // SatEditor
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F);
@@ -262,6 +269,7 @@
             ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem4)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem5)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem2)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.dxErrorProvider)).EndInit();
             this.ResumeLayout(false);
 
         }
@@ -283,5 +291,6 @@
         private DevExpress.XtraLayout.LayoutControlItem layoutControlItem4;
         private DevExpress.XtraLayout.LayoutControlItem layoutControlItem5;
         private DevExpress.XtraLayout.EmptySpaceItem emptySpaceItem2;
+        private DevExpress.XtraEditors.DXErrorProvider.DXErrorProvider dxErrorProvider;
     }
 }

+ 53 - 6
DataSimulation.Forms/EditForms/SatEditor.cs

@@ -24,7 +24,20 @@ namespace DataSimulation.Forms.EditForms
             this.Text = "添加卫星";
             info = new SatInfo();
             this.StartPosition = FormStartPosition.CenterParent;
+            txtSatLon.EditValueChanged += TxtSatLon_EditValueChanged;
+            searchLookUpEdit1.EditValueChanged += SearchLookUpEdit1_EditValueChanged;
         }
+
+        private void SearchLookUpEdit1_EditValueChanged(object sender, EventArgs e)
+        {
+            searchLookUpEdit1.CheckSearch(dxErrorProvider, "卫星");
+        }
+
+        private void TxtSatLon_EditValueChanged(object sender, EventArgs e)
+        {
+            txtSatLon.CheckLon(dxErrorProvider, "轨道");
+        }
+
         public SatEditor(SatInfo info)
             : this()
         {
@@ -34,11 +47,11 @@ namespace DataSimulation.Forms.EditForms
         private async void SatEditor_Load(object sender, EventArgs e)
         {
             var listXl = await XlCache.GetAllAsync();
-            this.searchLookUpEdit1.UseDefault().SetStringData(listXl.Select(p=>p.Sat)).UseDoubleClickToSelectAll();
+            this.searchLookUpEdit1.UseDefault().SetStringData(listXl.Select(p => p.Sat)).UseDoubleClickToSelectAll();
             if (this.Text == "编辑卫星" && info != null)
             {
                 this.txtSatName.Text = info.SatName;
-                this.txtSatLon.Text = info.SatLon.ToString();
+                this.txtSatLon.Text = $"{info.SatLon}";
             }
         }
 
@@ -46,9 +59,12 @@ namespace DataSimulation.Forms.EditForms
         {
             this.DialogResult = DialogResult.Cancel;
         }
-        private void btnOk_Click(object sender, EventArgs e)
+        private async void btnOk_Click(object sender, EventArgs e)
         {
-
+            if (!searchLookUpEdit1.CheckSearch(dxErrorProvider, "卫星") || !txtSatLon.CheckLon(dxErrorProvider, "轨道"))
+            {
+                return;
+            }
             try
             {
                 var sat = searchLookUpEdit1.Text;
@@ -58,12 +74,43 @@ namespace DataSimulation.Forms.EditForms
                 info.SatName = txtSatName.Text.Trim();
                 if (!string.IsNullOrWhiteSpace(txtSatLon.Text))
                     info.SatLon = Convert.ToDouble(txtSatLon.Text);
+                if (this.Text == "添加卫星")
+                {
+                    using (SimulationContext db = new SimulationContext())
+                    {
+                        bool isAny = db.SatInfos.Any(s => s.SatName == info.SatName && s.SatCode == info.SatCode && s.SatLon == info.SatLon);
+                        if (isAny)
+                        {
+                            DxHelper.MsgBoxHelper.ShowError($"添加卫星信息失败,已经存在卫星:{info.Sat}");
+                            return;
+                        }
+                        db.SatInfos.Add(info);
+                        await db.SaveChangesAsync();
+                    }
+                }
+                else
+                {
+                    using (SimulationContext db = new SimulationContext())
+                    {
+                        bool isAny = db.SatInfos.Any(s => s.ID != info.ID && s.SatName == info.SatName && s.SatCode == info.SatCode && s.SatLon == info.SatLon);
+                        if (isAny)
+                        {
+                            DxHelper.MsgBoxHelper.ShowError($"编辑卫星信息失败,已经存在卫星:{info.Sat}");
+                            return;
+                        }
+                        var find = await db.SatInfos.Where(p => p.ID == info.ID).FirstOrDefaultAsync();
+                        find.SatName = info.SatName;
+                        find.SatCode = info.SatCode;
+                        find.SatLon = info.SatLon;
+                        await db.SaveChangesAsync();
+                    }
+                }
                 this.DialogResult = DialogResult.OK;
             }
             catch (Exception ex)
             {
-                Serilog.Log.Error(ex, "编辑卫星信息出错");
-                DxHelper.MsgBoxHelper.ShowError("编辑卫星信息出错");
+                Serilog.Log.Error(ex, $"{this.Text}信息出错");
+                DxHelper.MsgBoxHelper.ShowError($"{this.Text}信息出错");
             }
         }
     }

+ 3 - 0
DataSimulation.Forms/EditForms/SatEditor.resx

@@ -117,4 +117,7 @@
   <resheader name="writer">
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
+  <metadata name="dxErrorProvider.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>17, 17</value>
+  </metadata>
 </root>

+ 48 - 0
DataSimulation.Forms/ExtensionsDev/BaseEditExtension.cs

@@ -21,6 +21,54 @@ namespace ExtensionsDev
             var ctrl = (BaseEdit)sender;
             ctrl.SelectAll();
         }
+        public static bool CheckSearch(this SearchLookUpEdit @this, DXErrorProvider dxErrorProvider, string msg)
+        {
+            if (string.IsNullOrWhiteSpace(@this.Text.Trim()))
+            {
+                dxErrorProvider.SetError(@this, $"{msg}不能为空!");
+                return false;
+            }
+            dxErrorProvider.SetError(@this, string.Empty);
+            return true;
+
+        }
+        public static bool CheckLon(this TextEdit @this, DXErrorProvider dxErrorProvider, string msg)
+        {
+            if (string.IsNullOrWhiteSpace(@this.Text.Trim()))
+            {
+                dxErrorProvider.SetError(@this, $"{msg}经度不能为空!");
+                return false;
+            }
+          
+            double lon;
+            bool isDoubleLon = Double.TryParse(@this.Text, out lon);
+            if (!isDoubleLon || lon > 180 || lon < -180)
+            {
+                dxErrorProvider.SetError(@this, $"{msg}经度范围[180,-180]!");
+                return false;
+            }
+            dxErrorProvider.SetError(@this, string.Empty);
+            return true;
+
+        }
+        public static bool CheckLat(this TextEdit @this, DXErrorProvider dxErrorProvider, string msg)
+        {
+            if (string.IsNullOrWhiteSpace(@this.Text.Trim()))
+            {
+                dxErrorProvider.SetError(@this, $"{msg}纬度不能为空!");
+                return false;
+            }
+            double lat;
+            bool isDoubleLat = Double.TryParse(@this.Text, out lat);
+            if (!isDoubleLat || lat > 90 || lat < -90)
+            {
+                dxErrorProvider.SetError(@this, $"{msg}纬度范围[90,-90]!");
+                return false;
+            }
+            dxErrorProvider.SetError(@this, string.Empty);
+            return true;
+
+        }
         public static bool CheckLonLat(this TextEdit @this, DXErrorProvider dxErrorProvider, string msg)
         {
             if (string.IsNullOrWhiteSpace(@this.Text.Trim()))

+ 8 - 0
DataSimulation.Forms/Images/Cancel.svg

@@ -0,0 +1,8 @@
+<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+	 viewBox="0 0 32 32" style="enable-background:new 0 0 32 32;" xml:space="preserve">
+<style type="text/css">
+	.Red{fill:#D11C1C;}
+</style>
+<path class="Red" d="M16,2C8.3,2,2,8.3,2,16s6.3,14,14,14s14-6.3,14-14S23.7,2,16,2z M23,20l-3,3l-4-4l-4,4l-3-3l4-4l-4-4l3-3l4,4
+	l4-4l3,3l-4,4L23,20z"/>
+</svg>

+ 16 - 0
DataSimulation.Forms/Images/Ok.svg

@@ -0,0 +1,16 @@
+<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+	 viewBox="0 0 32 32" style="enable-background:new 0 0 32 32;" xml:space="preserve">
+<style type="text/css">
+	.Blue{fill:#1177D7;}
+	.Yellow{fill:#FFB115;}
+	.Black{fill:#727272;}
+	.Green{fill:#039C23;}
+	.Red{fill:#D11C1C;}
+	.st0{opacity:0.75;}
+	.st1{opacity:0.5;}
+</style>
+<g id="CheckCircled">
+	<path class="Green" d="M16,4C9.4,4,4,9.4,4,16c0,6.6,5.4,12,12,12s12-5.4,12-12C28,9.4,22.6,4,16,4z M14,22l-6-6l2-2l4,4l8-8l2,2
+		L14,22z"/>
+</g>
+</svg>

+ 3 - 0
DataSimulation.Forms/MainForm.Designer.cs

@@ -90,6 +90,7 @@
             this.btnXl.Id = 2;
             this.btnXl.ImageOptions.SvgImage = ((DevExpress.Utils.Svg.SvgImage)(resources.GetObject("btnXl.ImageOptions.SvgImage")));
             this.btnXl.Name = "btnXl";
+            this.btnXl.ItemClick += new DevExpress.XtraBars.ItemClickEventHandler(this.btn_ItemClick);
             // 
             // btnSat
             // 
@@ -105,6 +106,7 @@
             this.btnTx.Id = 4;
             this.btnTx.ImageOptions.SvgImage = ((DevExpress.Utils.Svg.SvgImage)(resources.GetObject("btnTx.ImageOptions.SvgImage")));
             this.btnTx.Name = "btnTx";
+            this.btnTx.ItemClick += new DevExpress.XtraBars.ItemClickEventHandler(this.btn_ItemClick);
             // 
             // btnRef
             // 
@@ -112,6 +114,7 @@
             this.btnRef.Id = 5;
             this.btnRef.ImageOptions.SvgImage = ((DevExpress.Utils.Svg.SvgImage)(resources.GetObject("btnRef.ImageOptions.SvgImage")));
             this.btnRef.Name = "btnRef";
+            this.btnRef.ItemClick += new DevExpress.XtraBars.ItemClickEventHandler(this.btn_ItemClick);
             // 
             // ribbonPage1
             // 

+ 1 - 1
DataSimulation.Forms/MainForm.cs

@@ -25,7 +25,7 @@ namespace DataSimulation.Forms
             ctrlTypes.Add("任务管理", typeof(CtrlHome));
             ctrlTypes.Add("星历管理", typeof(CtrlXl));
             ctrlTypes.Add("卫星管理", typeof(CtrlSat));
-            ctrlTypes.Add("天线管理", typeof(CtrlSat));
+            ctrlTypes.Add("天线管理", typeof(CtrlAnt));
             ctrlTypes.Add("参考站管理", typeof(CtrlSat));
             btn_ItemClick(null, null);
         }

+ 4 - 16
DataSimulation.Forms/UserControl/CtrlAnt.cs

@@ -55,18 +55,14 @@ namespace DataSimulation.Forms.UserControl
             popupMenu1.ShowPopup(MousePosition);
         }
 
-        private async void btnAdd_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        private  void btnAdd_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
         {
             try
             {
                 AntEditor frm = new AntEditor();
                 if (frm.ShowDialog() != DialogResult.OK) return;
                 var addItem = frm.info;
-                using (SimulationContext db = new SimulationContext())
-                {
-                    db.AntInfos.Add(addItem);
-                    await db.SaveChangesAsync();
-                }
+              
                 list.Add(addItem);
                 gridView1.RefreshData();
             }
@@ -76,22 +72,14 @@ namespace DataSimulation.Forms.UserControl
                 DxHelper.MsgBoxHelper.ShowError("添加天线信息异常");
             }
         }
-        private async void btnEdit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        private  void btnEdit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
         {
             try
             {
                 var editItem = gridView1.GetFocusedRow() as AntInfo;
                 AntEditor frm = new AntEditor(editItem);
                 if (frm.ShowDialog() != DialogResult.OK) return;
-                editItem = frm.info;
-                using (SimulationContext db = new SimulationContext())
-                {
-                    var find = await db.AntInfos.Where(p => p.ID == editItem.ID).FirstOrDefaultAsync();
-                    find.AntName = editItem.AntName;
-                    find.AntLon = editItem.AntLon;
-                    find.AntLat = editItem.AntLat;
-                    await db.SaveChangesAsync();
-                }
+          
                 gridView1.RefreshData();
             }
             catch (Exception ex)

+ 2 - 16
DataSimulation.Forms/UserControl/CtrlSat.cs

@@ -55,18 +55,13 @@ namespace DataSimulation.Forms.UserControl
             popupMenu1.ShowPopup(MousePosition);
         }
 
-        private async void btnAdd_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        private void btnAdd_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
         {
             try
             {
                 SatEditor frm = new SatEditor();
                 if (frm.ShowDialog() != DialogResult.OK) return;
                 var addItem = frm.info;
-                using (SimulationContext db = new SimulationContext())
-                {
-                    db.SatInfos.Add(addItem);
-                    await db.SaveChangesAsync();
-                }
                 list.Add(addItem);
                 gridView1.RefreshData();
             }
@@ -76,22 +71,13 @@ namespace DataSimulation.Forms.UserControl
                 DxHelper.MsgBoxHelper.ShowError("添加卫星信息异常");
             }
         }
-        private async void btnEdit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        private  void btnEdit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
         {
             try
             {
                 var editItem = gridView1.GetFocusedRow() as SatInfo;
                 SatEditor frm = new SatEditor(editItem);
                 if (frm.ShowDialog() != DialogResult.OK) return;
-                editItem = frm.info;
-                using (SimulationContext db = new SimulationContext())
-                {
-                    var find = await db.SatInfos.Where(p => p.ID == editItem.ID).FirstOrDefaultAsync();
-                    find.SatName = editItem.SatName;
-                    find.SatCode = editItem.SatCode;
-                    find.SatLon = editItem.SatLon;
-                    await db.SaveChangesAsync();
-                }
                 gridView1.RefreshData();
             }
             catch (Exception ex)

+ 12 - 2
DataSimulation.Repostory/Model/AntInfo.cs

@@ -4,6 +4,7 @@ using System.Collections.Generic;
 using System.ComponentModel.DataAnnotations;
 using System.ComponentModel.DataAnnotations.Schema;
 using System.Linq;
+using System.Runtime.Remoting.Metadata.W3cXsd2001;
 using System.Text;
 using System.Threading.Tasks;
 
@@ -18,10 +19,19 @@ namespace DataSimulation.Repostory.Model
         [Display(Name = "天线名称")]
         public string AntName { get; set; }
 
-        [Display(Name = "天线经度")]
+        [Display(Name = "天线经度(°)")]
         public double AntLon { get; set; }
 
-        [Display(Name = "天线纬度")]
+        [Display(Name = "天线纬度(°)")]
         public double AntLat { get; set; }
+
+        [Display(Name = "天线", AutoGenerateField = false)]
+        public string Ant
+        {
+            get
+            {
+                return $"{AntName}[{AntLon},{AntLat}]°";
+            }
+        }
     }
 }

+ 11 - 2
DataSimulation.Repostory/Model/RefInfo.cs

@@ -15,10 +15,19 @@ namespace DataSimulation.Repostory.Model
         [Display(Name = "参考站名称")]
         public string RefName { get; set; }
 
-        [Display(Name = "参考站经度")]
+        [Display(Name = "参考站经度(°)")]
         public double RefLon { get; set; }
 
-        [Display(Name = "参考站纬度")]
+        [Display(Name = "参考站纬度(°)")]
         public double RefLat { get; set; }
+
+        [Display(Name = "参考站", AutoGenerateField = false)]
+        public string Ref
+        {
+            get
+            {
+                return $"{RefName}[{RefLon},{RefLat}]°";
+            }
+        }
     }
 }

+ 2 - 2
DataSimulation.Repostory/Model/SatInfo.cs

@@ -17,10 +17,10 @@ namespace DataSimulation.Repostory.Model
         [Display(Name = "卫星名称")]
         public string SatName { get; set; }
 
-        [Display(Name = "轨道经度")]
+        [Display(Name = "轨道经度(°)")]
         public double? SatLon { get; set; }
 
-        [Display(Name = "卫星")]
+        [Display(Name = "卫星", AutoGenerateField = false)]
         public string Sat
         {
             get