1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
using FLY.Thick.Base.UI;
using FLY.Thick.FilmCasting.IService;
using GalaSoft.MvvmLight.Command;
using System;
using System.ComponentModel;
using System.Windows.Controls;
using Unity;
namespace FLY.Thick.FilmCasting.UI
{
/// <summary>
/// PgScanWarning.xaml 的交互逻辑
/// </summary>
public partial class PgScanWarning : Page
{
PgScanWarningVm viewModel;
public PgScanWarning()
{
InitializeComponent();
}
[InjectionMethod]
public void Init(IScanWarningService scanWarningService)
{
viewModel = new PgScanWarningVm();
viewModel.Init(scanWarningService);
this.DataContext = viewModel;
}
}
public class PgScanWarningVm : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
#region 参数
/// <summary>
/// 使能
/// </summary>
public bool Enable { get; set; }
/// <summary>
/// 连续N个点,大于规格线(公差)才算报警
/// </summary>
public int AlarmCnt { get; set; }
/// <summary>
/// 是公差的多少倍 报警
/// </summary>
public double AlarmPercent { get; set; }
/// <summary>
/// 混合数
/// </summary>
public int Mix { get; set; }
#endregion
#region Command
public RelayCommand ApplyCmd { get; }
#endregion
IScanWarningService scanWarningService;
public PgScanWarningVm()
{
ApplyCmd = new RelayCommand(Apply);
}
public void Init(IScanWarningService scanWarningService)
{
this.scanWarningService = scanWarningService;
Misc.BindingOperations.SetBinding(scanWarningService, nameof(scanWarningService.Enable), this, nameof(Enable));
Misc.BindingOperations.SetBinding(scanWarningService, nameof(scanWarningService.AlarmCnt), this, nameof(AlarmCnt));
Misc.BindingOperations.SetBinding(scanWarningService, nameof(scanWarningService.AlarmPercent), this, nameof(AlarmPercent));
Misc.BindingOperations.SetBinding(scanWarningService, nameof(scanWarningService.Mix), this, nameof(Mix));
}
private void Apply()
{
if (!WdPassword.Authorize("ScanWarning"))
return;
scanWarningService.Enable = this.Enable;
scanWarningService.AlarmCnt = this.AlarmCnt;
scanWarningService.AlarmPercent = this.AlarmPercent;
scanWarningService.Mix = this.Mix;
scanWarningService.Apply();
FLY.ControlLibrary.Window_Tip.Show("应用成功",
null,
TimeSpan.FromSeconds(2));
}
}
}