From 8e5ba5665861b29a4b8da0335c81d620aa891862 Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期一, 08 三月 2021 09:23:54 +0800 Subject: [PATCH] Merge branch 'WJC' into temp-wxr --- HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/DeviceSet.cs | 274 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 237 insertions(+), 37 deletions(-) diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/DeviceSet.cs b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/DeviceSet.cs index 8ba618f..d7b7c56 100644 --- a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/DeviceSet.cs +++ b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/DeviceSet.cs @@ -11,7 +11,8 @@ { Tag = "PirView"; } - public void Show() { + public void Show() + { #region 鐣岄潰甯冨眬 this.BackgroundColor = CSS.CSS_Color.viewMiddle; PirDevice.View.TopView topView = new View.TopView(); @@ -19,38 +20,64 @@ topView.topIconBtn.Visible = true; this.AddChidren(topView.FLayoutView()); topView.clickBackBtn.MouseUpEventHandler += (sender, e) => { this.RemoveFromParent(); }; - VerticalScrolViewLayout vv = new VerticalScrolViewLayout(); + VerticalRefreshLayout vv = new VerticalRefreshLayout(); vv.Height = Application.GetRealHeight(667 - 64); vv.Y = Application.GetRealHeight(64); this.AddChidren(vv); - #endregion - int a = 3; - int b = 3; - for (int i = 0; i < b; i++) + vv.BeginHeaderRefreshingAction += () => { + //鍏抽棴鍒锋柊View锛� + vv.EndHeaderRefreshing(); + //鑾峰彇鍒楄〃 + Method.GetPirDeviceList(this,() => + { + Application.RunOnMainThread(() => + { + //鍒锋柊鐣岄潰 + UIView(vv); + }); + }); + + }; + #endregion + UIView(vv); + + } + /// <summary> + /// 鍔犺浇UI鐣岄潰 + /// </summary> + /// <param name="vv">涓婁笅婊戞帶浠�</param> + void UIView(VerticalRefreshLayout vv) + { + vv.RemoveAll(); + 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); - + //绾㈠瀹濇樉绀虹埗鎺т欢 FrameLayout devfLayout = new FrameLayout { Y = Application.GetRealHeight(12), X = Application.GetRealWidth(16), - Width = Application.GetRealWidth(375-16*2), - Height = Application.GetRealHeight(92 + (50 * a)), + Width = Application.GetRealWidth(375 - 16 * 2), + Height = Application.GetRealHeight(92 + (50 * pirDevice.FunctioList.Count)), BackgroundColor = CSS.CSS_Color.view, Radius = (uint)Application.GetRealHeight(12), }; fLayout.AddChidren(devfLayout); + + //绾㈠瀹濆浘鏍� Button priequipmentBtn = new Button { - Y=Application.GetRealHeight(16), + Y = Application.GetRealHeight(16), X = Application.GetRealWidth(5), Width = Application.GetRealWidth(60), Height = Application.GetRealWidth(60), @@ -61,11 +88,11 @@ //绾㈠瀹濆悕绉� Button deviceNameBtn = new Button { - Y=Application.GetRealHeight(16), + Y = Application.GetRealHeight(16), 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, @@ -75,7 +102,7 @@ //鐗堟湰鍙� Button versionBtn = new Button { - Y = deviceNameBtn.Bottom+ Application.GetRealHeight(4), + Y = deviceNameBtn.Bottom + Application.GetRealHeight(4), X = priequipmentBtn.Right + Application.GetRealWidth(7), Width = Application.GetRealWidth(120), Height = Application.GetRealHeight(17), @@ -92,7 +119,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, @@ -106,7 +133,7 @@ X = geBtn.Right, Width = Application.GetRealWidth(20), Height = Application.GetRealHeight(17), - Text ="/10", + Text = "/10", TextAlignment = TextAlignment.CenterLeft, TextSize = TextSize.text12, TextColor = CSS.CSS_Color.textCancelColor, @@ -115,7 +142,7 @@ //鐘舵�佸浘鏍� Button stateIconBtn = new Button { - Y =Application.GetRealHeight(23), + Y = Application.GetRealHeight(23), X = Application.GetRealWidth(291), Width = Application.GetRealWidth(8), Height = Application.GetRealWidth(8), @@ -129,39 +156,59 @@ X = Application.GetRealWidth(303), Width = Application.GetRealWidth(30), Height = Application.GetRealHeight(17), - TextID=StringId.zaixianhwb, + TextID = StringId.zaixianhwb, TextAlignment = TextAlignment.CenterLeft, TextSize = TextSize.text12, TextColor = 0xFF67D569,// CSS.CSS_Color.textColor, - IsBold=true, + IsBold = true, }; devfLayout.AddChidren(stateTextBtn); //绾� Button lineBtn = new Button { - Y = Application.GetRealHeight(92)-1, + Y = Application.GetRealHeight(92) - 1, X = Application.GetRealWidth(16), - Width = Application.GetRealWidth(343-16*2), - Height =1, + Width = Application.GetRealWidth(343 - 16 * 2), + Height = 1, BackgroundColor = CSS.CSS_Color.viewLine, }; devfLayout.AddChidren(lineBtn); + //鐐瑰嚮浜嬩欢 + FrameLayout clickFram = new FrameLayout + { + Y = Application.GetRealHeight(12), + X = Application.GetRealWidth(16), + Width = Application.GetRealWidth(375 - 16 * 2), + Height = Application.GetRealHeight(92), + BackgroundColor = 0x00000000, //CSS.CSS_Color.view, + Radius = (uint)Application.GetRealHeight(12), + Tag = Pir.pirDeviceList[i], + }; + fLayout.AddChidren(clickFram); - if (b - 1 == i) + clickFram.MouseUpEventHandler += (sender, e) => + { + var pirclick = (clickFram.Tag as Pir); + NewSwitchView(pirclick, vv); + }; + + if (Pir.pirDeviceList.Count - 1 == i) { //鏈�鍚庝竴涓悗闈㈠鍔犻棿闅旇儗鏅� vv.AddChidren(new FrameLayout { Height = Application.GetRealHeight(20) }); } #endregion - for (int j = 0; j < a; j++) { + for (int j = 0; j < pirDevice.FunctioList.Count; j++) + { + var control = pirDevice.FunctioList[i]; RowLayout funControlRow = new RowLayout { Y = Application.GetRealHeight(92 + (50 * j)), Width = Application.GetRealWidth(375 - 16 * 2), Height = Application.GetRealHeight(50), LineColor = CSS.CSS_Color.textWhiteColor, - SubViewWidth=Application.GetRealWidth(68), + SubViewWidth = Application.GetRealWidth(68), }; devfLayout.AddChidren(funControlRow); //閬ユ帶鍣ㄥ悕绉� @@ -170,30 +217,30 @@ X = Application.GetRealWidth(16), Width = Application.GetRealWidth(150), Height = Application.GetRealHeight(20), - Text =j.ToString(), - TextAlignment=TextAlignment.CenterLeft, + Text = control.name, + TextAlignment = TextAlignment.CenterLeft, TextSize = TextSize.text14, TextColor = CSS.CSS_Color.textColor, - Gravity=Gravity.CenterVertical, + Gravity = Gravity.CenterVertical, }; funControlRow.AddChidren(nameBtn); //閬ユ帶鍣ㄥ尯鍩� Button areaBtn = new Button { - X=Application.GetRealWidth(311+16-(40+100)), + X = Application.GetRealWidth(311 + 16 - (40 + 100)), Width = Application.GetRealWidth(100), Height = Application.GetRealHeight(17), Text = j.ToString(), TextAlignment = TextAlignment.CenterRight, TextSize = TextSize.text12, TextColor = CSS.CSS_Color.textCancelColor, - Gravity =Gravity.CenterVertical, + Gravity = Gravity.CenterVertical, }; funControlRow.AddChidren(areaBtn); //涓嬩竴绾у浘鏍� Button nextIconBtn = new Button { - X = Application.GetRealWidth(295+16), + X = Application.GetRealWidth(295 + 16), Width = Application.GetRealWidth(16), Height = Application.GetRealWidth(16), UnSelectedImagePath = "PirIcon/next.png", @@ -209,8 +256,9 @@ TextAlignment = TextAlignment.Center, TextSize = TextSize.text16, TextColor = CSS.CSS_Color.textWhiteColor, - IsBold=true, - BackgroundColor= CSS.CSS_Color.textRedColor, + IsBold = true, + BackgroundColor = CSS.CSS_Color.textRedColor, + Tag = control, }; funControlRow.AddRightView(delBtn); //绾� @@ -223,22 +271,174 @@ 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() != "") + { + pirDevice.FunctioList.Remove(Function); + UIView(vv); + } + else + { + Method method = new Method(); + method.ErrorShow(responsePackNew); + } + } + catch { } + + }); + } + + }) + { IsBackground = true }.Start(); }; } - + } - } + /// <summary> + /// 鍔犺浇寮规 + /// </summary> + /// <param name="pirclick"></param> + /// <param name="vv"></param> + void NewSwitchView(Pir pirclick, VerticalRefreshLayout vv) + { + FrameLayout frame = new FrameLayout { BackgroundColor = CSS.CSS_Color.viewTrans60lucence }; + this.AddChidren(frame); + SwitchView switchView = new SwitchView(); + switchView.btnOff.TextColor = CSS.CSS_Color.textConfirmColor; + switchView.FLayoutView(frame, StringId.shanchushebei, StringId.xiugaimingzi, "", (intValue) => + { + if (StringId.xiugaimingzi == intValue) + { + List<string> list = new List<string>(); + for (int b = 0; b < Pir.pirDeviceList.Count; b++) + { + list.Add(Pir.pirDeviceList[b].name); + } + TipPopView tipPopView = new TipPopView(); + tipPopView.InputBox(StringId.xiugaimingzi, pirclick.name, StringId.nameNull, StringId.NameAlreadyExists, list, (name, view) => + { + pirclick.name = name; + //鍔犺浇log + Loading loading = new Loading(); + view.AddChidren(loading); + HDL_ON.DAL.Server.ResponsePackNew responsePackNew = null; + loading.Start(); + new System.Threading.Thread(() => + { + try + { + responsePackNew = PirSend.DeviceRename(pirclick); + } + catch { } + finally + { + Application.RunOnMainThread(() => + { + loading.Hide(); + if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") + { + view.Close(); + UIView(vv); + } + else + { + Method method = new Method(); + method.ErrorShow(responsePackNew); + } + + }); + } + + }) + { IsBackground = true }.Start(); + + }, () => + { + NewSwitchView(pirclick, vv); + }, false); + + } + else + { + string text = Language.StringByID(StringId.shanchushebei) + pirclick.name + "?"; + TipPopView tipPopView = new TipPopView(); + tipPopView.TipBox(StringId.tip, text, (dialog) => + { + //鍔犺浇log + Loading loading = new Loading(); + dialog.AddChidren(loading); + HDL_ON.DAL.Server.ResponsePackNew responsePackNew = null; + loading.Start(); + new System.Threading.Thread(() => + { + try + { + responsePackNew = PirSend.DeleteDevice(pirclick.deviceId); + } + catch { } + finally + { + Application.RunOnMainThread(() => + { + loading.Hide(); + if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") + { + dialog.Close(); + UIView(vv); + } + else + { + + Method method = new Method(); + method.ErrorShow(responsePackNew); + } + + }); + } + + }) + { IsBackground = true }.Start(); + }, () => + { + NewSwitchView(pirclick, vv); + }, false); + + } + }); + } + + } } -- Gitblit v1.8.0