using System; using System.Collections.Generic; using HDL_ON.DAL.Server; using HDL_ON.DriverLayer; using HDL_ON.Entity; using HDL_ON.UI.CSS; using Newtonsoft.Json.Linq; using Shared; namespace HDL_ON.UI { public partial class FunctionBaseInfoSetPage : FrameLayout { #region 控件列表 FrameLayout bodyView; /// /// 功能名称显示按钮 /// Button btnFunctionName; /// /// 功能名称编辑按钮 /// Button btnEditName; /// /// 位置信息显示按钮 /// Button btnLocationValues; /// /// 位置信息跳转编辑按钮 /// Button btnLocationInfoRight; #endregion #region 局部变量 Function function; /// /// 后退时,刷新之前界面的显示信息 /// Action actionRefresh; /// /// 解绑设备回调 /// public Action actionDel; #endregion public FunctionBaseInfoSetPage(Function func, Action action) { bodyView = this; function = func; actionRefresh = action; } public override void RemoveFromParent() { new System.Threading.Thread(() => { Application.RunOnMainThread(() => { actionRefresh?.Invoke(); }); }) { IsBackground = true }.Start(); base.RemoveFromParent(); } /// /// 加载界面 /// public void LoadPage(bool locationSetting = true) { bodyView.BackgroundColor = CSS_Color.BackgroundColor; new TopViewDiv(bodyView, Language.StringByID(StringId.Setting)).LoadTopView(); var contentView = new VerticalScrolViewLayout() { Y = Application.GetRealHeight(64), Height = Application.GetRealHeight(600), ScrollEnabled = false, }; bodyView.AddChidren(contentView); #region name view var nameView = new FrameLayout() { Height = Application.GetRealHeight(50), BackgroundColor = CSS_Color.MainBackgroundColor, }; contentView.AddChidren(nameView); var btnNameText = new Button() { X = Application.GetRealWidth(16), Width = Application.GetRealWidth(160), TextAlignment = TextAlignment.CenterLeft, TextColor = CSS_Color.FirstLevelTitleColor, TextSize = CSS_FontSize.SubheadingFontSize, TextID = StringId.Name, }; nameView.AddChidren(btnNameText); btnFunctionName = new Button() { X = Application.GetRealWidth(86), Width = Application.GetRealWidth(237), TextAlignment = TextAlignment.CenterRight, TextColor = CSS_Color.PromptingColor1, TextSize = CSS_FontSize.TextFontSize, Text = function.name, }; nameView.AddChidren(btnFunctionName); btnEditName = new Button() { X = Application.GetRealWidth(333), Gravity = Gravity.CenterVertical, Width = Application.GetMinRealAverage(28), Height = Application.GetMinRealAverage(28), UnSelectedImagePath = "Public/Edit.png", }; nameView.AddChidren(btnEditName); //nameView.AddChidren( // new Button() // { // Gravity = Gravity.CenterHorizontal, // Y = Application.GetRealHeight(49), // BackgroundColor = CSS_Color.DividingLineColor, // Width = Application.GetRealWidth(343), // Height = Application.GetRealHeight(1) // }); #endregion if (locationSetting) { #region 位置管理 var locationMagtView = new FrameLayout() { Height = Application.GetRealHeight(55), BackgroundColor = CSS_Color.MainBackgroundColor, }; contentView.AddChidren(locationMagtView); var btnLocationMagtTitle = new Button() { X = Application.GetRealWidth(16), Width = Application.GetRealWidth(160), TextAlignment = TextAlignment.CenterLeft, TextColor = CSS_Color.FirstLevelTitleColor, TextSize = CSS_FontSize.SubheadingFontSize, TextID = StringId.LocationManagement, }; locationMagtView.AddChidren(btnLocationMagtTitle); btnLocationValues = new Button() { X = Application.GetRealWidth(86), Width = Application.GetRealWidth(237), TextAlignment = TextAlignment.CenterRight, TextColor = CSS_Color.PromptingColor1, TextSize = CSS_FontSize.TextFontSize, Text = function.GetRoomListName(), }; locationMagtView.AddChidren(btnLocationValues); btnLocationInfoRight = new Button() { X = Application.GetRealWidth(339), Gravity = Gravity.CenterVertical, Width = Application.GetMinRealAverage(16), Height = Application.GetMinRealAverage(16), UnSelectedImagePath = "Public/RightIcon.png", }; locationMagtView.AddChidren(btnLocationInfoRight); locationMagtView.AddChidren( new Button() { Gravity = Gravity.CenterHorizontal, BackgroundColor = CSS_Color.DividingLineColor, Width = Application.GetRealWidth(343), Height = Application.GetRealHeight(1) }); #endregion } LoadEventList(); } /// /// 加载选择弹窗 /// void LoadEditDialog(int min ,int max,int curValue,Action action) { List pickerItems = new List(); Dialog dialog = new Dialog(); var pView = new FrameLayout() { BackgroundColor = CSS_Color.DialogTransparentColor1, }; dialog.AddChidren(pView); var optionBaseView = new FrameLayout() { Y = Application.GetRealHeight(456 - 60), Gravity = Gravity.CenterHorizontal, Width = Application.GetRealWidth(343), Height = Application.GetRealHeight(260), AnimateSpeed = 0.3f, Animate = Animate.DownToUp, BackgroundColor = CSS_Color.MainBackgroundColor, Radius = (uint)Application.GetRealWidth(12), }; pView.AddChidren(optionBaseView); var topView = new FrameLayout() { Gravity = Gravity.CenterHorizontal, Width = Application.GetRealWidth(343), Height = Application.GetRealHeight(40), BackgroundColor = CSS_Color.MainBackgroundColor, Radius = (uint)Application.GetRealWidth(12), }; optionBaseView.AddChidren(topView); topView.AddChidren(new Button() { Y = Application.GetRealHeight(39), Height = Application.GetRealHeight(1), BackgroundColor = CSS_Color.DividingLineColor }); var btnCancel = new Button() { X = Application.GetRealWidth(21), Width = Application.GetRealWidth(100), TextAlignment = TextAlignment.CenterLeft, TextColor = CSS_Color.PromptingColor1, TextSize = CSS_FontSize.TextFontSize, TextID = StringId.Cancel, }; topView.AddChidren(btnCancel); var btnConfrim = new Button() { X = Application.GetRealWidth(160), Width = Application.GetRealWidth(160), TextAlignment = TextAlignment.CenterRight, TextColor = CSS_Color.MainColor, TextSize = CSS_FontSize.TextFontSize, TextID = StringId.Confirm, }; topView.AddChidren(btnConfrim); UIPickerView uIPickerView = new UIPickerView() { Y = Application.GetRealHeight(40), Height = Application.GetRealHeight(210), Radius = (uint)Application.GetRealWidth(12), }; for (int i = min; i <= max; i += 1) { pickerItems.Add(i.ToString()); } uIPickerView.setNPicker(pickerItems, null, null); optionBaseView.AddChidren(uIPickerView); uIPickerView.setCurrentItems(pickerItems.IndexOf(curValue.ToString()), 4, 5); string selectItem = pickerItems[0]; if (pickerItems.Contains(curValue.ToString())) { selectItem = curValue.ToString(); } dialog.Show(); pView.MouseUpEventHandler = (sender, e) => { dialog.Close(); }; btnCancel.MouseUpEventHandler = (sender, e) => { dialog.Close(); }; uIPickerView.OnSelectChangeEvent = (int1, int2, int3) => { selectItem = pickerItems[int1]; }; btnConfrim.MouseUpEventHandler = (sender, e) => { dialog.Close(); action?.Invoke(selectItem); }; } } }