逐帧 备份
This commit is contained in:
commit
ba51f93b17
112
FlieOperate/FileBase.cs
Normal file
112
FlieOperate/FileBase.cs
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace FlieOperate
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 关于文件的 操作类
|
||||||
|
/// </summary>
|
||||||
|
public class FileBase
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 资源管理器 文件类型 中文说明 和扩展名是 成对关系 数组长度要一致
|
||||||
|
/// </summary>
|
||||||
|
public static string[] FileClass { get; set; } = new string[] { "航点文件" };
|
||||||
|
/// <summary>
|
||||||
|
/// 扩展名 ps: "*.jpg;*.png" 这个格式算一组
|
||||||
|
/// </summary>
|
||||||
|
public static string[] Pascal { get; set; } = new string[] { "*.fcgm;" };
|
||||||
|
/// <summary>
|
||||||
|
/// 整合文件类型及扩展名
|
||||||
|
/// "航点文件|*.fcgm;*.txt|航点文件|*.fcgm;*.*";//资源管理器限制扩展名 例子
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>文件类型及扩展名</returns>
|
||||||
|
private static string SetFileClass()
|
||||||
|
{
|
||||||
|
string str = "";
|
||||||
|
for (int i = 0; i < FileClass.Length; i++)
|
||||||
|
{
|
||||||
|
str += FileClass[i] + "|" + Pascal[i];
|
||||||
|
if (i + 1 != FileClass.Length)//最后一次 不加|
|
||||||
|
{
|
||||||
|
str += "|";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 读取文件 存到字符串
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="FliePath">文件路径</param>
|
||||||
|
/// <returns>文件内容 字符串</returns>
|
||||||
|
public static string ReadFlieToStr(string FliePath)
|
||||||
|
{
|
||||||
|
FileStream fs = new FileStream(FliePath, FileMode.Open);
|
||||||
|
StreamReader fileStream = new StreamReader(fs);
|
||||||
|
string str = "";
|
||||||
|
string line;
|
||||||
|
while ((line = fileStream.ReadLine()) != null)
|
||||||
|
{
|
||||||
|
str += line;
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 字符串 保存到指定文件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filePath">指定文件和路径</param>
|
||||||
|
/// <param name="str">字符串</param>
|
||||||
|
private static void SaveStrToFile(string filePath, string str)
|
||||||
|
{
|
||||||
|
str = str.TrimEnd((char[])"\n\r".ToCharArray());//去除最后的回车符
|
||||||
|
string stream = null;
|
||||||
|
if (File.Exists(filePath))
|
||||||
|
{
|
||||||
|
StreamReader reader = new StreamReader(filePath);
|
||||||
|
stream = reader.ReadToEnd();
|
||||||
|
reader.Close();
|
||||||
|
}
|
||||||
|
FileStream fs = new FileStream(filePath, FileMode.OpenOrCreate);
|
||||||
|
StreamWriter sw = new StreamWriter(fs);
|
||||||
|
sw.Write(str);
|
||||||
|
sw.Close();
|
||||||
|
fs.Close();
|
||||||
|
}
|
||||||
|
public static void SaveExplorer(string str)
|
||||||
|
{
|
||||||
|
SaveFileDialog sfd = new SaveFileDialog();
|
||||||
|
sfd.Filter = SetFileClass();//设置文件类型
|
||||||
|
sfd.AddExtension = true;//设置自动在文件名中添加扩展名
|
||||||
|
if (sfd.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
SaveStrToFile(sfd.FileName, str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 资源管理器 获取文件路径
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="titName">资源管理器标题栏</param>
|
||||||
|
/// <param name="isSelect">out参数 判断是否获取到文件路径</param>
|
||||||
|
/// <returns>文件路径</returns>
|
||||||
|
public static string OpenExplorer(string titName, out bool isSelect)
|
||||||
|
{
|
||||||
|
Microsoft.Win32.OpenFileDialog ofdl = new Microsoft.Win32.OpenFileDialog();//打开资源管理器
|
||||||
|
ofdl.Filter = SetFileClass();//设置文件类型
|
||||||
|
ofdl.Title = titName;
|
||||||
|
if (ofdl.ShowDialog() == true)//执行打开资源管理器 并判断有没有获取到文件名
|
||||||
|
{
|
||||||
|
isSelect = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
isSelect = false;
|
||||||
|
}
|
||||||
|
return ofdl.FileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
FlieOperate/FlieOperate.csproj
Normal file
60
FlieOperate/FlieOperate.csproj
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{C354FD6B-5863-4246-BB48-6DF14A85C161}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>FlieOperate</RootNamespace>
|
||||||
|
<AssemblyName>FlieOperate</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<Deterministic>true</Deterministic>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\FlyCube\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="PresentationFramework" />
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Windows.Forms" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="FileBase.cs" />
|
||||||
|
<Compile Include="JsonBase.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<WCFMetadata Include="Connected Services\" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
</Project>
|
80
FlieOperate/JsonBase.cs
Normal file
80
FlieOperate/JsonBase.cs
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace FlieOperate
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 飞行魔方地面站 fcgm Json文件层级 结构模型
|
||||||
|
/// </summary>
|
||||||
|
public class FcgmJsonModel
|
||||||
|
{
|
||||||
|
public string ID { get; set; }
|
||||||
|
public string ver { get; set; }
|
||||||
|
public int coptercount { get; set; }
|
||||||
|
public int taskcount { get; set; }
|
||||||
|
public List<Groups> groups { get; set; }
|
||||||
|
public class Groups
|
||||||
|
{
|
||||||
|
public string groupName { get; set; }
|
||||||
|
public List<int> copterIndexList { get; set; }
|
||||||
|
}
|
||||||
|
public List<List<double>> locate { get; set; }
|
||||||
|
public List<Tasks> tasks { get; set; }
|
||||||
|
public class Tasks
|
||||||
|
{
|
||||||
|
public int type { get; set; }//100:起飞 0:普通航点 6:降落
|
||||||
|
public int takeoffnumber { get; set; }//起飞任务独有
|
||||||
|
public int takeoffTime { get; set; }//起飞任务独有
|
||||||
|
public bool staggerRoutes { get; set; }
|
||||||
|
public int flytoTime { get; set; }
|
||||||
|
public int loiterTime { get; set; }
|
||||||
|
public string taskname { get; set; }
|
||||||
|
public List<SingleCopterInfos> singleCopterInfos { get; set; }
|
||||||
|
public class SingleCopterInfos
|
||||||
|
{
|
||||||
|
public int waitTime { get; set; }//起飞降落 独有
|
||||||
|
public double x { get; set; }
|
||||||
|
public double y { get; set; }
|
||||||
|
public double targetAlt { get; set; }
|
||||||
|
public List<LedInfos> ledInfos { get; set; }
|
||||||
|
public class LedInfos
|
||||||
|
{
|
||||||
|
public double Delay { get; set; }
|
||||||
|
public int LEDMode { get; set; }
|
||||||
|
public double LEDInterval { get; set; }
|
||||||
|
public int LEDRate { get; set; }
|
||||||
|
public int LEDTimes { get; set; }
|
||||||
|
public string LEDRGB { get; set; }
|
||||||
|
}
|
||||||
|
public bool isLandWaypoint { get; set; }//返航点
|
||||||
|
public bool isChangeSpeed { get; set; }//改变速度
|
||||||
|
public double levelSpeed { get; set; }
|
||||||
|
public double upSpeed { get; set; }
|
||||||
|
public double downSpeed { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class JsonBase
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 航点文件转存到FcgmJsonModel对象里面 反序列化
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="FliePath">航点文件路径</param>
|
||||||
|
/// <returns>航点FcgmJsonModel对象</returns>
|
||||||
|
public static FcgmJsonModel JsonToModel(string FliePath)
|
||||||
|
{
|
||||||
|
string str = FileBase.ReadFlieToStr(FliePath);
|
||||||
|
FcgmJsonModel fcgmModel = JsonConvert.DeserializeObject<FcgmJsonModel>(str);//反系列化
|
||||||
|
return fcgmModel;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// FcgmJsonModel对象 序列化 成 json
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fcgmJsonModel"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string ModelTojson(FcgmJsonModel fcgmJsonModel)
|
||||||
|
{
|
||||||
|
return JsonConvert.SerializeObject(fcgmJsonModel); //转为字符串
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
1116
FlyBase/FlyBase.cs
Normal file
1116
FlyBase/FlyBase.cs
Normal file
File diff suppressed because it is too large
Load Diff
26
FlyCube/MainWindow.xaml
Normal file
26
FlyCube/MainWindow.xaml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<Window x:Class="FlyCube.MainWindow"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:gif="http://wpfanimatedgif.codeplex.com"
|
||||||
|
xmlns:local="clr-namespace:FlyCube"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
xmlns:control="clr-namespace:ControlLibrary"
|
||||||
|
Title="无人机编队-灯光映射" Height="860" Width="1070" MinHeight="860" MinWidth="1070" Padding="0" Background="#FF2D2D30">
|
||||||
|
<WrapPanel Name="MainBody" Height="800" Width="1030" Margin="10">
|
||||||
|
<Grid Name="MainContral" Width="800" Height="800" HorizontalAlignment="Left" VerticalAlignment="Top" ClipToBounds="True" Background="#FF363636" >
|
||||||
|
<!--<Image x:Name="image1" Source="C:\Users\Administrator\Desktop\1.gif" VerticalAlignment="Top" HorizontalAlignment="Left" Width="800" Height="100" />-->
|
||||||
|
<!--<Image gif:ImageBehavior.AnimatedSource="C:\Users\Administrator\Desktop\1.gif" />-->
|
||||||
|
<Canvas Name="LayerPlane" Width="800" Height="800" HorizontalAlignment="Left" VerticalAlignment="Top" Panel.ZIndex="1">
|
||||||
|
<Label Content="顶视图" FontSize="14" Background="#556b6b6b" Foreground="#FFDCDCDC" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0" />
|
||||||
|
</Canvas>
|
||||||
|
</Grid>
|
||||||
|
<Grid Name="MainMenu" Width="220" Height="800" Margin="10,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Top">
|
||||||
|
<Button Content="导入航点" HorizontalAlignment="Left" VerticalAlignment="Top" Width="220" Height="49" Margin="0,0,0,0" Click="ImportFcgm_Click"/>
|
||||||
|
<Button Content="导入映射图" HorizontalAlignment="Left" VerticalAlignment="Top" Width="220" Height="49" Margin="0,54,0,0" Click="ImportImg_Click"/>
|
||||||
|
<Button Content="保存航点" HorizontalAlignment="Left" VerticalAlignment="Top" Width="220" Height="49" Margin="0,108,0,0" Click="ExportFcgm_Click"/>
|
||||||
|
<Button Content="渲染" HorizontalAlignment="Left" VerticalAlignment="Top" Width="220" Height="49" Margin="0,162,0,0" Click="Render_Click"/>
|
||||||
|
</Grid>
|
||||||
|
</WrapPanel>
|
||||||
|
</Window>
|
236
FlyCube/MainWindow.xaml.cs
Normal file
236
FlyCube/MainWindow.xaml.cs
Normal file
@ -0,0 +1,236 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
using FlyBase;
|
||||||
|
using FlieOperate;
|
||||||
|
using static FlieOperate.FcgmJsonModel.Tasks.SingleCopterInfos;
|
||||||
|
using FlyCube.Models;
|
||||||
|
using ControlLibrary;
|
||||||
|
using WpfAnimatedGif;//播放GIF
|
||||||
|
|
||||||
|
|
||||||
|
namespace FlyCube
|
||||||
|
{
|
||||||
|
public partial class MainWindow : Window
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 航点文件 模型对象
|
||||||
|
/// </summary>
|
||||||
|
public FcgmJsonModel FcgmInfo { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 主画布
|
||||||
|
/// </summary>
|
||||||
|
public MainCanvas TopCanvas { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 导入航点 在画布上的位置
|
||||||
|
/// </summary>
|
||||||
|
public Vector3[] PlaneVecOnCanvas { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 导入的gif路径
|
||||||
|
/// </summary>
|
||||||
|
public string ImagePath { get; set; }
|
||||||
|
public MainWindow()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
//创建一个 主画布对象
|
||||||
|
TopCanvas = new MainCanvas(this.LayerPlane);
|
||||||
|
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 导入航点
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ImportFcgm_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
//资源管理器 获取航点文件路径
|
||||||
|
FileBase.FileClass = new string[] { "航点文件" };
|
||||||
|
FileBase.Pascal = new string[] { "*.fcgm" };
|
||||||
|
string FliePath = FileBase.OpenExplorer("航点文件导入",out bool isSelect);
|
||||||
|
if (!isSelect)
|
||||||
|
{
|
||||||
|
return;//未打开文件跳出.
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.FcgmInfo = JsonBase.JsonToModel(FliePath);//Json航点文件 转存到 对象里
|
||||||
|
}
|
||||||
|
//获取航点
|
||||||
|
Vector3[] planesPos = new Vector3[this.FcgmInfo.coptercount];
|
||||||
|
int id = 0;
|
||||||
|
foreach (var item in this.FcgmInfo.tasks[2].singleCopterInfos)
|
||||||
|
{
|
||||||
|
planesPos[id] = new Vector3(item.x*100, item.targetAlt*100, -item.y*100);//转换厘米单位
|
||||||
|
id++;
|
||||||
|
}
|
||||||
|
Vector3 planesCenterPos=FlyVecFun.GetPosCenter(planesPos);//获取航点的中心点
|
||||||
|
//坐标集合 自适应画布 缩放比例因子
|
||||||
|
double[] planesPosWhl = FlyVecFun.GetVecsWithHighLength(planesPos);
|
||||||
|
double scale;//比例因子
|
||||||
|
if (planesPosWhl[0] > planesPosWhl[2])//宽图
|
||||||
|
{
|
||||||
|
scale = planesPosWhl[0] / 500;//比例因子
|
||||||
|
}
|
||||||
|
else//高图
|
||||||
|
{
|
||||||
|
scale = planesPosWhl[2] / 500;//比例因子
|
||||||
|
}
|
||||||
|
//在画布创建飞机
|
||||||
|
PlaneVecOnCanvas = new Vector3[FcgmInfo.coptercount];
|
||||||
|
int planeId = 0;
|
||||||
|
foreach (var item in planesPos)
|
||||||
|
{
|
||||||
|
Vector3 v = item.SetZeroEd(planesCenterPos) / scale + 400;
|
||||||
|
TopCanvas.CreatePlanes(v, planeId);
|
||||||
|
PlaneVecOnCanvas[planeId] = v;
|
||||||
|
planeId++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 输出航点
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ExportFcgm_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
string jsonStr = JsonBase.ModelTojson(this.FcgmInfo);
|
||||||
|
FileBase.FileClass = new string[] { "航点文件" };
|
||||||
|
FileBase.Pascal = new string[] { "*.fcgm" };
|
||||||
|
FileBase.SaveExplorer(jsonStr);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 导入图片
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ImportImg_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
//资源管理器 获取航点文件路径
|
||||||
|
FileBase.FileClass = new string[] { "动态图片","静态图片" };
|
||||||
|
FileBase.Pascal = new string[] { "*.gif","*.jpeg;*.jpg;*.png"};
|
||||||
|
ImagePath = FileBase.OpenExplorer("映射图片导入", out bool isSelect);
|
||||||
|
if (!isSelect)
|
||||||
|
{
|
||||||
|
return;//未打开文件跳出.
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TopCanvas.ImportGif(ImagePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void Render_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
ImageUtility img = new ImageUtility(this.ImagePath);
|
||||||
|
int id = 0;
|
||||||
|
foreach (Vector3 item in PlaneVecOnCanvas)
|
||||||
|
{
|
||||||
|
List<LedInfos> ledInfos = new List<LedInfos>();
|
||||||
|
Color[] colors = img.GetColorsForGifPos((int)item.X, (int)item.Y);
|
||||||
|
foreach (var color in colors)
|
||||||
|
{
|
||||||
|
LedInfos led = new LedInfos();
|
||||||
|
led.Delay = 0.1;
|
||||||
|
led.LEDMode = 0;
|
||||||
|
led.LEDInterval = 0.0;
|
||||||
|
led.LEDRate = 0;
|
||||||
|
led.LEDTimes = 0;
|
||||||
|
led.LEDRGB = color.ToString().Remove(0, 3);
|
||||||
|
ledInfos.Add(led);
|
||||||
|
}
|
||||||
|
this.FcgmInfo.tasks[2].singleCopterInfos[id].ledInfos = ledInfos;
|
||||||
|
id++;
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageBox.Show("成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 灯光 组
|
||||||
|
/// </summary>
|
||||||
|
public enum LightClass
|
||||||
|
{
|
||||||
|
常亮 = 0,
|
||||||
|
同步闪烁单色 = 1,
|
||||||
|
同步闪烁随机 = 2,
|
||||||
|
异步闪烁单色 = 3,
|
||||||
|
异步闪烁随机 = 4,
|
||||||
|
渐亮 = 5,
|
||||||
|
渐暗 = 6,
|
||||||
|
呼吸灯单色 = 7,
|
||||||
|
呼吸灯随机 = 8,
|
||||||
|
异步呼吸灯单色 = 9,
|
||||||
|
异步呼吸灯随机 = 10,
|
||||||
|
变色单色 = 11,
|
||||||
|
变色随机 = 12,
|
||||||
|
异步变色单色 = 13,
|
||||||
|
异步变色随机 = 14,
|
||||||
|
拉烟 = 15
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 画布 渲染
|
||||||
|
/// </summary>
|
||||||
|
public class MainCanvas
|
||||||
|
{
|
||||||
|
public Canvas MyCanvas { get; set; }
|
||||||
|
public MainCanvas(Canvas canvas)
|
||||||
|
{
|
||||||
|
this.MyCanvas = canvas;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 创建 飞机元素
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="planePos">指定坐标</param>
|
||||||
|
/// <param name="planeId">指定ID</param>
|
||||||
|
public void CreatePlanes(Vector3 planePos, int planeId)
|
||||||
|
{
|
||||||
|
Ellipse plane = new Ellipse();//实例一个圆形
|
||||||
|
plane.Width = plane.Height = 13;
|
||||||
|
plane.Fill = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255));
|
||||||
|
plane.StrokeThickness = 2;
|
||||||
|
plane.Stroke = new SolidColorBrush(Color.FromArgb(255, 36, 36, 36));
|
||||||
|
plane.Name = "plane" + Convert.ToString(planeId);
|
||||||
|
//插入飞机
|
||||||
|
MyCanvas.Children.Add(plane);
|
||||||
|
Canvas.SetLeft(plane, planePos.X);
|
||||||
|
Canvas.SetTop(plane, planePos.Z);
|
||||||
|
}
|
||||||
|
public void ImportGif(string path)
|
||||||
|
{
|
||||||
|
string extendName = string.Copy(path);
|
||||||
|
string[] extendNameArr = extendName.Split('.');//获取扩展名
|
||||||
|
Image img = new Image();
|
||||||
|
if (extendNameArr[1]=="gif")
|
||||||
|
{
|
||||||
|
var image = new BitmapImage();
|
||||||
|
image.BeginInit();
|
||||||
|
image.UriSource = new Uri(path);
|
||||||
|
image.EndInit();
|
||||||
|
ImageBehavior.SetAnimatedSource(img, image);
|
||||||
|
MyCanvas.Children.Add(img);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
img.Source = new BitmapImage(new Uri(path));
|
||||||
|
MyCanvas.Children.Add(img);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user