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

1. 整理 界面模块

parent 5aee9945
using Newtonsoft.Json.Linq;
using System;
using System.CodeDom;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static Misc.BindingOperations;
namespace Misc
{
......@@ -51,7 +53,45 @@ namespace Misc
{
return GetValue<T>(key, default(T));
}
public object GetValue(Type type, string key, object defaultValue)
{
var cell = cells.Find(c => c.Key == key);
if (cell == null)
{
cell = new KeyValueCell() { Key = key, Value = defaultValue };
cell.IsConverted = true;
cells.Add(cell);
return cell.Value;
}
else
{
if (cell.IsConverted)
return cell.Value;
else
{
cell.ToValue(type);
return cell.Value;
}
}
}
public object GetValue(Type type, string key)
{
var cell = cells.Find(c => c.Key == key);
if (cell == null)
{
return null;
}
else
{
if (cell.IsConverted)
return cell.Value;
else
{
cell.ToValue(type);
return cell.Value;
}
}
}
/// <summary>
/// 获取值,如果没有返回默认值
......@@ -84,6 +124,41 @@ namespace Misc
}
}
/// <summary>
/// 双向绑定
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="src"></param>
/// <param name="target"></param>
/// <param name="propertyName"></param>
/// <param name="defaultValue"></param>
public void SetBinding<T>(INotifyPropertyChanged target, string propertyName, T defaultValue)
{
Type type_s = target.GetType();
System.Reflection.PropertyInfo pi_t = type_s.GetProperty(propertyName);
if (pi_t == null)
return;
object obj = GetValue<T>(propertyName, defaultValue);
pi_t.SetValue(target, obj);
target.PropertyChanged += (s, e) =>
{
if (e.PropertyName == propertyName)
{
object o = pi_t.GetValue(target);
SetValue(propertyName, o);
}
};
ValueChanged += (s, e) =>
{
if (e.Key == propertyName) {
object o = GetValue<T>(propertyName, defaultValue);
pi_t.SetValue(target, o);
}
};
}
private string path;
public event UiParamDictionaryValueChangedHandler ValueChanged;
......@@ -109,11 +184,20 @@ namespace Misc
}
public void Save()
{
try
foreach (var cell in cells)
{
foreach (var cell in cells)
try
{
cell.ToToken();
}
catch (Exception e)
{
}
}
try
{
string json = Newtonsoft.Json.JsonConvert.SerializeObject(cells, Newtonsoft.Json.Formatting.Indented);
File.WriteAllText(path, json);
}
......@@ -166,6 +250,13 @@ namespace Misc
return;
Value = Token.ToObject<T>();
}
public void ToValue(Type type)
{
IsConverted = true;
if (Token == null)
return;
Value = Token.ToObject(type);
}
public void ToToken()
{
Token = JToken.FromObject(Value);
......
......@@ -129,6 +129,57 @@ namespace Misc
}break;
}
}
public static void SetBinding(INotifyPropertyChanged src, string srcPropertyName, ParamDictionary target, string targetPropertyName, BindingMode mode)
{
Type type_s = src.GetType();
System.Reflection.PropertyInfo pi_s = type_s.GetProperty(srcPropertyName);
if (pi_s == null)
return;
switch (mode)
{
case BindingMode.OneWay://src->target
{
object obj = pi_s.GetValue(src, null);
target.SetValue(targetPropertyName, obj);
src.PropertyChanged += (s, e) =>
{
if (e.PropertyName == srcPropertyName)
{
object o = pi_s.GetValue(src, null);
target.SetValue(targetPropertyName, obj);
}
};
}
break;
case BindingMode.TwoWay://src->target then target->src
{
object obj = pi_s.GetValue(src, null);
target.SetValue(targetPropertyName, obj);
src.PropertyChanged += (s, e) =>
{
if (e.PropertyName == srcPropertyName)
{
object o = pi_s.GetValue(s, null);
target.SetValue(targetPropertyName, obj);
}
};
target.ValueChanged += (s, e) =>
{
if (e.Key == targetPropertyName)
{
object o = target.GetValue(pi_s.PropertyType, targetPropertyName);
pi_s.SetValue(src, o, null);
}
};
}
break;
}
}
}
}
......@@ -92,28 +92,11 @@ namespace FLY.Thick.Base.UI.CustomSection
{
this.paramDictionary = paramDictionary;
this.lCUS1 = lCUS1;
WarningTipPath = this.paramDictionary.GetValue(ParamDistItemKeys.WarningTipPath, "");
var v = this.paramDictionary.GetValue<int>(ParamDistItemKeys.WarningDurationSec);
WarningDurationSec = this.paramDictionary.GetValue(ParamDistItemKeys.WarningDurationSec, 5);
EnableScanErrBigTip = this.paramDictionary.GetValue(ParamDistItemKeys.EnableScanErrBigTip, false);
LCUS1_PortName = this.paramDictionary.GetValue(ParamDistItemKeys.LCUS1_PortName, "COM1");
EnableLCUS1 = this.paramDictionary.GetValue(ParamDistItemKeys.EnableLCUS1, false);
this.PropertyChanged += (s, e) =>
{
if (e.PropertyName == "WarningTipPath")
this.paramDictionary.SetValue(ParamDistItemKeys.WarningTipPath, WarningTipPath);
else if (e.PropertyName == "WarningDurationSec")
this.paramDictionary.SetValue(ParamDistItemKeys.WarningDurationSec, WarningDurationSec);
else if (e.PropertyName == "EnableScanErrBigTip")
this.paramDictionary.SetValue(ParamDistItemKeys.EnableScanErrBigTip, EnableScanErrBigTip);
else if (e.PropertyName == "LCUS1_PortName")
this.paramDictionary.SetValue(ParamDistItemKeys.LCUS1_PortName, LCUS1_PortName);
else if (e.PropertyName == "EnableLCUS1")
this.paramDictionary.SetValue(ParamDistItemKeys.EnableLCUS1, EnableLCUS1);
};
paramDictionary.SetBinding(this, "WarningTipPath", "");
paramDictionary.SetBinding(this, "WarningDurationSec", 5);
paramDictionary.SetBinding(this, "EnableScanErrBigTip", false);
paramDictionary.SetBinding(this, "LCUS1_PortName", "COM1");
paramDictionary.SetBinding(this, "EnableLCUS1", false);
}
private void Play()
......
......@@ -41,7 +41,6 @@ namespace FLY.Thick.Base.UI.CustomSection
public bool HaveOSK_mouse { get; set; }
ParamDictionary paramDictionary;
public UcSectionOskVm()
{
......@@ -49,16 +48,8 @@ namespace FLY.Thick.Base.UI.CustomSection
public void Init(ParamDictionary paramDictionary)
{
this.paramDictionary = paramDictionary;
HaveOSK = paramDictionary.GetValue(ParamDistItemKeys.HaveOSK, true);
HaveOSK_mouse = paramDictionary.GetValue(ParamDistItemKeys.HaveOSK_mouse, false);
this.PropertyChanged += (s, e) =>
{
if (e.PropertyName == ParamDistItemKeys.HaveOSK)
this.paramDictionary.SetValue(ParamDistItemKeys.HaveOSK, HaveOSK);
else if (e.PropertyName == ParamDistItemKeys.HaveOSK_mouse)
this.paramDictionary.SetValue(ParamDistItemKeys.HaveOSK_mouse, HaveOSK_mouse);
};
paramDictionary.SetBinding(this, "HaveOSK", false);
paramDictionary.SetBinding(this, "HaveOSK_mouse", false);
}
}
......
......@@ -203,6 +203,9 @@
<Compile Include="PgPwManager.xaml.cs">
<DependentUpon>PgPwManager.xaml</DependentUpon>
</Compile>
<Compile Include="UiModule\DynAreaFilmWidth.xaml.cs">
<DependentUpon>DynAreaFilmWidth.xaml</DependentUpon>
</Compile>
<Compile Include="UiModule\DynAreaIO.xaml.cs">
<DependentUpon>DynAreaIO.xaml</DependentUpon>
</Compile>
......@@ -371,6 +374,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="UiModule\DynAreaFilmWidth.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="UiModule\DynAreaIO.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
......
......@@ -21,7 +21,7 @@
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="496*" />
<RowDefinition />
</Grid.RowDefinitions>
<Grid Background="{StaticResource Background_Title}" >
<Grid.ColumnDefinitions>
......
......@@ -24,22 +24,27 @@
<RowDefinition Height="auto" />
<RowDefinition />
</Grid.RowDefinitions>
<Grid Name="grid_null"/>
<StackPanel Orientation="Horizontal" Background="{StaticResource Background_Title}">
<Button Style="{StaticResource ButtonStyle_back2}" Command="BrowseBack"/>
<TextBlock Style="{StaticResource TextBlockStyle_Title}" Text="机架信息"/>
</StackPanel>
<Grid Background="{StaticResource Background_Title}" >
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" >
<Button Style="{StaticResource ButtonStyle_back2}" Command="BrowseBack" />
<TextBlock Style="{StaticResource TextBlockStyle_Title}" Text="机架信息"/>
</StackPanel>
<local:CtMicroGage Grid.Column="1" x:Name="mircoGage" Background="Transparent" VerticalAlignment="Bottom"/>
</Grid>
<Grid Grid.Row="1" Margin="0,5,0,5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Button Click="button_start_Click" >
<TextBlock Text="录制" >
<TextBlock >
<TextBlock.Style>
<Style TargetType="TextBlock" BasedOn="{StaticResource TextStyle_paramSection}" >
<Setter Property="Text" Value="录制"/>
<Style.Triggers>
<DataTrigger Binding="{Binding IsRunning}" Value="True">
<Setter Property="Text" Value="停止"/>
......
......@@ -40,6 +40,7 @@ namespace FLY.Thick.Base.UI
this.getSample = getSample;
this.borderSearch = borderSearch;
this.container = container;
container.BuildUp(mircoGage);
}
private void Page_Loaded(object sender, RoutedEventArgs e1)
{
......@@ -99,6 +100,9 @@ namespace FLY.Thick.Base.UI
{
update();
};
DataBindAll();
update();
}
void InitializeComponent2()
......
......@@ -7,7 +7,7 @@
xmlns:sys="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d"
d:DesignHeight="1200" d:DesignWidth="1024"
Background="White">
Background="WhiteSmoke">
<Page.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
......@@ -15,14 +15,16 @@
<ResourceDictionary Source="pack://application:,,,/FLY.Thick.Base.UI;component/Converter/Dictionary_MyConv.xaml"/>
</ResourceDictionary.MergedDictionaries>
<local:GetSampleVmUt x:Key="unittest"/>
<local:Item2IndexConverter x:Key="i2iConv"/>
<local:Item2DirectionConverter x:Key="i2dConv"/>
</ResourceDictionary>
</Page.Resources>
<Grid d:DataContext="{StaticResource unittest}" >
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="496*" />
<RowDefinition />
</Grid.RowDefinitions>
<Grid Name="grid_null"/>
<Grid Name="grid_initparam"/>
<StackPanel Orientation="Horizontal" Background="{StaticResource Background_Title}">
<Button Style="{StaticResource ButtonStyle_back2}" Command="BrowseBack"/>
<TextBlock Style="{StaticResource TextBlockStyle_Title}" Text="样品标定"/>
......@@ -54,8 +56,8 @@
<Run >
<MultiBinding Converter="{StaticResource outsp2mpminconv}" Mode="OneWay" StringFormat="{}{0:F1}">
<Binding Path="Velocity" />
<Binding Path="DataContext.Encoder1_mmpp" ElementName="grid_null"/>
<Binding Path="DataContext.Speed1Scale" ElementName="grid_null"/>
<Binding Path="DataContext.Encoder1_mmpp" ElementName="grid_initparam"/>
<Binding Path="DataContext.Speed1Scale" ElementName="grid_initparam"/>
</MultiBinding>
</Run>
<Run Text="m/min"/>
......@@ -72,7 +74,7 @@
<Run>
<MultiBinding Converter="{StaticResource p2mmconv}" Mode="OneWay" StringFormat="{}{0:F0}">
<Binding Path="Range" />
<Binding Path="DataContext.Encoder1_mmpp" ElementName="grid_null"/>
<Binding Path="DataContext.Encoder1_mmpp" ElementName="grid_initparam"/>
</MultiBinding>
</Run>
<Run Text="mm"/>
......@@ -114,13 +116,13 @@
<TextBox Style="{StaticResource TextBoxStyle_FieldContent}" Text="{Binding ErrValue}" />
</StackPanel>
</StackPanel>
<Button Style="{StaticResource ButtonStyle2}" Click="button_getorgad_Click" FontSize="27">
<Button Style="{StaticResource ButtonStyle2}" FontSize="27" Command="{Binding GetOrgAdCmd}">
<StackPanel>
<TextBlock Text="计算"/>
<TextBlock Text="原始AD值"/>
</StackPanel>
</Button>
<Button Style="{StaticResource ButtonStyle2}" Click="button_gageinfo_Click" FontSize="27">
<Button Style="{StaticResource ButtonStyle2}" FontSize="27" Click="btnGageInfoClick">
<StackPanel>
<TextBlock Text="机架信息"/>
</StackPanel>
......@@ -142,12 +144,13 @@
<Setter Property="TextAlignment" Value="Center"/>
</Style>
</StackPanel.Resources>
<Border Width="150" Background="{StaticResource Brush_theme_bar}" Margin="0,5,5,5">
<TextBlock Style="{StaticResource TextBlockStyle_ItemHeader}">
<Run Text="样品"/>
</TextBlock>
<Border Style="{StaticResource BorderStyle_paramSection}">
<TextBlock Text="样品"/>
</Border>
<StackPanel>
<StackPanel.Resources>
<CollectionViewSource Source="{Binding Samples}" x:Key="samplesViewSource" />
</StackPanel.Resources>
<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource TextBlockStyle_header_no}" Text="序号" />
<TextBlock Style="{StaticResource TextBlockStyle_header}" Text="使能" />
......@@ -156,7 +159,7 @@
<TextBlock Style="{StaticResource TextBlockStyle_header}" Text="位置" />
</StackPanel>
<ItemsControl x:Name="itemcontrol" ItemsSource="{Binding Samples}">
<ItemsControl ItemsSource="{Binding Source={StaticResource samplesViewSource}}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel/>
......@@ -168,7 +171,7 @@
<Rectangle Height="2" Fill="Gray"/>
<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent}" Width="{StaticResource column0_width}" Margin="0">
<Run Text="{Binding Index}"/>
<Run Text="{Binding Path=., Mode=OneWay, Converter={StaticResource i2iConv}, ConverterParameter={StaticResource samplesViewSource}}"/>
</TextBlock>
<ToggleButton Style="{StaticResource ToggleButtonStyle1}" IsChecked="{Binding Enable}" Width="{StaticResource column_width}" Margin="0"/>
<ToggleButton Style="{StaticResource ToggleButtonStyle1}" IsChecked="{Binding JustForCheck}" Width="{StaticResource column_width}" Margin="0"/>
......@@ -180,7 +183,7 @@
<Run>
<MultiBinding Converter="{StaticResource p2mmconv}" Mode="OneWay" StringFormat="{}{0:F0}">
<Binding Path="Position" />
<Binding Path="DataContext.Encoder1_mmpp" ElementName="grid_null"/>
<Binding Path="DataContext.Encoder1_mmpp" ElementName="grid_initparam"/>
</MultiBinding>
</Run>
<Run Text="mm" />
......@@ -200,8 +203,8 @@
<StackPanel Orientation="Horizontal">
<Border Background="{StaticResource Brush_theme_bar}" Margin="0,5,5,5" Width="150">
<TextBlock Style="{StaticResource TextBlockStyle_ItemHeader}" Text="位置修正" />
<Border Style="{StaticResource BorderStyle_paramSection}">
<TextBlock Text="位置修正" />
</Border>
<StackPanel>
<StackPanel Orientation="Horizontal">
......@@ -215,7 +218,7 @@
<Run>
<MultiBinding Converter="{StaticResource p2mmconv}" Mode="OneWay" StringFormat="{}{0:F0}">
<Binding Path="Search" />
<Binding Path="DataContext.Encoder1_mmpp" ElementName="grid_null"/>
<Binding Path="DataContext.Encoder1_mmpp" ElementName="grid_initparam"/>
</MultiBinding>
</Run>
<Run Text="mm" /></TextBlock>
......@@ -235,13 +238,14 @@
<Setter Property="Width" Value="{StaticResource column_width}"/>
<Setter Property="TextAlignment" Value="Center"/>
</Style>
<CollectionViewSource Source="{Binding Features}" x:Key="featuresViewSource" />
</StackPanel.Resources>
<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource TextBlockStyle_header_no}" Text="特征" />
<TextBlock Style="{StaticResource TextBlockStyle_header}" Text="使能" />
<TextBlock Style="{StaticResource TextBlockStyle_header}" Text="位置" />
</StackPanel>
<ItemsControl ItemsSource="{Binding Features}">
<ItemsControl ItemsSource="{Binding Source={StaticResource featuresViewSource}}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel/>
......@@ -253,7 +257,7 @@
<Rectangle Height="2" Fill="Gray"/>
<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent}" FontSize="20" Width="{StaticResource column0_width}" Margin="0" VerticalAlignment="Center">
<Run Text="{Binding Name}"/>
<Run Text="{Binding Path=., Mode=OneWay, Converter={StaticResource i2dConv},ConverterParameter={StaticResource featuresViewSource}}"/>
</TextBlock>
<ToggleButton Style="{StaticResource ToggleButtonStyle1}" IsChecked="{Binding Enable}" Width="{StaticResource column_width}" Margin="0"/>
......@@ -266,7 +270,7 @@
<Run>
<MultiBinding Converter="{StaticResource p2mmconv}" Mode="OneWay" StringFormat="{}{0:F0}">
<Binding Path="StartPos" />
<Binding Path="DataContext.Encoder1_mmpp" ElementName="grid_null"/>
<Binding Path="DataContext.Encoder1_mmpp" ElementName="grid_initparam"/>
</MultiBinding>
</Run>
<Run Text="mm" />
......@@ -274,7 +278,7 @@
<Run>
<MultiBinding Converter="{StaticResource p2mmconv}" Mode="OneWay" StringFormat="{}{0:F0}">
<Binding Path="EndPos" />
<Binding Path="DataContext.Encoder1_mmpp" ElementName="grid_null"/>
<Binding Path="DataContext.Encoder1_mmpp" ElementName="grid_initparam"/>
</MultiBinding>
</Run>
<Run Text="mm" />
......@@ -295,7 +299,7 @@
<StackPanel Orientation="Horizontal">
<Button Style="{StaticResource ButtonStyle3}" MinHeight="100" Margin="0,5,5,5" Width="150" Click="btnGetTempDatasClick" >
<Button Style="{StaticResource ButtonStyle3}" MinHeight="100" Margin="0,5,5,5" Width="150" Command="{Binding GetTempDataCmd}" >
<TextBlock Style="{StaticResource TextBlockStyle_ItemHeader}" Text="获取采集&#x0a;过程" />
</Button>
<StackPanel Orientation="Horizontal">
......@@ -325,13 +329,7 @@
</StackPanel>
</ScrollViewer>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" >
<Button Style="{StaticResource ButtonStyle_empty}" HorizontalAlignment="Right" VerticalAlignment="Bottom" Click="button_apply_Click" Margin="0,0,20,-45" >
<Grid >
<Ellipse Fill="White" Height="90" Width="90"/>
<Path Data="{StaticResource Geometry_check-circle}" Fill="#FF31AE15" Stretch="Fill" Height="80" Width="80" />
</Grid>
</Button>
</StackPanel>
<Button Style="{StaticResource ButtonStyle_apply}" VerticalAlignment="Bottom" Margin="0,0,20,-45"
Command="{Binding ApplyCmd}"/>
</Grid>
</Page>
using FLY.Thick.Base.IService;
using GalaSoft.MvvmLight.Command;
using System;
using System.Collections.Generic;
using System.ComponentModel;
......@@ -40,54 +41,139 @@ namespace FLY.Thick.Base.UI
this.gageInfoService = gageInfoService;
this.container = container;
//复制一份 getsample
//TODO
viewModel = new GetSampleVm();
string json = Newtonsoft.Json.JsonConvert.SerializeObject(getSampleService);
Newtonsoft.Json.JsonConvert.PopulateObject(json, viewModel);
viewModel.IsChanged = false;
foreach (var s in viewModel.Samples)
s.IsChanged = false;
foreach (var s in viewModel.Features)
s.IsChanged = false;
viewModel.Init(getSampleService, gageInfoService, tempdatas);
this.DataContext = viewModel;
this.grid_null.DataContext = this.initParamService;
this.grid_initparam.DataContext = this.initParamService;
}
private void btnGageInfoClick(object sender, RoutedEventArgs e)
{
Page p = (container.IsRegistered<Page>("pgGageInfo")) ? container.Resolve<Page>("pgGageInfo") : new PgGageInfo();
container.BuildUp(p);
NavigationService.Navigate(p);
}
private void button_apply_Click(object sender, RoutedEventArgs e)
}
public class GetSampleVm : INotifyPropertyChanged
{
#region 参数
/// <summary>
/// 参数:使能
/// </summary>
public bool Enable { get; set; }
/// <summary>
/// 参数:间隔
/// </summary>
public int Interval { get; set; }
/// <summary>
/// 参数:速度
/// </summary>
public UInt32 Velocity { get; set; }
/// <summary>
/// 参数:样品点范围
/// </summary>
public int Range { get; set; }
/// <summary>
/// 参数:移动滤波 ,窗口值
/// </summary>
public int Window { get; set; }
/// <summary>
/// 使用%方式检查异常
/// </summary>
public bool IsCheckByPercent { get; set; }
/// <summary>
/// 异常%
/// </summary>
public double ErrPercent { get; set; }
/// <summary>
/// 异常值
/// </summary>
public int ErrValue { get; set; }
/// <summary>
/// 参数:样品点参数
/// </summary>
public SampleCell[] Samples { get; private set; }
/// <summary>
/// 参数:特征查找范围
/// </summary>
public int Search { get; set; }
/// <summary>
/// 参数:特征参数
/// </summary>
public SampleFeature[] Features { get; private set; }
#endregion
#region Command
public RelayCommand ApplyCmd { get; }
public RelayCommand GetOrgAdCmd { get; }
public RelayCommand GetTempDataCmd { get; }
#endregion
public event PropertyChangedEventHandler PropertyChanged;
IGetSampleService getSampleService;
IGageInfoService gageInfoService;
ItemsControl tempdatas;
public GetSampleVm()
{
ApplyCmd = new RelayCommand(Apply);
GetOrgAdCmd = new RelayCommand(GetOrgAd);
GetTempDataCmd = new RelayCommand(GetTempData);
}
[InjectionMethod]
public void Init(
IGetSampleService getSampleService,
IGageInfoService gageInfoService,
ItemsControl tempdatas)
{
if (!WdPassword.Authorize("GetSample"))
return;
bool isChanged = false;
if (viewModel.IsChanged)
isChanged = true;
else if (viewModel.Samples.Any(s => s.IsChanged))
isChanged = true;
else if (viewModel.Features.Any(f => f.IsChanged))
isChanged = true;
if (!isChanged)
this.getSampleService = getSampleService;
this.gageInfoService = gageInfoService;
this.tempdatas = tempdatas;
Misc.BindingOperations.SetBinding(this.getSampleService, "Enable", this, "Enable");
Misc.BindingOperations.SetBinding(this.getSampleService, "Interval", this, "Interval");
Misc.BindingOperations.SetBinding(this.getSampleService, "Velocity", this, "Velocity");
Misc.BindingOperations.SetBinding(this.getSampleService, "Range", this, "Range");
Misc.BindingOperations.SetBinding(this.getSampleService, "Window", this, "Window");
Misc.BindingOperations.SetBinding(this.getSampleService, "IsCheckByPercent", this, "IsCheckByPercent");
Misc.BindingOperations.SetBinding(this.getSampleService, "ErrPercent", this, "ErrPercent");
Misc.BindingOperations.SetBinding(this.getSampleService, "ErrValue", this, "ErrValue");
Misc.BindingOperations.SetBinding(this.getSampleService, "Search", this, "Search");
Samples = new SampleCell[this.getSampleService.Samples.Count()];
Features = new SampleFeature[this.getSampleService.Features.Count()];
for (int i = 0; i < Samples.Count(); i++)
{
FLY.ControlLibrary.Window_Tip.Show("操作无效",
"没有任何数据被修改",
TimeSpan.FromSeconds(2));
return;
Samples[i] = new SampleCell();
Misc.BindingOperations.SetBinding(this.getSampleService.Samples[i], "Enable", Samples[i], "Enable");
Misc.BindingOperations.SetBinding(this.getSampleService.Samples[i], "JustForCheck", Samples[i], "JustForCheck");
Misc.BindingOperations.SetBinding(this.getSampleService.Samples[i], "OrgAD", Samples[i], "OrgAD");
Misc.BindingOperations.SetBinding(this.getSampleService.Samples[i], "Position", Samples[i], "Position");
}
//复制一份 到 getSampleService
//TODO
string json = Newtonsoft.Json.JsonConvert.SerializeObject(viewModel);
Newtonsoft.Json.JsonConvert.PopulateObject(json, getSampleService);
getSampleService.Apply();
FLY.ControlLibrary.Window_Tip.Show("应用成功",
null,
TimeSpan.FromSeconds(2));
for (int i = 0; i < Features.Count(); i++)
{
Features[i] = new SampleFeature();
Misc.BindingOperations.SetBinding(this.getSampleService.Features[i], "Enable", Features[i], "Enable");
Misc.BindingOperations.SetBinding(this.getSampleService.Features[i], "StartPos", Features[i], "StartPos");
Misc.BindingOperations.SetBinding(this.getSampleService.Features[i], "EndPos", Features[i], "EndPos");
}
}
private void button_getorgad_Click(object sender, RoutedEventArgs e)
private void GetOrgAd()
{
if (gageInfoService.ForwData == null || gageInfoService.BackwData == null)
{
......@@ -99,14 +185,14 @@ namespace FLY.Thick.Base.UI
int[] forwdata = gageInfoService.ForwData.ToArray();
int[] backwdata = gageInfoService.BackwData.ToArray();
for (int i = 0; i < viewModel.Samples.Count(); i++)
for (int i = 0; i < Samples.Count(); i++)
{
var sampleCell = viewModel.Samples[i];
var sampleCell = Samples[i];
if (sampleCell.Enable)
{
int grid = sampleCell.Position / gageInfoService.PosOfGrid;
int range = viewModel.Range / gageInfoService.PosOfGrid;
int range = Range / gageInfoService.PosOfGrid;
int bg = grid - range;
int eg = grid + range;
......@@ -142,18 +228,53 @@ namespace FLY.Thick.Base.UI
FLY.ControlLibrary.Window_Tip.Show("设置完成",
null,
TimeSpan.FromSeconds(2));
}
private void button_gageinfo_Click(object sender, RoutedEventArgs e)
private void Apply()
{
Page p = (container.IsRegistered<Page>("pgGageInfo")) ? container.Resolve<Page>("pgGageInfo") : new PgGageInfo();
container.BuildUp(p);
NavigationService.Navigate(p);
if (!WdPassword.Authorize("GetSample"))
return;
this.getSampleService.Enable = this.Enable;
this.getSampleService.Interval = this.Interval;
this.getSampleService.Range = this.Range;
this.getSampleService.Velocity = this.Velocity;
this.getSampleService.Window = this.Window;
this.getSampleService.IsCheckByPercent = this.IsCheckByPercent;
this.getSampleService.ErrPercent = this.ErrPercent;
this.getSampleService.ErrValue = this.ErrValue;
for (int i = 0; i < Samples.Count(); i++)
{
var sample_src = this.Samples[i];
var sample_desp = this.getSampleService.Samples[i];
sample_desp.Enable = sample_src.Enable;
sample_desp.JustForCheck = sample_src.JustForCheck;
sample_desp.OrgAD = sample_src.OrgAD;
sample_desp.Position = sample_src.Position;
}
this.getSampleService.Search = this.Search;
for (int i = 0; i < Features.Count(); i++)
{
var feature_src = this.Features[i];
var feature_desp = this.getSampleService.Features[i];
feature_desp.Enable = feature_src.Enable;
feature_desp.StartPos = feature_src.StartPos;
feature_desp.EndPos = feature_src.EndPos;
}
getSampleService.Apply();
FLY.ControlLibrary.Window_Tip.Show("应用成功",
null,
TimeSpan.FromSeconds(2));
}
private void btnGetTempDatasClick(object sender, RoutedEventArgs e)
private void GetTempData()
{
getSampleService.GetTempFilterDatas((asyncContext, retData) =>
{
......@@ -165,82 +286,11 @@ namespace FLY.Thick.Base.UI
}, null);
}
}
public class GetSampleVm : INotifyPropertyChanged
{
public GetSampleVm()
{
}
#region IGetSampleService 成员
/// <summary>
/// 参数:使能
/// </summary>
public bool Enable { get; set; }
/// <summary>
/// 参数:间隔
/// </summary>
public int Interval { get; set; }
/// <summary>
/// 采样计数
/// </summary>
public int Timer { get; set; }
/// <summary>
/// 参数:速度
/// </summary>
public UInt32 Velocity { get; set; }
/// <summary>
/// 参数:样品点范围
/// </summary>
public int Range { get; set; }
/// <summary>
/// 滤波窗口
/// </summary>
public int Window { get; set; }
/// <summary>
/// 样品
/// </summary>
public SampleCell[] Samples { get; set; }
/// <summary>
/// 查找公差
/// </summary>
public int Search { get; set; }
/// <summary>
/// 特征 相识度 0 正, 1 反
/// </summary>
public SampleFeature[] Features { get; set; }
/// <summary>
/// 状态:从flyad7 得到的。 用于绘制图
/// </summary>
public int PosOfGrid { get; set; } = 10;
public event PropertyChangedEventHandler PropertyChanged;
#endregion
public bool IsChanged { get; set; }
}
public class GetSampleVmUt : INotifyPropertyChanged
{
public GetSampleVmUt()
{
Samples = new SampleCell[3];
for (int i = 0; i < Samples.Count(); i++)
{
SampleCell sampleCell = new SampleCell();
......@@ -270,11 +320,6 @@ namespace FLY.Thick.Base.UI
/// </summary>
public int Interval { get; set; }
/// <summary>
/// 采样计数
/// </summary>
public int Timer { get; set; }
/// <summary>
/// 参数:速度
/// </summary>
......@@ -285,27 +330,35 @@ namespace FLY.Thick.Base.UI
/// </summary>
public int Range { get; set; }
/// <summary>
/// 滤波窗口
/// 参数:移动滤波 ,窗口值
/// </summary>
public int Window { get; set; }
/// <summary>
/// 样品
/// 使用%方式检查异常
/// </summary>
public SampleCell[] Samples { get; set; } = new SampleCell[3];
public bool IsCheckByPercent { get; set; }
/// <summary>
/// 查找公差
/// 异常%
/// </summary>
public double ErrPercent { get; set; }
/// <summary>
/// 异常值
/// </summary>
public int ErrValue { get; set; }
/// <summary>
/// 参数:样品点参数
/// </summary>
public SampleCell[] Samples { get; }
/// <summary>
/// 参数:特征查找范围
/// </summary>
public int Search { get; set; }
/// <summary>
/// 特征 相识度 0 正, 1 反
/// 参数:特征参数
/// </summary>
public SampleFeature[] Features { get; set; } = new SampleFeature[2];
public SampleFeature[] Features { get; }
/// <summary>
/// 状态:从flyad7 得到的。 用于绘制图
......
......@@ -22,8 +22,7 @@
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="496*" />
<RowDefinition Height="auto" />
<RowDefinition />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Background="{StaticResource Brush_theme_bar}">
<Button Style="{StaticResource ButtonStyle_back2}" Command="BrowseBack"/>
......
<UserControl x:Class="FLY.Thick.Base.UI.UiModule.DynAreaFilmWidth"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
d:DesignWidth="250"
mc:Ignorable="d" >
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Dictionary_MyStyle.xaml"/>
<ResourceDictionary Source="pack://application:,,,/FLY.Thick.Base.UI;component/Converter/Dictionary_MyConv.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style TargetType="TextBlock" x:Key="TextBlockStyle_ItemHeader">
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="FontFamily" Value="YouYuan"/>
<Setter Property="FontSize" Value="12"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="Foreground" Value="#FF3B3B3B"/>
<Setter Property="Margin" Value="5,0"/>
</Style>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Button Click="Border_Width_Click" Width="250" Style="{StaticResource ButtonStyle_empty}" Visibility="{Binding Enable,Converter={StaticResource visbilityconv},ConverterParameter=Collapsed}">
<Border Style="{StaticResource BorderStyle_module}" >
<StackPanel Margin="2">
<StackPanel Orientation="Horizontal" Margin="2">
<StackPanel Orientation="Horizontal" >
<TextBlock Text="横向宽度" FontSize="12" FontWeight="Bold" FontFamily="YouYuan" TextAlignment="Center" HorizontalAlignment="Center" Foreground="#FF3B3B3B" />
<StackPanel Orientation="Horizontal" Margin="5,0">
<TextBlock Text="{Binding Width, StringFormat={}{0:F0}}" FontSize="20" FontFamily="Microsoft Sans Serif" TextAlignment="Center" HorizontalAlignment="Center" Foreground="{StaticResource Color_theme_activity}" />
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent_mm}" Text="mm" FontSize="12" />
</StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="纵向速度" FontSize="12" FontWeight="Bold" FontFamily="YouYuan" TextAlignment="Center" HorizontalAlignment="Center" Foreground="#FF3B3B3B" />
<StackPanel Orientation="Horizontal" Margin="5,0">
<TextBlock Text="{Binding FilmVelocity, StringFormat={}{0:F1}}" FontSize="24" FontFamily="Microsoft Sans Serif" TextAlignment="Center" HorizontalAlignment="Center" Foreground="{StaticResource Color_theme_activity}" />
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent_mm}" Text="m/min" FontSize="12" />
</StackPanel>
</StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="2">
<StackPanel Orientation="Horizontal">
<TextBlock Text="纵向位置" FontSize="12" FontWeight="Bold" FontFamily="YouYuan" TextAlignment="Center" HorizontalAlignment="Center" Foreground="#FF3B3B3B" />
<StackPanel Orientation="Horizontal" Margin="5,0">
<TextBlock Text="{Binding FilmPosition, StringFormat={}{0:F2}}" FontSize="24" FontFamily="Microsoft Sans Serif" TextAlignment="Center" HorizontalAlignment="Center" Foreground="{StaticResource Color_theme_activity}" />
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent_mm}" Text="m" FontSize="12" />
</StackPanel>
</StackPanel>
</StackPanel>
</StackPanel>
</Border>
</Button>
</Grid>
</UserControl>
\ No newline at end of file
using FLY.Thick.Base.Common;
using MultiLayout.UiModule;
using System.Windows;
using System.Windows.Controls;
using Unity;
namespace FLY.Thick.Base.UI.UiModule
{
/// <summary>
/// DynAreaFilmWidth.xaml 的交互逻辑
/// </summary>
public partial class DynAreaFilmWidth : UserControl
{
//TDGage gage;
private IUnityContainer container;
private DynArea dynArea;
public DynAreaFilmWidth()
{
InitializeComponent();
}
[InjectionMethod]
public void Init(
IUnityContainer container,
FLY.Thick.Base.IService.IDynAreaService dynAreaService
)
{
this.container = container;
dynArea = dynAreaService.DynArea;
this.DataContext = dynArea;
}
private void Border_Width_Click(object sender, RoutedEventArgs e)
{
PgBorderSearch p = new PgBorderSearch();
container.BuildUp(p);
MultiLayout.FlyLayoutManager.NavigationService.Navigate(p);
}
}
public class UiModule2_DynAreaFilmWidth : IUiModule2
{
/// <summary>
/// 控件标题
/// 它的值取决于culture
/// </summary>
public string Title => "边界查找";
public ComponentType Type => ComponentType.DynArea;
public bool IsUnique => true;
/// <summary>
/// 控件
/// 创建时,需要给它唯一ID,让加载自己的数据
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public FrameworkElement GetComponent(int id, IUnityContainer container)
{
DynAreaFilmWidth graph = new DynAreaFilmWidth();
container.BuildUp(graph);
return graph;
}
/// <summary>
/// 控件缩略图,用于编辑界面时,大致看看
/// 创建时,需要给它唯一ID,让加载自己的数据
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public FrameworkElement GetThumbnail()
{
return new System.Windows.Controls.Grid();
}
/// <summary>
/// 给出全部控件ID, 控件自行删除没有的参数
/// </summary>
/// <param name="IDs"></param>
public void MatchParam(int[] IDs)
{
}
}
}
......@@ -19,20 +19,6 @@ namespace FLY.Thick.Base.Client
[JsonObject(MemberSerialization.OptIn)]
public class GetSampleServiceClient : FObjServiceClient, IGetSampleService
{
public GetSampleServiceClient(UInt32 id) : base(id) { init(); }
void init()
{
for (int i = 0; i < Samples.Count(); i++)
{
Samples[i] = new SampleCell();
}
Features[0] = new SampleFeature();
Features[1] = new SampleFeature();
}
public GetSampleServiceClient(UInt32 serviceId, string connName) : base(serviceId, connName) { init(); }
#region IGetSampleService 成员
/// <summary>
......@@ -112,11 +98,11 @@ namespace FLY.Thick.Base.Client
/// </summary>
[JsonProperty]
public int PosOfGrid { get; set; } = 10;
/// <summary>
///
/// </summary>
public void Apply()
public void Apply()
{
GETSAMPLE_OBJ_INTERFACE.Pack_Params p = new GETSAMPLE_OBJ_INTERFACE.Pack_Params
{
......@@ -126,7 +112,7 @@ namespace FLY.Thick.Base.Client
range = Range,
window = Window,
IsCheckByPercent = IsCheckByPercent,
ErrPercent =ErrPercent,
ErrPercent = ErrPercent,
ErrValue = ErrValue,
search = Search,
samples = from sample in Samples
......@@ -152,13 +138,26 @@ namespace FLY.Thick.Base.Client
//获取所有数据,设置推送
CurrObjSys.SetValueEx(
mConn, mServerID, ID,
mConn, mServerID, ID,
GETSAMPLE_OBJ_INTERFACE.SET_PARAMS,
Misc.Converter.StringToBytes(json)
);
}
#endregion
public GetSampleServiceClient(UInt32 id) : base(id) { init(); }
public GetSampleServiceClient(UInt32 serviceId, string connName) : base(serviceId, connName) { init(); }
void init()
{
for (int i = 0; i < Samples.Count(); i++)
Samples[i] = new SampleCell();
for (int i = 0; i < Features.Count(); i++)
Features[i] = new SampleFeature();
}
public override void ConnectNotify(IFConn from)
{
......
......@@ -149,7 +149,6 @@ namespace FLY.Thick.Base.IService
/// </summary>
public int SampleValue { get; set; }
public bool IsChanged { get; set; }
#region INotifyPropertyChanged 成员
......@@ -206,7 +205,6 @@ namespace FLY.Thick.Base.IService
[DoNotCheckEquality]
public int[] ScanData { get; set; }
public bool IsChanged { get; set; }
#region INotifyPropertyChanged 成员
public event PropertyChangedEventHandler PropertyChanged;
......
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