Commit d9662735 authored by 潘栩锋's avatar 潘栩锋 🚴

Flyad7_WPF 测试 TimeGridAdv

parent ba757040
......@@ -445,7 +445,7 @@ namespace FlyADBase
/// </summary>
/// <param name="gridAdvUnits"></param>
/// <param name="dat"></param>
public void ToGrid(List<GridAdvUnit> gridAdvUnits, out int[] dat)
public void ToGrid(IEnumerable<GridAdvUnit> gridAdvUnits, out int[] dat)
{
dat = mTimeGridAdvHelper.ToGrid(gridAdvUnits, PosOfGrid, SGrid.GRID_MAX_SIZE);
}
......
......@@ -129,7 +129,7 @@ namespace FlyADBase
/// </summary>
/// <param name="gridAdvUnits"></param>
/// <param name="dat"></param>
void ToGrid(List<GridAdvUnit> gridAdvUnits, out int[] dat);
void ToGrid(IEnumerable<GridAdvUnit> gridAdvUnits, out int[] dat);
/// <summary>
/// 动作完成
/// </summary>
......
......@@ -515,7 +515,7 @@ namespace FlyADBase
/// <param name="posOfGrid"></param>
/// <param name="gridLen"></param>
/// <returns></returns>
public int[] ToGrid(List<GridAdvUnit> gridAdvUnits, int posOfGrid, int gridLen)
public int[] ToGrid(IEnumerable<GridAdvUnit> gridAdvUnits, int posOfGrid, int gridLen)
{
int[] grids_sum = new int[gridLen];
int[] grids_cnt = new int[gridLen];
......
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace Flyad7_WPF.Converters
{
public class BinConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
string index_str = (string)parameter;
if (!int.TryParse(index_str, out int index))
{
index = 0;
}
if (index < 0)
index = 0;
if (index > 15)
index = 15;
if (!(value is UInt16))
return null;
UInt16 v = (UInt16)value;
if (Misc.MyBase.CHECKBIT(v, index))
{
return 1;
}
else
{
return 0;
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace Flyad7_WPF.Converters
{
public class BytesConverter : IValueConverter
{
#region IValueConverter 成员
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
byte[] bs = (byte[])value;
string str = "";
for (int i = 0; i < bs.Length; i++)
str += bs[i].ToString("X2");
return str;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
string str = (string)value;
string h = "";
List<byte> bs = new List<byte>();
for (int i = 0; i < str.Length; i++)
{
if (str[i] != ' ')
h += str[i];
if (((str[i] == ' ') && (h.Length != 0)) ||
(h.Length >= 2))
{
byte b = 0;
if (byte.TryParse(h, System.Globalization.NumberStyles.AllowHexSpecifier, null, out b))
{
bs.Add(b);
}
else
{
break;
}
h = "";
}
}
return bs.ToArray();
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace Flyad7_WPF.Converters
{
public class IO2BinConverter : IValueConverter
{
#region IValueConverter 成员
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
UInt16 io = (UInt16)value;
string str = System.Convert.ToString(io, 2);
return str.PadLeft(16, '0');
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return System.Convert.ToUInt16((string)value, 2);
}
#endregion
}
}
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Flyad7_WPF.Converters">
<local:BytesConverter x:Key="bytesconv"/>
<local:IO2BinConverter x:Key="io2bin"/>
<local:BinConverter x:Key="binConv"/>
</ResourceDictionary>
\ No newline at end of file
......@@ -38,7 +38,7 @@ namespace Flyad7_WPF
public UInt32 HVelocity2;
public int PosLen;
public int ADLag;
public int ADLag { get; set; }
#region INotifyPropertyChanged 成员
public event PropertyChangedEventHandler PropertyChanged;
......@@ -77,6 +77,7 @@ namespace Flyad7_WPF
{
string json = File.ReadAllText(file_path);
var param = JsonConvert.DeserializeObject<DebugAppParamJsonDB>(json);
EPStr = param.EPStr;
HasTimeGrid = param.HasTimeGrid;
HasGrid = param.HasGrid;
......
......@@ -73,8 +73,14 @@
</ApplicationDefinition>
<Compile Include="AutoForwBackw.cs" />
<Compile Include="AutoSync.cs" />
<Compile Include="Converters\BinConverter.cs" />
<Compile Include="Converters\BytesConverter.cs" />
<Compile Include="Converters\IO2BinConverter.cs" />
<Compile Include="DebugAppParam.cs" />
<Compile Include="FlyADClientUI.cs" />
<Compile Include="Window1.xaml.cs">
<DependentUpon>Window1.xaml</DependentUpon>
</Compile>
<Compile Include="Window_InitArea.xaml.cs">
<DependentUpon>Window_InitArea.xaml</DependentUpon>
</Compile>
......@@ -87,6 +93,10 @@
<Compile Include="Window_sync_graph.xaml.cs">
<DependentUpon>Window_sync_graph.xaml</DependentUpon>
</Compile>
<Page Include="Converters\MyConv.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
......@@ -99,6 +109,10 @@
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="Window1.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Window_InitArea.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
......
......@@ -3,19 +3,23 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:flyadbase="clr-namespace:FlyADBase;assembly=FlyADBase"
xmlns:local="clr-namespace:Flyad7_WPF"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:Chr="clr-namespace:System.Windows.Forms.DataVisualization.Charting;assembly=System.Windows.Forms.DataVisualization"
Title="MainWindow" Height="606" Width="1161">
Title="MainWindow" Height="606" Width="1161" d:DataContext="{d:DesignInstance Type=flyadbase:FlyAD7}">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Converters/MyConv.xaml"/>
</ResourceDictionary.MergedDictionaries>
<ObjectDataProvider MethodName="GetValues" ObjectType="{x:Type sys:Enum}" x:Key="MOTORTYPE">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="flyadbase:MOTORTYPE" />
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
<local:IO2BinConverter x:Key="io2bin"></local:IO2BinConverter>
<local:BytesConverter x:Key="bytesconv">
</local:BytesConverter>
<Style TargetType="TextBlock" x:Key="TextBlockStyle_groupTitle">
<Setter Property="FontSize" Value="16" />
</Style>
......@@ -122,11 +126,11 @@
<StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource TextBlockStyle_itemTitle}" Text="输入" />
<TextBox Style="{StaticResource TextBoxStyle_itemContent}" Text="{Binding IStatus,Converter={StaticResource ResourceKey=io2bin}}" IsEnabled="False" Width="121" />
<TextBox Style="{StaticResource TextBoxStyle_itemContent}" Text="{Binding IStatus,Mode=OneWay,Converter={StaticResource ResourceKey=io2bin}}" IsEnabled="False" Width="120" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource TextBlockStyle_itemTitle}" Text="输出" />
<TextBox Style="{StaticResource TextBoxStyle_itemContent}" Text="{Binding OStatus,Converter={StaticResource ResourceKey=io2bin}}" IsEnabled="False" Width="120" />
<TextBox Style="{StaticResource TextBoxStyle_itemContent}" Text="{Binding OStatus,Mode=OneWay,Converter={StaticResource ResourceKey=io2bin}}" IsEnabled="False" Width="120" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<Button Style="{StaticResource ButtonStyle}" Content="输出设置" Click="button_output_Click" />
......@@ -140,10 +144,10 @@
<Setter Property="Margin" Value="3"/>
</Style>
</StackPanel.Resources>
<Button Style="{StaticResource ButtonStyle_Bit}" x:Name="button_bit3" Content="1" Click="button_setbit_Click" />
<Button Style="{StaticResource ButtonStyle_Bit}" x:Name="button_bit2" Content="1" Click="button_setbit_Click" />
<Button Style="{StaticResource ButtonStyle_Bit}" x:Name="button_bit1" Content="1" Click="button_setbit_Click" />
<Button Style="{StaticResource ButtonStyle_Bit}" x:Name="button_bit0" Content="1" Click="button_setbit_Click" />
<Button Style="{StaticResource ButtonStyle_Bit}" x:Name="button_bit3" Content="{Binding OStatus,Converter={StaticResource binConv}, ConverterParameter=3}" Tag="3" Click="button_setbit_Click" />
<Button Style="{StaticResource ButtonStyle_Bit}" x:Name="button_bit2" Content="{Binding OStatus,Converter={StaticResource binConv}, ConverterParameter=2}" Tag="2" Click="button_setbit_Click" />
<Button Style="{StaticResource ButtonStyle_Bit}" x:Name="button_bit1" Content="{Binding OStatus,Converter={StaticResource binConv}, ConverterParameter=1}" Tag="1" Click="button_setbit_Click" />
<Button Style="{StaticResource ButtonStyle_Bit}" x:Name="button_bit0" Content="{Binding OStatus,Converter={StaticResource binConv}, ConverterParameter=0}" Tag="0" Click="button_setbit_Click" />
</StackPanel>
</StackPanel>
</GroupBox>
......
<Window x:Class="Flyad7_WPF.Window1"
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:local="clr-namespace:Flyad7_WPF"
mc:Ignorable="d"
Title="Window1" Height="450" Width="800">
<Grid>
</Grid>
</Window>
using System;
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;
namespace Flyad7_WPF
{
/// <summary>
/// Window1.xaml 的交互逻辑
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
}
}
using System;
using Flyad7_WPF.Converters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment