using System; using System.Collections.Generic; using HDL_ON.DAL.Server; using HDL_ON.Entity; using HDL_ON.UI.CSS; using Shared; namespace HDL_ON.UI { public class Iot_BrandFunctionListPage :FrameLayout { FrameLayout bodyView; FrameLayout contentView; FrameLayout optionView; IntegratedBrand_Iot brand_Iot; /// /// 解绑回调 /// public Action unboundAction; public Iot_BrandFunctionListPage(IntegratedBrand_Iot brand_Iot) { bodyView = this; this.brand_Iot = brand_Iot; } public void LoadPage() { Action action = () => { var page = new iot_BindTipPage(); MainPage.BasePageView.AddChidren(page); page.unboundAction = () => { this.RemoveFromParent(); unboundAction?.Invoke(); }; page.LoadPage(brand_Iot); MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; }; var topView = new TopViewDiv(bodyView, brand_Iot.brandName); topView.maginY = 10; topView.LoadTopView_3tyIot(action); bodyView.BackgroundColor = CSS_Color.MainBackgroundColor; bodyView.AddChidren(new Button { Y = Application.GetRealHeight(64+10), Height = Application.GetRealHeight(1), BackgroundColor = CSS_Color.DividingLineColor, }); Button btnTipText = new Button() { Y = Application.GetRealHeight(80+10), Width = Application.GetRealWidth(347), Height = Application.GetRealHeight(65), Gravity = Gravity.CenterHorizontal, Radius = (uint)Application.GetRealWidth(5), BackgroundColor = 0x194484F4, TextColor = CSS_Color.FirstLevelTitleColor, Padding = new Padding(12, Application.GetRealWidth(16), 12, Application.GetRealWidth(16)), TextSize = CSS_FontSize.TextFontSize, Text = "*您可以将第三方品牌的设备关联到On Pro您当前的住宅上。", IsMoreLines = true, TextAlignment = TextAlignment.CenterLeft, }; bodyView.AddChidren(btnTipText); if (Language.CurrentLanguage != "Chinese") { btnTipText.Text = "*You can associate third-party branded devices with on Pro's current home."; } contentView = new FrameLayout() { Y = Application.GetRealHeight(150+10), Height = Application.GetRealHeight(573-10), }; bodyView.AddChidren(contentView); var waitPage = new Loading(); contentView.AddChidren(waitPage); waitPage.Start(""); new System.Threading.Thread(() => { try { var pack0 = http.Search3tyIotDevice(brand_Iot.companyId); if(pack0 != null) { } var pack = http.Get3tyIotDeviceFunctionList(brand_Iot.companyId); if (pack != null) { if (pack.Code == StateCode.SUCCESS) { var list = Newtonsoft.Json.JsonConvert.DeserializeObject>(pack.Data.ToString()); Application.RunOnMainThread(() => { LoadDeviceFunctionControlZone(list); }); } } } catch { } finally { Application.RunOnMainThread(() => { waitPage.Hide(); waitPage.RemoveFromParent(); }); } }) { IsBackground = true }.Start(); optionView = new FrameLayout() { Y = Application.GetRealHeight(667 - 80), Height = Application.GetRealHeight(90), Radius = (uint)Application.GetRealWidth(22), //Visible =false, }; bodyView.AddChidren(optionView); var btnComfirm = new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(14), Width = Application.GetRealWidth(164), Height = Application.GetRealHeight(44), TextAlignment = TextAlignment.Center, BackgroundColor = CSS_Color.MainColor, TextColor = CSS_Color.MainBackgroundColor, TextSize = CSS_FontSize.SubheadingFontSize, TextID = StringId.Confirm, Radius = (uint)Application.GetRealHeight(22) }; optionView.AddChidren(btnComfirm); btnComfirm.MouseUpEventHandler = (sender, e) => { var pack = http.Set3tyIotFunctionToHouse(optionList, DB_ResidenceData.Instance.CurrentRegion.id, brand_Iot.companyId); if (pack != null) { if (pack.Code == StateCode.SUCCESS) { optionView.Visible = false; } } //var pack = http.Set3tyIotFunctionToHouse(function.deviceId, "0", brand_Iot.companyId); //if (pack != null) //{ // if (pack.Code == StateCode.SUCCESS) // { // btnName.IsSelected = btnIcon.IsSelected = btnCheckIcon.IsSelected = false; // } //} }; } /// /// 加载设备功能显示区域 /// void LoadDeviceFunctionControlZone(List list) { contentView.RemoveAll(); if (list.Count == 0) { NotListTipView(); return; } VerticalScrolViewLayout deviceFunctionView = new VerticalScrolViewLayout(); contentView.AddChidren(deviceFunctionView); #region ContextView var rowView = new FrameLayout(); try { int index = 0; foreach (var function in list) { if(function.homeId != DB_ResidenceData.Instance.CurrentRegion.id && function.homeId != "0") { continue; } if (index % 2 == 0) { rowView = new FrameLayout() { Height = Application.GetRealWidth(140), }; deviceFunctionView.AddChidren(rowView); } var functionView_X = Application.GetRealWidth((182 + 7) * (index % 2)); if (index % 2 == 0) { functionView_X += Application.GetRealWidth(7); } var functionView = new FrameLayout() { X = functionView_X, Width = Application.GetRealWidth(182), Height = Application.GetRealWidth(140), Radius = (uint)Application.GetRealWidth(12), Tag = function.sid }; rowView.AddChidren(functionView); var btnbg = new Button() { UnSelectedImagePath = "Collection/Functionbg.png", SelectedImagePath = "Collection/Functionbg.png", Tag = function.sid }; functionView.AddChidren(btnbg); LoadDeviceFunctionDiv(functionView, function); index++; } if (index == 0) { var view = new FrameLayout(); deviceFunctionView.AddChidren(view); var btnNoCollectionTip = new Button() { Height = Application.GetRealHeight(42), Y = Application.GetRealHeight(100), TextAlignment = TextAlignment.Center, TextColor = CSS_Color.PromptingColor1, TextSize = CSS_FontSize.PromptFontSize_FirstLevel, Text = "没有任何设备" }; view.AddChidren(btnNoCollectionTip); if (Language.CurrentLanguage != "Chinese") { btnNoCollectionTip.Text = "No equipment"; } } } catch (Exception ex) { } deviceFunctionView.AddChidren(new Button { Height = Application.GetRealHeight(30) }); #endregion deviceFunctionView.AddChidren(new Button { Height = Application.GetRealHeight(90), }); } /// /// 加载功能控制卡片 /// void LoadDeviceFunctionDiv(FrameLayout view, Function function) { try { var btnCheckIcon = new Button() { X = Application.GetRealWidth(22), Y = Application.GetRealHeight(16), Width = Application.GetRealWidth(21), Height = Application.GetRealWidth(21), UnSelectedImagePath = "Public/IotCheckIcon.png", SelectedImagePath = "Public/IotCheckOnIcon.png", }; view.AddChidren(btnCheckIcon); Button btnIcon; btnIcon = new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(24), Width = Application.GetMinRealAverage(54), Height = Application.GetMinRealAverage(54), }; view.AddChidren(btnIcon); btnIcon.UnSelectedImagePath = $"FunctionIcon/Icon/HomeIcon/{function.IconName}_blue.png"; btnIcon.SelectedImagePath = $"FunctionIcon/Icon/HomeIcon/{function.IconName}_white.png"; Button btnName; btnName = new Button() { Y = btnIcon.Bottom, Text = function.name, IsBold = true, TextColor = CSS_Color.FirstLevelTitleColor, SelectedTextColor = CSS_Color.MainBackgroundColor, TextSize = CSS_FontSize.TextFontSize, Height = Application.GetRealWidth(24), TextAlignment = TextAlignment.Center, }; view.AddChidren(btnName); Button btnClick = new Button(); view.AddChidren(btnClick); btnClick.MouseUpEventHandler = (sender, e) => { if (optionList.Contains(function.deviceId)) { btnCheckIcon.IsSelected = function.collect = false; optionList.Remove(function.deviceId); } else { btnCheckIcon.IsSelected = function.collect = true; optionList.Add(function.deviceId); } optionView.Visible =true; }; if (function.homeId == DB_ResidenceData.Instance.CurrentRegion.id ) { btnCheckIcon.IsSelected = true; optionList.Add(function.deviceId); } } catch (Exception ex) { MainPage.Log("homepage LoadControlView error : " + ex.Message); } } /// /// 记录需要操作的列表 /// private List optionList = new List(); void NotListTipView() { contentView.RemoveAll(); var btnTip = new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(88 + 10), Width = Application.GetRealWidth(180), Height = Application.GetRealWidth(180), UnSelectedImagePath = "TipNot.png", }; contentView.AddChidren(btnTip); var btnTipText = new Button() { Y = Application.GetRealHeight(252), Height = Application.GetRealHeight(52), TextSize = CSS_FontSize.TextFontSize, TextColor = CSS_Color.FirstLevelTitleColor, TextAlignment = TextAlignment.Center, TextID = StringId.TipNotThirdPartyDevice, }; contentView.AddChidren(btnTipText); var btnAdd = new Button() { Y = Application.GetRealHeight(400), Gravity = Gravity.CenterHorizontal, Width = Application.GetRealWidth(220), Height = Application.GetRealWidth(44), BackgroundColor = CSS_Color.MainColor, TextAlignment = TextAlignment.Center, TextColor = CSS_Color.MainBackgroundColor, TextSize = CSS_FontSize.SubheadingFontSize, IsBold = true, Radius = (uint)Application.GetRealWidth(22), BorderColor = 0x00000000, BorderWidth = 0, Text = "查看设备支持范围" }; //contentView.AddChidren(btnAdd); btnAdd.MouseUpEventHandler = (sender, e) => { //var page = new AddThirdPartyBrandListpage(brandList); //MainPage.BasePageView.AddChidren(page); //page.LoadPage(); //MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; }; } HttpServerRequest http = new HttpServerRequest(); } }