From 2ed75b8b337048e5d75e6d9ec8307633134f02fd Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期四, 10 十月 2019 11:33:04 +0800 Subject: [PATCH] 个人中心添加楼层和创建房间,实装二级验证 --- ZigbeeApp/Shared/Phone/Device/Logic/LogicCommunalPage.cs | 301 +++++++++++++++++++++++++++++-------------------- 1 files changed, 176 insertions(+), 125 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/LogicCommunalPage.cs b/ZigbeeApp/Shared/Phone/Device/Logic/LogicCommunalPage.cs index 5f62f26..171aa2f 100755 --- a/ZigbeeApp/Shared/Phone/Device/Logic/LogicCommunalPage.cs +++ b/ZigbeeApp/Shared/Phone/Device/Logic/LogicCommunalPage.cs @@ -40,14 +40,14 @@ var titleName = new Button { - + TextSize = 17, TextColor = ZigbeeColor.Current.LogicTextBlackColor, TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(150), }; topFrameLayout.AddChidren(titleName); - if (Common.Logic.CurrentLogic.LogicId == 1) + if (Common.Logic.CurrentLogic.LogicId != 0) { titleName.Text = Language.StringByID(MyInternationalizationString.editautomation); } @@ -65,6 +65,7 @@ UnSelectedImagePath = "ZigeeLogic/Back.png", }; topFrameLayout.AddChidren(back); + back.MouseDownEventHandler += (sender, e) => { //if (Common.Logic.CurrentLogic.LogicId != 0) @@ -163,7 +164,7 @@ }; logicnamefl.AddChidren(text); - logicTextBox = new EditText + logicTextBox = new EditText { Width = Application.GetRealWidth(900), Height = Application.GetRealHeight(60), @@ -171,12 +172,12 @@ Y = text.Bottom + Application.GetRealHeight(10), TextAlignment = TextAlignment.CenterLeft, TextColor = ZigbeeColor.Current.LogicTextBlackColor, - TextSize=13, - Text =Common.Logic.CurrentLogic.LogicName, + TextSize = 13, + Text = Common.Logic.CurrentLogic.LogicName, //TextID=MyInternationalizationString.automation1, }; logicnamefl.AddChidren(logicTextBox); - + var btnline = new Button { Height = Application.GetRealHeight(4), @@ -193,7 +194,7 @@ //BackgroundColor = 0xff323232, }; middle.AddChidren(conditionRowLayout); - + conditionRowLayout.AddChidren(new Button { Width = Application.GetRealWidth(300), @@ -279,9 +280,9 @@ }; addfl.AddChidren(addbtn); addbtn.MouseUpEventHandler += (sender, e) => - { - ConditionView(); - }; + { + ConditionView(); + }; } else { @@ -335,7 +336,7 @@ case 0: { string s = ""; - s = conditions["StartMin"].Length < 2 ? "0" + conditions["StartMin"] : conditions["StartMin"]; + s = conditions["StartMin"].Length < 2 ? "0" + conditions["StartMin"] : conditions["StartMin"]; timevalue.Text = Language.StringByID(MyInternationalizationString.time) + conditions["StartHour"] + ":" + s; } break; @@ -364,7 +365,7 @@ } else { - timevalue.Text =Language.StringByID(MyInternationalizationString.sunset); + timevalue.Text = Language.StringByID(MyInternationalizationString.sunset); } break; case 3: @@ -378,7 +379,7 @@ } else { - timevalue.Text =Language.StringByID(MyInternationalizationString.noon); + timevalue.Text = Language.StringByID(MyInternationalizationString.noon); } break; } @@ -387,9 +388,9 @@ break; case 5: { - string s1="", s2=""; - s1 = conditions["StartMin"].Length < 2 ? "0" + conditions["StartMin"] : conditions["StartMin"]; - s2 = conditions["StopMin"].Length <2 ? "0" + conditions["StopMin"] : conditions["StopMin"]; + string s1 = "", s2 = ""; + s1 = conditions["StartMin"].Length < 2 ? "0" + conditions["StartMin"] : conditions["StartMin"]; + s2 = conditions["StopMin"].Length < 2 ? "0" + conditions["StopMin"] : conditions["StopMin"]; ///鏄剧ず鏃堕棿 var timevalue = new Button { @@ -406,7 +407,7 @@ var timeedit = new Button { - BackgroundColor =ZigbeeColor.Current.LogicEditBlackColor, + BackgroundColor = ZigbeeColor.Current.LogicEditBlackColor, Text = Language.StringByID(MyInternationalizationString.edit), //TextColor = ZigbeeColor.Current.LogicTextBlackColor, }; @@ -445,7 +446,7 @@ var deviceedit = new Button { - BackgroundColor =ZigbeeColor.Current.LogicEditBlackColor, + BackgroundColor = ZigbeeColor.Current.LogicEditBlackColor, Text = Language.StringByID(MyInternationalizationString.edit), TextColor = ZigbeeColor.Current.LogicTextBlackColor, }; @@ -469,7 +470,7 @@ Height = Application.GetRealHeight(160), Gravity = Gravity.CenterVertical, TextAlignment = TextAlignment.CenterRight, - X = Application.GetRealWidth(1080 - 330), + X = Application.GetRealWidth(1080 - 340), TextColor = ZigbeeColor.Current.LogicTextBlackColor, }; conditionsowLayout.AddChidren(devicestatus); @@ -588,7 +589,16 @@ } break; - } + default: + { + if (intvalue == "1") + { + devicestatus.TextID = MyInternationalizationString.callthepolice; + } + } + break; + + } } break; case DeviceType.OnOffSwitch: @@ -640,7 +650,7 @@ var logicedit = new Button { - BackgroundColor =ZigbeeColor.Current.LogicEditBlackColor, + BackgroundColor = ZigbeeColor.Current.LogicEditBlackColor, Text = Language.StringByID(MyInternationalizationString.edit), TextColor = ZigbeeColor.Current.LogicTextBlackColor, }; @@ -695,7 +705,7 @@ var btnsecurityedit = new Button { - BackgroundColor =ZigbeeColor.Current.LogicEditBlackColor, + BackgroundColor = ZigbeeColor.Current.LogicEditBlackColor, Text = Language.StringByID(MyInternationalizationString.edit), TextColor = ZigbeeColor.Current.LogicTextBlackColor, }; @@ -737,7 +747,7 @@ break; case 7: { - var btnlocation= new Button + var btnlocation = new Button { X = Application.GetRealWidth(40), Width = Application.GetRealWidth(700), @@ -753,14 +763,14 @@ var btnlocationedit = new Button { - BackgroundColor =ZigbeeColor.Current.LogicEditBlackColor, + BackgroundColor = ZigbeeColor.Current.LogicEditBlackColor, Text = Language.StringByID(MyInternationalizationString.edit), TextColor = ZigbeeColor.Current.LogicTextBlackColor, }; conditionsowLayout.AddRightView(btnlocationedit); btnlocationedit.MouseUpEventHandler += (sender, e) => { - + var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor }; this.AddChidren(flMain); AddLogicPage.LocationView(flMain, true); @@ -779,11 +789,11 @@ if (conditions["AtHome"] == "1") { - locationstatus.Text =Language.StringByID(MyInternationalizationString.athome); + locationstatus.Text = Language.StringByID(MyInternationalizationString.athome); } else { - locationstatus.Text =Language.StringByID(MyInternationalizationString.leavehome); + locationstatus.Text = Language.StringByID(MyInternationalizationString.leavehome); } } break; @@ -814,7 +824,7 @@ } }; alert.Show(); - + }; } @@ -830,7 +840,7 @@ // BackgroundColor = 0xff323232, }; middle.AddChidren(targetRowLayout); - + var btntargettitle = new Button { @@ -947,7 +957,7 @@ } else { - var actionsrowLayout = new RowLayout + var actionsrowLayout = new RowLayout { Height = Application.GetRealHeight(160), }; @@ -960,8 +970,8 @@ { case 10: { - var delaytime =actions["DelayTime"].ToString(); - + var delaytime = actions["DelayTime"].ToString(); + var btnDelayTime = new Button { X = Application.GetRealWidth(40), @@ -976,7 +986,7 @@ ///缂栬緫璁惧鐘舵�丅utton var timeedit = new Button { - BackgroundColor =ZigbeeColor.Current.LogicEditBlackColor, + BackgroundColor = ZigbeeColor.Current.LogicEditBlackColor, Text = Language.StringByID(MyInternationalizationString.edit), TextColor = ZigbeeColor.Current.LogicTextBlackColor, }; @@ -1021,7 +1031,7 @@ } ListActions[i].Add("Time", 0); } - + ///璁惧鍚嶇ОButton var btndevicename = new Button { @@ -1055,15 +1065,15 @@ Height = Application.GetRealHeight(160), Gravity = Gravity.CenterVertical, TextAlignment = TextAlignment.CenterRight, - X = Application.GetRealWidth(1080 - 330), + X = Application.GetRealWidth(1080 - 340), TextColor = ZigbeeColor.Current.LogicTextBlackColor, - }; + }; actionsrowLayout.AddChidren(devicestatus); ///缂栬緫璁惧鐘舵�丅utton var deviceedit = new Button { - BackgroundColor =ZigbeeColor.Current.LogicEditBlackColor, + BackgroundColor = ZigbeeColor.Current.LogicEditBlackColor, Text = Language.StringByID(MyInternationalizationString.edit), TextColor = ZigbeeColor.Current.LogicTextBlackColor, }; @@ -1071,23 +1081,22 @@ ///缂栬緫鐐瑰嚮浜嬩欢 deviceedit.MouseUpEventHandler += (sender, e) => - { - //var deviceStatePage = new DeviceStatePage(); - //UserView.HomePage.Instance.AddChidren(deviceStatePage); - //UserView.HomePage.Instance.PageIndex += 1; - //deviceStatePage.IsDeviceEditor = true; - //deviceStatePage.Show(deviceinof); + { + //var deviceStatePage = new DeviceStatePage(); + //UserView.HomePage.Instance.AddChidren(deviceStatePage); + //UserView.HomePage.Instance.PageIndex += 1; + //deviceStatePage.IsDeviceEditor = true; + //deviceStatePage.Show(deviceinof); - //ActionModifyDeviceStateView(deviceinof); - var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor }; - this.AddChidren(flMain); - LogicDevicePage.CurrentDeviceStateView(flMain, deviceinof, true); - }; + //ActionModifyDeviceStateView(deviceinof); + var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor }; + this.AddChidren(flMain); + LogicDevicePage.CurrentDeviceStateView(flMain, deviceinof, true); + }; switch (deviceinof.Type) { - case DeviceType.OnOffOutput: { var TaskList = actions["TaskList"] as List<Dictionary<string, string>>; @@ -1108,6 +1117,38 @@ devicestatus.Text = devicestatus.Text + Language.StringByID(MyInternationalizationString.close); } } + + } + + } + break; + case DeviceType.DimmableLight: + { + var TaskList = actions["TaskList"] as List<Dictionary<string, string>>; + if (TaskList == null) + { + continue; + } + foreach (var status in TaskList) + { + if (status["TaskType"].ToString() == "3") + { + var intvalue = int.Parse(status["Data1"]); + var lightbrightnessvalue = (intvalue * 100) / 254; + devicestatus.Text = lightbrightnessvalue.ToString() + "%"; + } + else if (status["TaskType"].ToString() == "1") + { + if (status["Data1"].ToString() == "1") + { + devicestatus.Text = devicestatus.Text + Language.StringByID(MyInternationalizationString.open); + } + else + { + devicestatus.Text = devicestatus.Text + Language.StringByID(MyInternationalizationString.close); + } + } + } @@ -1216,7 +1257,7 @@ //TextColor = 0xff121212, X = Application.GetRealWidth(1080 - 330), TextColor = ZigbeeColor.Current.LogicTextBlackColor, - TextAlignment=TextAlignment.CenterRight, + TextAlignment = TextAlignment.CenterRight, }; actionsrowLayout.AddChidren(logicstatus); @@ -1240,7 +1281,7 @@ Gravity = Gravity.CenterVertical, TextColor = ZigbeeColor.Current.LogicTextBlackColor, //TextColor = 0xff121212, - TextID = MyInternationalizationString.securitymode, + TextID = MyInternationalizationString.security, }; actionsrowLayout.AddChidren(btnsecurity); @@ -1268,9 +1309,9 @@ Height = Application.GetRealHeight(160), Gravity = Gravity.CenterVertical, //TextColor = 0xff121212, - X = Application.GetRealWidth(1080 -330), + X = Application.GetRealWidth(1080 - 330), TextColor = ZigbeeColor.Current.LogicTextBlackColor, - TextAlignment=TextAlignment.CenterRight, + TextAlignment = TextAlignment.CenterRight, }; actionsrowLayout.AddChidren(securitystatus); @@ -1337,13 +1378,13 @@ #endregion #region ----鎺ㄩ�佽缃�---- - + /* var pushRowLayout = new RowLayout { Height = Application.GetRealHeight(150), }; middle.AddChidren(pushRowLayout); - + var btnpushtitle = new Button { //Text = "鎺ㄩ�佽缃�", @@ -1360,14 +1401,14 @@ //TextID = MyInternationalizationString.execute, }; pushRowLayout.AddChidren(btnpushtitle); - + var pushswitchRowlayout = new RowLayout { Height = Application.GetRealHeight(160), LineColor = ZigbeeColor.Current.LogicLineColor, }; middle.AddChidren(pushswitchRowlayout); - + var btnswitchtxet = new Button { //Text = "鎺ㄩ�佸紑鍏�", @@ -1378,7 +1419,7 @@ TextID = MyInternationalizationString.pushswitch, }; pushswitchRowlayout.AddChidren(btnswitchtxet); - + var btnswitch = new Button { Width = Application.GetMinRealAverage(183), @@ -1389,26 +1430,26 @@ Gravity = Gravity.CenterVertical, }; pushswitchRowlayout.AddChidren(btnswitch); - + btnswitch.MouseUpEventHandler += (sender1, e1) => { btnswitch.IsSelected = !btnswitch.IsSelected; if (btnswitch.IsSelected) { - + } else { - + } }; - + var custompushRowLayout = new RowLayout { Height = Application.GetRealHeight(160), }; middle.AddChidren(custompushRowLayout); - + var btncustompush = new Button { TextID = MyInternationalizationString.custompush, @@ -1419,8 +1460,8 @@ TextColor = ZigbeeColor.Current.LogicTextBlackColor, }; custompushRowLayout.AddChidren(btncustompush); - - + + var custompushback = new Button { Width = Application.GetRealWidth(110), @@ -1437,14 +1478,15 @@ UserView.HomePage.Instance.AddChidren(CustomText); UserView.HomePage.Instance.PageIndex += 1; CustomText.Show(); - + }; btncustompush.MouseUpEventHandler += customclick; custompushback.MouseUpEventHandler += customclick; custompushRowLayout.MouseUpEventHandler += customclick; + */ #endregion - + var btnsave = new Button { Height = Application.GetRealHeight(150),//194 @@ -1461,50 +1503,50 @@ AddChidren(btnsave); } btnsave.MouseUpEventHandler += async (sender, e) => - { - var name = logicTextBox.Text.Trim(); + { + var name = logicTextBox.Text.Trim(); - if (string.IsNullOrEmpty(logicTextBox.Text.Trim())) - { - new Alert(Language.StringByID(MyInternationalizationString.Tip), Language.StringByID(MyInternationalizationString.PleaseEnterLogicName), Language.StringByID(MyInternationalizationString.Close)).Show(); - return; - } - var logicname = Common.Logic.LogicList.Find((logic) => Common.Logic.CurrentLogic.LogicId != logic.LogicId && logic.LogicName == name); - if (logicname != null) - { - new Alert(Language.StringByID(MyInternationalizationString.Tip), Language.StringByID(MyInternationalizationString.Rename), Language.StringByID(MyInternationalizationString.Close)).Show(); - return; - } + if (string.IsNullOrEmpty(logicTextBox.Text.Trim())) + { + new Alert(Language.StringByID(MyInternationalizationString.Tip), Language.StringByID(MyInternationalizationString.PleaseEnterLogicName), Language.StringByID(MyInternationalizationString.Close)).Show(); + return; + } + var logicname = Common.Logic.LogicList.Find((logic) => Common.Logic.CurrentLogic.LogicId != logic.LogicId && logic.LogicName == name); + if (logicname != null) + { + new Alert(Language.StringByID(MyInternationalizationString.Tip), Language.StringByID(MyInternationalizationString.Rename), Language.StringByID(MyInternationalizationString.Close)).Show(); + return; + } - Common.Logic.CurrentLogic.LogicName = name; + Common.Logic.CurrentLogic.LogicName = name; - //鍒ゆ柇鏄柊娣诲姞閫昏緫(榛樿0)杩樻槸淇敼閫昏緫 - CommonPage.Loading.Start(); - if (Common.Logic.CurrentLogic.LogicId == 0) - { - //鍙戦�佹坊鍔犻�昏緫鍛戒护 - var logicifon = await Send.AddModifyLogic(Common.Logic.CurrentLogic); - if (logicifon != null && logicifon.LogicId != 0) - { - Common.Logic.CurrentLogic.LogicId = logicifon.LogicId; - Common.Logic.LogicList.Add(Common.Logic.CurrentLogic); - } - } - else - { - //鍙戦�佷慨鏀归�昏緫鍛戒护 - Send.AddModifyLogic(Common.Logic.CurrentLogic); - } + //鍒ゆ柇鏄柊娣诲姞閫昏緫(榛樿0)杩樻槸淇敼閫昏緫 + CommonPage.Loading.Start(); + if (Common.Logic.CurrentLogic.LogicId == 0) + { + //鍙戦�佹坊鍔犻�昏緫鍛戒护 + var logicifon = await Send.AddModifyLogic(Common.Logic.CurrentLogic); + if (logicifon != null && logicifon.LogicId != 0) + { + Common.Logic.CurrentLogic.LogicId = logicifon.LogicId; + Common.Logic.LogicList.Add(Common.Logic.CurrentLogic); + } + } + else + { + //鍙戦�佷慨鏀归�昏緫鍛戒护 + Send.AddModifyLogic(Common.Logic.CurrentLogic); + } - CommonPage.Loading.Hide(); - UserView.HomePage.Instance.RemoveViewByTag("Logic"); - Category.Category.instance?.RefreshBodyView(); - //UserView.HomePage.Instance.RemoveAt("Logic1"); - //Category.Category category = new Category.Category(); - //UserView.HomePage.Instance.AddChidren(category); - //UserView.HomePage.Instance.PageIndex += 1; - //category.Show(2); - }; + CommonPage.Loading.Hide(); + UserView.HomePage.Instance.RemoveViewByTag("Logic"); + Category.Category.instance?.RefreshBodyView(); + //UserView.HomePage.Instance.RemoveAt("Logic1"); + //Category.Category category = new Category.Category(); + //UserView.HomePage.Instance.AddChidren(category); + //UserView.HomePage.Instance.PageIndex += 1; + //category.Show(2); + }; } @@ -1585,7 +1627,7 @@ if (dictionary.Count != 0 && dictionary.Count == 1) { string len = "", leng = ""; - int minvalue = 0,Maximum=0; + int minvalue = 0, Maximum = 0; foreach (var value in dictionary) { ///鍙栧嚭鏈堜唤 @@ -1625,13 +1667,13 @@ { leng = month.ToString(); } - if (minvalue==Maximum) + if (minvalue == Maximum) { btndisplaycycle.Text = Language.StringByID(MyInternationalizationString.everyyear) + leng + "/" + (minvalue.ToString().Length < 2 ? "0" + minvalue.ToString() : minvalue.ToString()); } else { - btndisplaycycle.Text = Language.StringByID(MyInternationalizationString.everyyear) + leng + "/" + (minvalue.ToString().Length < 2 ? "0" + minvalue.ToString() : minvalue.ToString()) + "-" + leng + "/" + (Maximum.ToString().Length < 2 ? "0" + Maximum.ToString():Maximum.ToString()); + btndisplaycycle.Text = Language.StringByID(MyInternationalizationString.everyyear) + leng + "/" + (minvalue.ToString().Length < 2 ? "0" + minvalue.ToString() : minvalue.ToString()) + "-" + leng + "/" + (Maximum.ToString().Length < 2 ? "0" + Maximum.ToString() : Maximum.ToString()); } } @@ -1643,7 +1685,7 @@ foreach (var value in dictionary) { string len = "", leng = ""; - int minvalue = 0,Maximum=0; + int minvalue = 0, Maximum = 0; ///鍙栧嚭鏈堜唤 var month = value.Key; ///鍙栧嚭鏃ユ暟 @@ -1654,7 +1696,7 @@ { len += str.Substring(j, 1); } - + if (month.ToString().Length < 2) { @@ -1692,7 +1734,7 @@ Maximum = j + 1; } } - stringtext += leng + "/" + (Maximum.ToString().Length < 2 ? "0" +Maximum.ToString() :Maximum.ToString()); + stringtext += leng + "/" + (Maximum.ToString().Length < 2 ? "0" + Maximum.ToString() : Maximum.ToString()); } b++; @@ -1800,21 +1842,25 @@ var frameLayout = new FrameLayout { - Y = Application.GetRealHeight(1920 - 720), - Height = Application.GetRealHeight(720), - BackgroundColor = ZigbeeColor.Current.LogicTopViewBackgroundColor, + Y = Application.GetRealHeight(1920 - 680 - 50), + Height = Application.GetRealHeight(680), + BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor, + Width = Application.GetRealWidth(1000), + X = Application.GetRealWidth(40), + Radius = (uint)Application.GetRealHeight(40), }; flMain.AddChidren(frameLayout); - var titlerow = new RowLayout + var titlerow = new FrameLayout { - Height = Application.GetRealHeight(180), + Height = Application.GetRealHeight(150), }; frameLayout.AddChidren(titlerow); + var titlebtn = new Button { //Text = "璇烽�夋嫨澶氭潯浠剁粍鍚�", - //TextID = MyInternationalizationString.Multicondition, + TextID = MyInternationalizationString.multicondition, TextSize = 16, TextColor = ZigbeeColor.Current.LogicTextBlackColor, }; @@ -1822,7 +1868,7 @@ var androw = new RowLayout { - Height = Application.GetRealHeight(180), + Height = Application.GetRealHeight(160), Y = titlerow.Bottom, }; frameLayout.AddChidren(androw); @@ -1831,13 +1877,15 @@ Width = Application.GetRealWidth(600), TextID = MyInternationalizationString.Allconditions, TextColor = ZigbeeColor.Current.LogicTextBlackColor, - //Text = "婊¤冻鍏ㄩ儴鏉′欢鏃�", + //Text = "婊¤冻鍏ㄩ儴鏉′欢鏃�", + TextAlignment = TextAlignment.CenterLeft, + X = Application.GetRealHeight(50), }; androw.AddChidren(andbtn); var orrow = new RowLayout { - Height = Application.GetRealHeight(180), + Height = Application.GetRealHeight(160), Y = androw.Bottom, }; frameLayout.AddChidren(orrow); @@ -1847,6 +1895,8 @@ TextID = MyInternationalizationString.anycondition, //Text = "婊¤冻浠讳竴鏉′欢鏃�", TextColor = ZigbeeColor.Current.LogicTextBlackColor, + TextAlignment = TextAlignment.CenterLeft, + X = Application.GetRealHeight(50) }; orrow.AddChidren(orbtn); @@ -1854,9 +1904,10 @@ { TextID = MyInternationalizationString.cancel, TextSize = 16, - Y = orrow.Bottom, - Height = Application.GetRealHeight(180), + Y = orrow.Bottom + Application.GetRealHeight(30), + Height = Application.GetRealHeight(160), TextColor = ZigbeeColor.Current.LogicTextBlackColor, + BackgroundColor = ZigbeeColor.Current.LogicTopViewBackgroundColor, }; frameLayout.AddChidren(cancelbtn); cancelbtn.MouseUpEventHandler += (sender4, e4) => @@ -1899,6 +1950,6 @@ addLogicPage.Show(); } } - + } } -- Gitblit v1.8.0