From 48ba446936b51fffafa7c3600c0dadc6ac0e8c20 Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期五, 10 七月 2020 10:52:13 +0800 Subject: [PATCH] 2020-07-10-01 --- ZigbeeApp/Shared/Phone/Device/Logic/Nightlight.cs | 352 ++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 317 insertions(+), 35 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/Nightlight.cs b/ZigbeeApp/Shared/Phone/Device/Logic/Nightlight.cs index dce3693..5ce1f29 100644 --- a/ZigbeeApp/Shared/Phone/Device/Logic/Nightlight.cs +++ b/ZigbeeApp/Shared/Phone/Device/Logic/Nightlight.cs @@ -1,4 +1,5 @@ 锘縰sing System; +using System.Collections.Generic; using Shared; using Shared.Common; using Shared.R; @@ -12,14 +13,16 @@ { Tag = "Logic"; } - - public void Show() + string selectedDeviceStatus = ""; + Dictionary<string, object> actionsInfo = null; + List<Dictionary<string, string>> TaskList = null; + public void Show(CommonDevice common, bool edit,string str_if,Dictionary<string, object> editdeviceActionInfo = null) { - + actionsInfo = editdeviceActionInfo; this.BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor; TopView view = new TopView(); this.AddChidren(view.TopRowView()); - view.toptitleNameBtn.Text = Name; + view.toptitleNameBtn.Text = LocalDevice.Current.GetDeviceEpointName(common); view.clickBtn.MouseDownEventHandler += (sender, e) => { RemoveFromParent(); @@ -33,39 +36,141 @@ this.AddChidren(middle); LogicView.LightView openView = new LogicView.LightView(); - openView.titleBtn.Text = "澶滅伅寮�鍏�"; + openView.titleBtn.Text = Language.StringByID(MyInternationalizationString.nightLightSwitch); middle.AddChidren(openView.Show()); - openView.clickviewBtn.MouseUpEventHandler += (sender, e) => { - CurrentDeviceView("澶滅伅寮�鍏�",new CommonDevice { },true, ""); - + openView.clickviewBtn.MouseUpEventHandler += (sender, e) => + { + CurrentDeviceView("澶滅伅寮�鍏�", common, edit, openView.seletecdTextBtn); }; LogicView.LightView brightnessView = new LogicView.LightView(); brightnessView.frameLayout.Y = openView.frameLayout.Bottom; - brightnessView.titleBtn.Text = "浜害"; + brightnessView.titleBtn.Text = Language.StringByID(MyInternationalizationString.brightness); middle.AddChidren(brightnessView.Show()); - brightnessView.clickviewBtn.MouseUpEventHandler += (sender, e) => { - CurrentDeviceView("浜害", new CommonDevice { }, true, ""); + brightnessView.clickviewBtn.MouseUpEventHandler += (sender, e) => + { + CurrentDeviceView("浜害", common, edit, brightnessView.seletecdTextBtn); }; LogicView.LightView colorTemperatureView = new LogicView.LightView(); colorTemperatureView.frameLayout.Y = brightnessView.frameLayout.Bottom; - colorTemperatureView.titleBtn.Text = "鑹叉俯"; + colorTemperatureView.titleBtn.Text = Language.StringByID(MyInternationalizationString.colorTemperature); middle.AddChidren(colorTemperatureView.Show()); - colorTemperatureView.clickviewBtn.MouseUpEventHandler += (sender, e) => { - CurrentDeviceView("鑹叉俯", new CommonDevice { }, true, ""); + colorTemperatureView.clickviewBtn.MouseUpEventHandler += (sender, e) => + { + CurrentDeviceView("鑹叉俯", common, edit, colorTemperatureView.seletecdTextBtn); }; LogicView.LightView buzzView = new LogicView.LightView(); buzzView.frameLayout.Y = colorTemperatureView.frameLayout.Bottom; - buzzView.titleBtn.Text = "铚傞福鍣�"; + buzzView.titleBtn.Text = Language.StringByID(MyInternationalizationString.buzzer); middle.AddChidren(buzzView.Show()); - buzzView.clickviewBtn.MouseUpEventHandler += (sender, e) => { - CurrentDeviceView("铚傞福鍣�", new CommonDevice { }, true, ""); + buzzView.clickviewBtn.MouseUpEventHandler += (sender, e) => + { + CurrentDeviceView("铚傞福鍣�", common, edit, buzzView.seletecdTextBtn); }; + LogicView.SaveView saveView = new LogicView.SaveView(); + saveView.frameLayout.Y = middle.Height - Application.GetRealHeight(260); + middle.AddChidren(saveView.Show()); + saveView.clickviewBtn.MouseUpEventHandler += (sender, e) => + { + if (selectedDeviceStatus != "" && actionsInfo != null) + { + LogicIfon.AddDeviceActions(common, actionsInfo); + } + else + { + if (!edit) + { + var alert = new UserCenter.ShowMsgControl(UserCenter.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(() => { }); + } + + }; + + 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()) + { + TaskList = deviceinfo["TaskList"] as List<Dictionary<string, string>>; + foreach (var tasks in TaskList) + { + 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() + "K"; + } + break; + } + } + break; + } + } + } + } } - public void CurrentDeviceView(string if_str, CommonDevice common, bool edit, string str) + public void CurrentDeviceView(string if_str, CommonDevice common, bool edit, Button button) { var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor }; this.AddChidren(flMain); @@ -80,12 +185,26 @@ }; flMain.MouseUpEventHandler += clickcancel; completeView.Btncancel.MouseUpEventHandler += clickcancel; + if (actionsInfo == null) + { + actionsInfo = new Dictionary<string, object>(); + TaskList = new List<Dictionary<string, string>>(); + actionsInfo.Add("LinkType", 0); + actionsInfo.Add("DeviceAddr", common.DeviceAddr); + actionsInfo.Add("Epoint", common.DeviceEpoint); + actionsInfo.Add("Time", 0); + actionsInfo.Add("TaskList", TaskList); + } + string status = ""; - switch (if_str) { case "澶滅伅寮�鍏�": { + + Dictionary<string, string> switchDictionary = new Dictionary<string, string>(); + Send.dictionary(switchDictionary, "TaskType", "1"); + Send.dictionary(switchDictionary, "Data2", "0"); mFunView openView = new mFunView(); openView.frameLayout.Y = Application.GetRealHeight(140 + 20); openView.titleBtn.TextID = MyInternationalizationString.open; @@ -98,32 +217,63 @@ ///鐐瑰嚮纭浜嬩欢 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(switchDictionary, "Data1", "1");//榛樿鍊� + DicValue("1", switchDictionary); + 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(switchDictionary, "Data1", "0");//榛樿鍊� + DicValue("1", switchDictionary); + status = Language.StringByID(MyInternationalizationString.close); }; + if (TaskList != null && 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 "浜害": { + Dictionary<string, string> brightnessDictionary = new Dictionary<string, string>(); + Send.dictionary(brightnessDictionary, "TaskType", "3"); + Send.dictionary(brightnessDictionary, "Data2", "0"); var horizontalSeekBarVol = new DiyImageSeekBar { - Y = Application.GetRealHeight(140), - X = Application.GetRealWidth(78), - Width = Application.GetRealWidth(918), - Height = Application.GetRealHeight(320),//婊戝姩鏉$埗鎺т欢楂樺害 + 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,//閫変腑杩涘害鏉¢鑹� @@ -134,23 +284,47 @@ SeekBarViewHeight = Application.GetRealHeight(6),//杩涘害鏉$殑楂樺害10 }; completeView.Show(2).AddChidren(horizontalSeekBarVol); + EventHandler<int> progressclick = (sender, e) => + { + selectedDeviceStatus = "3"; + int lightbrightnessvalue = (254 * horizontalSeekBarVol.Progress) / 100; + Send.dictionary(brightnessDictionary, "Data1", lightbrightnessvalue.ToString()); + DicValue("3", brightnessDictionary); + status = horizontalSeekBarVol.Progress.ToString() + "%"; + }; + horizontalSeekBarVol.OnProgressChangedEvent += progressclick; + horizontalSeekBarVol.OnStopTrackingTouchEvent += progressclick; + + if (TaskList != null && 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 titleBtn = new Button + Dictionary<string, string> brightnessDictionary = new Dictionary<string, string>(); + Send.dictionary(brightnessDictionary, "TaskType", "8"); + Send.dictionary(brightnessDictionary, "Data2", "0"); + Button seekIconBtn = new Button { - Y = Application.GetRealHeight(140+154), + Y = Application.GetRealHeight(140 + 154), X = Application.GetRealWidth(78), Height = Application.GetRealHeight(12), Width = Application.GetRealWidth(918), - //TextID = MyInternationalizationString.logicathomegarrison, - TextAlignment = TextAlignment.CenterLeft, - TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor, - TextSize = 14, - UnSelectedImagePath= "ZigeeLogic/seek.png", + UnSelectedImagePath = "ZigeeLogic/seek.png", }; - completeView.Show(2).AddChidren(titleBtn); + completeView.Show(2).AddChidren(seekIconBtn); var horizontalSeekBarVol = new DiyImageSeekBar { Y = Application.GetRealHeight(140), @@ -160,18 +334,52 @@ IsProgressTextShow = true,//鏄剧ず鐧惧垎姣� IsClickable = true,//杩涘害鏉℃槸鍚︽粦鍔� ProgressBarColor = 0x00000000,// ZigbeeColor.Current.LogicProgressColorSelected,//閫変腑杩涘害鏉¢鑹� - SeekBarBackgroundColor= 0x00000000, + SeekBarBackgroundColor = 0x00000000, ThumbImagePath = "ZigeeLogic/progressbtn2.png",//杩涘害鏉℃寜閽浘鏍� ThumbImageHeight = Application.GetRealHeight(89),//杩涘害鏉℃寜閽浘鏍囩殑楂樺害锛堥粯璁ゆ鏂瑰舰锛氬鍜岄珮涓�鏍凤級 ProgressTextColor = ZigbeeColor.Current.LogicBtnCancelColor, ProgressTextSize = 9,//鏄剧ず鐧惧垎姣斿瓧浣撳ぇ灏�12 SeekBarViewHeight = Application.GetRealHeight(12),//杩涘害鏉$殑楂樺害10 + MinValue = 30, + MaxValue = 60, + ProgressBarUnitSring = "K",//鍒囨崲鍗曚綅 }; completeView.Show(2).AddChidren(horizontalSeekBarVol); + EventHandler<int> progressclick = (sender, e) => + { + selectedDeviceStatus = "8"; + var lightbrightnessvalue = 1000000 / (100 * horizontalSeekBarVol.Progress); + Send.dictionary(brightnessDictionary, "Data1", lightbrightnessvalue.ToString()); + DicValue("8", brightnessDictionary); + status = horizontalSeekBarVol.Progress.ToString() + "K"; + }; + horizontalSeekBarVol.OnProgressChangedEvent += progressclick; + horizontalSeekBarVol.OnStopTrackingTouchEvent += progressclick; + + + if (TaskList != null && 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; + } + + } + } } break; case "铚傞福鍣�": { + Dictionary<string, string> switchDictionary = new Dictionary<string, string>(); + Send.dictionary(switchDictionary, "TaskType", "7"); + Send.dictionary(switchDictionary, "Data2", "0"); + + mFunView openView = new mFunView(); openView.frameLayout.Y = Application.GetRealHeight(140 + 20); openView.titleBtn.TextID = MyInternationalizationString.open; @@ -185,30 +393,104 @@ ///鐐瑰嚮纭浜嬩欢 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(switchDictionary, "Data1", "1");//榛樿鍊� + DicValue("7", switchDictionary); + 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(switchDictionary, "Data1", "0");//榛樿鍊� + DicValue("7", switchDictionary); + status = Language.StringByID(MyInternationalizationString.close); }; + + if (TaskList != null && 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 (selectedDeviceStatus != "") + { + flMain.RemoveFromParent(); + button.Text = status; + + } + else + { + if (!edit) + { + var alert = new UserCenter.ShowMsgControl(UserCenter.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) + { + if (TaskList != null) + { + TaskList.Add(dictionay); + } + } + } } } -- Gitblit v1.8.0