OnInitAutoScan.cs 2.67 KB
Newer Older
1 2 3 4 5 6 7 8
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;
9
using System.Windows;
10 11 12

namespace FLY.Thick.Base.UI.OnInit
{
潘栩锋's avatar
潘栩锋 committed
13 14 15
    /// <summary>
    /// 显示 自动扫描 提示, 只是负责显示而已
    /// </summary>
16 17
    public class OnInitAutoScan : IOnInit
    {
18
        FLY.OBJComponents.IService.IWarningSystem2Service warningService;
19 20
        ITDGageService tDGageService;
        int autoscan_tip_id = -1;
21
        public OnInitAutoScan(FLY.OBJComponents.IService.IWarningSystem2Service warningService, ITDGageService tDGageService, int lv=1) 
22 23 24 25 26 27 28 29 30 31
        {
            Level = lv;
            this.warningService = warningService;
            this.tDGageService = tDGageService;
        }

        public int Level { get; }

        public void OnInit()
        {
潘栩锋's avatar
潘栩锋 committed
32
            tDGageService.DynArea.PropertyChanged += (s, e) =>
33 34 35
            {
                DynArea dynArea = s as DynArea;

潘栩锋's avatar
潘栩锋 committed
36
                if (e.PropertyName == nameof(dynArea.ControllerState))
37 38 39 40 41 42 43 44 45 46 47 48
                {
                    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)
                    {
49 50
                        string msg = (string)Application.Current.TryFindResource("str.OnInit.PauseScan");
                        FLY.ControlLibrary.Window_WarningTip.Show(null,msg,TimeSpan.MaxValue);
51 52
                    }
                }
潘栩锋's avatar
潘栩锋 committed
53
                else if (e.PropertyName == nameof(dynArea.AutoScanCounter))
54 55 56
                {
                    if (dynArea.ControllerState == CTRL_STATE.AUTOSCAN)
                    {
57 58 59 60 61
                        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),
62 63
                            null,
                            warningService.Reset,
64
                            okcontent,
65 66 67 68 69 70 71 72
                            ()=> { tDGageService.StartP2(STARTP2_MODE.STOP); });
                    }
                }

            };
        }
    }
}