From 6fa9d69da922c8049f5acfcbb9ce9fd26811024c Mon Sep 17 00:00:00 2001 From: xm <1271024303@qq.com> Date: 星期四, 16 四月 2020 17:10:57 +0800 Subject: [PATCH] 请合并代码 --- ZigbeeApp/Shared/Phone/Device/Logic/RoomAndDeviceView.cs | 463 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 463 insertions(+), 0 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/RoomAndDeviceView.cs b/ZigbeeApp/Shared/Phone/Device/Logic/RoomAndDeviceView.cs new file mode 100755 index 0000000..adac499 --- /dev/null +++ b/ZigbeeApp/Shared/Phone/Device/Logic/RoomAndDeviceView.cs @@ -0,0 +1,463 @@ +锘縰sing System; +using Shared.Common; +using Shared.R; +using Shared; +using ZigBee.Device; +using System.Collections.Generic; +namespace Shared.Phone.Device.Logic +{ + public class RoomAndDeviceView : FrameLayout + { + public RoomAndDeviceView() + { + Tag = "Logic"; + } + Button roombjButton = new Button(); + Button roomTextButton = new Button(); + Button devicetypeButton = new Button(); + FrameLayout clickframeLayout = new FrameLayout(); + Button clickbutton = new Button(); + Button clicktextcolcrbutton = new Button(); + /// <summary> + /// 鍒ゆ柇瀛楃 + /// </summary> + public string IfType; + /// <summary> + /// 鎴块棿婊戝姩鐨勬帶浠� + /// </summary> + public HorizontalScrolViewLayout roomhorizontalScrol = new HorizontalScrolViewLayout + { + Width = Application.GetRealWidth(1080 - 58), + Height = Application.GetRealHeight(200), + X = Application.GetRealWidth(58), + Y = Application.GetRealHeight(184), + }; + /// <summary> + /// 璁惧绫诲瀷婊戝姩鐨勬帶浠� + /// </summary> + public HorizontalScrolViewLayout devicetypehorizontalScrol = new HorizontalScrolViewLayout + { + Width = Application.GetRealWidth(1080 - 58), + Height = Application.GetRealHeight(280), + Y = Application.GetRealHeight(184 + 200), + BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor, + X = Application.GetRealWidth(58), + // Radius = (uint)Application.GetRealHeight(50), + + }; + /// <summary> + /// 鏄剧ず璁惧鍒楄〃鐨勬帶浠� + /// </summary> + public VerticalScrolViewLayout middle = new VerticalScrolViewLayout + { + X = Application.GetRealWidth(58), + Y = Application.GetRealHeight(184 + 200 + 280 + 40), + Height = Application.GetRealHeight(Method.H - 40 - 184 - 280 - 200), + BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor, + }; + + public void Show(string Name) + { + #region 涓婇潰鐨勫竷灞�浠g爜 + UserView.HomePage.Instance.ScrollEnabled = false;//閿佷綇宸︽粦 + this.BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor; + TopView view = new TopView(); + this.AddChidren(view.TopRowView(true)); + view.toptitleNameBtn.Text = Name; + view.clickBtn.MouseDownEventHandler += (sender, e) => + { + UserView.HomePage.Instance.ScrollEnabled = true;//鎭㈠宸︽粦 + RemoveFromParent(); + }; + view.foolrnameBtn.Text = Config.Instance.Home.GetCurrentFloorName; + if (Config.Instance.Home.FloorDics.Count < 2) + { + ///娌℃湁妤煎眰鎴栬�呭彧鏈変竴涓ゼ灞傦紝榛樿涓嶆樉绀哄浘鏍囧拰鏂囨湰; + view.foolrnameBtn.Visible = false; + view.dropdownBtn.Visible = false; + view.foolrclickBtn.Visible = false; + } + if (Config.Instance.Home.FloorDics.Count == 0) + { + Config.Instance.Home.CurrentFloorId = ""; + } + #endregion + + ///鎴块棿鍒楄〃 + var roomlists = Method.GetRoomList(IfType, Config.Instance.Home.CurrentFloorId); + if (roomlists.Count == 0) + { + //杩斿洖娌℃湁鎴块棿闅愯棌涓嬮潰鏁村潡; + devicetypehorizontalScrol.Height = 0; + middle.Height = 0; + } + /// 璁惧绫诲瀷鍒楄〃 + var deviceTypeList = Method.GetDevice(IfType); + this.AddChidren(roomhorizontalScrol); + this.AddChidren(devicetypehorizontalScrol); + this.AddChidren(middle); + devicetypehorizontalScrol.SetCornerWithSameRadius(Application.GetRealHeight(50), HDLUtils.RectCornerBottomLeft); + middle.SetCornerWithSameRadius(Application.GetRealHeight(50), HDLUtils.RectCornerTopLeft); + ///妤煎眰鐐瑰嚮浜嬩欢 + view.foolrclickBtn.MouseUpEventHandler += (sender, e) => + { + var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor }; + this.AddChidren(flMain); + flMain.MouseUpEventHandler += (sender2, e2) => + { + flMain.RemoveFromParent(); + }; + var foolrbjicon = new FrameLayout + { + + Width = Application.GetRealWidth(450), + Height = Application.GetRealHeight(780), + X = Application.GetRealWidth(1080 - 468 - 35), + Y = Application.GetRealHeight(184), + BackgroundImagePath = "Item/SelectFloor_Right.png", + }; + flMain.AddChidren(foolrbjicon); + + var btnfoolrtext = new Button + { + Width = Application.GetRealWidth(450), + Height = Application.GetRealHeight(150), + TextAlignment = TextAlignment.CenterLeft, + TextColor = ZigbeeColor.Current.LogicTextBlackColor, + X = Application.GetRealWidth(80), + TextID = MyInternationalizationString.selecfoolr, + TextSize = 14, + }; + foolrbjicon.AddChidren(btnfoolrtext); + + var foolrbj = new VerticalScrolViewLayout + { + + Width = Application.GetRealWidth(450), + Height = foolrbjicon.Height - btnfoolrtext.Height, + X = Application.GetRealWidth(80), + Y = btnfoolrtext.Bottom, + }; + foolrbjicon.AddChidren(foolrbj); + + foreach (var foolr in Config.Instance.Home.FloorDics) + { + var foolrRowLayout = new RowLayout + { + Height = Application.GetRealHeight(150), + LineColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, + }; + foolrbj.AddChidren(foolrRowLayout); + + var btnfoolricon = new Button + { + Width = Application.GetMinRealAverage(81), + Height = Application.GetMinRealAverage(81), + UnSelectedImagePath = "Floor/Floor.png", + Gravity = Gravity.CenterVertical, + }; + foolrRowLayout.AddChidren(btnfoolricon); + + var btnfoolrname = new Button + { + Width = Application.GetRealWidth(250), + Height = Application.GetRealHeight(150), + Text = foolr.Value, + TextAlignment = TextAlignment.CenterLeft, + TextColor = ZigbeeColor.Current.LogicBtnCancelColor, + Tag = foolr.Key, + X = btnfoolricon.Right + Application.GetRealWidth(12), + TextSize = 14, + }; + foolrRowLayout.AddChidren(btnfoolrname); + if (view.foolrnameBtn.Text == foolr.Value) + { + btnfoolricon.UnSelectedImagePath = "Floor/FloorSelected.png"; + btnfoolrname.TextColor = ZigbeeColor.Current.LogicTextBlackColor; + } + + EventHandler<MouseEventArgs> foolrnameclick = (sender13, e13) => + { + + roomhorizontalScrol.RemoveAll(); + devicetypehorizontalScrol.RemoveAll(); + middle.RemoveAll(); + view.foolrnameBtn.Text = btnfoolrname.Text; + flMain.RemoveFromParent(); + var list = Method.GetRoomList(IfType, btnfoolrname.Tag.ToString()); + if (list.Count == 0) + { + devicetypehorizontalScrol.Height = 0; + middle.Height = 0; + } + else + { + devicetypehorizontalScrol.Height = Application.GetRealHeight(280); + middle.Height = Application.GetRealHeight(1920 - 40 - 184 - 280 - 200); + } + AllRoomView(list, deviceTypeList); + }; + foolrRowLayout.MouseUpEventHandler += foolrnameclick; + btnfoolrname.MouseUpEventHandler += foolrnameclick; + + } + + }; + AllRoomView(roomlists, deviceTypeList); + } + /// <summary> + /// 鍔犺浇鎵�鏈夋埧闂寸殑瑙嗗浘鏂规硶 + /// </summary> + void AllRoomView(List<Common.Room> roomlist, List<DeviceType> deviceTypeList) + { + for (int i = 0; i < roomlist.Count; i++) + { + var room = roomlist[i]; + + var fra = new FrameLayout + { + Height = Application.GetRealHeight(200), + Width = Application.GetRealWidth(255), + }; + roomhorizontalScrol.AddChidren(fra); + + var roombjBtn = new Button + { + Height = Application.GetRealHeight(158), + Width = Application.GetRealWidth(255), + UnSelectedImagePath = "ZigeeLogic/iconBackgroundColor.png", + SelectedImagePath = "ZigeeLogic/iconSelectedBackgroundColor.png", + Y = Application.GetRealHeight(21), + }; + fra.AddChidren(roombjBtn); + + var roomnameBtn = new Button + { + + Height = Application.GetRealHeight(152 - 26 - 20), + Width = Application.GetRealWidth(255 - 20 - 50), + Text = room.Name, + TextColor = ZigbeeColor.Current.LogicBtnCancelColor, + SelectedTextColor = ZigbeeColor.Current.LogicBlankBackgroundColor, + Y = Application.GetRealHeight(21 + 13 + 10), + X = Application.GetRealWidth(10 + 25), + + }; + fra.AddChidren(roomnameBtn); + + if (i == 0)// + { + roombjButton.IsSelected = false; + roombjButton = roombjBtn; + roombjBtn.IsSelected = true; + + roomTextButton.IsSelected = false; + roomTextButton = roomnameBtn; + roomnameBtn.IsSelected = true; + + roombjBtn.IsSelected = true; + roomnameBtn.IsSelected = true; + + var list = Method.GetDeviceUIList(room, deviceTypeList); + AllDeviceTypeView(list); + } + + EventHandler<MouseEventArgs> roomclick = (sender, e) => + { + roombjButton.IsSelected = false; + roombjButton = roombjBtn; + roombjBtn.IsSelected = true; + + roomTextButton.IsSelected = false; + roomTextButton = roomnameBtn; + roomnameBtn.IsSelected = true; + + + var list = Method.GetDeviceUIList(room, deviceTypeList); + AllDeviceTypeView(list); + }; + roomnameBtn.MouseUpEventHandler += roomclick; + roombjBtn.MouseUpEventHandler += roomclick; + + } + } + /// <summary> + /// 鍔犺浇璇ュ尯鍩熸墍鏈夎澶囪鍥炬柟娉� + /// </summary>0 + /// <param name="devicelist">Devicelist.</param> + void AllDeviceTypeView(List<CommonDevice> devicelist) + { + var devicetypelist = Method.GetDeviceTypeList(devicelist); + devicetypehorizontalScrol.RemoveAll(); + for (int i = 0; i < devicetypelist.Count; i++) + { + var devicetype = devicetypelist[i]; + var spaceRowLayout = new FrameLayout(); + devicetypehorizontalScrol.AddChidren(spaceRowLayout); + if (i == 0) + { + spaceRowLayout.Width = Application.GetRealWidth(37); + } + else + { + spaceRowLayout.Width = Application.GetRealWidth(80); + } + + var deviceRowLayout = new FrameLayout + { + Width = Application.GetRealWidth(156 + 20), + Height = Application.GetRealHeight(280 - 30), + Y = Application.GetRealHeight(30), + }; + devicetypehorizontalScrol.AddChidren(deviceRowLayout); + + var backgroundColor = new Button + { + Width = Application.GetMinRealAverage(156), + Height = Application.GetMinRealAverage(180), + X = Application.GetRealWidth(10), + UnSelectedImagePath = "ZigeeLogic/deviceunselectedbackgroundcolor.png", + SelectedImagePath = "ZigeeLogic/deviceselectedbackgroundcolor.png", + }; + deviceRowLayout.AddChidren(backgroundColor); + + + var devicetypeicon = new Button + { + Width = Application.GetMinRealAverage(84), + Height = Application.GetMinRealAverage(84), + X = Application.GetRealWidth(46), + Y = Application.GetRealHeight(30), + UnSelectedImagePath =Method.GetDeviceTypeIcon(devicetype), + }; + deviceRowLayout.AddChidren(devicetypeicon); + + var devicetypename = new Button + { + Width = Application.GetRealWidth(176), + Height = Application.GetRealHeight(40), + Text = devicetype, + TextAlignment = TextAlignment.Center, + Y = backgroundColor.Bottom, + TextColor = ZigbeeColor.Current.LogicAddColor, + TextSize = 10, + }; + deviceRowLayout.AddChidren(devicetypename); + + EventHandler<MouseEventArgs> devicetypeclick = (sender13, e13) => + { + devicetypeButton.IsSelected = false; + devicetypeButton = backgroundColor; + backgroundColor.IsSelected = true; + var list = Method.GetDeviceType(devicetypename.Text); + ConditionDeviceView(list, devicelist); + }; + deviceRowLayout.MouseUpEventHandler += devicetypeclick; + devicetypename.MouseUpEventHandler += devicetypeclick; + devicetypeicon.MouseUpEventHandler += devicetypeclick; + backgroundColor.MouseUpEventHandler += devicetypeclick; + + } + ///鏄剧ず鎴块棿鎵�鏈夎澶� + ConditionDeviceView(new List<DeviceType>(), devicelist); + + } + /// <summary> + /// 鍔犺浇璇ョ被鍨嬭澶囪鍥炬柟娉� + /// </summary> + /// <param name="deviceTypelist">Device typelist.</param> + /// <param name="devicelist">璁惧鍒楄〃</param> + void ConditionDeviceView(List<DeviceType> deviceTypelist, List<CommonDevice> devicelist) + { + middle.RemoveAll(); + foreach (var common in devicelist) + { + if (deviceTypelist.Count != 0 && !deviceTypelist.Contains(common.Type)) + { + continue; + } + if (IfType == "condition_mould") + { + if (common.IasDeviceType != 13) + {//鑷姩鍖栨ā鏉垮彧鏀寔绾㈠浼犳劅鍣� + continue; + } + } + var deviceFramelayout = new FrameLayout + { + Height = Application.GetRealHeight(160), + }; + middle.AddChidren(deviceFramelayout); + var bjFramelayout = new FrameLayout + { + Width = Application.GetMinRealAverage(112), + Height = Application.GetMinRealAverage(112), + X = Application.GetRealWidth(58), + Y = Application.GetRealHeight(30 + 9), + Radius = (uint)Application.GetMinRealAverage(56), + BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, + }; + deviceFramelayout.AddChidren(bjFramelayout); + var deviceIconBtn = new Button + { + Width = Application.GetMinRealAverage(82), + Height = Application.GetMinRealAverage(82), + Gravity = Gravity.Center, + }; + bjFramelayout.AddChidren(deviceIconBtn); + Method.GetDeviceIcon(common, deviceIconBtn); + var deviceRow = new RowLayout + { + Y = Application.GetRealHeight(30), + Width = Application.GetRealWidth(850), + Height = Application.GetRealHeight(130), + X = Application.GetRealWidth(176 + 25), + //LineColor = ZigbeeColor.Current.LogicRowLayoutLineColor, + LineColor = ZigbeeColor.Current.LogicBlankBackgroundColor, + }; + deviceFramelayout.AddChidren(deviceRow); + var devicename = new Button + { + Text = LocalDevice.Current.GetDeviceEpointName(common), + TextAlignment = TextAlignment.CenterLeft, + TextColor = ZigbeeColor.Current.LogicTextBlackColor, + SelectedTextColor = ZigbeeColor.Current.LogicAddColor, + TextSize = 14, + }; + deviceRow.AddChidren(devicename); + + var lineBtn = new Button + { + Y = deviceFramelayout.Height-1, + Height = 1, + Width = Application.GetRealWidth(850), + X = Application.GetRealWidth(176 + 25), + BackgroundColor = ZigbeeColor.Current.LogicRowLayoutLineColor, + }; + deviceFramelayout.AddChidren(lineBtn); + EventHandler<MouseEventArgs> devicclick = (sen, e) => + { + clickbutton.IsSelected = false; + clickbutton = deviceIconBtn; + deviceIconBtn.IsSelected = true; + clickframeLayout.BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor; + clickframeLayout = bjFramelayout; + bjFramelayout.BackgroundColor = ZigbeeColor.Current.LogicIconBackgroundColor; + clicktextcolcrbutton.IsSelected = false; + clicktextcolcrbutton = devicename; + devicename.IsSelected = true; + var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor }; + this.AddChidren(flMain); + CurrentDeviceState.CurrentDeviceView(flMain, common, false, IfType); + + }; + deviceFramelayout.MouseUpEventHandler += devicclick; + bjFramelayout.MouseUpEventHandler += devicclick; + deviceIconBtn.MouseUpEventHandler += devicclick; + deviceRow.MouseUpEventHandler += devicclick; + devicename.MouseUpEventHandler += devicclick; + } + } + + } +} -- Gitblit v1.8.0