虚拟飞机用蓝色,真实飞机绿色
灯光模拟间隔不能低于1秒的bug 真实飞机替代虚拟飞机,虚拟飞机不能替代真实飞机
This commit is contained in:
parent
3efb9b719d
commit
7c71016e0c
@ -261,6 +261,13 @@ namespace Plane.FormationCreator
|
||||
lock(locker)
|
||||
{
|
||||
var copter = _copterManager.Copters.FirstOrDefault(c => c.Id == id.ToString());
|
||||
if ((copter != null)&&(copter is FakeCopter))
|
||||
{
|
||||
_copterManager.Copters.Remove(copter);
|
||||
copter = null;
|
||||
}
|
||||
|
||||
|
||||
if (copter == null)
|
||||
{
|
||||
if (_copterManager.EnAddCopter_Real())
|
||||
@ -273,6 +280,7 @@ namespace Plane.FormationCreator
|
||||
Id = id.ToString(),
|
||||
Name = id.ToString(),
|
||||
};
|
||||
copter.VirtualId = 0;
|
||||
int _index;
|
||||
_index = _copterManager.Copters.AddCopter(copter);
|
||||
copterStatus.Insert(_index, false);
|
||||
|
@ -17,12 +17,22 @@ namespace Plane.FormationCreator.Converters
|
||||
private static SolidColorBrush _zeroBrush = new SolidColorBrush(Color.FromArgb(125, 125, 125, 125));
|
||||
private static SolidColorBrush _oneBrush = Copter.DefaultBrush;
|
||||
|
||||
private static SolidColorBrush _FakeCopterBrush = Copter.DefaultFakeBrush;
|
||||
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (values[0] == DependencyProperty.UnsetValue) return _zeroBrush;
|
||||
var heartbeatCount = (ulong)values[0];
|
||||
if (heartbeatCount % 2 == 0) return _zeroBrush;
|
||||
|
||||
if (values[1] is FakeCopter)
|
||||
return _FakeCopterBrush;
|
||||
|
||||
if (values[1] is PLCopter)
|
||||
return _oneBrush;
|
||||
|
||||
var copter = values[1] as Copter;
|
||||
|
||||
return copter == null ? _oneBrush : copter.Brush;
|
||||
}
|
||||
|
||||
|
@ -43,8 +43,12 @@ namespace Plane.FormationCreator.Formation
|
||||
{
|
||||
return _brushIndex++ % _brushes.Length;
|
||||
}
|
||||
//真实飞机列表默认颜色
|
||||
internal static SolidColorBrush DefaultBrush { get; } = new SolidColorBrush(Color.FromRgb(50, 205, 50));
|
||||
//虚拟飞机列表默认颜色
|
||||
internal static SolidColorBrush DefaultFakeBrush { get; } = new SolidColorBrush(Color.FromRgb(28, 151, 234));
|
||||
|
||||
|
||||
internal static SolidColorBrush DefaultBrush { get; } = new SolidColorBrush(Color.FromRgb(28, 151, 234));
|
||||
private SolidColorBrush _Brush;
|
||||
public SolidColorBrush Brush
|
||||
{
|
||||
|
@ -90,6 +90,45 @@ namespace Plane.FormationCreator.Formation
|
||||
}
|
||||
else
|
||||
{
|
||||
//删除重复
|
||||
// if (entityObject is PLCopter)
|
||||
// {
|
||||
for (int i = 0; i < this.Count; i++)
|
||||
{
|
||||
if (sortbyid)
|
||||
{
|
||||
if (int.Parse(this[i].Id) == int.Parse(entityObject.Id))
|
||||
{
|
||||
if (this[i] is FakeCopter)
|
||||
Remove(this[i]);
|
||||
else
|
||||
{
|
||||
Message.Show($"无法加入飞机,已有重复的真实飞机ID[{this[i].Id}]!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
}else
|
||||
{
|
||||
|
||||
if ((entityObject.VirtualId!=0) &&(this[i].VirtualId == entityObject.VirtualId))
|
||||
{
|
||||
if (this[i] is FakeCopter)
|
||||
Remove(this[i]);
|
||||
else
|
||||
{
|
||||
Message.Show($"无法加入飞机,已有重复的真实飞机ID[{this[i].VirtualId}]!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
|
||||
bool isInsret = false;
|
||||
for (int i = 0; i < this.Count; i++)
|
||||
{
|
||||
@ -103,13 +142,15 @@ namespace Plane.FormationCreator.Formation
|
||||
_index = i;
|
||||
break;
|
||||
|
||||
}
|
||||
}else
|
||||
}
|
||||
}
|
||||
else
|
||||
//按VID排序插入
|
||||
{
|
||||
|
||||
if (this[i].VirtualId > entityObject.VirtualId)
|
||||
{
|
||||
|
||||
InsertItem(i, entityObject);
|
||||
isInsret = true;
|
||||
_index = i;
|
||||
@ -210,6 +251,35 @@ namespace Plane.FormationCreator.Formation
|
||||
netStatusChanged(Logined,Loginstate);
|
||||
}
|
||||
}
|
||||
public enum CopterSortType { ByID, ByVID, ByVIDShowAll };
|
||||
//排序类型
|
||||
private CopterSortType _SortType =0;
|
||||
public CopterSortType SortType
|
||||
{
|
||||
get { return _SortType; }
|
||||
set
|
||||
{
|
||||
Set(nameof(SortType), ref _SortType, value);
|
||||
switch (value)
|
||||
{
|
||||
case CopterSortType.ByID:
|
||||
sortbyid();
|
||||
break;
|
||||
case CopterSortType.ByVID:
|
||||
sortbyvid();
|
||||
break;
|
||||
case CopterSortType.ByVIDShowAll:
|
||||
sortbyvid(true);
|
||||
break;
|
||||
default:
|
||||
sortbyid();
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private int _EnCopterNumber = 0;
|
||||
@ -639,13 +709,21 @@ namespace Plane.FormationCreator.Formation
|
||||
/// <summary>
|
||||
/// 按VID重新排序飞机
|
||||
/// </summary>
|
||||
public void sortbyvid()
|
||||
public void sortbyvid(bool displayid=false)
|
||||
{
|
||||
List<ICopter> tempCopters = new List<ICopter>();
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 按原始ID重新排序飞机
|
||||
@ -657,6 +735,11 @@ namespace Plane.FormationCreator.Formation
|
||||
Copters.Clear();
|
||||
foreach (var copter in tempCopters)
|
||||
Copters.AddCopter(copter);
|
||||
foreach (var copter in Copters)
|
||||
{
|
||||
copter.DisplayVirtualId = false;
|
||||
copter.DisplayID = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ namespace Plane.FormationCreator.Formation
|
||||
LEDTestRun = true;
|
||||
foreach (LEDInfo vLEDInfo in LEDInfos)
|
||||
{
|
||||
Thread.Sleep((int)vLEDInfo.Delay * 1000);
|
||||
Thread.Sleep((int)(vLEDInfo.Delay * 1000));
|
||||
if (!LEDTestRun) break;
|
||||
_commModuleManager.LED_TaskAsync(vLEDInfo.LEDMode, vLEDInfo.LEDInterval, vLEDInfo.LEDTimes, vLEDInfo.LEDRGB, this.Copter);
|
||||
}
|
||||
|
@ -108,7 +108,9 @@ namespace Plane.FormationCreator.ViewModels
|
||||
copter.VirtualId = int.Parse(arrs[1]);
|
||||
}
|
||||
}
|
||||
Message.Show($"读入成功");
|
||||
|
||||
_copterManager.SortType = CopterManager.CopterSortType.ByVID;// .sortbyvid();
|
||||
Message.Show($"读入成功");
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
@ -169,16 +169,9 @@ namespace Plane.FormationCreator.ViewModels
|
||||
{
|
||||
return _SortbyVIdCommand ?? (_SortbyVIdCommand = new RelayCommand( () =>
|
||||
{
|
||||
_copterManager.sortbyvid();
|
||||
|
||||
|
||||
foreach (var copter in _copterManager.Copters)
|
||||
{
|
||||
copter.DisplayVirtualId = true;
|
||||
copter.DisplayID = false;
|
||||
}
|
||||
_copterManager.SortType = CopterManager.CopterSortType.ByVID;
|
||||
//强制刷新飞机显示
|
||||
// _copterManager.Copters.ForEach(copter => copter.RefreashLoc());
|
||||
// _copterManager.Copters.ForEach(copter => copter.RefreashLoc());
|
||||
|
||||
|
||||
}));
|
||||
@ -193,14 +186,10 @@ namespace Plane.FormationCreator.ViewModels
|
||||
{
|
||||
return _SortbyIdCommand ?? (_SortbyVIdCommand = new RelayCommand(() =>
|
||||
{
|
||||
_copterManager.sortbyid();
|
||||
foreach (var copter in _copterManager.Copters)
|
||||
{
|
||||
copter.DisplayVirtualId = false;
|
||||
copter.DisplayID = true;
|
||||
}
|
||||
_copterManager.SortType = CopterManager.CopterSortType.ByID;
|
||||
|
||||
//强制刷新飞机显示
|
||||
// _copterManager.Copters.ForEach(copter => copter.RefreashLoc());
|
||||
// _copterManager.Copters.ForEach(copter => copter.RefreashLoc());
|
||||
|
||||
}));
|
||||
}
|
||||
@ -223,24 +212,6 @@ namespace Plane.FormationCreator.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
bool showVirtualId = false;
|
||||
|
||||
private ICommand _SwitchIdVirtualIdCommand;
|
||||
public ICommand SwitchIdVirtualIdCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return _SwitchIdVirtualIdCommand ?? (_SwitchIdVirtualIdCommand = new RelayCommand(() =>
|
||||
{
|
||||
showVirtualId = !showVirtualId;
|
||||
foreach (var copter in _copterManager.Copters)
|
||||
{
|
||||
copter.DisplayVirtualId = showVirtualId;
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -251,11 +222,9 @@ namespace Plane.FormationCreator.ViewModels
|
||||
{
|
||||
return _ShowAllIDCommand ?? (_ShowAllIDCommand = new RelayCommand(() =>
|
||||
{
|
||||
foreach (var copter in _copterManager.Copters)
|
||||
{
|
||||
copter.DisplayVirtualId = true;
|
||||
copter.DisplayID = true;
|
||||
}
|
||||
|
||||
_copterManager.SortType = CopterManager.CopterSortType.ByVIDShowAll;
|
||||
|
||||
//强制刷新飞机显示
|
||||
// _copterManager.Copters.ForEach(copter => copter.RefreashLoc());
|
||||
|
||||
@ -367,6 +336,7 @@ namespace Plane.FormationCreator.ViewModels
|
||||
id: id,
|
||||
name: id
|
||||
);
|
||||
copter.VirtualId = _virtualCopterId;
|
||||
await copter.ConnectAsync();
|
||||
await copter.GetCopterDataAsync();
|
||||
_copterManager.Copters.AddCopter(copter);
|
||||
|
Loading…
Reference in New Issue
Block a user