修改添加新飞机排序和显示id可能和之前不一致问题

This commit is contained in:
xu 2020-05-22 21:50:42 +08:00
parent 7c71016e0c
commit bbb7804831
4 changed files with 33 additions and 33 deletions

View File

@ -201,7 +201,7 @@ namespace Plane.FormationCreator
Name = vIPID // ip.Substring(ip.LastIndexOf('.') + 1) Name = vIPID // ip.Substring(ip.LastIndexOf('.') + 1)
}; };
int _index; int _index;
_index = copters.AddCopter(copter); _index = copters.AddCopter(copter, _copterManager.SortType);
copterStatus.Insert(_index, false); copterStatus.Insert(_index, false);
copter.TextReceived += Copter_TextReceived; copter.TextReceived += Copter_TextReceived;
@ -282,7 +282,7 @@ namespace Plane.FormationCreator
}; };
copter.VirtualId = 0; copter.VirtualId = 0;
int _index; int _index;
_index = _copterManager.Copters.AddCopter(copter); _index = _copterManager.Copters.AddCopter(copter, _copterManager.SortType);
copterStatus.Insert(_index, false); copterStatus.Insert(_index, false);
copter.TextReceived += Copter_TextReceived; copter.TextReceived += Copter_TextReceived;
} }

View File

@ -34,10 +34,10 @@ namespace Plane.FormationCreator.Formation
/// 实现排序插入 /// 实现排序插入
/// </summary> /// </summary>
/// <param name="baseSemObjects"></param> /// <param name="baseSemObjects"></param>
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 // 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++) 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)) 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++) for (int i = 0; i < this.Count; i++)
{ {
//按ID排序插入 //按ID排序插入
if (sortbyid) if (vSortType == CopterManager.CopterSortType.ByID)
{ {
if (int.Parse(this[i].Id) > int.Parse(entityObject.Id)) if (int.Parse(this[i].Id) > int.Parse(entityObject.Id))
{ {
@ -141,14 +141,12 @@ namespace Plane.FormationCreator.Formation
isInsret = true; isInsret = true;
_index = i; _index = i;
break; break;
} }
} }
else else
//按VID排序插入 //按VID排序插入
{ {
if (this[i].VirtualId > entityObject.VirtualId)
if (this[i].VirtualId > entityObject.VirtualId)
{ {
InsertItem(i, entityObject); InsertItem(i, entityObject);
@ -164,7 +162,13 @@ namespace Plane.FormationCreator.Formation
Add(entityObject); Add(entityObject);
_index = this.Count()-1 ; _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; return _index;
} }
} }
@ -715,15 +719,7 @@ namespace Plane.FormationCreator.Formation
tempCopters.AddRange(Copters); tempCopters.AddRange(Copters);
Copters.Clear(); Copters.Clear();
foreach (var copter in tempCopters) foreach (var copter in tempCopters)
Copters.AddCopter(copter,false); Copters.AddCopter(copter,SortType);
foreach (var copter in Copters)
{
copter.DisplayVirtualId = true;
copter.DisplayID = displayid;
}
} }
/// <summary> /// <summary>
/// 按原始ID重新排序飞机 /// 按原始ID重新排序飞机
@ -734,12 +730,8 @@ namespace Plane.FormationCreator.Formation
tempCopters.AddRange(Copters); tempCopters.AddRange(Copters);
Copters.Clear(); Copters.Clear();
foreach (var copter in tempCopters) foreach (var copter in tempCopters)
Copters.AddCopter(copter); Copters.AddCopter(copter,SortType);
foreach (var copter in Copters)
{
copter.DisplayVirtualId = false;
copter.DisplayID = true;
}
} }
} }

View File

@ -339,7 +339,7 @@ namespace Plane.FormationCreator.ViewModels
copter.VirtualId = _virtualCopterId; copter.VirtualId = _virtualCopterId;
await copter.ConnectAsync(); await copter.ConnectAsync();
await copter.GetCopterDataAsync(); await copter.GetCopterDataAsync();
_copterManager.Copters.AddCopter(copter); _copterManager.Copters.AddCopter(copter, _copterManager.SortType);
_copterManager.CopterStatus.Add(false); _copterManager.CopterStatus.Add(false);
} }
} }

View File

@ -269,16 +269,24 @@ namespace Plane.FormationCreator.Views
} }
} }
if (Copter.DisplayVirtualId) switch (_copterManager.SortType)
{ {
CopterText.Text = Copter.VirtualId.ToString(); case CopterManager.CopterSortType.ByID:
CopterText.Foreground = new SolidColorBrush(Colors.Yellow); CopterText.Text = Copter.Name;
} CopterText.Foreground = new SolidColorBrush(Colors.White);
else break;
{ case CopterManager.CopterSortType.ByVID:
CopterText.Text = Copter.Name; case CopterManager.CopterSortType.ByVIDShowAll:
CopterText.Foreground = new SolidColorBrush(Colors.White); 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()) if (Copter.GetShowLEDAsync())