using System; using System.Collections.Generic; using HDL_ON.DriverLayer; using HDL_ON.Entity; using HDL_ON.Stan; using HDL_ON.UI.CSS; using Shared; namespace HDL_ON.UI { public partial class ClothesHangerSetTimePage : FrameLayout { FrameLayout bodyView; Function device; public ClothesHangerSetTimePage(Function function) { device = function; bodyView = this; } /// /// 加载界面 /// public void LoadPage() { bodyView.BackgroundColor = CSS_Color.BackgroundColor; new TopViewDiv(bodyView, Language.StringByID(StringId.Time)).LoadTopView(); VerticalScrolViewLayout functionListView = new VerticalScrolViewLayout() { Y = Application.GetRealHeight(64), Height = Application.GetRealHeight(530), BackgroundColor = CSS_Color.BackgroundColor, ScrollEnabled = false, }; bodyView.AddChidren(functionListView); /// /// 小时取值范围 /// List hRange = new List { 0, 1, 2, 3, 4 }; /// /// 分钟取值范围 /// List mRange = new List { 0, 30 }; var menu = new List() { FunctionAttributeKey.HotDryTime, FunctionAttributeKey.WindDryTime, FunctionAttributeKey.DisinfectTime, FunctionAttributeKey.AnionTime }; List attrs = device.GetAttributes(); #region 烘干时间 ListCellView hotDryTimeCell; hotDryTimeCell = new ListCellView() { Height = Application.GetRealHeight(50), }; hotDryTimeCell.BtnTilte.TextID = StringId.HotDryTime; if (attrs.Contains(menu[0])) { var hotDryTime = 0; int.TryParse(device.GetAttrState(FunctionAttributeKey.HotDryTime), out hotDryTime); hotDryTimeCell.BtnSubtitle.Text = hotDryTime / 60 + Language.StringByID(StringId.HourUint) + hotDryTime % 60 + Language.StringByID(StringId.MinuteUint); functionListView.AddChidren(hotDryTimeCell); hotDryTimeCell.GoAction = () => { BottomTimeSelectControl timeControl = new BottomTimeSelectControl(hRange, mRange,3, Language.StringByID(StringId.HotDryTime)); timeControl.RowHeight = Application.GetRealHeight(50); timeControl.InitControl(0, 1, 162); timeControl.ChangePickerEvent(); timeControl.FinishEvent = (type, hours, min) => { if (type == 1)//0:取消;1:确定 { HdlThreadLogic.Current.RunThread(() => { var time = hours * 60 + min; var dic = new Dictionary(); dic.Add(FunctionAttributeKey.HotDryTime, time.ToString()); Control.Ins.SendWriteCommand(this.device, dic); HdlThreadLogic.Current.RunMain(() => { hotDryTimeCell.BtnSubtitle.Text = time / 60 + Language.StringByID(StringId.HourUint) + time % 60 + Language.StringByID(StringId.MinuteUint); }); }); } }; }; } #endregion #region 风干时间 ListCellView windDryCell; windDryCell = new ListCellView() { Height = Application.GetRealHeight(50), }; windDryCell.BtnTilte.TextID = StringId.WindDryTime; windDryCell.BtnSubtitle.Text = device.GetAttrState(FunctionAttributeKey.WindDryTime); if (attrs.Contains(menu[1])) { var windDryTime = 0; int.TryParse(device.GetAttrState(FunctionAttributeKey.WindDryTime), out windDryTime); windDryCell.BtnSubtitle.Text = windDryTime / 60 + Language.StringByID(StringId.HourUint) + windDryTime % 60 + Language.StringByID(StringId.MinuteUint); functionListView.AddChidren(windDryCell); windDryCell.GoAction = () => { BottomTimeSelectControl timeControl = new BottomTimeSelectControl(hRange, mRange,3,Language.StringByID(StringId.WindDryTime)); timeControl.RowHeight = Application.GetRealHeight(50); timeControl.InitControl(0, 1, 162); timeControl.ChangePickerEvent(); timeControl.FinishEvent = (type, hours, min) => { if (type == 1)//0:取消;1:确定 { HdlThreadLogic.Current.RunThread(() => { var time = hours * 60 + min; var dic = new Dictionary(); dic.Add(FunctionAttributeKey.WindDryTime, time.ToString()); Control.Ins.SendWriteCommand(this.device, dic); HdlThreadLogic.Current.RunMain(() => { windDryCell.BtnSubtitle.Text = time / 60 + Language.StringByID(StringId.HourUint) + time % 60 + Language.StringByID(StringId.MinuteUint); }); }); } }; }; } else { hotDryTimeCell.LineView.RemoveFromParent(); } #endregion #region 消毒时间 ListCellView disinfectTimeCell; disinfectTimeCell = new ListCellView() { Height = Application.GetRealHeight(50), }; disinfectTimeCell.BtnTilte.TextID = StringId.DisinfectTime; disinfectTimeCell.BtnSubtitle.Text = device.GetAttrState(FunctionAttributeKey.DisinfectTime); if (attrs.Contains(menu[2])) { var disinfectTime = 0; int.TryParse(device.GetAttrState(FunctionAttributeKey.DisinfectTime), out disinfectTime); disinfectTimeCell.BtnSubtitle.Text = disinfectTime / 60 + Language.StringByID(StringId.HourUint) + disinfectTime % 60 + Language.StringByID(StringId.MinuteUint); functionListView.AddChidren(disinfectTimeCell); disinfectTimeCell.GoAction = () => { BottomTimeSelectControl timeControl = new BottomTimeSelectControl(hRange, mRange,3, Language.StringByID(StringId.DisinfectTime)); timeControl.RowHeight = Application.GetRealHeight(50); timeControl.InitControl(0, 1, 162); timeControl.ChangePickerEvent(); timeControl.FinishEvent = (type, hours, min) => { if (type == 1)//0:取消;1:确定 { HdlThreadLogic.Current.RunThread(() => { var time = hours * 60 + min; var dic = new Dictionary(); dic.Add(FunctionAttributeKey.DisinfectTime, time.ToString()); Control.Ins.SendWriteCommand(this.device, dic); HdlThreadLogic.Current.RunMain(() => { disinfectTimeCell.BtnSubtitle.Text = time / 60 + Language.StringByID(StringId.HourUint) + time % 60 + Language.StringByID(StringId.MinuteUint); }); }); } }; }; } else { windDryCell.LineView.RemoveFromParent(); } #endregion #region 负离子时间 ListCellView anionTimeCell; anionTimeCell = new ListCellView() { Height = Application.GetRealHeight(50), }; anionTimeCell.BtnTilte.TextID = StringId.AnionTime; anionTimeCell.BtnSubtitle.Text = device.GetAttrState(FunctionAttributeKey.AnionTime); if (attrs.Contains(menu[3])) { var anionTime = 0; int.TryParse(device.GetAttrState(FunctionAttributeKey.HotDryTime), out anionTime); anionTimeCell.BtnSubtitle.Text = anionTime / 60 + Language.StringByID(StringId.HourUint) + anionTime % 60 + Language.StringByID(StringId.MinuteUint); functionListView.AddChidren(anionTimeCell); anionTimeCell.LineView.RemoveFromParent(); anionTimeCell.GoAction = () => { BottomTimeSelectControl timeControl = new BottomTimeSelectControl(hRange, mRange,3,Language.StringByID(StringId.AnionTime)); timeControl.RowHeight = Application.GetRealHeight(50); timeControl.InitControl(0, 1, 162); timeControl.ChangePickerEvent(); timeControl.FinishEvent = (type, hours, min) => { if (type == 1)//0:取消;1:确定 { HdlThreadLogic.Current.RunThread(() => { var time = hours * 60 + min; var dic = new Dictionary(); dic.Add(FunctionAttributeKey.AnionTime, time.ToString()); Control.Ins.SendWriteCommand(this.device, dic); HdlThreadLogic.Current.RunMain(() => { anionTimeCell.BtnSubtitle.Text = time / 60 + Language.StringByID(StringId.HourUint) + time % 60 + Language.StringByID(StringId.MinuteUint); }); }); } }; }; } else { disinfectTimeCell.LineView.RemoveFromParent(); } #endregion } } //--------------------------------------- public partial class ClothesHangerSetTimePage { } //======================================== }