From bbb7804831b242ab8a11271d5845acc36732f549 Mon Sep 17 00:00:00 2001 From: xu Date: Fri, 22 May 2020 21:50:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B7=BB=E5=8A=A0=E6=96=B0?= =?UTF-8?q?=E9=A3=9E=E6=9C=BA=E6=8E=92=E5=BA=8F=E5=92=8C=E6=98=BE=E7=A4=BA?= =?UTF-8?q?id=E5=8F=AF=E8=83=BD=E5=92=8C=E4=B9=8B=E5=89=8D=E4=B8=8D?= =?UTF-8?q?=E4=B8=80=E8=87=B4=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Plane.FormationCreator/App.xaml.cs | 4 +-- .../Formation/CopterManager.cs | 36 ++++++++----------- .../ViewModels/CopterListViewModel.cs | 2 +- .../Views/MapView_CopterDrawing.cs | 24 ++++++++----- 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/Plane.FormationCreator/App.xaml.cs b/Plane.FormationCreator/App.xaml.cs index 1c51c57..ec0aab8 100644 --- a/Plane.FormationCreator/App.xaml.cs +++ b/Plane.FormationCreator/App.xaml.cs @@ -201,7 +201,7 @@ namespace Plane.FormationCreator Name = vIPID // ip.Substring(ip.LastIndexOf('.') + 1) }; int _index; - _index = copters.AddCopter(copter); + _index = copters.AddCopter(copter, _copterManager.SortType); copterStatus.Insert(_index, false); copter.TextReceived += Copter_TextReceived; @@ -282,7 +282,7 @@ namespace Plane.FormationCreator }; copter.VirtualId = 0; int _index; - _index = _copterManager.Copters.AddCopter(copter); + _index = _copterManager.Copters.AddCopter(copter, _copterManager.SortType); copterStatus.Insert(_index, false); copter.TextReceived += Copter_TextReceived; } diff --git a/Plane.FormationCreator/Formation/CopterManager.cs b/Plane.FormationCreator/Formation/CopterManager.cs index 7682aa9..35df9da 100644 --- a/Plane.FormationCreator/Formation/CopterManager.cs +++ b/Plane.FormationCreator/Formation/CopterManager.cs @@ -34,10 +34,10 @@ namespace Plane.FormationCreator.Formation /// 实现排序插入 /// /// - public int AddCopter(ICopter entityObject,bool sortbyid=true) + public int AddCopter(ICopter entityObject, CopterManager.CopterSortType vSortType) { ////给第三方时候限制数量和时间用 - DateTime dateTime2019 = DateTime.Parse("2020-06-01"); + DateTime dateTime2019 = DateTime.Parse("2020-08-01"); //新增飞机区域限制:内蒙 // if (entityObject.Latitude < 37.4307185218 || entityObject.Latitude > 45.6754821756 @@ -95,7 +95,7 @@ namespace Plane.FormationCreator.Formation // { for (int i = 0; i < this.Count; i++) { - if (sortbyid) + if (vSortType == CopterManager.CopterSortType.ByID) { if (int.Parse(this[i].Id) == int.Parse(entityObject.Id)) { @@ -133,7 +133,7 @@ namespace Plane.FormationCreator.Formation for (int i = 0; i < this.Count; i++) { //按ID排序插入 - if (sortbyid) + if (vSortType == CopterManager.CopterSortType.ByID) { if (int.Parse(this[i].Id) > int.Parse(entityObject.Id)) { @@ -141,14 +141,12 @@ namespace Plane.FormationCreator.Formation isInsret = true; _index = i; break; - } } else //按VID排序插入 { - - if (this[i].VirtualId > entityObject.VirtualId) + if (this[i].VirtualId > entityObject.VirtualId) { InsertItem(i, entityObject); @@ -164,7 +162,13 @@ namespace Plane.FormationCreator.Formation Add(entityObject); _index = this.Count()-1 ; } + + } + + entityObject.DisplayID = ((vSortType == CopterManager.CopterSortType.ByID) || (vSortType == CopterManager.CopterSortType.ByVIDShowAll)); + entityObject.DisplayVirtualId = ((vSortType == CopterManager.CopterSortType.ByVID) || (vSortType == CopterManager.CopterSortType.ByVIDShowAll)); + return _index; } } @@ -715,15 +719,7 @@ namespace Plane.FormationCreator.Formation tempCopters.AddRange(Copters); Copters.Clear(); foreach (var copter in tempCopters) - Copters.AddCopter(copter,false); - - foreach (var copter in Copters) - { - copter.DisplayVirtualId = true; - copter.DisplayID = displayid; - } - - + Copters.AddCopter(copter,SortType); } /// /// 按原始ID重新排序飞机 @@ -734,12 +730,8 @@ namespace Plane.FormationCreator.Formation tempCopters.AddRange(Copters); Copters.Clear(); foreach (var copter in tempCopters) - Copters.AddCopter(copter); - foreach (var copter in Copters) - { - copter.DisplayVirtualId = false; - copter.DisplayID = true; - } + Copters.AddCopter(copter,SortType); + } } diff --git a/Plane.FormationCreator/ViewModels/CopterListViewModel.cs b/Plane.FormationCreator/ViewModels/CopterListViewModel.cs index c00a5c0..1ede92c 100644 --- a/Plane.FormationCreator/ViewModels/CopterListViewModel.cs +++ b/Plane.FormationCreator/ViewModels/CopterListViewModel.cs @@ -339,7 +339,7 @@ namespace Plane.FormationCreator.ViewModels copter.VirtualId = _virtualCopterId; await copter.ConnectAsync(); await copter.GetCopterDataAsync(); - _copterManager.Copters.AddCopter(copter); + _copterManager.Copters.AddCopter(copter, _copterManager.SortType); _copterManager.CopterStatus.Add(false); } } diff --git a/Plane.FormationCreator/Views/MapView_CopterDrawing.cs b/Plane.FormationCreator/Views/MapView_CopterDrawing.cs index 7f4638e..9075b2b 100644 --- a/Plane.FormationCreator/Views/MapView_CopterDrawing.cs +++ b/Plane.FormationCreator/Views/MapView_CopterDrawing.cs @@ -269,16 +269,24 @@ namespace Plane.FormationCreator.Views } } - if (Copter.DisplayVirtualId) + switch (_copterManager.SortType) { - CopterText.Text = Copter.VirtualId.ToString(); - CopterText.Foreground = new SolidColorBrush(Colors.Yellow); - } - else - { - CopterText.Text = Copter.Name; - CopterText.Foreground = new SolidColorBrush(Colors.White); + case CopterManager.CopterSortType.ByID: + CopterText.Text = Copter.Name; + CopterText.Foreground = new SolidColorBrush(Colors.White); + break; + case CopterManager.CopterSortType.ByVID: + case CopterManager.CopterSortType.ByVIDShowAll: + CopterText.Text = Copter.VirtualId.ToString(); + CopterText.Foreground = new SolidColorBrush(Colors.Yellow); + break; + default: + CopterText.Text = Copter.Name; + CopterText.Foreground = new SolidColorBrush(Colors.White); + break; } + + if (Copter.GetShowLEDAsync())