using FLY.Thick.Base.Common; using FLY.Thick.Base.IService; using MultiLayout.UiModule; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; namespace FLY.Thick.Base.UI.OnInit { /// /// 显示 自动扫描 提示, 只是负责显示而已 /// public class OnInitAutoScan : IOnInit { FLY.OBJComponents.IService.IWarningSystem2Service warningService; ITDGageService tDGageService; int autoscan_tip_id = -1; public OnInitAutoScan(FLY.OBJComponents.IService.IWarningSystem2Service warningService, ITDGageService tDGageService, int lv=1) { Level = lv; this.warningService = warningService; this.tDGageService = tDGageService; } public int Level { get; } public void OnInit() { tDGageService.DynArea.PropertyChanged += (s, e) => { DynArea dynArea = s as DynArea; if (e.PropertyName == nameof(dynArea.ControllerState)) { if (dynArea.ControllerState != CTRL_STATE.AUTOSCAN) { if (autoscan_tip_id != -1) { FLY.ControlLibrary.Window_WarningTip.Stop(autoscan_tip_id); autoscan_tip_id = -1; } } if (dynArea.ControllerState == CTRL_STATE.PAUSE) { string msg = (string)Application.Current.TryFindResource("str.OnInit.PauseScan"); FLY.ControlLibrary.Window_WarningTip.Show(null,msg,TimeSpan.MaxValue); } } else if (e.PropertyName == nameof(dynArea.AutoScanCounter)) { if (dynArea.ControllerState == CTRL_STATE.AUTOSCAN) { string okcontent = (string)Application.Current.TryFindResource("str.OnInit.Cancel"); string format = (string)Application.Current.TryFindResource("str.OnInit.AfterNsWillScan"); string msg = string.Format(format, dynArea.AutoScanCounter); autoscan_tip_id = FLY.ControlLibrary.Window_WarningTip.Show(null,msg,TimeSpan.FromSeconds(dynArea.AutoScanCounter), null, warningService.Reset, okcontent, ()=> { tDGageService.StartP2(STARTP2_MODE.STOP); }); } } }; } } }