| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using HDL_ON.Entity; |
| | | using HDL_ON.UI.CSS; |
| | | using Shared; |
| | |
| | | /// </summary> |
| | | static FrameLayout bodyView; |
| | | /// <summary> |
| | | /// 楼层选择下拉图标 |
| | | /// </summary> |
| | | Button btnFloorDownIcon; |
| | | /// <summary> |
| | | /// 楼层显示 |
| | | /// </summary> |
| | | Button btnFloor; |
| | | /// <summary> |
| | | /// 功能列表集合显示区域 |
| | | /// </summary> |
| | | static VerticalScrolViewLayout functionListView; |
| | | #endregion |
| | | |
| | | List<Function> functionList; |
| | | |
| | | public FunctionPage() |
| | | { |
| | | bodyView = this; |
| | | functionList = new List<Function>(); |
| | | } |
| | | |
| | | public void LoadPage(int titleId) |
| | |
| | | }; |
| | | bodyView.AddChidren(roomFloorChangeView); |
| | | #region 房间顶部切换显示区域 |
| | | /// <summary> |
| | | /// 楼层选择下拉图标 |
| | | /// </summary> |
| | | var btnFoorDownIcon = new Button() |
| | | btnFloorDownIcon = new Button() |
| | | { |
| | | Width = Application.GetMinRealAverage(16), |
| | | Height = Application.GetMinRealAverage(16), |
| | |
| | | Y = Application.GetRealHeight(18), |
| | | UnSelectedImagePath = "Public/DownIcon.png", |
| | | }; |
| | | roomFloorChangeView.AddChidren(btnFoorDownIcon); |
| | | /// <summary> |
| | | /// 楼层显示 |
| | | /// </summary> |
| | | var btnFoor = new Button() |
| | | roomFloorChangeView.AddChidren(btnFloorDownIcon); |
| | | |
| | | btnFloor = new Button() |
| | | { |
| | | X = btnFoorDownIcon.Right, |
| | | X = btnFloorDownIcon.Right, |
| | | Y = Application.GetRealHeight(18), |
| | | Width = Application.GetRealWidth(200), |
| | | Height = Application.GetMinRealAverage(16), |
| | |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | Text = DB_ResidenceData.residenceData.CurFoor, |
| | | }; |
| | | roomFloorChangeView.AddChidren(btnFoor); |
| | | roomFloorChangeView.AddChidren(btnFloor); |
| | | #endregion |
| | | |
| | | functionListView = new VerticalScrolViewLayout() |
| | |
| | | }; |
| | | bodyView.AddChidren(functionListView); |
| | | |
| | | foreach (var function in DB_ResidenceData.functionList.GetAllFunction()) |
| | | if (titleId == StringId.Lights) |
| | | { |
| | | if (titleId == StringId.Lights) |
| | | { |
| | | if (function.functionCategory != FunctionCategory.Light) |
| | | { |
| | | continue; |
| | | } |
| | | } |
| | | if (titleId == StringId.AC) |
| | | { |
| | | if (function.functionType != FunctionType.AC) |
| | | { |
| | | continue; |
| | | } |
| | | } |
| | | if (titleId == StringId.Curtain) |
| | | { |
| | | if (function.functionCategory != FunctionCategory.Curtain) |
| | | { |
| | | continue; |
| | | } |
| | | } |
| | | if(titleId == StringId.FloorHeating) |
| | | { |
| | | if(function.functionType != FunctionType.FloorHeating ) |
| | | { |
| | | continue; |
| | | } |
| | | } |
| | | if(titleId == StringId.Electric) |
| | | { |
| | | if(function.functionType != FunctionType.Socket && |
| | | function.functionType != FunctionType.TV && |
| | | function.functionType != FunctionType.Fan) |
| | | { |
| | | continue; |
| | | } |
| | | } |
| | | if (titleId == StringId.EnvironmentalScience) |
| | | { |
| | | functionList.AddRange(DB_ResidenceData.functionList.lights); |
| | | } |
| | | else if (titleId == StringId.AC) |
| | | { |
| | | functionList.AddRange(DB_ResidenceData.functionList.aCs); |
| | | } |
| | | else if (titleId == StringId.Curtain) |
| | | { |
| | | functionList.AddRange(DB_ResidenceData.functionList.curtains); |
| | | } |
| | | else if (titleId == StringId.FloorHeating) |
| | | { |
| | | functionList.AddRange(DB_ResidenceData.functionList.floorHeatings); |
| | | } |
| | | else if (titleId == StringId.Electric) |
| | | { |
| | | functionList.AddRange(DB_ResidenceData.functionList.electricals); |
| | | } |
| | | else if (titleId == StringId.EnvironmentalScience) |
| | | { |
| | | functionList.AddRange(DB_ResidenceData.functionList.sensorsEnvironmentalScience); |
| | | } |
| | | functionList.OrderByDescending(o => o.usageCount).ToList(); |
| | | |
| | | if (function.functionType != FunctionType.PM25 || |
| | | function.functionType != FunctionType.CO2 || |
| | | function.functionType != FunctionType.Temp || |
| | | function.functionType != FunctionType.TVOC || |
| | | function.functionType != FunctionType.Humidity) |
| | | { |
| | | continue; |
| | | } |
| | | } |
| | | ShowFunctionRow(functionList); |
| | | |
| | | LoadDialog_ChangeFloor(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 加载功能row |
| | | /// </summary> |
| | | void ShowFunctionRow(List<Function> showList) |
| | | { |
| | | functionListView.RemoveAll(); |
| | | foreach (var function in showList) |
| | | { |
| | | |
| | | if (function.functionType == FunctionType.RGB || function.functionType == FunctionType.Dimmer) |
| | | { |
| | | var functionDiv = new FunctionControlZone(function) |
| | |
| | | } |
| | | functionListView.AddChidren(new Button() { Height = Application.GetRealHeight(10) }); |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 住宅列表点击事件 |
| | | /// </summary> |
| | | void LoadDialog_ChangeFloor() |
| | | { |
| | | EventHandler<MouseEventArgs> eventHandler = (sender, e) => |
| | | { |
| | | var dialog = new Dialog(); |
| | | var dialogBody = new FrameLayout(); |
| | | dialog.AddChidren(dialogBody); |
| | | dialogBody.MouseUpEventHandler += (sender1, e1) => |
| | | { |
| | | dialog.Close(); |
| | | }; |
| | | |
| | | var dispalyView = new FrameLayout() |
| | | { |
| | | X = Application.GetRealWidth(10), |
| | | Y = Application.GetRealHeight(100), |
| | | Width = Application.GetRealWidth(160), |
| | | Height = Application.GetRealHeight(110), |
| | | BackgroundImagePath = "PersonalCenter/HomeList1bg.png", |
| | | }; |
| | | dialogBody.AddChidren(dispalyView); |
| | | |
| | | var contentView = new VerticalScrolViewLayout() |
| | | { |
| | | X = Application.GetRealWidth(8), |
| | | Y = Application.GetRealHeight(15), |
| | | Width = Application.GetRealWidth(150), |
| | | Height = Application.GetRealHeight(45 * 2), |
| | | ScrollEnabled = false |
| | | }; |
| | | dispalyView.AddChidren(contentView); |
| | | |
| | | if (DB_ResidenceData.rooms.Count < 2) |
| | | { |
| | | } |
| | | else if (DB_ResidenceData.rooms.Count < 3) |
| | | { |
| | | dispalyView = new FrameLayout() |
| | | { |
| | | X = Application.GetRealWidth(10), |
| | | Y = Application.GetRealHeight(100), |
| | | Width = Application.GetRealWidth(160), |
| | | Height = Application.GetRealHeight(155), |
| | | BackgroundImagePath = "PersonalCenter/HomeList2bg.png", |
| | | }; |
| | | dialogBody.AddChidren(dispalyView); |
| | | |
| | | contentView.Height = Application.GetRealHeight(45 * 3); |
| | | dispalyView.AddChidren(contentView); |
| | | } |
| | | else if (DB_ResidenceData.rooms.Count < 4) |
| | | { |
| | | dispalyView = new FrameLayout() |
| | | { |
| | | X = Application.GetRealWidth(10), |
| | | Y = Application.GetRealHeight(100), |
| | | Width = Application.GetRealWidth(160), |
| | | Height = Application.GetRealHeight(200), |
| | | BackgroundImagePath = "PersonalCenter/HomeList3bg.png", |
| | | }; |
| | | dialogBody.AddChidren(dispalyView); |
| | | |
| | | contentView.Height = Application.GetRealHeight(45 * 4); |
| | | dispalyView.AddChidren(contentView); |
| | | } |
| | | else |
| | | { |
| | | dispalyView = new FrameLayout() |
| | | { |
| | | X = Application.GetRealWidth(10), |
| | | Y = Application.GetRealHeight(100), |
| | | Width = Application.GetRealWidth(160), |
| | | Height = Application.GetRealHeight(245), |
| | | BackgroundImagePath = "PersonalCenter/HomeList4bg.png", |
| | | }; |
| | | dialogBody.AddChidren(dispalyView); |
| | | |
| | | contentView.Height = Application.GetRealHeight(45 * 5); |
| | | contentView.ScrollEnabled = true; |
| | | dispalyView.AddChidren(contentView); |
| | | } |
| | | |
| | | |
| | | List<Room> roomList = new List<Room>(); |
| | | roomList.Add(new Room() { sid = "", name = Language.StringByID(StringId.All) }); |
| | | roomList.AddRange(DB_ResidenceData.rooms); |
| | | foreach (var tempRoom in roomList) |
| | | { |
| | | var roomName = tempRoom.name; |
| | | if (roomName != Language.StringByID(StringId.All)) |
| | | { |
| | | contentView.AddChidren(new Button() |
| | | { |
| | | Gravity = Gravity.CenterHorizontal, |
| | | Width = Application.GetRealWidth(112), |
| | | Height = Application.GetRealHeight(1), |
| | | BackgroundColor = CSS_Color.BackgroundColor |
| | | }); |
| | | } |
| | | var btnHomeName = new Button() |
| | | { |
| | | Gravity = Gravity.CenterHorizontal, |
| | | Width = Application.GetRealWidth(112), |
| | | Height = Application.GetRealHeight(44), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextColor = CSS_Color.FirstLevelTitleColor, |
| | | SelectedTextColor = CSS_Color.MainColor, |
| | | Text = roomName, |
| | | TextSize = CSS_FontSize.SubheadingFontSize, |
| | | IsSelected = btnFloor.Text == roomName, |
| | | IsMoreLines = true, |
| | | }; |
| | | contentView.AddChidren(btnHomeName); |
| | | |
| | | btnHomeName.MouseUpEventHandler += (senderH, en) => |
| | | { |
| | | dialog.Close(); |
| | | btnFloor.Text = roomName; |
| | | if (roomName == Language.StringByID(StringId.All)) |
| | | { |
| | | ShowFunctionRow(functionList); |
| | | } |
| | | else |
| | | { |
| | | var showList = new List<Function>(); |
| | | foreach (var sf in functionList) |
| | | { |
| | | if(sf.roomIdList.Contains(tempRoom.sid)) |
| | | { |
| | | showList.Add(sf); |
| | | } |
| | | } |
| | | ShowFunctionRow(showList); |
| | | } |
| | | }; |
| | | } |
| | | |
| | | dialog.Show(); |
| | | }; |
| | | |
| | | btnFloor.MouseUpEventHandler = eventHandler; |
| | | btnFloorDownIcon.MouseUpEventHandler = eventHandler; |
| | | } |
| | | } |
| | | } |