From 25429f085093d89d543a0b90e30d0d62d1b7dac9 Mon Sep 17 00:00:00 2001 From: hxb <hxb@hdlchina.com.cn> Date: 星期二, 30 八月 2022 09:37:38 +0800 Subject: [PATCH] 合并了IOS的代码 --- ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceColorLightDetailCardForm.cs | 153 +++++++++++++++++++++++++------------------------- 1 files changed, 76 insertions(+), 77 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceColorLightDetailCardForm.cs b/ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceColorLightDetailCardForm.cs index de15ae1..37874aa 100755 --- a/ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceColorLightDetailCardForm.cs +++ b/ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceColorLightDetailCardForm.cs @@ -19,10 +19,6 @@ /// </summary> private List<ButtonBase> listControl = new List<ButtonBase>(); /// <summary> - /// MaxLevel - /// </summary> - private const int MaxLevel = 254; - /// <summary> /// 褰╃伅鎺т欢 /// </summary> private WaveSeekBar waveSeekBar = null; @@ -30,10 +26,6 @@ /// 杩涘害鍊兼槸鍚﹀湪鏀瑰彉涓� /// </summary> private bool isProgressing = false; - /// <summary> - /// 鑳藉惁鍙戦�佽繘搴﹀�� - /// </summary> - private bool canSetProgressValue = true; /// <summary> /// 鏄惁宸茬粡鍒濆鍖栦簡鎺т欢(鍥犱负搴曞眰鏈夊彲鑳戒細鍒锋柊鏁翠釜鐣岄潰) /// </summary> @@ -57,8 +49,10 @@ this.ScrollEnabled = false; //鍏堟竻绌� this.listControl = new List<ButtonBase>(); + //璁剧疆鍒濆鐘舵�� + this.IsLightOpen = ((LightBase)this.device).OnOffStatus == 1; //璁剧疆鐘舵�佹枃瀛� - if (((LightBase)this.device).OnOffStatus == 1) + if (this.IsLightOpen == true) { //浜害 XX this.SetStatuText(Language.StringByID(R.MyInternationalizationString.uBrightness) + " " + HdlDeviceOtherLogic.Current.GetDeviceStatu(this.device)); @@ -72,13 +66,21 @@ //褰╃伅鎺т欢 this.waveSeekBar = new WaveSeekBar(); waveSeekBar.Y = Application.GetRealHeight(377); - waveSeekBar.Width = Application.GetMinRealAverage(271); - waveSeekBar.Height = Application.GetMinRealAverage(533); + waveSeekBar.Width = this.GetPictrueRealSize(271); + waveSeekBar.Height = this.GetPictrueRealSize(533); waveSeekBar.Gravity = Gravity.CenterHorizontal; waveSeekBar.WavePadding = Application.GetRealWidth(8); waveSeekBar.MaxValue = 100; - waveSeekBar.Progress = (int)(((DimmableLight)this.device).Level * 1.0 / MaxLevel * 100); + waveSeekBar.Progress = HdlDeviceCommonLogic.Current.CalculateLightLevelPersent(((DimmableLight)this.device).Level); waveSeekBar.CornerRadius = Application.GetRealHeight(58); + if (this.IsLightOpen == true) + { + waveSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarColor_Start, ZigbeeColor.Current.GXCWaveSeekBarColor_End); + } + else + { + waveSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor, ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor); + } frameWhiteBack.AddChidren(waveSeekBar); //寮�鍏� @@ -87,6 +89,7 @@ btnSwitch.SelectedImagePath = "Item/SwitchSelected.png"; btnSwitch.Y = waveSeekBar.Bottom + Application.GetRealHeight(84); btnSwitch.Gravity = Gravity.CenterHorizontal; + btnSwitch.IsSelected = this.IsLightOpen; frameWhiteBack.AddChidren(btnSwitch); listControl.Add(btnSwitch); btnSwitch.ButtonClickEvent += (sender, e) => @@ -94,21 +97,6 @@ //鍙戦�佸紑鍏冲懡浠� this.SetSwitchCommand(!btnSwitch.IsSelected); }; - - //璁剧疆鍒濆鐘舵�� - this.IsLightOpen = ((LightBase)this.device).OnOffStatus == 1; - this.canSetProgressValue = this.IsLightOpen; - if (IsLightOpen == true) - { - btnSwitch.IsSelected = true; - waveSeekBar.IsClickable = true; - waveSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarColor_Start, ZigbeeColor.Current.GXCWaveSeekBarColor_End); - } - else - { - waveSeekBar.IsClickable = false; - waveSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor, ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor); - } //褰╃伅鎺т欢閲岄潰鐨勯偅涓樉绀虹櫨鍒嗘瘮鐨勬帶浠� int progressY = waveSeekBar.Y - Application.GetMinReal(154); @@ -154,7 +142,17 @@ //鍙樻洿杩涘害鐧惧垎姣旂殑鏄剧ず btnProgress.Y = progressY + waveSeekBar.NowProgressY; btnProgress.Text = value + "%"; - nowProgressValue = value; + if (Common.Config.Instance.Home.IsVirtually == false) + { + nowProgressValue = value; + } + else + { + //濡傛灉浣忓畢涓鸿櫄鎷熶綇瀹�,鐩存帴鏀圭紦瀛� + ((DimmableLight)this.device).Level = HdlDeviceCommonLogic.Current.CalculateLightLevel(value); + //浜害 XX + this.SetStatuText(Language.StringByID(R.MyInternationalizationString.uBrightness) + " " + HdlDeviceOtherLogic.Current.GetDeviceStatu(this.device)); + } }; if (this.hadInitControl == true) @@ -164,21 +162,26 @@ } this.hadInitControl = true; + if (Config.Instance.Home.IsVirtually == true) + { + //铏氭嫙浣忓畢 + return; + } + //寮�涓�涓嚎绋�,鐩戣鏄惁婊戝姩鐨勬粦鍔ㄦ潯,姣忕妫�娴嬩竴娆� HdlThreadLogic.Current.RunThread(() => { while (this.Parent != null) { System.Threading.Thread.Sleep(1000); - if (nowProgressValue == oldProgressValue - || this.canSetProgressValue == false) + if (nowProgressValue == oldProgressValue) { //鍊间竴鏍� continue; } oldProgressValue = nowProgressValue; //鍙戦�佽繘搴﹀�� - ((DimmableLight)this.device).SetLevel((int)(oldProgressValue * MaxLevel / 100.0)); + ((DimmableLight)this.device).SetLevel(HdlDeviceCommonLogic.Current.CalculateLightLevel(oldProgressValue)); } }); } @@ -193,52 +196,54 @@ /// <param name="isOpen"></param> private void SetSwitchCommand(bool isOpen) { - //褰撴寜涓嬪紑鍏虫寜閽椂,涓嶈兘鍐嶅彂閫佽繘搴﹀�� - this.canSetProgressValue = false; + //鑾峰彇褰撳墠浜害 + int level = Convert.ToInt32(this.device.GetType().InvokeMember("Level", System.Reflection.BindingFlags.GetField, null, this.device, null)); + //濡傛灉浣忓畢鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) + { + ((LightBase)this.device).OnOffStatus = isOpen == true ? 1 : 0; + if (((LightBase)this.device).OnOffStatus == 1 && level == 0) + { + //濡傛灉褰撳墠鏄墦寮�鐘舵��,骞朵笖浜害涓�0鐨勮瘽,鍒欓渶瑕佸彉鎴�100%浜害 + this.device.GetType().InvokeMember("Level", System.Reflection.BindingFlags.SetField, null, this.device, new object[] { 100 }); + } + //鍒锋柊寮�鍏崇姸鎬� + this.RefreshSwitchStatu(isOpen); + return; + } //妫�娴嬫槸鍚﹁幏鍙栫綉鍏冲弽棣堢殑缁撴灉,濡傛灉缃戝叧娌℃湁鍥炲,鍒欎細寮瑰嚭娑堟伅 this.StartCheckResponeResult(this.listControl, (result) => { HdlThreadLogic.Current.RunMain(() => { - //娌℃湁鎺ユ敹鍒扮綉鍏冲洖澶� - if (result == false) + bool statu = ((LightBase)this.device).OnOffStatus == 1; + //鎺ユ敹鍒扮綉鍏冲洖澶� + if (result == true) { - bool statu = ((LightBase)this.device).OnOffStatus == 1; //鍒锋柊寮�鍏崇姸鎬� this.RefreshSwitchStatu(statu); - if (statu == true) - { - //绛夊緟缁撴灉缁撴潫鍚�,褰╃伅鎺т欢鍙互婊戝姩 - waveSeekBar.IsClickable = true; - } + //鐘舵�佸彇鍙� + listControl[0].IsSelected = statu; } }); }); - - //鐘舵�佸彇鍙� - listControl[0].IsSelected = !listControl[0].IsSelected; - //鍙戦�佺瓑寰呯殑鏃堕棿鍐�,涓嶈兘婊戝姩褰╃伅鎺т欢 - waveSeekBar.IsClickable = false; - if (isOpen == true) - { - waveSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarColor_Start, ZigbeeColor.Current.GXCWaveSeekBarColor_End); - } - else - { - waveSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor, ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor); - } - if (isOpen == true) { //鎵撳紑 - this.SetStatuText(Language.StringByID(R.MyInternationalizationString.uOpen1)); - this.device.SwitchControl(1); + if (level == 0) + { + //濡傛灉褰撳墠鏄墦寮�鐘舵��,骞朵笖浜害涓�0鐨勮瘽,鍒欓渶瑕佸彉鎴�100%浜害 + this.device.GetType().InvokeMember("SetLevel", System.Reflection.BindingFlags.InvokeMethod, null, this.device, new object[] { 255 }); + } + else + { + this.device.SwitchControl(1); + } } else { //鍏抽棴 - this.SetStatuText(Language.StringByID(R.MyInternationalizationString.Close)); this.device.SwitchControl(0); } } @@ -255,17 +260,14 @@ /// <returns></returns> public override bool CheckResponeResultStatu(ReceiveComandDiv comandDiv, CommonDevice report) { - if (comandDiv == ReceiveComandDiv.A鑺傜偣鎺у埗鍙嶉) - { - return true; - } - else if (comandDiv == ReceiveComandDiv.A璁惧灞炴�т笂鎶�) + if (comandDiv == ReceiveComandDiv.A璁惧灞炴�т笂鎶�) { HdlThreadLogic.Current.RunMain(() => { //鍒锋柊寮�鍏崇姸鎬� this.RefreshSwitchStatu(((LightBase)this.device).OnOffStatus == 1); }); + return true; } return false; } @@ -284,11 +286,6 @@ { //浜害鏄繀椤昏鍒锋柊鐨� 浜害 XX this.SetStatuText(Language.StringByID(R.MyInternationalizationString.uBrightness) + " " + HdlDeviceOtherLogic.Current.GetDeviceStatu(this.device)); - if (this.isProgressing == false) - { - //褰撹繘搴﹀�煎湪鎵嬪姩鍙樻洿涓椂,涓嶆帴鏀舵帹閫� - waveSeekBar.Progress = (int)(((DimmableLight)this.device).Level * 1.0 / MaxLevel * 100); - } } if (isOpen == false && this.IsLightOpen == true) { @@ -296,29 +293,31 @@ this.SetStatuText(Language.StringByID(R.MyInternationalizationString.Close)); } + if (this.isProgressing == false) + { + //褰撹繘搴﹀�煎湪鎵嬪姩鍙樻洿涓椂,涓嶆帴鏀舵帹閫� + int progress = HdlDeviceCommonLogic.Current.CalculateLightLevelPersent(((DimmableLight)this.device).Level); + if (waveSeekBar.Progress != progress) + { + waveSeekBar.Progress = progress; + } + } + if (listControl[0].IsSelected != isOpen) { //寮�鍏崇姸鎬佸彉鏇� listControl[0].IsSelected = isOpen; - } - - //鐘舵�佷笉涓�鏍锋墠鍙樻洿 - if (this.IsLightOpen != isOpen) - { if (isOpen == true) { - waveSeekBar.IsClickable = true; waveSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarColor_Start, ZigbeeColor.Current.GXCWaveSeekBarColor_End); } else { - waveSeekBar.IsClickable = false; waveSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor, ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor); } } + this.IsLightOpen = isOpen; - //鍥炲鐨勭粨鏋滆,澶勪簬鎵撳紑鐘舵�佹墠鑳藉彂閫� - this.canSetProgressValue = this.IsLightOpen; } #endregion -- Gitblit v1.8.0