按VID排序

修改自动编号逻辑
//目前方案是
                //1.保证所有没有正确定位的飞机都人工编号,
                //2.然后选中2-3架飞机,1号飞机,第一排任意飞机,第一列任意飞机(尽量远离1号机),
                //3.开始计算
修改3飞机信息通道数据改为电池图标,并且不让拖动修改
显示VID变换黄色,以前是红色
This commit is contained in:
xu 2020-02-03 23:44:55 +08:00
parent 00d03a0025
commit 1e38390fc6
8 changed files with 437 additions and 284 deletions

View File

@ -18,7 +18,7 @@ namespace Plane.FormationCreator.Formation
/// 实现排序插入
/// </summary>
/// <param name="baseSemObjects"></param>
public int AddCopter(ICopter entityObject)
public int AddCopter(ICopter entityObject,bool sortbyid=true)
{
////给第三方时候限制数量和时间用
DateTime dateTime2019 = DateTime.Parse("2020-03-01");
@ -50,14 +50,29 @@ namespace Plane.FormationCreator.Formation
bool isInsret = false;
for (int i = 0; i < this.Count; i++)
{
if ( int.Parse(this[i].Id) > int.Parse(entityObject.Id))
//if (String.Compare(this[i].Name, entityObject.Name, false) >= 0)
//按ID排序插入
if (sortbyid)
{
InsertItem(i, entityObject);
isInsret = true;
_index= i;
break;
if (int.Parse(this[i].Id) > int.Parse(entityObject.Id))
{
InsertItem(i, entityObject);
isInsret = true;
_index = i;
break;
}
}else
//按VID排序插入
{
if (this[i].VirtualId > entityObject.VirtualId)
{
InsertItem(i, entityObject);
isInsret = true;
_index = i;
break;
}
}
}
if (!isInsret)
@ -88,6 +103,8 @@ namespace Plane.FormationCreator.Formation
public List<ICopter> ShowCopter = new List<ICopter>();
public CopterCollection Copters { get;} = new CopterCollection();
public ArrayList CopterStatus = new ArrayList();
@ -149,6 +166,28 @@ namespace Plane.FormationCreator.Formation
{
_selectCopterAction(copter);
}
/// <summary>
/// 按VID重新排序飞机
/// </summary>
public void sortbyvid()
{
List<ICopter> tempCopters = new List<ICopter>();
tempCopters.AddRange(Copters);
Copters.Clear();
foreach (var copter in tempCopters)
Copters.AddCopter(copter,false);
}
/// <summary>
/// 按原始ID重新排序飞机
/// </summary>
public void sortbyid()
{
List<ICopter> tempCopters = new List<ICopter>();
tempCopters.AddRange(Copters);
Copters.Clear();
foreach (var copter in tempCopters)
Copters.AddCopter(copter);
}
}

View File

@ -10,6 +10,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using Microsoft.Practices.ServiceLocation;
namespace Plane.FormationCreator.ViewModels
{
@ -28,12 +29,7 @@ namespace Plane.FormationCreator.ViewModels
set { Set(nameof(SingleVirtualId), ref _SingleVirtualId, value); }
}
private int _SingleRowCount = 0;
public int SingleRowCount
{
get { return _SingleRowCount; }
set { Set(nameof(SingleRowCount), ref _SingleRowCount, value); }
}
/// <summary>
/// 清除所有编号
@ -88,250 +84,160 @@ namespace Plane.FormationCreator.ViewModels
{
get
{
return _AutoLocationNumsCommand ?? (_AutoLocationNumsCommand = new RelayCommand(async () =>
{
int colCount = SingleRowCount;
int copterCount = _copterManager.Copters.Count;
/*
if (copterCount % colCount != 0)
{
Alert.Show($"列数设置错误!");
return;
}
*/
//列数用户设置colCount
//计算行数rowCount
int rowCount = copterCount / colCount;
//有多的飞机,多一行
//有整除余,代表最后一行是否没有满
bool havemode = (copterCount % colCount != 0);
//if (havemode)
// rowCount++;
int num = 1;
//目前方案是 选中3架飞机1号飞机第一排任意飞机第一列任意飞机尽量远离1号机
//用于计算横向和纵向的角度
if (_copterManager.AcceptingControlCopters.Count() == 3)
{
var copters = _copterManager.AcceptingControlCopters.ToList();
var firstCopter = copters[0];
var secondCopter = copters[1];
var thirdCopter = copters[2];
// var fourthCopter = copters[3];
//第一列角度(1,3) 用于计算每行第一架飞机
float firstColDirect =(float) GeographyUtils.RadToDeg(firstCopter.CalcDirection2D(thirdCopter));
//最后列角度(2,4) 用于计算每行最后一架飞机
float lastColDirect =(float) GeographyUtils.RadToDeg(secondCopter.CalcDirection2D(fourthCopter));
//目前方案是
//1.保证所有没有正确定位的飞机都人工编号,
//2.然后选中3架飞机1号飞机第一排任意飞机第一列任意飞机尽量远离1号机
//3.开始计算
return _AutoLocationNumsCommand ?? (_AutoLocationNumsCommand = new RelayCommand( () =>
{
//飞机摆放最小间距
FlightTaskManager _flightTaskManager = ServiceLocator.Current.GetInstance<FlightTaskManager>();
float StepDis_Row = _flightTaskManager.ColumnDistance; //行内间距-列间距
float StepDis_Col = _flightTaskManager.RowDistance ; //列间距-行间距
float FindDis =Math.Min(StepDis_Row, StepDis_Col); //查找半径
if (_copterManager.AcceptingControlCopters.Count() >= 2)
{
var copters = _copterManager.AcceptingControlCopters.ToList();
var firstCopter = copters[0];
var secondCopter = copters[1];
ICopter thirdCopter=null;
if (_copterManager.AcceptingControlCopters.Count()>2)
thirdCopter = copters[2];
/*
// //四个角从1号机开始选取(第一排第一个1, 第一排最后2, 最后一排第一个3 , 最后一排最后4)
//第一列角度(1,3) 用于计算每行第一架飞机
float firstColazimuth = GeographyUtils.RadToDeg(GeographyUtils.CalcDirection2D(
firstCopter.Latitude, firstCopter.Longitude,
thirdCopter.Latitude, thirdCopter.Longitude));
//最后列角度(2,4) 用于计算每行最后一架飞机
float lastColazimuth = GeographyUtils.RadToDeg(GeographyUtils.CalcDirection2D(
secondCopter.Latitude, secondCopter.Longitude,
fourthCopter.Latitude, fourthCopter.Longitude));
*/
ICopter destCopter = null;
ICopter sourceCopter = null;
ICopter rowfirstCopter = null;
ICopter rowlastCopter = null;
//行头位置行尾位置用ILocation2D不用ICopter是因为可能没有飞机
ILocation2D rowLocfirst = null;
ILocation2D rowLoclast = null;
//行查找步长
int rowfindstep = 1;
//按行循环
for (int i = 0; i < rowCount; i++)
//行角度(1,2) 用于查找每行的飞机位置
float RowDirect = (float)GeographyUtils.RadToDeg(firstCopter.CalcDirection2D(secondCopter));
//列角度(1,3) 用于查找每行第一架飞机
float ColDirect = 0;
if (thirdCopter!=null)
ColDirect = (float)GeographyUtils.RadToDeg(firstCopter.CalcDirection2D(thirdCopter));
ICopter FindedCopter = firstCopter;
ICopter LastCopter = firstCopter;
ILocation2D LastRowHewadCopter = firstCopter;
firstCopter.VirtualId = 1;
while (FindedCopter!=null)
{
//第一行开始结束是12
if (i == 0)
{
rowfirstCopter = firstCopter;
rowLocfirst = rowfirstCopter;
rowlastCopter = secondCopter;
rowLoclast = rowlastCopter;
}
//最后一行3,4
else if (i == rowCount - 1)
{
rowfirstCopter = thirdCopter;
rowLocfirst = rowfirstCopter;
rowlastCopter = fourthCopter;
rowLoclast = rowlastCopter;
}
else
//中间的行找该行的第一架和最后一架飞机
{
rowLocfirst=rowLocfirst.CalcLatLngSomeMetersAway2D(firstColDirect, 1.5f);
rowLoclast = rowLoclast.CalcLatLngSomeMetersAway2D(firstColDirect, 1.5f);
rowLocfirst.CalcLatLngSomeMetersAway2D(firstColDirect, 1.5f);
rowfirstCopter = FindNextCopter(rowLocfirst, firstColDirect, 1);
rowlastCopter = FindNextCopter(rowLoclast, lastColDirect, 1);
}
if (rowfirstCopter == null)
Message.Show($"无法找到第{i + 1}行的起始飞机");
if (rowlastCopter == null)
Message.Show($"无法找到第{i + 1}行的结束飞机");
rowfindstep = 1;
//每一行按列循环
for (int j = 0; j < colCount; j++)
{
//计算每一行方向
double curRowAzimuth = GeographyUtils.RadToDeg(GeographyUtils.CalcDirection2D(
rowfirstCopter.Latitude, rowfirstCopter.Longitude,
rowlastCopter.Latitude, rowlastCopter.Longitude));
if (j == 0)
{
destCopter = rowfirstCopter;
sourceCopter = rowfirstCopter;
}
else if (j == colCount - 1)
{
destCopter = rowlastCopter;
}
else
//按行查找飞机
{
ICopter tempCopter = null;
tempCopter = _copterManager.Copters.FirstOrDefault(o => o.VirtualId == num);
while (tempCopter != null)
{
num++;
j++;
tempCopter = _copterManager.Copters.FirstOrDefault(o => o.VirtualId == num);
}
//根据当前飞机destCopter按curRowAzimuth方向按间距1.5米找下一个飞机
destCopter = FindNextCopter(sourceCopter, curRowAzimuth, rowfindstep);
if (destCopter == null)
{
Message.Show($"在寻找第{num}号位置时候无法找到对应位置飞机");
//增加步长继续找
rowfindstep++;
//Alert.Show($"在寻找第{num}号位置时候无法找到对应位置飞机");
//return;
}
else
{
rowfindstep = 1;
sourceCopter = destCopter;
}
}
if (destCopter != null)
{
//赋予虚拟ID
destCopter.VirtualId = num;
Message.Show($"飞机{destCopter.Name} 虚拟ID = {destCopter.VirtualId}");
}
num++;
}
//按一行找飞机
FindedCopter = FindNextCopter(LastCopter, RowDirect, StepDis_Row, FindDis);
//一行找不到了 找下一行的前3架飞机
if ((FindedCopter == null)&&(thirdCopter!=null))
FindedCopter = FindNextColHeadCopter(out LastRowHewadCopter,LastRowHewadCopter, ColDirect, StepDis_Col, RowDirect, StepDis_Row, 3, FindDis);
//如果找到了分配ID
if (FindedCopter != null)
{
FindedCopter.VirtualId = GetVID(LastCopter.VirtualId);
Message.Show($"分配飞机VID:{FindedCopter.VirtualId}");
LastCopter = FindedCopter;
}
}
}
await Task.Delay(10);
}
}));
}
}
private ICopter FindNextCopter(ILocation2D startLoc, double azimuth, int findstep)
//根据位置和查找范围查找飞机
private ICopter FindCopteratLoc(ILocation2D startLoc, float findDis)
{
ICopter retCopter = null;
bool foundCopter = false;
float stepLength = 0;
double mindis = 500.0f;
while (!foundCopter)
ICopter foundCopter = null;
double mindis = 1000;
//所有没有虚拟ID的飞机
List<ICopter> NoVIDCopters = _copterManager.Copters.Where(o => o.VirtualId == 0).ToList();
//找距离startLoc最近的飞机
foreach (var copter in NoVIDCopters)
{
mindis = 500.0f;
stepLength += 1.5f * findstep;
//计算startCopter按azimuth方向移动stepLength后的位置targetLatLng
Tuple<double, double> targetLatLng = GeographyUtils.CalcLatLngSomeMetersAway2D(
startLoc.Latitude, startLoc.Longitude, (float)azimuth, stepLength);
//所有没有虚拟ID的飞机
List<ICopter> remainCopters = _copterManager.Copters.Where(o => o.VirtualId == 0).ToList();
foreach (var copter in remainCopters)
//计算这些飞机和startLoc的距离
double temp = startLoc.CalcDistance2D(copter);
//找最近的飞机
if (temp < mindis)
{
//计算这些飞机和targetLatLng的距离
double temp = GeographyUtils.CalcDistance2D(copter.Latitude, copter.Longitude,
targetLatLng.Item1, targetLatLng.Item2);
//找最近的飞机
if (temp < mindis)
{
mindis = temp;
retCopter = copter;
}
//如果目标点最近未标注飞机小于1米就认为找到了
if (mindis < 1.0)
{
foundCopter = true;
retCopter = copter;
break;
}
}
//不找更多步长
break;
if (stepLength > 15)
{
break;
mindis = temp;
foundCopter = copter;
}
}
if (foundCopter)
return retCopter;
else
return null;
//如果找到的最近的飞机小于查找半径就认为找到了
if (mindis < findDis)
retCopter = foundCopter;
return retCopter;
}
//根据当前位置和角度距离查找下一个位置
private ILocation2D FindNextLocal(ILocation2D startLoc, float directionDegrees, float distance)
//根据VID查找飞机
private ICopter FindCopteratVID(int VID)
{
ILocation2D retLoc = null;
List<ICopter> HaveVIDCopters = _copterManager.Copters.Where(o => o.VirtualId == VID).ToList();
if (HaveVIDCopters.Count==1)
return HaveVIDCopters[0];
return null;
}
//计算startCopter按azimuth方向移动stepLength后的位置targetLatLng
Tuple<double, double> targetLatLng = GeographyUtils.CalcLatLngSomeMetersAway2D(
startLoc.Latitude, startLoc.Longitude, directionDegrees, distance);
return retLoc;
//计算VID,找下一个没有提前分配的VID
private int GetVID(int VirtualId)
{
int retvid = VirtualId+1;
ICopter Copter = FindCopteratVID(retvid);
while (Copter!=null)
Copter = FindCopteratVID(++retvid);
return retvid;
}
/// <summary>
/// 按方向步长等找下一架飞机
/// </summary>
/// <param name="Copter">起始飞机</param>
/// <param name="Direct">方向</param>
/// <param name="findstep">步长</param>
/// <param name="finddis">查找半径</param>
/// <returns>找到的飞机</returns>
private ICopter FindNextCopter(ILocation2D Copter, float Direct,float findstep,float finddis,int findstepnum=5)
{
ICopter FindedCopter = null;
ILocation2D FindLoc = null;
int step = 1;
while ((FindedCopter == null) && (step <= findstepnum))
{
//查找下一个飞机应在摆放的位置
FindLoc = Copter.CalcLatLngSomeMetersAway2D(Direct, findstep * step++);
//该位置是否有飞机
FindedCopter = FindCopteratLoc(FindLoc, finddis);
}
return FindedCopter;
}
/// <summary>
///按方向步长等找下一行的第一架飞机同时输出该行第一个应该摆放飞机的位置
/// </summary>
/// <param name="HeadLoc">输出第一架飞机应该在的位置</param>
/// <param name="Copter">起始飞机</param>
/// <param name="ColDirect">列角度</param>
/// <param name="Colstep">列步长</param>
/// <param name="RowDirect">行角度</param>
/// <param name="Rowstep">行步长</param>
/// <param name="Rowstepnum">行查找深度</param>
/// <param name="finddis">位置查找范围</param>
/// <returns>找到的飞机</returns>
private ICopter FindNextColHeadCopter(out ILocation2D HeadLoc, ILocation2D Copter, float ColDirect, float Colstep,
float RowDirect, float Rowstep, int Rowstepnum,float finddis, int Colfindstepnum = 5)
{
ICopter FindedCopter = null;
HeadLoc = null;
int step = 1;
while ((FindedCopter == null) && (step <= Colfindstepnum))
{
//查找下一行第一架飞机应在摆放的位置
HeadLoc = Copter.CalcLatLngSomeMetersAway2D(ColDirect, Colstep * step++);
//该位置是否有飞机
FindedCopter = FindCopteratLoc(HeadLoc, finddis);
//如果没有飞机,横着找找行有没飞机
if (FindedCopter==null)
FindedCopter=FindNextCopter(HeadLoc, RowDirect, Rowstep, finddis, Rowstepnum);
}
return FindedCopter;
}
}

View File

@ -158,6 +158,38 @@ namespace Plane.FormationCreator.ViewModels
}));
}
}
private ICommand _SortbyVIdCommand;
public ICommand SortbyVIdCommand
{
get
{
return _SortbyVIdCommand ?? (_SortbyVIdCommand = new RelayCommand( () =>
{
_copterManager.sortbyvid();
}));
}
}
private ICommand _SortbyIdCommand;
public ICommand SortbyIdCommand
{
get
{
return _SortbyVIdCommand ?? (_SortbyVIdCommand = new RelayCommand(() =>
{
_copterManager.sortbyid();
}));
}
}
private ICommand _ShowAllCoptersCommand;
public ICommand ShowAllCoptersCommand
@ -180,14 +212,13 @@ namespace Plane.FormationCreator.ViewModels
{
get
{
return _SwitchIdVirtualIdCommand ?? (_SwitchIdVirtualIdCommand = new RelayCommand(async () =>
return _SwitchIdVirtualIdCommand ?? (_SwitchIdVirtualIdCommand = new RelayCommand(() =>
{
showVirtualId = !showVirtualId;
foreach (var copter in _copterManager.Copters)
{
copter.DisplayVirtualId = showVirtualId;
}
await Task.Delay(10);
}));
}
}
@ -223,11 +254,12 @@ namespace Plane.FormationCreator.ViewModels
//内蒙地区
// if (center.Lat < 37.4307185218 || center.Lat > 45.6754821756
// || center.Lng < 97.3493089056 || center.Lng > 115.8006783856)
// return ;
// if (center.Lat < 37.4307185218 || center.Lat > 45.6754821756
// || center.Lng < 97.3493089056 || center.Lng > 115.8006783856)
// return ;
LatLng? colLatLng = new LatLng(center.Lat, center.Lng);
@ -247,7 +279,7 @@ namespace Plane.FormationCreator.ViewModels
else
{
if (currcol < colnum)
targetLatLng = GeographyUtils.CalcLatLngSomeMetersAway2D(colLatLng.Value.Lat, colLatLng.Value.Lng , orientation + 90, currcol * coldis);
targetLatLng = GeographyUtils.CalcLatLngSomeMetersAway2D(colLatLng.Value.Lat, colLatLng.Value.Lng , orientation + 90, (currcol * coldis));
else
{
currrow++;
@ -257,7 +289,17 @@ namespace Plane.FormationCreator.ViewModels
colheadLatLng = targetLatLng;
}
_lastVirtualCopterLocation= new LatLng(targetLatLng.Item1, targetLatLng.Item2);
/*
//随机位置偏差40cm
Random r1 = new Random();
float rdrad= ((float)r1.Next(0, 360));
float rddis = ((float)r1.Next(-40, 40) / 100.0f);
targetLatLng = GeographyUtils.CalcLatLngSomeMetersAway2D(targetLatLng.Item1, targetLatLng.Item2, rdrad, rddis);
*/
_lastVirtualCopterLocation = new LatLng(targetLatLng.Item1, targetLatLng.Item2);
}
currcol++;
@ -271,6 +313,7 @@ namespace Plane.FormationCreator.ViewModels
*/
var copter = new FakeCopter(SynchronizationContext.Current);
copter.SetProperties(

View File

@ -15,7 +15,7 @@
<StackPanel Margin="10,0" Orientation="Horizontal" HorizontalAlignment="Center">
<TextBox Margin="0,5" Width="80" VerticalAlignment="Center"
Text="{Binding SingleVirtualId}"/>
<Button Margin="10,5" Width="80" Content = "设置" VerticalAlignment="Center"
<Button Margin="10,5" Width="100" Content = "设置编号" VerticalAlignment="Center"
Command="{Binding SetSingleVirtualIdCommand}"/>
</StackPanel>
</StackPanel>
@ -23,20 +23,15 @@
<StackPanel>
<TextBlock Margin="10,5" Text="自动编号"/>
<StackPanel Margin="10,0" >
<TextBlock Margin="0,5" Text="请从1号机开始按照顺序选中4个顶点的飞机后点击自动配置"/>
<StackPanel Margin="0,5" Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock Margin="0,0,10,0" Text="每行数量" VerticalAlignment="Center"/>
<TextBox Margin="0,0,10,0" Width="80" VerticalAlignment="Center"
Text="{Binding SingleRowCount}"/>
<Button Margin="0,0,10,0" Width="100" Content = "自动配置" VerticalAlignment="Center"
<TextBlock Margin="0,5" TextWrapping = "Wrap" Height="auto" Text="请按顺序选择2-3架飞机分别是1号机第一行任意飞机第一列任意飞机(如只有一行不用选),自动配置前必须:1.设置行间距和列间距2.把不在正确位置的飞机手动编号"/>
<Button Margin="0,0,0,0" Width="100" Content = "自动编号" VerticalAlignment="Center"
Command="{Binding AutoLocationNumsCommand}"/>
</StackPanel>
</StackPanel>
</StackPanel>
<StackPanel>
<TextBlock Margin="10,5" Text="清除编号"/>
<Button Margin="0,0" Width="120" Content = "清除所有编号" Command="{Binding ClearVirtualIdCommand}"/>
<TextBlock Margin="10,5" Text="清除所有编号"/>
<Button Margin="0,0" Width="100" Content = "清除编号" VerticalAlignment="Center" Command="{Binding ClearVirtualIdCommand}"/>
</StackPanel>
</StackPanel>

View File

@ -10,6 +10,170 @@
d:DesignHeight="300"
d:DesignWidth="300"
d:DataContext="{d:DesignInstance Type=ec:FakeCopter, IsDesignTimeCreatable=True}">
<UserControl.Resources>
<!--笔刷-->
<LinearGradientBrush x:Key="SliderBackground" StartPoint="0,0" EndPoint="0,1">
<GradientStop Offset="0" Color="#59ccfc"/>
<GradientStop Offset="0.5" Color="#00b3fe"/>
<GradientStop Offset="1" Color="#59ccfc"/>
</LinearGradientBrush>
<LinearGradientBrush x:Key="SliderThumb" StartPoint="0,0" EndPoint="0,1">
<GradientStop Offset="0" Color="#FFD9D3E8"/>
<!--<GradientStop Offset="1" Color="#dfdfdf"/>-->
</LinearGradientBrush>
<LinearGradientBrush x:Key="SliderText" StartPoint="0,0" EndPoint="0,1">
<GradientStop Offset="0" Color="#7cce45"/>
<GradientStop Offset="1" Color="#4ea017"/>
</LinearGradientBrush>
<!--Slider模板-->
<Style x:Key="Slider_RepeatButton" TargetType="RepeatButton">
<Setter Property="Focusable" Value="false" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RepeatButton">
<Border Background="{StaticResource SliderBackground}" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="Slider_RepeatButton1" TargetType="RepeatButton">
<Setter Property="Focusable" Value="false" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RepeatButton">
<Border Background="Transparent" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="Slider_Thumb" TargetType="Thumb">
<Setter Property="Focusable" Value="false" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Thumb">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Border Background="{StaticResource SliderBackground}"/>
<Border Grid.ColumnSpan="2" CornerRadius="4" Background="{StaticResource SliderThumb}" Width="15">
<!--<TextBlock Text="||" HorizontalAlignment="Center" VerticalAlignment="Center"/>-->
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="Slider_CustomStyle" TargetType="Slider">
<Setter Property="Focusable" Value="false" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Slider">
<Grid>
<!--<Grid.ColumnDefinitions>
<ColumnDefinition Width="80"/>
<ColumnDefinition/>
<ColumnDefinition Width="40"/>
</Grid.ColumnDefinitions>-->
<Grid.Effect>
<DropShadowEffect BlurRadius="10" ShadowDepth="1" />
</Grid.Effect>
<!--<Border HorizontalAlignment="Right" BorderBrush="Gray" BorderThickness="1,1,0,1" Background="{StaticResource SliderText}" Width="80" CornerRadius="8,0,0,8"/>-->
<!--<Border Grid.Column="2" HorizontalAlignment="Right" BorderBrush="Gray" BorderThickness="0,1,1,1" Background="{StaticResource SliderText}" Width="40" CornerRadius="0,8,8,0"/>-->
<!--<TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent},Path=Tag}" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="14"/>-->
<!--<TextBlock Grid.Column="2" Text="{Binding ElementName=PART_Track,Path=Value,StringFormat=\{0:N0\}}" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="14" DataContext="{Binding}" />-->
<Border Grid.Column="1" BorderBrush="Gray" BorderThickness="1" CornerRadius="8,0,0,8">
<Track Grid.Column="1" Name="PART_Track">
<Track.DecreaseRepeatButton>
<RepeatButton Style="{StaticResource Slider_RepeatButton}"
Command="Slider.DecreaseLarge"/>
</Track.DecreaseRepeatButton>
<Track.IncreaseRepeatButton>
<RepeatButton Style="{StaticResource Slider_RepeatButton1}"
Command="Slider.IncreaseLarge"/>
</Track.IncreaseRepeatButton>
<Track.Thumb>
<Thumb Style="{StaticResource Slider_Thumb}"/>
</Track.Thumb>
</Track>
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<StackPanel>
<TextBlock Text="飞行信息" />
<Grid>
@ -46,8 +210,10 @@
<StackPanel>
<TextBlock Text="ID" />
<TextBlock Text="{Binding Path=Id}" />
</StackPanel>
<TextBlock Width="30" Text="{Binding Path=Id}" />
<TextBlock Text="VID" />
<TextBlock Width="30" Text="{Binding Path=VirtualId}" />
</StackPanel>
<StackPanel>
<TextBlock Text="已连接:" />
<ContentPresenter Content="{Binding CommModuleConnected, Converter={StaticResource CheckSignConverter}, Mode=OneWay}" />
@ -125,26 +291,19 @@
</StackPanel.Resources>
<StackPanel>
<Slider x:Name="sldChannel3"
Width="100"
Minimum="1100"
Maximum="1900"
Value="{Binding Channel3, Mode=OneWay}"
<TextBlock Text="电压:" />
<Slider Style="{StaticResource Slider_CustomStyle}" x:Name="sldChannel3"
Width="80"
Minimum="12"
Maximum="16.8"
IsEnabled="False"
Value="{Binding Path=Voltage}"
ValueChanged="sldChannel3_ValueChanged">
<Slider.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.Blue.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Lime.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Slider.Resources>
</Slider>
</Slider>
</StackPanel>
<StackPanel>
<TextBlock Text="电压:" />
<TextBlock Text="电压值:" />
<TextBlock Text="{Binding Path=Voltage}" />
</StackPanel>
<StackPanel>
@ -165,9 +324,14 @@
<TextBlock Text="{Binding Longitude}" />
</StackPanel>
<StackPanel>
<TextBlock Text="通道3" />
<TextBlock Text="{Binding Channel3}" />
</StackPanel>
<TextBlock Text="通道3" />
<TextBlock Text="{Binding Channel3}" />
</StackPanel>
<StackPanel>
<TextBlock Text="通道4" />
<TextBlock Text="{Binding Channel4}" />
@ -178,7 +342,7 @@
</StackPanel>
<StackPanel>
<TextBlock Text="通信模块:" />
<TextBlock Text="通信模块版本" />
<TextBlock Text="{Binding CommModuleVersion}" />
</StackPanel>
</StackPanel>

View File

@ -38,10 +38,10 @@ namespace Plane.FormationCreator.Views
var copter = sldChannel3.DataContext as ICopter;
var selectedCopter = _copterManager.SelectedCopters.FirstOrDefault();
if (copter == null || copter != selectedCopter) return; // copter != selectedCopter 说明正在切换 copter。
var newCh3 = (ushort)e.NewValue;
if (Math.Abs(copter.Channel3 - newCh3) > 5)
var vol = (ushort)e.NewValue;
if (vol<15)
{
await copter.SetChannelsAsync(ch3: newCh3);
// sldChannel3.co
}
}
catch { }

View File

@ -20,6 +20,12 @@
<MenuItem Header="显示自动编号"
Foreground="White"
Command="{Binding SwitchIdVirtualIdCommand}"/>
<MenuItem Header="按自动编号排序"
Foreground="White"
Command="{Binding SortbyVIdCommand}"/>
<MenuItem Header="按飞机编号排序"
Foreground="White"
Command="{Binding SortbyIdCommand}"/>
</ContextMenu>
</UserControl.Resources>
<Grid>

View File

@ -246,7 +246,7 @@ namespace Plane.FormationCreator.Views
if (Copter.DisplayVirtualId)
{
CopterText.Text = Copter.VirtualId.ToString();
CopterText.Foreground = new SolidColorBrush(Colors.Red);
CopterText.Foreground = new SolidColorBrush(Colors.Yellow);
}
else
{