From f71e74b5f0d2716fbf05da016cdaa18d64e09f80 Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期四, 31 十二月 2020 17:01:18 +0800
Subject: [PATCH] 又换完成最新门锁。空气质量传感器完成数据和基本配置功能。开发图表和自动化的同事可下载此代码

---
 ZigbeeApp/Shared/Phone/Device/Logic/Nightlight.cs |  495 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 495 insertions(+), 0 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/Nightlight.cs b/ZigbeeApp/Shared/Phone/Device/Logic/Nightlight.cs
new file mode 100755
index 0000000..91c6590
--- /dev/null
+++ b/ZigbeeApp/Shared/Phone/Device/Logic/Nightlight.cs
@@ -0,0 +1,495 @@
+锘縰sing System;
+using System.Collections.Generic;
+using Shared;
+using Shared.Common;
+using Shared.R;
+using ZigBee.Device;
+
+namespace Shared.Phone.Device.Logic
+{
+    public class Nightlight : FrameLayout
+    {
+        public Nightlight()
+        {
+            Tag = "Logic";
+        }
+        string selectedDeviceStatus = "";
+        Dictionary<string, object> actionsInfo = null;
+        List<Dictionary<string, string>> TaskList = new List<Dictionary<string, string>>();
+        public void Show(CommonDevice common, bool edit,string str_if,Dictionary<string, object> editdeviceActionInfo = null)
+        {
+            #region  甯冨眬鐣岄潰
+            this.BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor;
+            TopView view = new TopView();
+            this.AddChidren(view.TopRowView());
+            view.toptitleNameBtn.Text = LocalDevice.Current.GetDeviceEpointName(common);
+            view.clickBtn.MouseDownEventHandler += (sender, e) =>
+            {
+                RemoveFromParent();
+              
+            };
+            var middle = new FrameLayout
+            {
+                Y = view.topRowLayout.Bottom,
+                Height = Application.GetRealHeight(Method.H - 184),
+                BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor,
+            };
+            this.AddChidren(middle);
+            //澶滅伅寮�鍏�
+            LogicView.LightView openView = new LogicView.LightView();
+            openView.titleBtn.Text = Language.StringByID(MyInternationalizationString.nightLightSwitch);
+            middle.AddChidren(openView.Show());
+          
+            //浜害
+            LogicView.LightView brightnessView = new LogicView.LightView();
+            brightnessView.frameLayout.Y = openView.frameLayout.Bottom;
+            brightnessView.titleBtn.Text = Language.StringByID(MyInternationalizationString.brightness);
+            middle.AddChidren(brightnessView.Show());
+         
+            //鑹叉俯
+            LogicView.LightView colorTemperatureView = new LogicView.LightView();
+            colorTemperatureView.frameLayout.Y = brightnessView.frameLayout.Bottom;
+            colorTemperatureView.titleBtn.Text = Language.StringByID(MyInternationalizationString.colorTemperature);
+            middle.AddChidren(colorTemperatureView.Show());
+           
+            //铚傞福鍣�
+            LogicView.LightView buzzView = new LogicView.LightView();
+            buzzView.frameLayout.Y = colorTemperatureView.frameLayout.Bottom;
+            buzzView.titleBtn.Text = Language.StringByID(MyInternationalizationString.buzzer);
+            middle.AddChidren(buzzView.Show());
+            //淇濆瓨
+            LogicView.SaveView saveView = new LogicView.SaveView();
+            saveView.frameLayout.Y = middle.Height - Application.GetRealHeight(260);
+            middle.AddChidren(saveView.Show());
+            #endregion
+
+            #region  鐐瑰嚮浜嬩欢
+            //澶滅伅寮�鍏崇偣鍑讳簨浠�
+            openView.clickviewBtn.MouseUpEventHandler += (sender, e) =>
+            {
+                CurrentDeviceView("澶滅伅寮�鍏�", common, edit, openView.seletecdTextBtn);
+            };
+            //浜害鐐瑰嚮浜嬩欢
+            brightnessView.clickviewBtn.MouseUpEventHandler += (sender, e) =>
+            {
+                CurrentDeviceView("浜害", common, edit, brightnessView.seletecdTextBtn);
+            };
+            //鑹叉俯鐐瑰嚮浜嬩欢
+            colorTemperatureView.clickviewBtn.MouseUpEventHandler += (sender, e) =>
+            {
+                CurrentDeviceView("鑹叉俯", common, edit, colorTemperatureView.seletecdTextBtn);
+            };
+            //铚傞福鍣ㄧ偣鍑讳簨浠�
+            buzzView.clickviewBtn.MouseUpEventHandler += (sender, e) =>
+            {
+                CurrentDeviceView("铚傞福鍣�", common, edit, buzzView.seletecdTextBtn);
+            };
+            //淇濆瓨鐐瑰嚮浜嬩欢
+            saveView.clickviewBtn.MouseUpEventHandler += (sender, e) =>
+            {
+                if (TaskList.Count!=0)
+                {
+                    LogicIfon.AddDeviceActions(common, actionsInfo);
+                }
+                else
+                {
+                    if (!edit)
+                    {
+                        var alert = new UserCenter.ShowMsgControl(ShowMsgType.Normal,
+                                    Language.StringByID(MyInternationalizationString.selectdevicestatuscondition),
+                                   Language.StringByID(MyInternationalizationString.confrim));
+                        alert.Show();
+                        return;
+                    }
+
+                }
+
+                if (str_if == "logic")
+                {
+                    var logicCommunalPage = new LogicCommunalPage();
+                    UserView.HomePage.Instance.AddChidren(logicCommunalPage);
+                    UserView.HomePage.Instance.PageIndex += 1;
+                    logicCommunalPage.Show(() => { });
+                }
+                else if (str_if == "lockaction")
+                {
+                    //闂ㄩ攣鑱斿姩浜嬩欢
+                    var lockLogicCommunalPage = new DoorLockLogic.LockLogicCommunalPage();
+                    UserView.HomePage.Instance.AddChidren(lockLogicCommunalPage);
+                    UserView.HomePage.Instance.PageIndex += 1;
+                    lockLogicCommunalPage.Show(() => { });
+                }
+
+            };
+            #endregion
+
+            if (edit)
+            {
+                    foreach (var deviceinfo in Common.Logic.CurrentLogic.Actions)
+                    {
+                        if (deviceinfo["LinkType"].ToString() == "0")
+                        {
+
+                            if (deviceinfo["DeviceAddr"].ToString() == common.DeviceAddr && deviceinfo["Epoint"].ToString() == common.DeviceEpoint.ToString())
+                            {
+                                var taskLists = deviceinfo["TaskList"] as List<Dictionary<string, string>>;
+                                foreach (var tasks in taskLists)
+                                {
+                                    TaskList.Add(tasks);
+                                    switch (tasks["TaskType"])
+                                    {
+                                        case "1":
+                                            {
+                                                if (tasks["Data1"] == "0")
+                                                {
+                                                    openView.seletecdTextBtn.TextID = MyInternationalizationString.close;
+                                                }
+                                                else
+                                                {
+                                                    openView.seletecdTextBtn.TextID = MyInternationalizationString.open;
+                                                }
+                                            }
+                                            break;
+                                        case "3":
+                                            {
+                                                var intvalue = int.Parse(tasks["Data1"]);
+                                                var lightbrightnessvalue = (intvalue * 100) / 254;
+                                                brightnessView.seletecdTextBtn.Text = lightbrightnessvalue.ToString() + "%";
+                                            }
+                                            break;
+                                        case "7":
+                                            {
+                                                if (tasks["Data1"] == "0")
+                                                {
+                                                    buzzView.seletecdTextBtn.TextID = MyInternationalizationString.close;
+                                                }
+                                                else
+                                                {
+                                                    buzzView.seletecdTextBtn.TextID = MyInternationalizationString.open;
+                                                }
+                                            }
+                                            break;
+                                        case "8":
+                                            {
+                                                var intvalue = int.Parse(tasks["Data1"]);
+                                                var lightbrightnessvalue = 1000000 / (intvalue * 100);
+                                                colorTemperatureView.seletecdTextBtn.Text = lightbrightnessvalue.ToString() + "00K";
+                                            }
+                                            break;
+                                    }
+                                }
+                                break;
+                            }
+                        }
+                    }
+            }
+
+            if (actionsInfo == null)
+            {
+                actionsInfo = new Dictionary<string, object>();
+                actionsInfo.Add("LinkType", 0);
+                actionsInfo.Add("DeviceAddr", common.DeviceAddr);
+                actionsInfo.Add("Epoint", common.DeviceEpoint);
+                actionsInfo.Add("Time", 0);
+                actionsInfo.Add("TaskList", TaskList);
+            }
+           
+        }
+        public void CurrentDeviceView(string if_str, CommonDevice common, bool edit, Button button)
+        {
+            #region  甯冨眬鐣岄潰
+            var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor };
+            this.AddChidren(flMain);
+            UserView.HomePage.Instance.ScrollEnabled = false;//涓嶈褰撳墠鐣岄潰婊戝姩
+            CompleteView completeView = new CompleteView();
+            flMain.AddChidren(completeView.Show(2));
+            completeView.Btntitle.Text = LocalDevice.Current.GetDeviceEpointName(common);
+            EventHandler<MouseEventArgs> clickcancel = (sender, e) =>
+            {
+                UserView.HomePage.Instance.ScrollEnabled = true;
+                flMain.RemoveFromParent();
+            };
+            flMain.MouseUpEventHandler += clickcancel;
+            completeView.Btncancel.MouseUpEventHandler += clickcancel;
+            #endregion
+
+            string status = "";
+            Dictionary<string, string> dictionaryLight = new Dictionary<string, string>();
+            dictionaryLight.Clear();
+            switch (if_str)
+            {
+                case "澶滅伅寮�鍏�":
+                    {
+                       
+                        mFunView openView = new mFunView();
+                        openView.frameLayout.Y = Application.GetRealHeight(140 + 20);
+                        openView.titleBtn.TextID = MyInternationalizationString.open;
+                        completeView.Show(2).AddChidren(openView.Show());
+                        mFunView closeView = new mFunView();
+                        closeView.frameLayout.Y = Application.GetRealHeight(140 + 20 + 160);
+                        closeView.titleBtn.TextID = MyInternationalizationString.close;
+                        completeView.Show(2).AddChidren(closeView.Show());
+                        closeView.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor;
+                        ///鐐瑰嚮纭浜嬩欢
+                        openView.clickviewBtn.MouseUpEventHandler += (sender, e) =>
+                        {
+                            selectedDeviceStatus = "1";
+                            openView.selectedIconBtn.Visible = true;
+                            closeView.selectedIconBtn.Visible = false;
+                            openView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor;
+                            closeView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
+                            Send.dictionary(dictionaryLight, "Data1", "1");//榛樿鍊�
+                            status = Language.StringByID(MyInternationalizationString.open);
+                        };
+
+                        ///鐐瑰嚮鍙栨秷浜嬩欢
+                        closeView.clickviewBtn.MouseUpEventHandler += (sender, e) =>
+                        {
+                            selectedDeviceStatus = "1";
+                            openView.selectedIconBtn.Visible = false;
+                            closeView.selectedIconBtn.Visible = true;
+                            openView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
+                            closeView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor;
+                            Send.dictionary(dictionaryLight, "Data1", "0");//榛樿鍊�
+                            status = Language.StringByID(MyInternationalizationString.close);
+
+                        };
+                        if ( TaskList.Count != 0)
+                        {
+                            foreach (var value in TaskList)
+                            {
+                                if (value["TaskType"] == "1")
+                                {
+                                    if (value["Data1"] == "1")
+                                    {
+                                        openView.selectedIconBtn.Visible = true;
+                                        closeView.selectedIconBtn.Visible = false;
+                                    }
+                                    else
+                                    {
+                                        openView.selectedIconBtn.Visible = false;
+                                        closeView.selectedIconBtn.Visible = true;
+                                    }
+                                    break;
+                                }
+
+                            }
+                        }
+                    }
+                    break;
+                case "浜害":
+                    {
+                        var horizontalSeekBarVol = new DiyImageSeekBar
+                        {
+                            Y = Application.GetRealHeight(140),//杩涘害鏉$埗鎺т欢Y鍧愭爣
+                            X = Application.GetRealWidth(78),//杩涘害鏉鍧愭爣
+                            Width = Application.GetRealWidth(918),//杩涘害鏉$殑闀垮害
+                            Height = Application.GetRealHeight(320),//杩涘害鏉$埗鎺т欢楂樺害
+                            IsProgressTextShow = true,//鏄剧ず鐧惧垎姣�
+                            IsClickable = true,//杩涘害鏉℃槸鍚︽粦鍔�
+                            ProgressBarColor = ZigbeeColor.Current.LogicProgressColorSelected,//閫変腑杩涘害鏉¢鑹�
+                            ThumbImagePath = "ZigeeLogic/progressbtn2.png",//杩涘害鏉℃寜閽浘鏍�
+                            ThumbImageHeight = Application.GetRealHeight(89),//杩涘害鏉℃寜閽浘鏍囩殑楂樺害锛堥粯璁ゆ鏂瑰舰锛氬鍜岄珮涓�鏍凤級
+                            ProgressTextColor = ZigbeeColor.Current.LogicBtnCancelColor,
+                            ProgressTextSize = 12,//鏄剧ず鐧惧垎姣斿瓧浣撳ぇ灏�12
+                            SeekBarViewHeight = Application.GetRealHeight(6),//杩涘害鏉$殑楂樺害10
+                            SeekBarPadding=30,
+                        };
+                        completeView.Show(2).AddChidren(horizontalSeekBarVol);
+                        EventHandler<int> progressclick = (sender, e) =>
+                        {
+                            selectedDeviceStatus = "3";
+                            int lightbrightnessvalue = (254 * horizontalSeekBarVol.Progress) / 100;
+                            Send.dictionary(dictionaryLight, "Data1", lightbrightnessvalue.ToString());
+                            status = horizontalSeekBarVol.Progress.ToString() + "%";
+                        };
+                        horizontalSeekBarVol.OnProgressChangedEvent += progressclick;
+                        horizontalSeekBarVol.OnStopTrackingTouchEvent += progressclick;
+
+                        if ( TaskList.Count != 0)
+                        {
+                            foreach (var value in TaskList)
+                            {
+                                if (value["TaskType"] == "3")
+                                {
+                                    var intvalue = int.Parse(value["Data1"]);
+                                    var lightbrightnessvalue = (intvalue * 100) / 254;
+                                    horizontalSeekBarVol.Progress = lightbrightnessvalue;
+                                    break;
+                                }
+
+                            }
+                        }
+                    }
+                    break;
+                case "鑹叉俯":
+                    {
+                        Button seekIconBtn = new Button
+                        {
+                            Y = Application.GetRealHeight(140 + 160),
+                            X = Application.GetRealWidth(78),
+                            Height = Application.GetRealHeight(12),
+                            Width = Application.GetRealWidth(918 - 120),
+                            UnSelectedImagePath = "ZigeeLogic/seek.png",
+                            Gravity = Gravity.CenterHorizontal
+                        };
+                        completeView.Show(2).AddChidren(seekIconBtn);
+                       
+                        var horizontalSeekBarVol = new UserCenter.SeekBarControl(918)
+                        {
+                            ProgressBarColor = 0x00000000,// ZigbeeColor.Current.LogicProgressColorSelected,//閫変腑杩涘害鏉¢鑹�
+                            SeekBarBackgroundColor = 0x00000000,
+                            SeekBarViewHeight = Application.GetRealHeight(20),
+                            SeekBarPadding = Application.GetRealWidth(60),
+                            MinValue = 30,
+                            MaxValue = 60,
+                            ProgressChangeDelayTime = 0,
+                        };
+                        completeView.Show(2).AddChidren(horizontalSeekBarVol);
+                        horizontalSeekBarVol.Y = seekIconBtn.Y - (horizontalSeekBarVol.Height - seekIconBtn.Height) / 2;
+                        horizontalSeekBarVol.ShowCustomTextView(Application.GetRealWidth(200), 12, ZigbeeColor.Current.LogicBtnCancelColor);
+                        EventHandler<int> progressclick = (sender, e) =>
+                        {
+                            horizontalSeekBarVol.SetCustomText(e * 100 + "K");
+                            selectedDeviceStatus = "8";
+                            var lightbrightnessvalue = 1000000 / (100 * horizontalSeekBarVol.Progress);
+                            Send.dictionary(dictionaryLight, "Data1", lightbrightnessvalue.ToString());
+                            status =horizontalSeekBarVol.Progress.ToString() + "00K";
+                        };
+                        horizontalSeekBarVol.OnProgressChangedEvent += progressclick;
+                        horizontalSeekBarVol.OnStopTrackingTouchEvent += progressclick;
+
+                        if ( TaskList.Count != 0)
+                        {
+                            foreach (var value in TaskList)
+                            {
+                                if (value["TaskType"] == "8")
+                                {
+                                    var intvalue = int.Parse(value["Data1"]);
+                                    var lightbrightnessvalue = 1000000 / (intvalue * 100);
+                                    horizontalSeekBarVol.Progress = lightbrightnessvalue;
+
+                                    break;
+                                }
+
+                            }
+                        }
+                        var intValue = horizontalSeekBarVol.Progress;
+                        if (intValue == 0) { intValue = 30; }
+                        horizontalSeekBarVol.SetCustomText(intValue * 100 + "K");
+                    }
+                    break;
+                case "铚傞福鍣�":
+                    {
+
+                        mFunView openView = new mFunView();
+                        openView.frameLayout.Y = Application.GetRealHeight(140 + 20);
+                        openView.titleBtn.TextID = MyInternationalizationString.open;
+                        completeView.Show(2).AddChidren(openView.Show());
+                        mFunView closeView = new mFunView();
+                        closeView.frameLayout.Y = Application.GetRealHeight(140 + 20 + 160);
+                        closeView.titleBtn.TextID = MyInternationalizationString.close;
+                        completeView.Show(2).AddChidren(closeView.Show());
+                        closeView.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor;
+
+                        ///鐐瑰嚮纭浜嬩欢
+                        openView.clickviewBtn.MouseUpEventHandler += (sender, e) =>
+                        {
+                            selectedDeviceStatus = "7";
+                            openView.selectedIconBtn.Visible = true;
+                            closeView.selectedIconBtn.Visible = false;
+                            openView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor;
+                            closeView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
+                            Send.dictionary(dictionaryLight, "Data1", "1");//榛樿鍊�
+                            status = Language.StringByID(MyInternationalizationString.open);
+                        };
+
+                        ///鐐瑰嚮鍙栨秷浜嬩欢
+                        closeView.clickviewBtn.MouseUpEventHandler += (sender, e) =>
+                        {
+                            selectedDeviceStatus = "7";
+                            openView.selectedIconBtn.Visible = false;
+                            closeView.selectedIconBtn.Visible = true;
+                            openView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
+                            closeView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor;
+                            Send.dictionary(dictionaryLight, "Data1", "0");//榛樿鍊�
+                            status = Language.StringByID(MyInternationalizationString.close);
+
+                        };
+
+                        if ( TaskList.Count != 0)
+                        {
+                            foreach (var value in TaskList)
+                            {
+                                if (value["TaskType"] == "7")
+                                {
+                                    if (value["Data1"] == "1")
+                                    {
+                                        openView.selectedIconBtn.Visible = true;
+                                        closeView.selectedIconBtn.Visible = false;
+                                    }
+                                    else
+                                    {
+                                        openView.selectedIconBtn.Visible = false;
+                                        closeView.selectedIconBtn.Visible = true;
+                                    }
+                                    break;
+                                }
+
+                            }
+                        }
+                    }
+                    break;
+            }
+            completeView.Btncomplete.MouseUpEventHandler += (sender, e) =>
+            {
+                if (dictionaryLight.Count!=0)
+                {
+                    Send.dictionary(dictionaryLight, "TaskType", selectedDeviceStatus);
+                    Send.dictionary(dictionaryLight, "Data2", "0");
+                    flMain.RemoveFromParent();
+                    DicValue(selectedDeviceStatus, dictionaryLight);
+                    button.Text = status;
+
+                }
+                else
+                {
+                    if (!edit)
+                    {
+                        var alert = new UserCenter.ShowMsgControl(ShowMsgType.Normal,
+                                    Language.StringByID(MyInternationalizationString.selectdevicestatuscondition),
+                                   Language.StringByID(MyInternationalizationString.confrim));
+                        alert.Show();
+                        return;
+                    }
+                    else
+                    {
+                        flMain.RemoveFromParent();
+                    }
+
+                }
+
+            };
+        }
+        public void DicValue(string str, Dictionary<string, string> dictionay)
+        {
+            bool d = false;
+            foreach (var tasks in TaskList)
+            {
+                if (tasks["TaskType"] == str)
+                {
+
+                    TaskList.Remove(tasks);
+                    TaskList.Add(dictionay);
+                    d = true;
+                    break;
+                }
+            }
+            if (!d)
+            {
+                TaskList.Add(dictionay);
+            }
+        }
+    }
+
+}

--
Gitblit v1.8.0