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())