From 404cdc88627f942df7944af04ee05b9d527752d6 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期一, 30 九月 2019 13:22:40 +0800
Subject: [PATCH] 合并了徐梅的按键面板绑定

---
 ZigbeeApp/Shared/Phone/UserCenter/Safety/LightAlarmSettionForm.cs |  298 ++++++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 234 insertions(+), 64 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Safety/LightAlarmSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Safety/LightAlarmSettionForm.cs
index ed93060..d06cd1e 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Safety/LightAlarmSettionForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Safety/LightAlarmSettionForm.cs
@@ -6,29 +6,24 @@
 namespace Shared.Phone.UserCenter.Safety
 {
     /// <summary>
-    /// 鐏厜鐨勫畨闃叉姤璀﹁缃晫闈�
+    /// 鐏厜绫荤殑瀹夐槻鎶ヨ璁剧疆鐣岄潰
     /// </summary>
-    public class LightAlarmSettionForm : UserCenterCommonForm
+    public class LightAlarmSettionForm : EditorCommonForm
     {
-        /// <summary>
-        /// 鐢婚潰鍏抽棴浜嬩欢
-        /// </summary>
-        /// <param name="statuText"></param>
-        /// <param name="listTaskinfo"></param>
-        public delegate void _FormCloseEvent(string statuText, List<Safeguard.TaskListInfo> listTaskinfo);
-        /// <summary>
-        /// 鐢婚潰鍏抽棴浜嬩欢
-        /// </summary>
-        public _FormCloseEvent formCloseEvent;
+        #region 鈻� 鍙橀噺澹版槑___________________________
 
         /// <summary>
-        /// 鍒楄〃鎺т欢
+        /// 鐢婚潰鍏抽棴浜嬩欢
         /// </summary>
-        private VerticalScrolViewLayout listView = null;
+        public Action<string, List<Safeguard.TaskListInfo>> ActionFormClose = null;
         /// <summary>
-        /// 鍔ㄤ綔淇℃伅
+        /// 鍔ㄤ綔淇℃伅  1 寮�鍏�/ 3浜害璋冭妭
         /// </summary>
-        private List<Safeguard.TaskListInfo> listTaskinfo = null;
+        private Dictionary<int, Safeguard.TaskListInfo> dicTaskinfo = new Dictionary<int, Safeguard.TaskListInfo>();
+
+        #endregion
+
+        #region 鈻� 鍒濆鍖朹____________________________
 
         /// <summary>
         /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓)
@@ -37,17 +32,25 @@
         /// <param name="i_listTaskInfo"></param>
         public void ShowForm(CommonDevice device, List<Safeguard.TaskListInfo> i_listTaskInfo)
         {
-            this.listTaskinfo = i_listTaskInfo;
+            UserView.HomePage.Instance.ScrollEnabled = false;
+
+            if (i_listTaskInfo != null)
+            {
+                foreach (var data in i_listTaskInfo)
+                {
+                    //浠ラ槻涓囦竴,鍓旈櫎涓嶅悎娉曟暟鎹�
+                    if (data.TaskType == 1 || data.TaskType == 3)
+                    {
+                        dicTaskinfo[data.TaskType] = data;
+                    }
+                }
+            }
+
             //璁剧疆澶撮儴淇℃伅
             base.SetTitleText(Common.LocalDevice.Current.GetDeviceEpointName(device));
 
             //鍒濆鍖栦腑閮ㄤ俊鎭�
             this.InitMiddleFrame();
-
-            if (this.listTaskinfo == null)
-            {
-                this.listTaskinfo = new List<Safeguard.TaskListInfo>();
-            }
         }
 
         /// <summary>
@@ -55,65 +58,232 @@
         /// </summary>
         private void InitMiddleFrame()
         {
-            listView = new VerticalScrolViewLayout();
-            listView.Height = bodyFrameLayout.Height;
+            //娓呯┖bodyFrame
+            this.ClearBodyFrame();
+
+            var frameTemp = new FrameLayout();
+            frameTemp.Height = Application.GetRealHeight(6);
+            frameTemp.BackgroundColor = UserCenterColor.Current.White;
+            bodyFrameLayout.AddChidren(frameTemp);
+
+            var listView = new VerticalListControl(29);
+            listView.Y = frameTemp.Bottom;
+            listView.BackgroundColor = UserCenterColor.Current.White;
+            listView.Height = Application.GetRealHeight(700 - 256 + 46);
+            if (dicTaskinfo.ContainsKey(5) == true)
+            {
+                //灞曞紑鐧惧垎姣旇皟鑺�
+                listView.Height = Application.GetRealHeight(700);
+            }
             bodyFrameLayout.AddChidren(listView);
 
             //寮�
-            var staRow = new StatuRowLayout(listView);
-            var btnOpen = new RowCenterView(false);
-            btnOpen.TextID = R.MyInternationalizationString.uSimpleOpen;
-            staRow.AddChidren(btnOpen);
-            staRow.MouseUpEvent += (sender, e) =>
+            var btnOpenRow = new FrameRowControl(listView.rowSpace / 2);
+            listView.AddChidren(btnOpenRow);
+            //鍥炬爣
+            var btnOpenIcon = btnOpenRow.AddLeftIcon(81);
+            btnOpenIcon.UnSelectedImagePath = "Item/OpenIcon.png";
+            //鏂囧瓧
+            var btnOpenView = btnOpenRow.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uSimpleOpen), 400);
+            btnOpenView.TextSize = 15;
+            //鐘舵��
+            var btnOpenStatu = btnOpenRow.AddMostRightEmptyIcon(58, 58);
+            if (dicTaskinfo.ContainsKey(1) == false || dicTaskinfo[1].Data1 != 1)
             {
-                var info = new Safeguard.TaskListInfo();
-                info.TaskType = 1;
-                info.Data1 = 1;
-                this.listTaskinfo.Add(info);
-                //鍏抽棴鐢婚潰涔嬪墠
-                this.BeforeCloseForm();
+                btnOpenStatu.Visible = false;
+            }
+            btnOpenStatu.UnSelectedImagePath = "Item/Tick.png";
+            //搴曠嚎
+            btnOpenRow.AddBottomLine();
+
+            //===========================================================================
+            //鍏�
+            var btnCloseRow = new FrameRowControl(listView.rowSpace / 2);
+            listView.AddChidren(btnCloseRow);
+            //鍥炬爣
+            var btnCloseIcon = btnCloseRow.AddLeftIcon(81);
+            btnCloseIcon.UnSelectedImagePath = "Item/CloseIcon.png";
+            //鏂囧瓧
+            var btnCloseView = btnCloseRow.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uSimpleClose), 400);
+            btnCloseView.TextSize = 15;
+            //鐘舵��
+            var btnCloseStatu = btnCloseRow.AddMostRightEmptyIcon(58, 58);
+            if (dicTaskinfo.ContainsKey(1) == false || dicTaskinfo[1].Data1 != 0)
+            {
+                btnCloseStatu.Visible = false;
+            }
+            btnCloseStatu.UnSelectedImagePath = "Item/Tick.png";
+            //搴曠嚎
+            btnCloseRow.AddBottomLine();
+
+            //===========================================================================
+            //鐧惧垎姣旇皟鑺�
+            var btnPersentRow = new FrameRowControl(listView.rowSpace / 2);
+            btnPersentRow.UseClickStatu = false;
+            listView.AddChidren(btnPersentRow);
+            //鍥炬爣
+            var btnPersentIcon = btnPersentRow.AddLeftIcon(81);
+            btnPersentIcon.UnSelectedImagePath = "Item/PersentIcon.png";
+            //鏂囧瓧
+            var btnPersentView = btnPersentRow.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uPersentAdjust), 400);
+            btnPersentView.TextSize = 15;
+            //鍙冲浘鏍�
+            var btnPersentRight = btnPersentRow.AddMostRightEmptyIcon(58, 58);
+            btnPersentRight.UnSelectedImagePath = "Item/Next.png";
+            btnPersentRight.SelectedImagePath = "Item/Down.png";
+            if (dicTaskinfo.ContainsKey(3) == true)
+            {
+                //灞曞紑鐧惧垎姣旇皟鑺�
+                btnPersentRight.IsSelected = true;
+            }
+
+            //===========================================================================
+            //杩涘害鏉$殑鑳屾櫙瀹瑰櫒
+            var frameProfra = new FrameLayout();
+            frameProfra.Height = Application.GetRealHeight(256);
+            listView.AddChidren(frameProfra);
+
+            //褰撳墠XX%
+            string persentText = Language.StringByID(R.MyInternationalizationString.uNow1);
+            var nowProValue = 0;
+            if (dicTaskinfo.ContainsKey(3) == true)
+            {
+                //3:浜害璋冭妭
+                nowProValue = dicTaskinfo[3].Data1;
+            }
+
+            var btnPersentValue = new NormalViewControl(400, 49, true);
+            btnPersentValue.Text = persentText + nowProValue + "%";
+            btnPersentValue.X = btnPersentView.X;
+            btnPersentValue.Y = Application.GetRealHeight(35);
+            btnPersentValue.TextColor = UserCenterColor.Current.TextGrayColor2;
+            btnPersentValue.TextSize = 12;
+            frameProfra.AddChidren(btnPersentValue);
+
+            //杩涘害鏉�
+            var seekBar = new HorizontalSeekBar();
+            seekBar.X = btnPersentValue.X;
+            seekBar.Y = btnPersentValue.Bottom + Application.GetRealHeight(46);
+            seekBar.Width = Application.GetRealWidth(850);
+            seekBar.Height = Application.GetRealHeight(60);
+            seekBar.Max = 100;
+            seekBar.BackgroundColor = 0xfff5f5f5;
+            seekBar.ThumbColor = Common.ZigbeeColor.Current.GXCButtonBlueColor;
+            seekBar.ProgressColor = 0xff232323;
+            seekBar.Progress = nowProValue;
+            frameProfra.AddChidren(seekBar);
+
+            seekBar.ProgressChanged += (sender, value) =>
+            {
+                nowProValue = value;
+                btnPersentValue.Text = persentText + value + "%";
+            };
+
+            //鐧惧垎姣旇皟鑺傜偣鍑�
+            btnPersentRow.ButtonClickEvent += (sender, e) =>
+            {
+                btnPersentRight.IsSelected = !btnPersentRight.IsSelected;
+                if (btnPersentRight.IsSelected == true)
+                {
+                    listView.Height += frameProfra.Height - Application.GetRealHeight(23);
+                }
+                else
+                {
+                    listView.Height -= frameProfra.Height - Application.GetRealHeight(23);
+                }
+            };
+
+            //寮�
+            btnOpenRow.ButtonClickEvent += (sender, e) =>
+            {
+                if (btnOpenStatu.Visible == true)
+                {
+                    //鍙栨秷
+                    dicTaskinfo.Remove(1);
+                    btnOpenStatu.Visible = false;
+                }
+                else
+                {
+                    //娣诲姞
+                    btnOpenStatu.Visible = true;
+                    btnCloseStatu.Visible = false;
+
+                    dicTaskinfo[1] = new Safeguard.TaskListInfo();
+                    dicTaskinfo[1].TaskType = 1;
+                    dicTaskinfo[1].Data1 = 1;
+                }
             };
 
             //鍏�
-            staRow = new StatuRowLayout(listView);
-            var btnClose = new RowCenterView(false);
-            btnClose.TextID = R.MyInternationalizationString.uSimpleClose;
-            staRow.AddChidren(btnClose);
-            staRow.MouseUpEvent += (sender, e) =>
+            btnCloseRow.ButtonClickEvent += (sender, e) =>
             {
-                var info = new Safeguard.TaskListInfo();
-                info.TaskType = 1;
-                info.Data1 = 0;
-                this.listTaskinfo.Add(info);
-                //鍏抽棴鐢婚潰涔嬪墠
-                this.BeforeCloseForm();
+                if (btnCloseStatu.Visible == true)
+                {
+                    //鍙栨秷
+                    dicTaskinfo.Remove(1);
+                }
+                else
+                {
+                    //娣诲姞
+                    btnOpenStatu.Visible = false;
+                    btnCloseStatu.Visible = true;
+
+                    dicTaskinfo[1] = new Safeguard.TaskListInfo();
+                    dicTaskinfo[1].TaskType = 1;
+                    dicTaskinfo[1].Data1 = 0;
+                }
             };
 
-            //鏃犲姩浣�
-            staRow = new StatuRowLayout(listView);
-            var btnNotAction = new RowCenterView(false);
-            btnNotAction.TextID = R.MyInternationalizationString.uNotAction;
-            staRow.AddChidren(btnNotAction);
-            staRow.MouseUpEvent += (sender, e) =>
+            //瀹屾垚
+            var btnFinish = new BottomClickButton();
+            btnFinish.TextID = R.MyInternationalizationString.uFinish;
+            bodyFrameLayout.AddChidren(btnFinish);
+            btnFinish.ButtonClickEvent += (sender, e) =>
             {
-                this.listTaskinfo = null;
-                //鍏抽棴鐢婚潰涔嬪墠
-                this.BeforeCloseForm();
+                if (this.ActionFormClose != null)
+                {
+                    if (btnPersentRight.IsSelected == false || seekBar.Progress == 0)
+                    {
+                        dicTaskinfo.Remove(3);
+                    }
+                    else
+                    {
+                        //鐧惧垎姣旇皟鑺�
+                        dicTaskinfo[3] = new Safeguard.TaskListInfo();
+                        dicTaskinfo[3].TaskType = 3;
+                        dicTaskinfo[3].Data1 = seekBar.Progress;
+                    }
+
+                    var listData = new List<Safeguard.TaskListInfo>();
+                    foreach (var data in dicTaskinfo.Values)
+                    {
+                        listData.Add(data);
+                    }
+                    dicTaskinfo = null;
+
+                    //鑾峰彇鐘舵�佺殑鏄剧ず鏂囨湰
+                    string statuText = HdlSafeguardLogic.Current.GetLightAlarmStatuText(listData);
+                    this.ActionFormClose(statuText, listData);
+                }
+                this.CloseForm();
             };
         }
+
+        #endregion
+
+        #region 鈻� 鐣岄潰鍏抽棴___________________________
 
         /// <summary>
-        /// 鍏抽棴鐢婚潰涔嬪墠
+        /// 鐣岄潰鍏抽棴
         /// </summary>
-        private void BeforeCloseForm()
+        public override void CloseForm()
         {
-            if (this.formCloseEvent != null)
-            {
-                //鑾峰彇鐘舵�佺殑鏄剧ず鏂囨湰
-                string statuText = SafeguardLogic.GetLightAlarmStatuText(this.listTaskinfo);
-                this.formCloseEvent(statuText, this.listTaskinfo);
-            }
-            this.CloseForm();
+            UserView.HomePage.Instance.ScrollEnabled = true;
+            ActionFormClose = null;
+
+            base.CloseForm();
         }
+
+        #endregion
     }
 }

--
Gitblit v1.8.0