gongqiuhong il y a 1 an
Parent
commit
cfbd8dbe8b

+ 1 - 0
XdCxRhDW.App/EditForms/SatEditor.cs

@@ -7,6 +7,7 @@ using System.Data;
 using System.Data.Entity;
 using System.Drawing;
 using System.Linq;
+using System.Runtime.Remoting.Metadata.W3cXsd2001;
 using System.Text;
 using System.Threading.Tasks;
 using System.Windows.Documents;

+ 9 - 8
XdCxRhDW.App/EditForms/TaskEditor.Designer.cs

@@ -28,16 +28,16 @@
         /// </summary>
         private void InitializeComponent()
         {
-            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.btnSave = new DevExpress.XtraEditors.SimpleButton();
             this.txtTaskName = new DevExpress.XtraEditors.TextEdit();
@@ -131,7 +131,6 @@
             this.txtPosType.Size = new System.Drawing.Size(393, 170);
             this.txtPosType.StyleController = this.layoutControl1;
             this.txtPosType.TabIndex = 5;
-            this.txtPosType.SelectedIndexChanged += new System.EventHandler(this.txtPosType_SelectedIndexChanged);
             this.txtPosType.EditValueChanged += new System.EventHandler(this.txtPosType_EditValueChanged);
             // 
             // txtFreq
@@ -139,7 +138,7 @@
             this.txtFreq.Location = new System.Drawing.Point(22, 418);
             this.txtFreq.Name = "txtFreq";
             this.txtFreq.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
-            new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Glyph, "MHz", -1, false, true, false, editorButtonImageOptions3, new DevExpress.Utils.KeyShortcut(System.Windows.Forms.Keys.None), serializableAppearanceObject9, serializableAppearanceObject10, serializableAppearanceObject11, serializableAppearanceObject12, "", null, null, DevExpress.Utils.ToolTipAnchor.Default)});
+            new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Glyph, "MHz", -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.txtFreq.Properties.MaskSettings.Set("MaskManagerType", typeof(DevExpress.Data.Mask.NumericMaskManager));
             this.txtFreq.Properties.MaskSettings.Set("MaskManagerSignature", "allowNull=False");
             this.txtFreq.Properties.MaskSettings.Set("mask", "f3");
@@ -152,7 +151,7 @@
             this.txtBand.Location = new System.Drawing.Point(220, 418);
             this.txtBand.Name = "txtBand";
             this.txtBand.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
-            new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Glyph, "MHz", -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, "MHz", -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.txtBand.Properties.MaskSettings.Set("MaskManagerType", typeof(DevExpress.Data.Mask.NumericMaskManager));
             this.txtBand.Properties.MaskSettings.Set("MaskManagerSignature", "allowNull=False");
             this.txtBand.Properties.MaskSettings.Set("mask", "f3");
@@ -306,6 +305,7 @@
             this.layoutControlItemAdja1.Text = "邻星1";
             this.layoutControlItemAdja1.TextLocation = DevExpress.Utils.Locations.Top;
             this.layoutControlItemAdja1.TextSize = new System.Drawing.Size(48, 14);
+            this.layoutControlItemAdja1.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
             // 
             // layoutControlItemAdja2
             // 
@@ -316,6 +316,7 @@
             this.layoutControlItemAdja2.Text = "邻星2";
             this.layoutControlItemAdja2.TextLocation = DevExpress.Utils.Locations.Top;
             this.layoutControlItemAdja2.TextSize = new System.Drawing.Size(48, 14);
+            this.layoutControlItemAdja2.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
             // 
             // layoutControlItem7
             // 

+ 59 - 19
XdCxRhDW.App/EditForms/TaskEditor.cs

@@ -12,6 +12,7 @@ using System.Data.Entity;
 using System.Drawing;
 using System.Linq;
 using System.Reflection;
+using System.Runtime.InteropServices;
 using System.Text;
 using System.Threading.Tasks;
 using System.Windows.Documents;
@@ -58,8 +59,21 @@ namespace XdCxRhDW.App.EditForms
             }
             if (this.Text == "编辑任务" && info != null)
             {
-                this.txtTaskName.Text = info.TaskName;
-                this.txtPosType.SelectedIndex = (int)info.PosType;
+                using (RHDWContext db = new RHDWContext())
+                {
+                    var satMain = await db.SatInfos.Where(w => w.SatCode == info.MainSat).FirstOrDefaultAsync();
+                    var satAdja1 = await db.SatInfos.Where(w => w.SatCode == info.Adja1Sat).FirstOrDefaultAsync();
+                    var satAdja2 = await db.SatInfos.Where(w => w.SatCode == info.Adja2Sat).FirstOrDefaultAsync();
+
+                    this.txtTaskName.Text = info.TaskName;
+                    this.txtPosType.SelectedIndex = (int)info.PosType;
+                    this.txtMainSat.EditValue = satMain;
+                    this.txtAdja1Sat.EditValue = satAdja1;
+                    this.txtAdja2Sat.EditValue = satAdja2;
+                    this.txtFreq.EditValue = info.Freq * 1e-6;
+                    this.txtBand.EditValue = info.Band * 1e-6;
+                }
+
             }
         }
 
@@ -71,10 +85,12 @@ namespace XdCxRhDW.App.EditForms
                 info.TaskName = txtTaskName.Text;
                 info.PosType = (EnumPosType)txtPosType.SelectedIndex;
                 info.MainSat = ((SatInfo)txtMainSat.EditValue).SatCode;
-                info.Adja1Sat = ((SatInfo)txtAdja1Sat.EditValue).SatCode;
-                info.Adja2Sat = ((SatInfo)txtAdja2Sat.EditValue).SatCode;
-                info.Freq = (long)((double)txtFreq.EditValue * 1e6);
-                info.Band = (int)((double)txtBand.EditValue * 1e6);
+                if (txtAdja1Sat.EditValue != null)
+                    info.Adja1Sat = ((SatInfo)txtAdja1Sat.EditValue).SatCode;
+                if (txtAdja2Sat.EditValue != null)
+                    info.Adja2Sat = ((SatInfo)txtAdja2Sat.EditValue).SatCode;
+                info.Freq = (long)(Convert.ToDouble(txtFreq.EditValue) * 1e6);
+                info.Band = (int)(Convert.ToDouble(txtBand.EditValue) * 1e6);
                 this.DialogResult = DialogResult.OK;
             }
             catch (Exception ex)
@@ -84,22 +100,46 @@ namespace XdCxRhDW.App.EditForms
             }
         }
 
-        private void txtPosType_SelectedIndexChanged(object sender, EventArgs e)
-        {
-            switch (txtPosType.SelectedIndex)
-            {
-                case 0:
-                    break;
-                case 1:
-                    break;
-                default:
-                    break;
-            }
-        }
 
         private void txtPosType_EditValueChanged(object sender, EventArgs e)
         {
-
+            RadioGroup posTypeRadioGroup = sender as RadioGroup;
+            var posType = (EnumPosType)posTypeRadioGroup.Properties.Items[posTypeRadioGroup.SelectedIndex].Value;
+            //var description = (EnumPosType)posType.Properties.Items[posType.SelectedIndex].Description;
+            if (posType == EnumPosType.X1D1CX)
+            {
+                layoutControlItemAdja1.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
+                layoutControlItemAdja2.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
+            }
+            else if (posType == EnumPosType.X2D1)
+            {
+                layoutControlItemAdja1.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
+                layoutControlItemAdja2.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
+            }
+            else if (posType == EnumPosType.RH)
+            {
+                layoutControlItemAdja1.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
+                layoutControlItemAdja2.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
+            }
+            else if (posType == EnumPosType.X3TwoDto)
+            {
+                layoutControlItemAdja1.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
+                layoutControlItemAdja2.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
+            }
+            else if (posType == EnumPosType.X3TwoDfo)
+            {
+                layoutControlItemAdja1.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
+                layoutControlItemAdja2.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
+            }
+            else if (posType == EnumPosType.X2Dfo)
+            {
+                layoutControlItemAdja1.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
+                layoutControlItemAdja2.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
+            }
+            else
+            {
+                return;
+            }
         }
     }
 }

+ 2 - 2
XdCxRhDW.Repostory/Model/TaskInfo.cs

@@ -26,10 +26,10 @@ namespace XdCxRhDW.Repostory.Model
         public int MainSat { get; set; }
 
         [Display(Name = "邻星1")]
-        public int Adja1Sat { get; set; }
+        public int? Adja1Sat { get; set; }
 
         [Display(Name = "邻星2")]
-        public int Adja2Sat { get; set; }
+        public int? Adja2Sat { get; set; }
 
         [Display(Name = "上行频点(Hz)")]
         public long Freq { get; set; }