From 1d1cad99a27c9f644c84eb3d376c70bd30a55879 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期三, 10 三月 2021 18:02:13 +0800
Subject: [PATCH] 2021-3-10-1

---
 HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/DeviceSet.cs |  152 ++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 126 insertions(+), 26 deletions(-)

diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/DeviceSet.cs b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/DeviceSet.cs
index 7a72667..7f35847 100644
--- a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/DeviceSet.cs
+++ b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/DeviceSet.cs
@@ -11,18 +11,37 @@
         {
             Tag = "PirView";
         }
-        public void Show() {
+        public void Show(Action action)
+        {
             #region 鐣岄潰甯冨眬
             this.BackgroundColor = CSS.CSS_Color.viewMiddle;
             PirDevice.View.TopView topView = new View.TopView();
             topView.topNameBtn.TextID = StringId.shebeigaunli;
             topView.topIconBtn.Visible = true;
             this.AddChidren(topView.FLayoutView());
-            topView.clickBackBtn.MouseUpEventHandler += (sender, e) => { this.RemoveFromParent(); };
-            VerticalScrolViewLayout vv = new VerticalScrolViewLayout();
+            topView.clickBackBtn.MouseUpEventHandler += (sender, e) => {
+                action();
+                this.RemoveFromParent();
+            };
+            VerticalRefreshLayout vv = new VerticalRefreshLayout();
             vv.Height = Application.GetRealHeight(667 - 64);
             vv.Y = Application.GetRealHeight(64);
             this.AddChidren(vv);
+            vv.BeginHeaderRefreshingAction += () =>
+            {
+                //鍏抽棴鍒锋柊View锛�
+                vv.EndHeaderRefreshing();
+                //鑾峰彇鍒楄〃
+                Method.GetPirDeviceList(this,() =>
+                {
+                    Application.RunOnMainThread(() =>
+                    {
+                        //鍒锋柊鐣岄潰
+                        UIView(vv);
+                    });
+                });
+
+            };
             #endregion
             UIView(vv);
 
@@ -31,16 +50,17 @@
         /// 鍔犺浇UI鐣岄潰
         /// </summary>
         /// <param name="vv">涓婁笅婊戞帶浠�</param>
-        void UIView(VerticalScrolViewLayout vv) {
+        void UIView(VerticalRefreshLayout vv)
+        {
             vv.RemoveAll();
-            int a = 3;
             for (int i = 0; i < Pir.pirDeviceList.Count; i++)
             {
+                var pirDevice = Pir.pirDeviceList[i];
                 #region 绾㈠瀹濆浘鏍� 鐗堟湰鍙� 鍚嶇О 鐘舵��
                 FrameLayout fLayout = new FrameLayout
                 {
                     Width = Application.GetRealWidth(375),
-                    Height = Application.GetRealHeight(12 + 92 + (50 * a)),
+                    Height = Application.GetRealHeight(12 + 92 + (50 * pirDevice.FunctioList.Count)),
                 };
                 vv.AddChidren(fLayout);
 
@@ -50,7 +70,7 @@
                     Y = Application.GetRealHeight(12),
                     X = Application.GetRealWidth(16),
                     Width = Application.GetRealWidth(375 - 16 * 2),
-                    Height = Application.GetRealHeight(92 + (50 * a)),
+                    Height = Application.GetRealHeight(92 + (50 * pirDevice.FunctioList.Count)),
                     BackgroundColor = CSS.CSS_Color.view,
                     Radius = (uint)Application.GetRealHeight(12),
                 };
@@ -75,7 +95,7 @@
                     X = priequipmentBtn.Right + Application.GetRealWidth(7),
                     Width = Application.GetRealWidth(120),
                     Height = Application.GetRealHeight(20),
-                    Text = "绾㈠瀹滱" + i.ToString(),
+                    Text = pirDevice.name,
                     TextAlignment = TextAlignment.CenterLeft,
                     TextSize = TextSize.text14,
                     TextColor = CSS.CSS_Color.textColor,
@@ -102,7 +122,7 @@
                     X = priequipmentBtn.Right + Application.GetRealWidth(7),
                     Width = Application.GetRealWidth(120),
                     Height = Application.GetRealHeight(17),
-                    Text = "2",
+                    Text = pirDevice.FunctioList.Count.ToString(),
                     TextAlignment = TextAlignment.CenterLeft,
                     TextSize = TextSize.text12,
                     TextColor = CSS.CSS_Color.textConfirmColor,
@@ -130,6 +150,7 @@
                     Width = Application.GetRealWidth(8),
                     Height = Application.GetRealWidth(8),
                     UnSelectedImagePath = "PirIcon/online.png",
+                    SelectedImagePath = "PirIcon/offline.png",
                 };
                 devfLayout.AddChidren(stateIconBtn);
                 //绾㈠瀹濈姸鎬侊紙鍦ㄧ嚎-绂荤嚎锛�
@@ -143,9 +164,17 @@
                     TextAlignment = TextAlignment.CenterLeft,
                     TextSize = TextSize.text12,
                     TextColor = 0xFF67D569,// CSS.CSS_Color.textColor,
+                    SelectedTextColor =CSS.CSS_Color.textRedColor,
                     IsBold = true,
                 };
                 devfLayout.AddChidren(stateTextBtn);
+                if (pirDevice.online) {
+                    stateIconBtn.IsSelected = true;
+                    stateTextBtn.IsSelected = true;
+                } else {
+                    stateIconBtn.IsSelected = false;
+                    stateTextBtn.IsSelected = false;
+                }
                 //绾�
                 Button lineBtn = new Button
                 {
@@ -163,15 +192,16 @@
                     X = Application.GetRealWidth(16),
                     Width = Application.GetRealWidth(375 - 16 * 2),
                     Height = Application.GetRealHeight(92),
-                    BackgroundColor = CSS.CSS_Color.view,
+                    BackgroundColor = 0x00000000, //CSS.CSS_Color.view,
                     Radius = (uint)Application.GetRealHeight(12),
                     Tag = Pir.pirDeviceList[i],
                 };
                 fLayout.AddChidren(clickFram);
 
-                clickFram.MouseUpEventHandler += (sender, e) => {
+                clickFram.MouseUpEventHandler += (sender, e) =>
+                {
                     var pirclick = (clickFram.Tag as Pir);
-                    NewSwitchView( pirclick,  vv);
+                    NewSwitchView(pirclick, vv);
                 };
 
                 if (Pir.pirDeviceList.Count - 1 == i)
@@ -181,8 +211,9 @@
                 }
                 #endregion
 
-                for (int j = 0; j < a; j++)
+                for (int j = 0; j < pirDevice.FunctioList.Count; j++)
                 {
+                    var control = pirDevice.FunctioList[j];
                     RowLayout funControlRow = new RowLayout
                     {
                         Y = Application.GetRealHeight(92 + (50 * j)),
@@ -198,7 +229,7 @@
                         X = Application.GetRealWidth(16),
                         Width = Application.GetRealWidth(150),
                         Height = Application.GetRealHeight(20),
-                        Text = j.ToString(),
+                        Text = control.name,
                         TextAlignment = TextAlignment.CenterLeft,
                         TextSize = TextSize.text14,
                         TextColor = CSS.CSS_Color.textColor,
@@ -211,7 +242,7 @@
                         X = Application.GetRealWidth(311 + 16 - (40 + 100)),
                         Width = Application.GetRealWidth(100),
                         Height = Application.GetRealHeight(17),
-                        Text = j.ToString(),
+                        Text = Intelligence.Automation.LogicMethod.GetGetRoomName(control),
                         TextAlignment = TextAlignment.CenterRight,
                         TextSize = TextSize.text12,
                         TextColor = CSS.CSS_Color.textCancelColor,
@@ -239,6 +270,7 @@
                         TextColor = CSS.CSS_Color.textWhiteColor,
                         IsBold = true,
                         BackgroundColor = CSS.CSS_Color.textRedColor,
+                        Tag = control,
                     };
                     funControlRow.AddRightView(delBtn);
                     //绾�
@@ -251,16 +283,80 @@
                         BackgroundColor = CSS.CSS_Color.viewLine,
                     };
                     funControlRow.AddChidren(line1Btn);
-                    if (j == a - 1)
+                    if (j == pirDevice.FunctioList.Count - 1)
                     {
                         //鏈�鍚庢敼鍙樹竴涓嚎鐨勯鑹�
                         line1Btn.BackgroundColor = CSS.CSS_Color.viewTranslucence;
                         funControlRow.LineColor = CSS.CSS_Color.viewTranslucence;
                     }
-                    delBtn.MouseUpEventHandler += (sender, e) => {
+                    delBtn.MouseUpEventHandler += (sender, e) =>
+                    {
 
+                        var Function = delBtn.Tag as Entity.Function;
+                        //鍔犺浇log
+                        Loading loading = new Loading();
+                        this.AddChidren(loading);
+                        HDL_ON.DAL.Server.ResponsePackNew responsePackNew = null;
+                        loading.Start();
+                        new System.Threading.Thread(() =>
+                        {
+                            try
+                            {
+                                responsePackNew = PirSend.DeleteDevice(Function.deviceId);
+                            }
+                            catch { }
+                            finally
+                            {
+                                Application.RunOnMainThread(() =>
+                                {
+                                    loading.Hide();
+                                    try
+                                    {
+                                        if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "")
+                                        {
+                                            var function = pirDevice.FunctioList.Find((c)=>c.sid== Function.sid);
+                                            if (function != null)
+                                            {
+                                                pirDevice.FunctioList.Remove(Function);
+                                                if (Pir.currPir != null && pirDevice.sid == Pir.currPir.sid)
+                                                {
+                                                    Pir.currPir.FunctioList = pirDevice.FunctioList;
+                                                }
+                                            }
+                                            UIView(vv);
+                                        }
 
+                                        else
+                                        {
+                                            Method method = new Method();
+                                            method.ErrorShow(responsePackNew);
+                                        }
+                                    }
+                                    catch { }
+
+                                });
+                            }
+
+                        })
+                        { IsBackground = true }.Start();
                     };
+                    EventHandler<MouseEventArgs> editClick = (sender, e) =>
+                    {
+                        EditControl editControl = new EditControl();
+                        MainPage.BasePageView.AddChidren(editControl);
+                        editControl.Show(control, pirDevice, (device) =>
+                        {
+                            //鍥炶皟鏇存柊鍚嶅瓧/鍖哄煙
+                            nameBtn.Text = device.name;
+                            areaBtn.Text = Intelligence.Automation.LogicMethod.GetGetRoomName(device);
+
+                        });
+                        MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+                    };
+                    funControlRow.MouseUpEventHandler += editClick;
+                    nameBtn.MouseUpEventHandler += editClick;
+                    areaBtn.MouseUpEventHandler += editClick;
+                    nextIconBtn.MouseUpEventHandler += editClick;
                 }
 
 
@@ -272,7 +368,8 @@
         /// </summary>
         /// <param name="pirclick"></param>
         /// <param name="vv"></param>
-        void NewSwitchView(Pir pirclick,VerticalScrolViewLayout vv) {
+        void NewSwitchView(Pir pirclick, VerticalRefreshLayout vv)
+        {
             FrameLayout frame = new FrameLayout { BackgroundColor = CSS.CSS_Color.viewTrans60lucence };
             this.AddChidren(frame);
             SwitchView switchView = new SwitchView();
@@ -286,8 +383,8 @@
                     {
                         list.Add(Pir.pirDeviceList[b].name);
                     }
-                    TipPopView tipPopView = new TipPopView();
-                    tipPopView.InputBox(StringId.xiugaimingzi, pirclick.name, StringId.nameNull, StringId.NameAlreadyExists, list, (name, view) =>
+                    Method methodView = new Method(); 
+                    methodView.EditControlName(StringId.xiugaimingzi, list, pirclick.name, (name, view) =>
                     {
                         pirclick.name = name;
                         //鍔犺浇log
@@ -299,7 +396,7 @@
                         {
                             try
                             {
-                                responsePackNew = PirSend.DeviceRename(pirclick);
+                                responsePackNew = PirSend.DeviceRename(pirclick.deviceId, pirclick.name);
                             }
                             catch { }
                             finally
@@ -323,17 +420,17 @@
 
                         })
                         { IsBackground = true }.Start();
-
-                    }, () => {
+                    },()=> {
                         NewSwitchView(pirclick, vv);
-                    }, false);
+                    },false);
 
                 }
                 else
                 {
                     string text = Language.StringByID(StringId.shanchushebei) + pirclick.name + "?";
                     TipPopView tipPopView = new TipPopView();
-                    tipPopView.TipBox(StringId.tip, text, (dialog) => {
+                    tipPopView.TipBox(StringId.tip, text, (dialog) =>
+                    {
                         //鍔犺浇log
                         Loading loading = new Loading();
                         dialog.AddChidren(loading);
@@ -368,12 +465,15 @@
 
                         })
                         { IsBackground = true }.Start();
-                    }, () => {
+                    }, () =>
+                    {
                         NewSwitchView(pirclick, vv);
                     }, false);
 
                 }
             });
         }
+
+      
     }
 }

--
Gitblit v1.8.0