lei zou hace 1 año
padre
commit
56e9462d86

+ 4 - 4
XdCxRhDW.App/CorTools/XlCalculateForm.cs

@@ -37,9 +37,9 @@ namespace XdCxRhDW.App.CorTools
 
         private async void XlCalculateForm_Load(object sender, EventArgs e)
         {
-            gridControl.Init().UseSort().UseFilter().UseMultiSelect().UseRowNumber();
+            gridControl.Init<SatEphDto>().UseSort().UseFilter().UseMultiSelect().UseRowNumber();
             gridControl.DataSource = list;
-            LoadData();
+            await LoadData();
             txtTle.UseDoubleClickToSelectAll();
             txtTle.UseDefault().SetStringData(resXl);
         }
@@ -63,7 +63,7 @@ namespace XdCxRhDW.App.CorTools
 
         private async void btnCalculate_Click(object sender, EventArgs e)
         {
-           
+
             if (!string.IsNullOrEmpty(txtEndTime.Text) && string.IsNullOrEmpty(txtSpanSeconds.Text))
             {
                 DxHelper.MsgBoxHelper.ShowInfo("请填写推算间隔");
@@ -72,7 +72,7 @@ namespace XdCxRhDW.App.CorTools
             var startTime = Convert.ToDateTime(txtStartTime.EditValue);
             var endTime = Convert.ToDateTime(txtEndTime.EditValue);
             if (!string.IsNullOrEmpty(txtStartTime.Text) && !string.IsNullOrEmpty(txtEndTime.Text))
-            {              
+            {
                 if (endTime < startTime)
                 {
                     DxHelper.MsgBoxHelper.ShowInfo("结束时间不能大于开始时间");

+ 1 - 1
XdCxRhDW.App/CpuCgTools/FormCpuCg.cs

@@ -65,7 +65,7 @@ namespace XdCxRhDw.CpuCgTools
 
         private void XtraForm1_Load(object sender, EventArgs e)
         {
-            gridControl1.Init().UseExportCsv().UseExportXlsx();
+            gridControl1.Init<CgRes>().UseExportCsv().UseExportXlsx();
             gridControl1.DataSource = list;
             txtF1.UseChooseFile();
             txtF2.UseChooseFile();

+ 4 - 0
XdCxRhDW.App/EditForms/TaskEditor.Designer.cs

@@ -139,6 +139,8 @@
             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, editorButtonImageOptions1, new DevExpress.Utils.KeyShortcut(System.Windows.Forms.Keys.None), serializableAppearanceObject1, serializableAppearanceObject2, serializableAppearanceObject3, serializableAppearanceObject4, "", null, null, DevExpress.Utils.ToolTipAnchor.Default)});
+            this.txtFreq.Properties.DisplayFormat.FormatString = "f3";
+            this.txtFreq.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
             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,6 +154,8 @@
             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, editorButtonImageOptions2, new DevExpress.Utils.KeyShortcut(System.Windows.Forms.Keys.None), serializableAppearanceObject5, serializableAppearanceObject6, serializableAppearanceObject7, serializableAppearanceObject8, "", null, null, DevExpress.Utils.ToolTipAnchor.Default)});
+            this.txtBand.Properties.DisplayFormat.FormatString = "f3";
+            this.txtBand.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
             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");

+ 2 - 2
XdCxRhDW.App/EditForms/TaskEditor.cs

@@ -70,8 +70,8 @@ namespace XdCxRhDW.App.EditForms
                     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;
+                    this.txtFreq.EditValue = info.Freq * (decimal)1e-6;
+                    this.txtBand.EditValue = info.Band * (decimal)1e-6;
                 }
             }
         }

+ 54 - 12
XdCxRhDW.App/ExtensionsDev/GridControlEx.cs

@@ -1,4 +1,5 @@
-using DevExpress.Utils;
+using DevExpress.Office.Crypto;
+using DevExpress.Utils;
 using DevExpress.Utils.Menu;
 using DevExpress.Utils.Svg;
 using DevExpress.XtraBars;
@@ -22,6 +23,7 @@ using System.Threading;
 using System.Threading.Tasks;
 using System.Windows.Forms;
 using System.Xml.Linq;
+using XdCxRhDW.Core;
 
 public static class GridControlEx
 {
@@ -38,8 +40,10 @@ public static class GridControlEx
     /// </summary>
     /// <param name="grid"></param>
     /// <param name="rowHeight"></param>
+    /// <typeparam name="T">绑定的数据源模型类型</typeparam>
+    /// <param name="searchLookUpEdit">searchLookUpEditd控件</param>
     /// <returns></returns>
-    public static GridControl Init(this GridControl grid, int rowHeight = 24)
+    public static GridControl Init<T>(this GridControl grid, int rowHeight = 24, Control searchLookUpEdit = null)
     {
         grid.MainView.BorderStyle = BorderStyles.Flat;
         var view = grid.MainView as GridView;
@@ -74,29 +78,67 @@ public static class GridControlEx
 
         view.PopupMenuShowing += View_PopupMenuShowing;
         view.OptionsSelection.EnableAppearanceFocusedCell = false;
+        string GetLayoutName()
+        {
+            Control ctrl;
+            if (searchLookUpEdit != null)
+                ctrl = searchLookUpEdit;
+            else
+                ctrl = grid;
+            while (ctrl.Parent != null)
+            {
+                ctrl = ctrl.Parent;
+                if (ctrl is UserControl) break;
+            }
+            var props = typeof(T).GetProperties();
+            StringBuilder sb = new StringBuilder();
+            foreach (var item in props)
+            {
+                sb.Append(item.Name);
+            }
+            var md5 = MD5Helper.StrToMD5(sb.ToString());
+            if (searchLookUpEdit != null)
+                return $"{ctrl.Name}_{searchLookUpEdit.Name}_{md5}";
+            else
+                return $"{ctrl.Name}_{grid.Name}_{md5}";
+        }
+        string name = GetLayoutName();
         grid.Load += (sender, e) =>
         {
-            var frm = grid.FindForm();
+            Form frm = null;
+            if (searchLookUpEdit == null)
+                frm = grid.FindForm();
+            else
+                frm = searchLookUpEdit.FindForm();
             if (frm != null)
             {
-                frm.FormClosing += (sender2, e2) =>
+                //frm.FormClosing += (sender2, e2) =>
+                //{
+                //    if (e2.CloseReason == CloseReason.UserClosing || e2.CloseReason == CloseReason.MdiFormClosing)
+                //    {
+                //        Directory.CreateDirectory("Layout");
+                //        if (name == null) return;
+                //        grid.MainView?.SaveLayoutToXml($"Layout\\{name}.xml", OptionsLayoutBase.FullLayout);
+                //    }
+                //};
+                frm.VisibleChanged += (sender2, e2) =>
                 {
-                    if (e2.CloseReason == CloseReason.UserClosing||e2.CloseReason== CloseReason.MdiFormClosing)
-                    {
-                        Directory.CreateDirectory("Layout");
-                        grid.MainView?.SaveLayoutToXml($"Layout\\{grid.Name}.xml", OptionsLayoutBase.FullLayout);
-                    }
+                    Directory.CreateDirectory("Layout");
+                    if (name == null) return;
+                    grid.MainView?.SaveLayoutToXml($"Layout\\{name}.xml", OptionsLayoutBase.FullLayout);
                 };
             }
         };
-        string file = $"Layout\\{grid.Name}.xml";
-        if (File.Exists(file))
-            view.RestoreLayoutFromXml(file, OptionsLayoutBase.FullLayout);
+        if (name != null && File.Exists($"Layout\\{name}.xml"))
+        {
+            view.RestoreLayoutFromXml($"Layout\\{name}.xml", OptionsLayoutBase.FullLayout);
+        }
         view.KeyUp += View_KeyUp;
         grid.Tag = new GridTag();
         return grid;
     }
 
+
     public static GridControl UseExportCsv(this GridControl grid)
     {
         GridTag tag = grid.Tag as GridTag;

+ 6 - 2
XdCxRhDW.App/ExtensionsDev/MapControlEx.cs

@@ -88,7 +88,7 @@ public static class MapControlEx
     private static GoogleMapType mMapType = GoogleMapType.Normal;
     private static List<MapControl> listMapCtrl = new List<MapControl>();
     private const int _dotSize = 8;
-    private const int _selectedDotSize = 16;
+    private const int _selectedDotSize = 12;
     public static MapControl SetMapLayerType(this MapControl ctrl, string wmsUrl)
     {
         if (!string.IsNullOrWhiteSpace(wmsUrl))
@@ -479,7 +479,11 @@ public static class MapControlEx
         if (clearDrawLayer)
             ctrl.ClearDrawObj();
         innerData.posStorge.Items.Clear();
-        if (items == null || !items.Any()) return;
+        if (items == null || !items.Any())
+        {
+            ctrl.Refresh();
+            return;
+        }
         List<MapDot> list = new List<MapDot>();
         for (int i = 0; i < items.Count(); i++)
         {

+ 15 - 12
XdCxRhDW.App/ExtensionsDev/SearchLookUpEditExtension.cs

@@ -34,7 +34,7 @@ namespace ExtensionsDev
             ctrl.Properties.ShowClearButton = showClearBtn;
             ctrl.Properties.ShowFooter = false;
             ctrl.Properties.ShowPopupShadow = true;
-            
+
             return ctrl;
         }
 
@@ -50,7 +50,7 @@ namespace ExtensionsDev
             ctrl.Properties.DataSource = data;
             GridView view = ctrl.Properties.View;
             view.OptionsView.ShowColumnHeaders = false;
-            view.GridControl.Init();
+            view.GridControl.Init<string>(searchLookUpEdit: ctrl);
             return ctrl;
         }
         /// <summary>
@@ -64,7 +64,7 @@ namespace ExtensionsDev
             ctrl.Properties.DataSource = data;
             GridView view = ctrl.Properties.View;
             view.OptionsView.ShowColumnHeaders = true;
-            view.GridControl.Init();
+            view.GridControl.Init<T>(searchLookUpEdit:ctrl);
             ctrl.CustomDisplayText += (sender, e) =>
             {
                 if (e.Value == null) return;
@@ -86,15 +86,18 @@ namespace ExtensionsDev
             var props = dataType.GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
             foreach (GridColumn column in view.Columns)
             {
-                var prop = props.First(p => p.Name == column.FieldName);
-                var attrDisplay = prop.GetCustomAttribute<DisplayAttribute>();
-                var attrDisplayName = prop.GetCustomAttribute<DisplayNameAttribute>();
-                if (attrDisplay == null && attrDisplayName == null)
-                    column.Visible = false;
-                else if (attrDisplay != null && attrDisplay.GetAutoGenerateFilter() != null && !attrDisplay.AutoGenerateFilter)
-                    column.Visible = false;
-                else
-                    column.Visible = true;
+                if (column.Visible)
+                {
+                    var prop = props.First(p => p.Name == column.FieldName);
+                    var attrDisplay = prop.GetCustomAttribute<DisplayAttribute>();
+                    var attrDisplayName = prop.GetCustomAttribute<DisplayNameAttribute>();
+                    if (attrDisplay == null && attrDisplayName == null)
+                        column.Visible = false;
+                    else if (attrDisplay != null && attrDisplay.GetAutoGenerateFilter() != null && !attrDisplay.AutoGenerateFilter)
+                        column.Visible = false;
+                    else
+                        column.Visible = true;
+                }
             }
 
         }

+ 1 - 1
XdCxRhDW.App/UserControl/CtrlCgRes.cs

@@ -31,7 +31,7 @@ namespace XdCxRhDW.App.UserControl
         {
             try
             {
-                gridCg.Init().UseSort().UseFilter().UseMultiSelect().UseRowNumber();
+                gridCg.Init<CgRes>().UseSort().UseFilter().UseMultiSelect().UseRowNumber();
                 using (RHDWContext db = new RHDWContext())
                 {
                     gridCg.DataSource = await db.CgRes.OrderByDescending(p => p.SigTime).ToListAsync();

+ 1 - 1
XdCxRhDW.App/UserControl/CtrlCxRes.cs

@@ -27,7 +27,7 @@ namespace XdCxRhDW.App.UserControl
         {
             try
             {
-                gridCx.Init().UseSort().UseFilter().UseMultiSelect().UseRowNumber();
+                gridCx.Init<CxRes>().UseSort().UseFilter().UseMultiSelect().UseRowNumber();
                 using (RHDWContext db = new RHDWContext())
                 {
                     gridCx.DataSource = await db.CxRes.OrderByDescending(p => p.SigTime).ToListAsync();

+ 13 - 3
XdCxRhDW.App/UserControl/CtrlHome.cs

@@ -25,6 +25,7 @@ using XdCxRhDW.Repostory.EFContext;
 using XdCxRhDW.Core.Api;
 using XdCxRhDW.WebApi;
 using XdCxRhDW.Core.ObServer;
+using DevExpress.XtraBars.Docking2010;
 namespace XdCxRhDW.App.UserControl
 {
     public partial class CtrlHome : DevExpress.XtraEditors.XtraUserControl
@@ -33,8 +34,8 @@ namespace XdCxRhDW.App.UserControl
         public CtrlHome()
         {
             InitializeComponent();
-            gridHomeTask.Init();
-            gridHomePosRes.Init().UseMultiSelect().UseRowNumber();
+            gridHomeTask.Init<TaskInfo>();
+            gridHomePosRes.Init<PosRes>().UseMultiSelect().UseRowNumber();
             btnDrawDto.ImageOptions.SvgImage = SvgHelper.LoadFromFile("Image\\DtoLine.svg");
             btnDrawDfo.ImageOptions.SvgImage = SvgHelper.LoadFromFile("Image\\DfoLine.svg");
             btnGDOP.ImageOptions.SvgImage = SvgHelper.LoadFromFile("Image\\GDOP.svg");
@@ -260,6 +261,7 @@ namespace XdCxRhDW.App.UserControl
             this.svgImageCollection1.Add("Running", SvgHelper.CreateCycle("#2E8B57"));
             gridView1.CustomDrawCell += GridView1_CustomDrawCell;
             gridView1.CustomColumnDisplayText += GridView1_CustomColumnDisplayText;
+            gridView1.RowClick += GridView1_RowClick;
             using (RHDWContext db = new RHDWContext())
             {
                 var settings = await db.SysSetings.FirstOrDefaultAsync();
@@ -298,6 +300,14 @@ namespace XdCxRhDW.App.UserControl
             WaitHelper.CloseForm();
         }
 
+        private void GridView1_RowClick(object sender, RowClickEventArgs e)
+        {
+            if (e.Clicks > 1)
+            {
+                layoutControlGroup1_CustomButtonClick(null,new BaseButtonEventArgs(new GroupBoxButton() { Caption="编辑任务"} ));
+            }
+        }
+
         private void GridView1_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
         {
             if (e.Column.FieldName == nameof(TaskInfo.Freq))
@@ -410,7 +420,7 @@ namespace XdCxRhDW.App.UserControl
             }
             popupMenu2.ShowPopup(MousePosition);
         }
-        private async void layoutControlGroup1_CustomButtonClick(object sender, DevExpress.XtraBars.Docking2010.BaseButtonEventArgs e)
+        private async void layoutControlGroup1_CustomButtonClick(object sender, BaseButtonEventArgs e)
         {
             var txt = (e.Button as GroupBoxButton).Caption;
             if (txt == "新建任务")

+ 1 - 1
XdCxRhDW.App/UserControl/CtrlPosRes.cs

@@ -29,7 +29,7 @@ namespace XdCxRhDW.App.UserControl
         {
             try
             {
-                gridPos.Init().UseSort().UseFilter().UseMultiSelect().UseRowNumber();
+                gridPos.Init<PosRes>().UseSort().UseFilter().UseMultiSelect().UseRowNumber();
                 using (RHDWContext db = new RHDWContext())
                 {
                     gridPos.DataSource = await db.PosRes.OrderByDescending(p => p.SigTime).ToListAsync();

+ 1 - 1
XdCxRhDW.App/UserControl/CtrlSat.cs

@@ -29,7 +29,7 @@ namespace XdCxRhDW.App.UserControl
         {
             try
             {
-                gridSat.Init().UseSort().UseFilter().UseMultiSelect().UseRowNumber();
+                gridSat.Init<SatInfo>().UseSort().UseFilter().UseMultiSelect().UseRowNumber();
                 gridSat.DataSource = list;
                 using (RHDWContext db = new RHDWContext())
                 {

+ 1 - 1
XdCxRhDW.App/UserControl/CtrlTarget.cs

@@ -29,7 +29,7 @@ namespace XdCxRhDW.App.UserControl
         {
             try
             {
-                gridTar.Init().UseSort().UseFilter().UseMultiSelect().UseRowNumber();
+                gridTar.Init<TargetInfo>().UseSort().UseFilter().UseMultiSelect().UseRowNumber();
                 gridTar.DataSource = list;
                 using (RHDWContext db = new RHDWContext())
                 {

+ 1 - 1
XdCxRhDW.App/UserControl/CtrlXl.cs

@@ -26,7 +26,7 @@ namespace XdCxRhDW.App.UserControl
         }
         private async void CtrlXl_Load(object sender, EventArgs e)
         {
-            gridXl.Init().UseSort().UseFilter().UseMultiSelect().UseRowNumber();
+            gridXl.Init<XlInfo>().UseSort().UseFilter().UseMultiSelect().UseRowNumber();
             gridXl.DataSource = list;
             await LoadData();
         }

+ 29 - 0
XdCxRhDW.Core/MD5Helper.cs

@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Security.Cryptography;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace XdCxRhDW.Core
+{
+    public class MD5Helper
+    {
+        public static string StrToMD5(string str)
+        {
+            MD5 md5 = MD5.Create();
+
+            byte[] c = System.Text.Encoding.Default.GetBytes(str);
+
+            byte[] b = md5.ComputeHash(c);//用来计算指定数组的hash值
+
+            //将每一个字节数组中的元素都tostring,在转成16进制
+            string newStr = null;
+            for (int i = 0; i < b.Length; i++)
+            {
+                newStr += b[i].ToString("X2");  //ToString(param);//传入不同的param可以转换成不同的效果
+            }
+            return newStr;
+        }     
+    }
+}

+ 1 - 0
XdCxRhDW.Core/XdCxRhDW.Core.csproj

@@ -62,6 +62,7 @@
     <Compile Include="Api\时差线\OutputHelper.cs" />
     <Compile Include="Api\频差线\DfoLineModel.cs" />
     <Compile Include="Api\频差线\DrawDfoLineHelper.cs" />
+    <Compile Include="MD5Helper.cs" />
     <Compile Include="HttpHelper.cs" />
     <Compile Include="IpHelper.cs" />
     <Compile Include="ObServer\PosObServer.cs" />