using FLY.Thick.Base.UI;
using FLY.Thick.Blowing.Client;
using FLY.Thick.Blowing.IService;
using GalaSoft.MvvmLight.Command;
using System;
using System.ComponentModel;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using Unity;
namespace FLY.Thick.Blowing.UI.Fix.Client
{
///
/// Page_ScanWarning.xaml 的交互逻辑
///
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 参数
///
/// 使能
///
public bool Enable { get; set; }
///
/// 自动目标值
///
public bool IsAutoTarget { get; set; }
///
/// 连续N个点,大于规格线(公差)才算报警
///
public int AlarmCnt_Tolerance { 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, "Enable", this, "Enable");
Misc.BindingOperations.SetBinding(scanWarningService, "IsAutoTarget", this, "IsAutoTarget");
Misc.BindingOperations.SetBinding(scanWarningService, "AlarmCnt_Tolerance", this, "AlarmCnt_Tolerance");
}
private void Apply()
{
if (!WdPassword.Authorize("ScanWarning"))
return;
scanWarningService.Enable = this.Enable;
scanWarningService.IsAutoTarget = this.IsAutoTarget;
scanWarningService.AlarmCnt_Tolerance = this.AlarmCnt_Tolerance;
scanWarningService.Apply();
FLY.ControlLibrary.Window_Tip.Show("应用成功",
null,
TimeSpan.FromSeconds(2));
}
}
}