Explorar o código

添加批量删除和使用镜像点

wyq hai 1 ano
pai
achega
6190703682

+ 24 - 0
XdCxRhDW.App/Image/Pos.svg

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 21.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
+<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">
+	.Black{fill:#727272;}
+	.Green{fill:#039C23;}
+	.Yellow{fill:#FFB115;}
+	.Blue{fill:#1177D7;}
+	.Red{fill:#D11C1C;}
+</style>
+<g id="Handwheel">
+	<path class="Blue" d="M29,14h-3.1c-0.2-2.3-1.1-4.4-2.5-6l2.2-2.2c0.4-0.4,0.4-1,0-1.4s-1-0.4-1.4,0L22,6.5c-1.7-1.4-3.8-2.3-6-2.5
+		V1c0-0.5-0.4-1-1-1s-1,0.5-1,1v3.1c-2.3,0.2-4.4,1.1-6,2.5L5.8,4.4C5.4,4,4.8,4,4.4,4.4s-0.4,1,0,1.4L6.5,8c-1.4,1.7-2.3,3.8-2.5,6
+		H1c-0.6,0-1,0.5-1,1s0.4,1,1,1h3.1c0.2,2.3,1.1,4.4,2.5,6l-2.2,2.2c-0.4,0.4-0.4,1,0,1.4s1,0.4,1.4,0L8,23.5c1.7,1.4,3.8,2.3,6,2.5
+		V29c0,0.5,0.4,1,1,1s1-0.5,1-1v-3.1c2.3-0.2,4.4-1.1,6-2.5l2.2,2.2c0.4,0.4,1,0.4,1.4,0s0.4-1,0-1.4L23.5,22c1.4-1.7,2.3-3.8,2.5-6
+		H29c0.6,0,1-0.5,1-1S29.6,14,29,14z M16,6.1c1.7,0.2,3.3,0.9,4.6,1.9l-2.9,2.9c-0.5-0.3-1.1-0.6-1.8-0.7V6.1z M14,6.1v4
+		c-0.6,0.1-1.2,0.4-1.8,0.7L9.4,8C10.7,6.9,12.3,6.3,14,6.1z M8,9.4l2.9,2.9c-0.3,0.5-0.6,1.1-0.7,1.8h-4C6.3,12.3,6.9,10.7,8,9.4z
+		 M6.1,16h4c0.1,0.6,0.4,1.2,0.7,1.8L8,20.6C6.9,19.3,6.3,17.7,6.1,16z M14,23.9c-1.7-0.2-3.3-0.9-4.6-1.9l2.9-2.9
+		c0.5,0.3,1.1,0.6,1.8,0.7V23.9z M15,18c-1.7,0-3-1.3-3-3s1.3-3,3-3s3,1.3,3,3S16.7,18,15,18z M16,23.9v-4c0.6-0.1,1.2-0.4,1.8-0.7
+		l2.9,2.9C19.3,23.1,17.7,23.7,16,23.9z M22,20.6l-2.9-2.9c0.3-0.5,0.6-1.1,0.7-1.8h4C23.7,17.7,23.1,19.3,22,20.6z M19.9,14
+		c-0.1-0.6-0.4-1.2-0.7-1.8L22,9.4c1,1.3,1.7,2.9,1.9,4.6H19.9z"/>
+</g>
+</svg>

+ 97 - 1
XdCxRhDW.App/UserControl/CtrlHome.cs

@@ -27,6 +27,8 @@ using XdCxRhDW.WebApi;
 using XdCxRhDW.Core.ObServer;
 using DevExpress.XtraBars.Docking2010;
 using ExtensionsDev;
+using DevExpress.XtraEditors;
+using System.Data.Entity.Migrations;
 namespace XdCxRhDW.App.UserControl
 {
     public partial class CtrlHome : DevExpress.XtraEditors.XtraUserControl
@@ -112,7 +114,14 @@ namespace XdCxRhDW.App.UserControl
                     var txres = await db.TxInfos.ToListAsync();
                     txList.AddRange(txres);
                 }
-
+                mapControl1.AddRectMenu<PosRes>("删除定位点", SvgHelper.CreateClose(), items =>
+                {
+                    DeletePosRes(items);
+                });
+                mapControl1.AddRectMenu<PosRes>("使用镜像点", SvgHelper.LoadFromFile("Image\\Pos.svg"), items =>
+                   {
+                       UseMirr(items);
+                   });
                 mapControl1.AddPosMenu<PosRes>("绘制时差线", SvgHelper.LoadFromFile("Image\\DtoLine.svg"), item =>
                 {
                     DrawDtoLine(item);
@@ -245,7 +254,94 @@ namespace XdCxRhDW.App.UserControl
 
             WaitHelper.CloseForm();
         }
+        private async void UseMirr(IEnumerable<PosRes> items)
+        {
+            if (items == null || items.Count() == 0)
+            {
+                DxHelper.MsgBoxHelper.ShowWarning($"请选择需要使用镜像点的定位数据信息!");
+                return;
+            }
+            try
+            {
+                if (XtraMessageBox.Show("确认使用镜像点?", "确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
+                {
+                    return;
+                }
+                var posItems = mapControl1.GetRectPosItem<PosRes>().ToList();
+                var ids = posItems.Select(m => m.ID).ToList();
+                using (RHDWContext db = new RHDWContext())
+                {
+                    List<PosRes> list = await db.PosRes.Where(p => ids.Contains(p.ID)).ToListAsync();
+                    UpdatePosRes(list);
+                    db.PosRes.AddOrUpdate(list.ToArray());
+                    await db.SaveChangesAsync();
+
+                    UpdatePosRes(posItems);
+                    mapControl1.UpdatePosItem(posItems);
+                }
+                gridView2.RefreshData();
+            }
+            catch (Exception ex)
+            {
+                Serilog.Log.Error("使用镜像点失败", ex);
+                XtraMessageBox.Show("使用镜像点失败");
+            }
+
+        }
+        private async void DeletePosRes(IEnumerable<PosRes> items)
+        {
+            if (items == null || items.Count() == 0)
+            {
+                DxHelper.MsgBoxHelper.ShowWarning($"请选择需要删除的定位数据信息!");
+                return;
+            }
+            try
+            {
+                if (XtraMessageBox.Show("确认删除定位点?", "确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
+                {
+                    return;
+                }
+                var positems = mapControl1.GetRectPosItem<PosRes>().ToList();
+                var ids = positems.Select(m => m.ID).ToList();
+
+                using (RHDWContext db = new RHDWContext())
+                {
+                    List<PosRes> list = await db.PosRes.Where(p => ids.Contains(p.ID)).ToListAsync();
+                    foreach (var item in ids)
+                    {
+                        var posres = list.Find(m => m.ID == item);
+                        db.PosRes.Remove(posres);
+                    }
+                    await db.SaveChangesAsync();
+                    // mapControl1.DelPosItem(items);
+                }
+                var ds = this.gridHomePosRes.DataSource as List<PosRes>;
+                int count = ds.RemoveAll(m => ids.Contains(m.ID));
+                gridView2.RefreshData();
+            }
+            catch (Exception ex)
+            {
+                Serilog.Log.Error("删除定位点失败", ex);
+                XtraMessageBox.Show("删除定位点失败");
+            }
+        }
+        private void UpdatePosRes(IEnumerable<PosRes> pos)
+        {
+            foreach (var item in pos)
+            {
+                var mirrlon = item.MirrLon;
+                var mirrLat = item.MirrLat;
+                if (mirrlon == 999 && mirrLat == 999)
+                {
+                    continue;
+                }
+                item.MirrLon = item.PosLon;
+                item.MirrLat = item.PosLat;
+                item.PosLon = mirrlon;
+                item.PosLat = mirrLat;
+            }
 
+        }
         private async void GridView1_FocusedRowObjectChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventArgs e)
         {
             mapControl1.DelFixedImg("Sat");

+ 3 - 0
XdCxRhDW.App/XdCxRhDW.App.csproj

@@ -586,6 +586,9 @@
     <Content Include="Image\GDOP.svg">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>
+    <Content Include="Image\Pos.svg">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
     <Content Include="xcorr\dmc.exe">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>