LCUS1_dependOn.cs 1.42 KB
Newer Older
潘栩锋's avatar
潘栩锋 committed
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
using Misc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FLY.Thick.Base.UI
{
    public class LCUS1_dependOn:LCUS1
    {
        ParamDictionary paramDictionary;
        FLY.OBJComponents.IService.IWarningService warningService;
        public LCUS1_dependOn(
            ParamDictionary paramDictionary, 
            FLY.OBJComponents.IService.IWarningService warningService) 
        {
            this.paramDictionary = paramDictionary;
            this.warningService = warningService;
            PortName = this.paramDictionary.GetValue("LCUS1_PortName", "COM1");
            this.paramDictionary.ValueChanged += (s, e) =>
            {
                if (e.Key == "LCUS1_PortName")
                {
                    PortName = e.Value as string;
                }
            };

            this.warningService.PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == "IsRinging")
                {
                    if (this.paramDictionary.GetValue("EnableLCUS1",false))
                    {
                        if (this.warningService.IsRinging)
                        {
                            On();
                        }
                        else
                        {
                            Off();
                        }
                    }
                }
            };
        }
    }
}