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();
                        }
                    }
                }
            };
        }
    }
}
