Exemplo n.º 1
0
        public DigitalAdjustmentNode(KNXDigitalAdjustment knx, BackgroundWorker worker)
            : base(knx, worker)
        {
            this.Name = ImageKey = SelectedImageKey = MyConst.Controls.KnxDigitalAdjustmentType;

            SetText(this.Title);

            this.ReadAddressId   = knx.ReadAddressId ?? new Dictionary <string, KNXSelectedAddress>();
            this.WriteAddressIds = knx.WriteAddressIds ?? new Dictionary <string, KNXSelectedAddress>();

            if (ImportedHelper.IsLessThan2_0_3())
            {
                if (!string.IsNullOrEmpty(knx.LeftImage))
                {
                    this.LeftImage = ProjResManager.CopyImageSole(Path.Combine(this.ImagePath, knx.LeftImage));
                }
                if (!string.IsNullOrEmpty(knx.RightImage))
                {
                    this.RightImage = ProjResManager.CopyImageSole(Path.Combine(this.ImagePath, knx.RightImage));
                }
            }
            else if (ImportedHelper.IsLessThan2_5_6())
            {
                this.LeftImage  = ProjResManager.CopyImageSole(Path.Combine(this.ImagePath, NAME_LEFTIMAGE));
                this.RightImage = ProjResManager.CopyImageSole(Path.Combine(this.ImagePath, NAME_RIGHTIMAGE));
            }
            else
            {
                this.LeftImage  = knx.LeftImage;
                this.RightImage = knx.RightImage;
            }
            this.DecimalDigit = (EDecimalDigit)Enum.ToObject(typeof(EDecimalDigit), knx.DecimalDigit);
            this.MaxValue     = knx.MaxValue;
            this.MinValue     = knx.MinValue;

            if (ImportedHelper.IsLessThan2_1_8() && knx.Unit > (int)EMeasurementUnit.Centigrade)
            {
                this.Unit = (EMeasurementUnit)Enum.ToObject(typeof(EMeasurementUnit), knx.Unit - 1);
            }
            else
            {
                this.Unit = (EMeasurementUnit)Enum.ToObject(typeof(EMeasurementUnit), knx.Unit);
            }

            if (ImportedHelper.IsLessThan2_5_3())
            {
                this.RegulationStep = ERegulationStep.One;
            }
            else
            {
                if (ImportedHelper.IsLessThan2_5_4())
                {
                    knx.RegStep        += 2;
                    this.RegulationStep = (ERegulationStep)Enum.ToObject(typeof(ERegulationStep), knx.RegStep);
                }
                else
                {
                    this.RegulationStep = (ERegulationStep)EnumExtension.ConvertFrom(typeof(ERegulationStep), knx.RegulationStep);
                }
            }

            if (ImportedHelper.IsLessThan2_5_4())
            {
                this.ValueFont = this.TitleFont.Clone();
            }
            else
            {
                this.ValueFont = new STFont(knx.ValueFont);
            }
        }