From c7df85937f73fb347ee0b19e9c052d2d00a6df6c Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期五, 18 九月 2020 13:58:19 +0800 Subject: [PATCH] 新版本 --- ZigbeeApp/Shared/Phone/Device/Logic/Nightlight.cs | 230 ++++++++++++++++++++++++++++---------------------------- 1 files changed, 115 insertions(+), 115 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/Nightlight.cs b/ZigbeeApp/Shared/Phone/Device/Logic/Nightlight.cs index 1292f36..a2bcb2a 100755 --- a/ZigbeeApp/Shared/Phone/Device/Logic/Nightlight.cs +++ b/ZigbeeApp/Shared/Phone/Device/Logic/Nightlight.cs @@ -15,10 +15,10 @@ } string selectedDeviceStatus = ""; Dictionary<string, object> actionsInfo = null; - List<Dictionary<string, string>> TaskList = 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) { - actionsInfo = editdeviceActionInfo; + #region 甯冨眬鐣岄潰 this.BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor; TopView view = new TopView(); this.AddChidren(view.TopRowView()); @@ -26,6 +26,7 @@ view.clickBtn.MouseDownEventHandler += (sender, e) => { RemoveFromParent(); + }; var middle = new FrameLayout { @@ -34,48 +35,59 @@ BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, }; this.AddChidren(middle); - + //澶滅伅寮�鍏� LogicView.LightView openView = new LogicView.LightView(); openView.titleBtn.Text = Language.StringByID(MyInternationalizationString.nightLightSwitch); middle.AddChidren(openView.Show()); - 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 = Language.StringByID(MyInternationalizationString.brightness); middle.AddChidren(brightnessView.Show()); - 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 = Language.StringByID(MyInternationalizationString.colorTemperature); middle.AddChidren(colorTemperatureView.Show()); - 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 = 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); }; - - 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) + if (TaskList.Count!=0) { LogicIfon.AddDeviceActions(common, actionsInfo); } @@ -83,7 +95,7 @@ { if (!edit) { - var alert = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Normal, + var alert = new UserCenter.ShowMsgControl(ShowMsgType.Normal, Language.StringByID(MyInternationalizationString.selectdevicestatuscondition), Language.StringByID(MyInternationalizationString.confrim)); alert.Show(); @@ -109,69 +121,83 @@ } }; + #endregion if (edit) { - foreach (var deviceinfo in Common.Logic.CurrentLogic.Actions) - { - if (deviceinfo["LinkType"].ToString() == "0") + foreach (var deviceinfo in Common.Logic.CurrentLogic.Actions) { - - if (deviceinfo["DeviceAddr"].ToString() == common.DeviceAddr && deviceinfo["Epoint"].ToString() == common.DeviceEpoint.ToString()) + if (deviceinfo["LinkType"].ToString() == "0") { - TaskList = deviceinfo["TaskList"] as List<Dictionary<string, string>>; - foreach (var tasks in TaskList) + + if (deviceinfo["DeviceAddr"].ToString() == common.DeviceAddr && deviceinfo["Epoint"].ToString() == common.DeviceEpoint.ToString()) { - switch (tasks["TaskType"]) + var taskLists = deviceinfo["TaskList"] as List<Dictionary<string, string>>; + foreach (var tasks in taskLists) { - case "1": - { - if (tasks["Data1"] == "0") + TaskList.Add(tasks); + switch (tasks["TaskType"]) + { + case "1": { - openView.seletecdTextBtn.TextID = MyInternationalizationString.close; + if (tasks["Data1"] == "0") + { + openView.seletecdTextBtn.TextID = MyInternationalizationString.close; + } + else + { + openView.seletecdTextBtn.TextID = MyInternationalizationString.open; + } } - else + break; + case "3": { - openView.seletecdTextBtn.TextID = MyInternationalizationString.open; + var intvalue = int.Parse(tasks["Data1"]); + var lightbrightnessvalue = (intvalue * 100) / 254; + brightnessView.seletecdTextBtn.Text = lightbrightnessvalue.ToString() + "%"; } - } - 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") + break; + case "7": { - buzzView.seletecdTextBtn.TextID = MyInternationalizationString.close; + if (tasks["Data1"] == "0") + { + buzzView.seletecdTextBtn.TextID = MyInternationalizationString.close; + } + else + { + buzzView.seletecdTextBtn.TextID = MyInternationalizationString.open; + } } - else + break; + case "8": { - buzzView.seletecdTextBtn.TextID = MyInternationalizationString.open; + var intvalue = int.Parse(tasks["Data1"]); + var lightbrightnessvalue = 1000000 / (intvalue * 100); + colorTemperatureView.seletecdTextBtn.Text = lightbrightnessvalue.ToString() + "00K"; } - } - break; - case "8": - { - var intvalue = int.Parse(tasks["Data1"]); - var lightbrightnessvalue = 1000000 / (intvalue * 100); - colorTemperatureView.seletecdTextBtn.Text = lightbrightnessvalue.ToString() + "K"; - } - break; + break; + } } + 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;//涓嶈褰撳墠鐣岄潰婊戝姩 @@ -185,26 +211,16 @@ }; 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 = ""; + #endregion + string status = ""; + Dictionary<string, string> dictionaryLight = new Dictionary<string, string>(); + dictionaryLight.Clear(); 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; @@ -222,8 +238,7 @@ closeView.selectedIconBtn.Visible = false; openView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor; closeView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor; - Send.dictionary(switchDictionary, "Data1", "1");//榛樿鍊� - DicValue("1", switchDictionary); + Send.dictionary(dictionaryLight, "Data1", "1");//榛樿鍊� status = Language.StringByID(MyInternationalizationString.open); }; @@ -235,12 +250,11 @@ closeView.selectedIconBtn.Visible = true; openView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor; closeView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor; - Send.dictionary(switchDictionary, "Data1", "0");//榛樿鍊� - DicValue("1", switchDictionary); + Send.dictionary(dictionaryLight, "Data1", "0");//榛樿鍊� status = Language.StringByID(MyInternationalizationString.close); }; - if (TaskList != null && TaskList.Count != 0) + if ( TaskList.Count != 0) { foreach (var value in TaskList) { @@ -265,37 +279,34 @@ 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),//杩涘害鏉$埗鎺т欢Y鍧愭爣 X = Application.GetRealWidth(78),//杩涘害鏉鍧愭爣 Width = Application.GetRealWidth(918),//杩涘害鏉$殑闀垮害 - Height = Application.GetRealHeight(320),//杩涘害鏉$埗鎺ф帶浠堕珮搴� + 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 = 9,//鏄剧ず鐧惧垎姣斿瓧浣撳ぇ灏�12 + 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(brightnessDictionary, "Data1", lightbrightnessvalue.ToString()); - DicValue("3", brightnessDictionary); + Send.dictionary(dictionaryLight, "Data1", lightbrightnessvalue.ToString()); status = horizontalSeekBarVol.Progress.ToString() + "%"; }; horizontalSeekBarVol.OnProgressChangedEvent += progressclick; horizontalSeekBarVol.OnStopTrackingTouchEvent += progressclick; - if (TaskList != null && TaskList.Count != 0) + if ( TaskList.Count != 0) { foreach (var value in TaskList) { @@ -313,9 +324,6 @@ break; case "鑹叉俯": { - 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 + 160), @@ -345,14 +353,13 @@ horizontalSeekBarVol.SetCustomText(e * 100 + "K"); selectedDeviceStatus = "8"; var lightbrightnessvalue = 1000000 / (100 * horizontalSeekBarVol.Progress); - Send.dictionary(brightnessDictionary, "Data1", lightbrightnessvalue.ToString()); - DicValue("8", brightnessDictionary); - status =horizontalSeekBarVol.Progress.ToString() + "K"; + Send.dictionary(dictionaryLight, "Data1", lightbrightnessvalue.ToString()); + status =horizontalSeekBarVol.Progress.ToString() + "00K"; }; horizontalSeekBarVol.OnProgressChangedEvent += progressclick; horizontalSeekBarVol.OnStopTrackingTouchEvent += progressclick; - if (TaskList != null && TaskList.Count != 0) + if ( TaskList.Count != 0) { foreach (var value in TaskList) { @@ -374,10 +381,6 @@ 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); @@ -397,8 +400,7 @@ closeView.selectedIconBtn.Visible = false; openView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor; closeView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor; - Send.dictionary(switchDictionary, "Data1", "1");//榛樿鍊� - DicValue("7", switchDictionary); + Send.dictionary(dictionaryLight, "Data1", "1");//榛樿鍊� status = Language.StringByID(MyInternationalizationString.open); }; @@ -410,13 +412,12 @@ closeView.selectedIconBtn.Visible = true; openView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor; closeView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor; - Send.dictionary(switchDictionary, "Data1", "0");//榛樿鍊� - DicValue("7", switchDictionary); + Send.dictionary(dictionaryLight, "Data1", "0");//榛樿鍊� status = Language.StringByID(MyInternationalizationString.close); }; - if (TaskList != null && TaskList.Count != 0) + if ( TaskList.Count != 0) { foreach (var value in TaskList) { @@ -442,10 +443,12 @@ } completeView.Btncomplete.MouseUpEventHandler += (sender, e) => { - if (selectedDeviceStatus != "") + if (dictionaryLight.Count!=0) { - + Send.dictionary(dictionaryLight, "TaskType", selectedDeviceStatus); + Send.dictionary(dictionaryLight, "Data2", "0"); flMain.RemoveFromParent(); + DicValue(selectedDeviceStatus, dictionaryLight); button.Text = status; } @@ -453,7 +456,7 @@ { if (!edit) { - var alert = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Normal, + var alert = new UserCenter.ShowMsgControl(ShowMsgType.Normal, Language.StringByID(MyInternationalizationString.selectdevicestatuscondition), Language.StringByID(MyInternationalizationString.confrim)); alert.Show(); @@ -484,10 +487,7 @@ } if (!d) { - if (TaskList != null) - { - TaskList.Add(dictionay); - } + TaskList.Add(dictionay); } } } -- Gitblit v1.8.0