Пример #1
0
        /// <summary>
        /// 自定义灯光
        /// </summary>
        public void LivingLightCustom()
        {
            string            str    = File.ReadToEnd(lightfile, Encoding.GetEncoding(28591));
            LivingLightStatus status = JsonConvert.DeserializeObject <LivingLightStatus>(str);

            this.LivingFoyerLightLevel = status.Light1;
            this.LivingDropLightLevel  = status.Light2;
            this.LivingBeltLightLevel  = status.Light3;
            this.LivingFrontLightLevel = status.Light4;
            this.LivingBackLightLevel  = status.Light5;
            this.LivingRightLightLevel = status.Light6;
        }
Пример #2
0
        /// <summary>
        /// 保存自定义灯光
        /// </summary>
        public void LivingLightCustomSave()
        {
            LivingLightStatus status = new LivingLightStatus();

            status.Light1 = this.LivingFoyerLightLevel;
            status.Light2 = this.LivingDropLightLevel;
            status.Light3 = this.LivingBeltLightLevel;
            status.Light4 = this.LivingFrontLightLevel;
            status.Light5 = this.LivingBackLightLevel;
            status.Light6 = this.LivingRightLightLevel;


            if (File.Exists(lightfile))
            {
                File.Delete(lightfile);
            }
            string strLight = JsonConvert.SerializeObject(status);

            using (FileStream fileStream = new FileStream(lightfile, FileMode.Create))
            {
                fileStream.Write(strLight, Encoding.GetEncoding(28591));
                fileStream.Flush();
            }
        }