From 9a4b76398009cf76c508d61f7e48fb6f5cb7ac2d Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期二, 21 七月 2020 09:46:53 +0800
Subject: [PATCH] 请合并最新多功能面板代码

---
 ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceColorLightDetailCardForm.cs |  332 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 332 insertions(+), 0 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceColorLightDetailCardForm.cs b/ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceColorLightDetailCardForm.cs
new file mode 100755
index 0000000..cc9f72d
--- /dev/null
+++ b/ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceColorLightDetailCardForm.cs
@@ -0,0 +1,332 @@
+锘縰sing Shared.Common;
+using Shared.Phone.UserCenter;
+using System;
+using System.Collections.Generic;
+using System.Text;
+using ZigBee.Device;
+
+namespace Shared.Phone.MainPage.ControlForm
+{
+    /// <summary>
+    /// 褰╃伅(璋冨厜鍣�)绫诲瀷鐨勬繁搴﹀崱鐗囩晫闈�
+    /// </summary>
+    public class DeviceColorLightDetailCardForm : DeviceDetailCardCommonForm
+    {
+        #region 鈻� 鍙橀噺澹版槑___________________________
+
+        /// <summary>
+        /// 鐣岄潰涓婂彲浠ユ搷浣滅殑鎺т欢
+        /// </summary>
+        private List<ButtonBase> listControl = new List<ButtonBase>();
+        /// <summary>
+        /// MaxLevel
+        /// </summary>
+        private const int MaxLevel = 254;
+        /// <summary>
+        /// 褰╃伅鎺т欢
+        /// </summary>
+        private WaveSeekBar waveSeekBar = null;
+        /// <summary>
+        /// 杩涘害鍊兼槸鍚﹀湪鏀瑰彉涓�
+        /// </summary>
+        private bool isProgressing = false;
+        /// <summary>
+        /// 鑳藉惁鍙戦�佽繘搴﹀��
+        /// </summary>
+        private bool canSetProgressValue = true;
+        /// <summary>
+        /// 鏄惁宸茬粡鍒濆鍖栦簡鎺т欢(鍥犱负搴曞眰鏈夊彲鑳戒細鍒锋柊鏁翠釜鐣岄潰)
+        /// </summary>
+        private bool hadInitControl = false;
+        /// <summary>
+        /// 褰╃伅鏄惁鏄墦寮�鐘舵��(涓嶈兘鐢ㄦ帶浠剁殑Select鏉ュ垽鏂�,澶潙)
+        /// </summary>
+        private bool IsLightOpen = false;
+
+        #endregion
+
+        #region 鈻� 鍒濆鍖朹____________________________
+
+        /// <summary>
+        /// 搴曞眰鍒濆鍖栦腑閮ㄦ帶浠跺畬鎴愪箣鍚�
+        /// </summary>
+        /// <param name="frameWhiteBack"></param>
+        public override void InitMiddleFrameAfter(FrameLayout frameWhiteBack)
+        {
+            //宸︽粦涓嶈兘
+            this.ScrollEnabled = false;
+            //鍏堟竻绌�
+            this.listControl = new List<ButtonBase>();
+            //璁剧疆鐘舵�佹枃瀛�
+            if (((LightBase)this.device).OnOffStatus == 1)
+            {
+                //浜害 XX
+                this.SetStatuText(Language.StringByID(R.MyInternationalizationString.uBrightness) + "  " + HdlDeviceOtherLogic.Current.GetDeviceStatu(this.device));
+            }
+            else
+            {
+                //鍏抽棴
+                this.SetStatuText(Language.StringByID(R.MyInternationalizationString.Close));
+            }
+
+            //褰╃伅鎺т欢
+            this.waveSeekBar = new WaveSeekBar();
+            waveSeekBar.Y = Application.GetRealHeight(377);
+            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.CornerRadius = Application.GetRealHeight(58);
+            frameWhiteBack.AddChidren(waveSeekBar);
+
+            //寮�鍏�
+            var btnSwitch = new IconViewControl(81);
+            btnSwitch.UnSelectedImagePath = "Item/Switch.png";
+            btnSwitch.SelectedImagePath = "Item/SwitchSelected.png";
+            btnSwitch.Y = waveSeekBar.Bottom + Application.GetRealHeight(84);
+            btnSwitch.Gravity = Gravity.CenterHorizontal;
+            frameWhiteBack.AddChidren(btnSwitch);
+            listControl.Add(btnSwitch);
+            btnSwitch.ButtonClickEvent += (sender, e) =>
+            {
+                //鍙戦�佸紑鍏冲懡浠�
+                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);
+            var btnProgress = new NormalViewControl(Application.GetMinReal(135), Application.GetMinReal(104), false);
+            btnProgress.Y = progressY;
+            btnProgress.UnSelectedImagePath = "Item/ProgressBubbles.png";
+            btnProgress.IsBold = true;
+            btnProgress.TextColor = UserCenterColor.Current.White;
+            btnProgress.Gravity = Gravity.CenterHorizontal;
+            btnProgress.TextAlignment = TextAlignment.Center;
+            frameWhiteBack.AddChidren(btnProgress);
+            btnProgress.Visible = false;
+
+            //寮�濮嬫粦鍔ㄧ殑浜嬩欢
+            waveSeekBar.OnStartTrackingTouchEvent += (sender, e) =>
+            {
+                //杩涘害鍊煎紑濮嬪彉鏇�
+                this.isProgressing = true;
+                //鍙樻洿杩涘害鐧惧垎姣旂殑鏄剧ず
+                btnProgress.Y = progressY + waveSeekBar.NowProgressY;
+                btnProgress.Text = waveSeekBar.Progress + "%";
+                waveSeekBar.IsProgressTextShow = false;
+                if (btnProgress.Visible == false)
+                {
+                    btnProgress.Visible = true;
+                }
+            };
+
+            //缁撴潫婊戝姩鐨勪簨浠�
+            waveSeekBar.OnStopTrackingTouchEvent += (sender, e) =>
+            {
+                //杩涘害鍊煎紑濮嬬粨鏉�
+                this.isProgressing = false;
+                btnProgress.Visible = false;
+                waveSeekBar.IsProgressTextShow = true;
+            };
+
+            //婊戝姩杩囩▼涓�
+            int oldProgressValue = waveSeekBar.Progress;//涔嬪墠鐨勫��
+            int nowProgressValue = oldProgressValue;//鍙樻洿鐨勫��
+            waveSeekBar.OnProgressChangedEvent += (sender, value) =>
+            {
+                //鍙樻洿杩涘害鐧惧垎姣旂殑鏄剧ず
+                btnProgress.Y = progressY + waveSeekBar.NowProgressY;
+                btnProgress.Text = value + "%";
+                if (Common.Config.Instance.Home.IsVirtually == false)
+                {
+                    nowProgressValue = value;
+                }
+                else
+                {
+                    //濡傛灉浣忓畢涓鸿櫄鎷熶綇瀹�,鐩存帴鏀圭紦瀛�
+                    ((DimmableLight)this.device).Level = value * MaxLevel / 100;
+                    //浜害 XX
+                    this.SetStatuText(Language.StringByID(R.MyInternationalizationString.uBrightness) + "  " + HdlDeviceOtherLogic.Current.GetDeviceStatu(this.device));
+                }
+            };
+
+            if (this.hadInitControl == true)
+            {
+                //宸茬粡瀹屾垚鍒濆鍖�
+                return;
+            }
+            this.hadInitControl = true;
+
+            //寮�涓�涓嚎绋�,鐩戣鏄惁婊戝姩鐨勬粦鍔ㄦ潯,姣忕妫�娴嬩竴娆�
+            HdlThreadLogic.Current.RunThread(() =>
+            {
+                while (this.Parent != null)
+                {
+                    System.Threading.Thread.Sleep(1000);
+                    if (nowProgressValue == oldProgressValue
+                    || this.canSetProgressValue == false)
+                    {
+                        //鍊间竴鏍�
+                        continue;
+                    }
+                    oldProgressValue = nowProgressValue;
+                    //鍙戦�佽繘搴﹀��
+                    ((DimmableLight)this.device).SetLevel((int)(oldProgressValue * MaxLevel / 100.0));
+                }
+            });
+        }
+
+        #endregion
+
+        #region 鈻� 鍙戦�佸紑鍏冲懡浠______________________
+
+        /// <summary>
+        /// 鍙戦�佸紑鍏冲懡浠�
+        /// </summary>
+        /// <param name="isOpen"></param>
+        private void SetSwitchCommand(bool isOpen)
+        {
+            //濡傛灉浣忓畢鏄櫄鎷熶綇瀹�
+            if (Common.Config.Instance.Home.IsVirtually == true)
+            {
+                ((LightBase)this.device).OnOffStatus = isOpen == true ? 1 : 0;
+                //鍒锋柊寮�鍏崇姸鎬�
+                this.RefreshSwitchStatu(isOpen);
+                return;
+            }
+
+            //褰撴寜涓嬪紑鍏虫寜閽椂,涓嶈兘鍐嶅彂閫佽繘搴﹀��
+            this.canSetProgressValue = false;
+
+            //妫�娴嬫槸鍚﹁幏鍙栫綉鍏冲弽棣堢殑缁撴灉,濡傛灉缃戝叧娌℃湁鍥炲,鍒欎細寮瑰嚭娑堟伅
+            this.StartCheckResponeResult(this.listControl, (result) =>
+            {
+                HdlThreadLogic.Current.RunMain(() =>
+                {
+                    bool statu = ((LightBase)this.device).OnOffStatus == 1;
+                    //鎺ユ敹鍒扮綉鍏冲洖澶�
+                    if (result == true)
+                    {
+                        //鍒锋柊寮�鍏崇姸鎬�
+                        this.RefreshSwitchStatu(statu);
+                        //鐘舵�佸彇鍙�
+                        listControl[0].IsSelected = statu;
+                    }
+                    if (statu == true)
+                    {
+                        //绛夊緟缁撴灉缁撴潫鍚�,褰╃伅鎺т欢鍙互婊戝姩
+                        waveSeekBar.IsClickable = true;
+                    }
+                });
+            });
+
+            //鍙戦�佺瓑寰呯殑鏃堕棿鍐�,涓嶈兘婊戝姩褰╃伅鎺т欢
+            waveSeekBar.IsClickable = false;
+
+            if (isOpen == true)
+            {
+                //鎵撳紑
+                this.device.SwitchControl(1);
+            }
+            else
+            {
+                //鍏抽棴
+                this.device.SwitchControl(0);
+            }
+        }
+
+        #endregion
+
+        #region 鈻� 鏄惁鑾峰彇缃戝叧鍙嶉鐨勭粨鏋淿____________
+
+        /// <summary>
+        /// 妫�娴嬬綉鍏崇殑鍙嶉缁撴灉(灞炴�т笂鎶ョ殑瀵硅薄锛歞evice.DeviceStatusReport)
+        /// </summary>
+        /// <param name="comandDiv">鍛戒护鍖哄垎</param>
+        /// <param name="report">涓婃姤鏁版嵁</param>
+        /// <returns></returns>
+        public override bool CheckResponeResultStatu(ReceiveComandDiv comandDiv, CommonDevice report)
+        {
+            if (comandDiv == ReceiveComandDiv.A璁惧灞炴�т笂鎶�)
+            {
+                HdlThreadLogic.Current.RunMain(() =>
+                {
+                    //鍒锋柊寮�鍏崇姸鎬�
+                    this.RefreshSwitchStatu(((LightBase)this.device).OnOffStatus == 1);
+                });
+                return true;
+            }
+            return false;
+        }
+
+        #endregion
+
+        #region 鈻� 鍒锋柊寮�鍏崇姸鎬乢______________________
+
+        /// <summary>
+        /// 鍒锋柊寮�鍏崇姸鎬�
+        /// </summary>
+        /// <param name="isOpen">鎵撳紑鐘舵��</param>
+        private void RefreshSwitchStatu(bool isOpen)
+        {
+            if (isOpen == true)
+            {
+                //浜害鏄繀椤昏鍒锋柊鐨�  浜害 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)
+            {
+                //鐘舵�佷笉涓�鏍�,鎵嶅彉鏇村瓧鏍�:鍏抽棴
+                this.SetStatuText(Language.StringByID(R.MyInternationalizationString.Close));
+            }
+
+            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