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 class AcControlPage : DeviceFunctionCardCommonForm { #region ■ 变量声明___________________________ /// /// 空调温度控制控件 /// //DiyArcSeekBar arcBar; DiyImageSeekBar setTempBar; /// /// 减号按钮 /// //Button btnMinus; /// /// 加号按钮 /// //Button btnPlus; /// /// 温度按钮 /// Button btnTemp; Button btnTempUint; /// /// 室内温度按钮 /// Button btnIndoorTemp; /// /// 模式按钮 /// Button btnMode; /// /// 扫风按钮 /// Button btnSwing; /// /// 风速按钮 /// Button btnWindSpeed; /// /// 开关按钮 /// Button btnSwitch; AC acFunction = new AC(); /// /// 控制时间 /// DateTime controlTime = DateTime.MinValue.AddDays(10); #endregion #region ■ 初始化_____________________________ /// /// 初始化白色区域的内容 /// public override void InitFrameWhiteContent() { var sk = device.GetAttribute(FunctionAttributeKey.SetTemp); if (sk != null) { if (sk.min == 0) { sk.min = 16; } if (sk.max == 0) { sk.max = 32; } } base.ShowColltionButton = false; base.SetTitleText(Language.StringByID(StringId.Electric)); //初始化第一个索引页的内容 this.InitFrameWhiteContent1(); //刷新当前设备的状态缓存 //this.RefreshNowDeviceStatuMemory(this.device); //刷新界面状态 this.RefreshFormStatu(); //读取状态 Control.Ins.SendReadCommand(device); } /// /// 初始化第一个索引页的内容 /// private void InitFrameWhiteContent1() { //获取温度值 string setTempTemp = device.GetAttrState(FunctionAttributeKey.SetTemp); var temp = (int)Convert.ToDouble(setTempTemp); if (temp <= 0) { //默认值改成16,2022年06月10日10:03:19 成甫要求的 temp = 16; device.SetAttrState(FunctionAttributeKey.SetTemp, temp.ToString()); } var setTempAttr = device.GetAttribute(FunctionAttributeKey.SetTemp); { btnTemp = new Button() { Y = Application.GetRealHeight(121), Gravity = Gravity.CenterHorizontal, Height = Application.GetRealHeight(70), TextAlignment = TextAlignment.TopCenter, TextColor = CSS_Color.FirstLevelTitleColor, TextSize = 60, Text = "---", IsBold = true, }; if (setTempAttr.step == "0.5") { btnTemp.Text = Convert.ToDouble(setTempAttr.curValue).ToString("0.0"); } else { if (setTempAttr.curValue.ToString().Contains(".")) { btnTemp.Text = setTempAttr.curValue.ToString().Split(".")[0]; } else { btnTemp.Text = setTempAttr.curValue.ToString(); } } #if __IOS__ btnTemp.Width = btnTemp.GetTextWidth() + Application.GetRealWidth(10); #else btnTemp.Width = btnTemp.GetTextWidth() + Application.GetRealWidth(5); #endif FrameWhiteCentet1.AddChidren(btnTemp); btnTempUint = new Button() { X = btnTemp.Right, Y = Application.GetRealHeight(131), Width = Application.GetRealWidth(30), Height = Application.GetRealHeight(30), TextColor = CSS_Color.FirstLevelTitleColor, TextSize = CSS_FontSize.EmphasisFontSize_Secondary, IsBold = true, TextAlignment = TextAlignment.CenterLeft, Text = "°C", }; FrameWhiteCentet1.AddChidren(btnTempUint); btnIndoorTemp = new Button() { Gravity = Gravity.CenterHorizontal, Y = btnTemp.Bottom, Width = Application.GetRealWidth(120), Height = Application.GetRealHeight(30), Text = Language.StringByID(StringId.Indoor) + " 20°C", TextColor = CSS_Color.PromptingColor1, TextSize = CSS_FontSize.PromptFontSize_FirstLevel, TextAlignment = TextAlignment.TopCenter, }; FrameWhiteCentet1.AddChidren(btnIndoorTemp); var setTempView = new FrameLayout() { Height = Application.GetRealHeight(80), Y = Application.GetRealHeight(10) + btnIndoorTemp.Bottom, }; FrameWhiteCentet1.AddChidren(setTempView); var btnMinTemp = new Button() { X = Application.GetRealWidth(22), Width = Application.GetRealWidth(22), TextAlignment = TextAlignment.Center, Text = setTempAttr.min.ToString(), TextSize = 12, TextColor = 0xFFC0C7D4, }; setTempView.AddChidren(btnMinTemp); setTempBar = new DiyImageSeekBar() { X = btnMinTemp.Right, Y = Application.GetRealHeight(4), Width = Application.GetRealWidth(240), //Height = Application.GetRealHeight(41), //ProgressBarColor = CSS_Color.MainColor, //SeekBarBackgroundColor = CSS_Color.BackgroundColor, //MinValue = 16, //MaxValue = 30, //IsProgressTextShow = false, //ThumbImageHeight = 30, //Width = Application.GetRealWidth(238), Height = Application.GetRealHeight(72), SeekBarViewHeight = Application.GetRealHeight(14), ThumbImagePath = "FunctionIcon/Acst/ThumbImage.png", ThumbImageHeight = Application.GetRealHeight(51), ProgressBarColor = device.trait_on_off.curValue.ToString() == "on" ? CSS_Color.MainColor : CSS_Color.DividingLineColor, Progress = 0, SeekBarPadding = Application.GetRealWidth(20), IsProgressTextShow = false, ProgressChangeDelayTime = 0, }; if (setTempAttr.step == "0.5") { setTempBar.MaxValue = (setTempAttr.max - setTempAttr.min) * 2; } else { setTempBar.MaxValue = (setTempAttr.max - setTempAttr.min); } setTempView.AddChidren(setTempBar); var btnMaxTemp = new Button() { X = setTempBar.Right, Width = Application.GetRealWidth(24), TextAlignment = TextAlignment.Center, Text = setTempAttr.max.ToString(), TextSize = 12, TextColor = 0xFFC0C7D4, }; setTempView.AddChidren(btnMaxTemp); } btnMode = new Button() { X = Application.GetRealWidth(60), Y = Application.GetRealHeight(334), Width = Application.GetRealWidth(30), Height = Application.GetRealWidth(30), UnSelectedImagePath = acFunction.GetModeIconPath(device.GetAttrState(FunctionAttributeKey.Mode)), }; FrameWhiteCentet1.AddChidren(btnMode); btnSwing = new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(330), Width = Application.GetRealWidth(40), Height = Application.GetRealWidth(40), UnSelectedImagePath = "FunctionIcon/AC/SweepIconNullOn.png", }; if (device.GetAttribute(FunctionAttributeKey.Swing) != null) { FrameWhiteCentet1.AddChidren(btnSwing); } btnWindSpeed = new Button() { X = Application.GetRealWidth(235), Y = Application.GetRealHeight(337), Width = Application.GetRealWidth(30), Height = Application.GetRealWidth(30), UnSelectedImagePath = acFunction.GetFanIconPath(device.GetAttrState(FunctionAttributeKey.FanSpeed)), }; FrameWhiteCentet1.AddChidren(btnWindSpeed); btnSwitch = new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(466), Width = Application.GetRealWidth(32), Height = Application.GetRealWidth(32), UnSelectedImagePath = "Public/PowerClose.png", SelectedImagePath = "Public/PowerOpen.png", IsSelected = device.GetAttrState(FunctionAttributeKey.OnOff) == "on" }; FrameWhiteCentet1.AddChidren(btnSwitch); setTempBar.OnProgressChangedEvent = (sender, e) => { if (setTempAttr.step == "0.5") { btnTemp.Text = (setTempAttr.min + ((double)e / 2)).ToString("0.0"); } else { btnTemp.Text = (setTempAttr.min + e).ToString(); } #if __IOS__ btnTemp.Width = btnTemp.GetTextWidth() + Application.GetRealWidth(10); #else btnTemp.Width = btnTemp.GetTextWidth() + Application.GetRealWidth(5); #endif btnTempUint.X = btnTemp.Right; }; setTempBar.OnStopTrackingTouchEvent = (sender, e) => { temp = e; Dictionary d = new Dictionary(); device.SetAttrState(FunctionAttributeKey.SetTemp, e.ToString()); if (setTempAttr.step == "0.5") { double ex = (double)e / 2; btnTemp.Text = (setTempAttr.min + ((double)ex)).ToString("0.0"); d.Add(FunctionAttributeKey.SetTemp, (setTempAttr.min + ex).ToString()); } else { btnTemp.Text = (setTempAttr.min + e).ToString(); d.Add(FunctionAttributeKey.SetTemp, (setTempAttr.min + e).ToString()); } #if __IOS__ btnTemp.Width = btnTemp.GetTextWidth() + Application.GetRealWidth(10); #else btnTemp.Width = btnTemp.GetTextWidth() + Application.GetRealWidth(5); #endif btnTempUint.X = btnTemp.Right; controlTime = DateTime.Now; Control.Ins.SendWriteCommand(device, d); }; LoadEvent_AcStatesChange(); LoadDiv_IrView(); } /// /// 加载修改模式区域 /// void LoadDiv_ChangeModeView() { Dialog dialog = new Dialog(); FrameLayout dialogView = new FrameLayout() { BackgroundColor = CSS_Color.DialogTransparentColor1, }; dialog.AddChidren(dialogView); FrameLayout modeChangeView; modeChangeView = new FrameLayout() { X = Application.GetRealWidth(30), Y = Application.GetRealHeight(128), Width = Application.GetRealWidth(160), Height = Application.GetRealHeight(287), BackgroundImagePath = "FunctionIcon/AC/DivBg1.png", }; dialogView.AddChidren(modeChangeView); Button btnTitle; btnTitle = new Button() { X = Application.GetRealWidth(8 + 16), Y = Application.GetRealHeight(8), Width = Application.GetRealWidth(112), Height = Application.GetRealHeight(44), TextID = StringId.ChooseMode, TextAlignment = TextAlignment.CenterLeft, TextColor = CSS_Color.FirstLevelTitleColor, TextSize = CSS_FontSize.EmphasisFontSize_Secondary, }; modeChangeView.AddChidren(btnTitle); Button btnLine = new Button() { X = btnTitle.X, Y = btnTitle.Bottom, Width = Application.GetRealWidth(112), Height = Application.GetRealHeight(1), BackgroundColor = CSS_Color.BackgroundColor, }; modeChangeView.AddChidren(btnLine); var modeList = device.GetAttribute(FunctionAttributeKey.Mode).value; foreach (var m in modeList) { Button btnModeIcon = new Button() { X = btnTitle.X, Y = Application.GetRealHeight(44 * (modeList.IndexOf(m) + 1) + 10 + 8), Width = Application.GetRealWidth(24), Height = Application.GetRealWidth(24), IsSelected = device.GetAttrState(FunctionAttributeKey.Mode) == m, }; modeChangeView.AddChidren(btnModeIcon); Button btnModeText = new Button() { X = Application.GetRealWidth(12) + btnModeIcon.Right, Y = Application.GetRealHeight(44 * (modeList.IndexOf(m) + 1) + 8), Height = Application.GetRealHeight(44), Width = Application.GetRealWidth(90), TextAlignment = TextAlignment.CenterLeft, TextColor = CSS_Color.FirstLevelTitleColor, SelectedTextColor = CSS_Color.MainColor, IsSelected = device.GetAttrState(FunctionAttributeKey.Mode) == m, TextSize = CSS_FontSize.TextFontSize, }; modeChangeView.AddChidren(btnModeText); btnModeIcon.UnSelectedImagePath = acFunction.GetModeIconPath(m, false); btnModeIcon.SelectedImagePath = acFunction.GetModeIconPath(m); btnModeText.Text = acFunction.GetModeAttrText(m); if (modeList.IndexOf(m) < modeList.Count - 1) { modeChangeView.AddChidren(new Button() { X = btnTitle.X, Y = btnModeText.Bottom, Width = Application.GetRealWidth(112), Height = Application.GetRealHeight(1), BackgroundColor = CSS_Color.BackgroundColor, }); } EventHandler eventHandler = (sender, e) => { dialog.Close(); }; EventHandler eventHandler1 = (sender, e) => { //if (!device.online) //{ // new Tip() // { // CloseTime = 1, // Text = Language.StringByID(StringId.DeviceOfflineCannotOption), // Direction = AMPopTipDirection.None, // }.Show(MainPage.BaseView); //} btnModeIcon.IsSelected = btnModeText.IsSelected = true; device.SetAttrState(FunctionAttributeKey.Mode, m); btnMode.UnSelectedImagePath = acFunction.GetModeIconPath(m); Dictionary d = new Dictionary(); d.Add(FunctionAttributeKey.Mode, m); Control.Ins.SendWriteCommand(device, d); dialog.Close(); if (device.GetAttrState(FunctionAttributeKey.Mode) == "fan") { setTempBar.IsClickable = false; setTempBar.IsOffline = true; } else { setTempBar.IsOffline = false; setTempBar.IsClickable = true; } }; btnModeIcon.MouseUpEventHandler = eventHandler1; btnModeText.MouseUpEventHandler = eventHandler1; dialogView.MouseUpEventHandler = eventHandler; } dialogView.MouseUpEventHandler = (sender, e) => { dialog.Close(); }; dialog.Show(); } /// /// 加载修改扫风模式区域 /// void LoadDiv_ChangeSwingView() { Dialog dialog = new Dialog(); FrameLayout dialogView = new FrameLayout() { BackgroundColor = CSS_Color.DialogTransparentColor1, }; dialog.AddChidren(dialogView); FrameLayout modeChangeView; modeChangeView = new FrameLayout() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(128), Width = Application.GetRealWidth(160), Height = Application.GetRealHeight(287), BackgroundImagePath = "FunctionIcon/AC/DivBg2.png", }; dialogView.AddChidren(modeChangeView); Button btnTitle; btnTitle = new Button() { X = Application.GetRealWidth(8 + 16), Y = Application.GetRealHeight(8), Width = Application.GetRealWidth(112), Height = Application.GetRealHeight(44), TextID = StringId.Swing, TextAlignment = TextAlignment.CenterLeft, TextColor = CSS_Color.FirstLevelTitleColor, TextSize = CSS_FontSize.EmphasisFontSize_Secondary, }; modeChangeView.AddChidren(btnTitle); Button btnLine = new Button() { X = btnTitle.X, Y = btnTitle.Bottom, Width = Application.GetRealWidth(112), Height = Application.GetRealHeight(1), BackgroundColor = CSS_Color.BackgroundColor, }; modeChangeView.AddChidren(btnLine); var modeList = device.GetAttribute(FunctionAttributeKey.Swing).value; foreach (var m in modeList) { Button btnModeIcon = new Button() { X = btnTitle.X, Y = Application.GetRealHeight(44 * (modeList.IndexOf(m) + 1) + 10 + 8), Width = Application.GetRealWidth(24), Height = Application.GetRealWidth(24), IsSelected = device.GetAttrState(FunctionAttributeKey.Swing) == m, }; modeChangeView.AddChidren(btnModeIcon); Button btnModeText = new Button() { X = Application.GetRealWidth(12) + btnModeIcon.Right, Y = Application.GetRealHeight(44 * (modeList.IndexOf(m) + 1) + 8), Height = Application.GetRealHeight(44), Width = Application.GetRealWidth(90), TextAlignment = TextAlignment.CenterLeft, TextColor = CSS_Color.FirstLevelTitleColor, SelectedTextColor = CSS_Color.MainColor, IsSelected = device.GetAttrState(FunctionAttributeKey.Swing) == m, TextSize = CSS_FontSize.TextFontSize, }; modeChangeView.AddChidren(btnModeText); if (modeList.IndexOf(m) < modeList.Count - 1) { modeChangeView.AddChidren(new Button() { X = btnTitle.X, Y = btnModeText.Bottom, Width = Application.GetRealWidth(112), Height = Application.GetRealHeight(1), BackgroundColor = CSS_Color.BackgroundColor, }); } btnModeIcon.UnSelectedImagePath = acFunction.GetSwingIconPath(m, false); btnModeIcon.SelectedImagePath = acFunction.GetSwingIconPath(m); btnModeText.Text = acFunction.GetSwingAttrText(m); EventHandler eventHandler = (sender, e) => { dialog.Close(); }; EventHandler eventHandler1 = (sender, e) => { //if (!device.online) //{ // new Tip() // { // CloseTime = 1, // Text = Language.StringByID(StringId.DeviceOfflineCannotOption), // Direction = AMPopTipDirection.None, // }.Show(MainPage.BaseView); //} btnModeIcon.IsSelected = btnModeText.IsSelected = true; device.SetAttrState(FunctionAttributeKey.Swing, m); btnSwing.UnSelectedImagePath = acFunction.GetSwingIconPath(m); Dictionary d = new Dictionary(); d.Add(FunctionAttributeKey.Swing, m); Control.Ins.SendWriteCommand(device, d); dialog.Close(); }; btnModeIcon.MouseUpEventHandler = eventHandler1; btnModeText.MouseUpEventHandler = eventHandler1; dialogView.MouseUpEventHandler = eventHandler; } dialogView.MouseUpEventHandler = (sender, e) => { dialog.Close(); }; dialog.Show(); } /// /// 加载修改模式区域 /// void LoadDiv_ChangeFanView() { Dialog dialog = new Dialog(); FrameLayout dialogView = new FrameLayout() { BackgroundColor = CSS_Color.DialogTransparentColor1, }; dialog.AddChidren(dialogView); FrameLayout modeChangeView; modeChangeView = new FrameLayout() { X = Application.GetRealWidth(185), Y = Application.GetRealHeight(172), Width = Application.GetRealWidth(160), Height = Application.GetRealHeight(243), BackgroundImagePath = "FunctionIcon/AC/DivBg2.png", }; dialogView.AddChidren(modeChangeView); Button btnTitle; btnTitle = new Button() { X = Application.GetRealWidth(8 + 16), Y = Application.GetRealHeight(8), Width = Application.GetRealWidth(112), Height = Application.GetRealHeight(44), TextID = StringId.ChooseFan, TextAlignment = TextAlignment.CenterLeft, TextColor = CSS_Color.FirstLevelTitleColor, TextSize = CSS_FontSize.EmphasisFontSize_Secondary, }; modeChangeView.AddChidren(btnTitle); Button btnLine = new Button() { X = btnTitle.X, Y = btnTitle.Bottom, Width = Application.GetRealWidth(112), Height = Application.GetRealHeight(1), BackgroundColor = CSS_Color.BackgroundColor, }; modeChangeView.AddChidren(btnLine); var modeList = device.GetAttribute(FunctionAttributeKey.FanSpeed).value; foreach (var m in modeList) { Button btnFanIcon = new Button() { X = btnTitle.X, Y = Application.GetRealHeight(44 * (modeList.IndexOf(m) + 1) + 10 + 8), Width = Application.GetRealWidth(24), Height = Application.GetRealWidth(24), IsSelected = device.GetAttrState(FunctionAttributeKey.FanSpeed) == m, }; modeChangeView.AddChidren(btnFanIcon); Button btnFanText = new Button() { X = Application.GetRealWidth(12) + btnFanIcon.Right, Y = Application.GetRealHeight(44 * (modeList.IndexOf(m) + 1) + 8), Height = Application.GetRealHeight(44), Width = Application.GetRealWidth(70), TextAlignment = TextAlignment.CenterLeft, TextColor = CSS_Color.FirstLevelTitleColor, SelectedTextColor = CSS_Color.MainColor, IsSelected = device.GetAttrState(FunctionAttributeKey.FanSpeed) == m, TextSize = CSS_FontSize.TextFontSize, }; modeChangeView.AddChidren(btnFanText); btnFanIcon.UnSelectedImagePath = acFunction.GetFanIconPath(m, false); btnFanIcon.SelectedImagePath = acFunction.GetFanIconPath(m); btnFanText.Text = acFunction.GetFanAttrText(m); if (modeList.IndexOf(m) < modeList.Count - 1) { modeChangeView.AddChidren(new Button() { X = btnTitle.X, Y = btnFanText.Bottom, Width = Application.GetRealWidth(112), Height = Application.GetRealHeight(1), BackgroundColor = CSS_Color.BackgroundColor, }); } EventHandler closeDialogEvent = (sender, e) => { dialog.Close(); }; EventHandler eventHandler1 = (sender, e) => { //if (!device.online) //{ // new Tip() // { // CloseTime = 1, // Text = Language.StringByID(StringId.DeviceOfflineCannotOption), // Direction = AMPopTipDirection.None, // }.Show(MainPage.BaseView); //} btnFanIcon.IsSelected = btnFanText.IsSelected = true; device.SetAttrState(FunctionAttributeKey.FanSpeed, m); btnWindSpeed.UnSelectedImagePath = acFunction.GetFanIconPath(m); System.Collections.Generic.Dictionary d = new System.Collections.Generic.Dictionary(); d.Add(FunctionAttributeKey.FanSpeed, m); Control.Ins.SendWriteCommand(device, d); //btnWindSpeed.UnSelectedImagePath = btnFanIcon.UnSelectedImagePath; dialog.Close(); }; btnFanIcon.MouseUpEventHandler = eventHandler1; btnFanText.MouseUpEventHandler = eventHandler1; dialogView.MouseUpEventHandler = closeDialogEvent; } dialog.Show(); } /// /// 加载红外遥控器,额外按钮 /// void LoadDiv_IrView() { if (device.spk == SPK.AcIr) { var btnMore = new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(334 + 80), Width = Application.GetRealWidth(35), Height = Application.GetRealWidth(35), UnSelectedImagePath = "FunctionIcon/AC/More.png", }; FrameWhiteCentet1.AddChidren(btnMore); btnMore.MouseUpEventHandler = (sender, e) => { LoadDialog_IrMoreView(); }; } } /// /// 加载额外对红外按钮界面 /// void LoadDialog_IrMoreView() { Dialog dialog = new Dialog(); var div = new FrameLayout(); dialog.AddChidren(div); div.MouseUpEventHandler = (sender, e) => { dialog.Close(); }; var bodyView = new FrameLayout() { Y = Application.GetRealHeight(427),//667 Height = Application.GetRealHeight(240), BackgroundColor = CSS_Color.MainBackgroundColor, }; div.AddChidren(bodyView); var contentView = new VerticalScrolViewLayout() { Y = Application.GetRealHeight(16), Gravity = Gravity.CenterHorizontal, Width = Application.GetRealWidth(296 + 200), }; bodyView.AddChidren(contentView); var row = new FrameLayout() { Height = Application.GetRealHeight(60), Width = Application.GetRealWidth(296), Gravity = Gravity.CenterHorizontal, }; contentView.AddChidren(row); int index = 0; List attrList = new List(); attrList.AddRange(device.attributes); attrList.Add(new FunctionAttributes() { key = "+", }); foreach (var attr in attrList) { if (attr.key == FunctionAttributeKey.Mode || attr.key == FunctionAttributeKey.OnOff || attr.key == FunctionAttributeKey.SetTemp || attr.key == FunctionAttributeKey.SetTempStep || attr.key == FunctionAttributeKey.FanSpeed || attr.key == FunctionAttributeKey.FanManual || attr.key == FunctionAttributeKey.FanAuto ) { continue; } if (index != 0 && index % 3 == 0) { row = new FrameLayout() { Height = Application.GetRealHeight(56), Width = Application.GetRealWidth(296), Gravity = Gravity.CenterHorizontal, }; contentView.AddChidren(row); } if (attr.key == "+") { var addView = new FrameLayout() { Gravity = Gravity.CenterVertical, Width = Application.GetRealWidth(88), Height = Application.GetRealHeight(40), Radius = (uint)Application.GetRealHeight(18), BorderColor = CSS_Color.PromptingColor1, BorderWidth = (uint)Application.GetRealWidth(2), }; if (index % 3 == 1) { addView.Gravity = Gravity.Center; } else if (index % 3 == 2) { addView.X = Application.GetRealWidth(208); } row.AddChidren(addView); var btnAdd = new Button() { Gravity = Gravity.Center, UnSelectedImagePath = "Public/PlusSignIcon.png", Width = Application.GetRealWidth(32), Height = Application.GetRealWidth(32), }; addView.AddChidren(btnAdd); btnAdd.MouseUpEventHandler = (sender, e) => { dialog.Close(); Action action = () => { LoadDialog_IrMoreView(); }; var addButton = new AcControlPage_AddIrButton(action); MainPage.BasePageView.AddChidren(addButton); addButton.Show(device); MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; }; } else { var btn = new Button() { Gravity = Gravity.CenterVertical, Width = Application.GetRealWidth(88), Height = Application.GetRealHeight(40), Radius = (uint)Application.GetRealHeight(18), BorderColor = CSS_Color.PromptingColor1, BorderWidth = (uint)Application.GetRealWidth(2), TextAlignment = TextAlignment.Center, TextSize = CSS_FontSize.TextFontSize, TextColor = CSS_Color.FirstLevelTitleColor, SelectedTextColor = CSS_Color.MainBackgroundColor, SelectedBackgroundColor = CSS_Color.MainColor, }; if (attr.value.Count > 0) { btn.Text = attr.value[0]; } if (index % 3 == 1) { btn.Gravity = Gravity.Center; } else if (index % 3 == 2) { btn.X = Application.GetRealWidth(208); } row.AddChidren(btn); btn.MouseUpEventHandler = (sender, e) => { //if (!device.online) //{ // new Tip() // { // CloseTime = 1, // Text = Language.StringByID(StringId.DeviceOfflineCannotOption), // Direction = AMPopTipDirection.None, // }.Show(MainPage.BaseView); //} Dictionary d = new Dictionary(); d.Add(attr.key, ""); Control.Ins.SendWriteCommand(device, d); new System.Threading.Thread(() => { System.Threading.Thread.Sleep(2000); Application.RunOnMainThread(() => { btn.IsSelected = false; }); }) { IsBackground = true }.Start(); }; } index++; } dialog.Show(); } #endregion #region ■ 设备状态反馈_______________________ /// /// 设备状态反馈 /// /// public override void DeviceStatuPush(Function i_LocalDevice) { //不是同一个东西 if (this.device.sid != i_LocalDevice.sid) { return; } //刷新当前设备的状态缓存 //this.RefreshNowDeviceStatuMemory(i_LocalDevice); //刷新界面状态 this.RefreshFormStatu(); } #endregion #region ■ 发送各种命令_______________________ /// /// 温度改变模式 /// void LoadEvent_TempChange() { } /// /// 控制模式事件 /// void LoadEvent_AcStatesChange() { btnMode.MouseUpEventHandler = (sender, e) => { if (device.trait_on_off.curValue.ToString() == "off") { return; } LoadDiv_ChangeModeView(); }; //扫风改变模式 btnSwing.MouseUpEventHandler = (sender, e) => { if (device.trait_on_off.curValue.ToString() == "off") { return; } LoadDiv_ChangeSwingView(); }; btnWindSpeed.MouseUpEventHandler = (sender, e) => { if (device.trait_on_off.curValue.ToString() == "off") { return; } LoadDiv_ChangeFanView(); }; btnSwitch.MouseUpEventHandler = (sender, e) => { //if (!device.online) //{ // new Tip() // { // CloseTime = 1, // Text = Language.StringByID(StringId.DeviceOfflineCannotOption), // Direction = AMPopTipDirection.None, // }.Show(MainPage.BaseView); //} btnSwitch.IsSelected = !btnSwitch.IsSelected; device.trait_on_off.curValue = btnSwitch.IsSelected ? "on" : "off"; if (device.trait_on_off.curValue.ToString() == "on") { btnSwitch.IsSelected = true; //setTempBar.IsOffline = false; //setTempBar.Enable = true; //setTempBar.ProgressBarColor = CSS_Color.MainColor; } else { btnSwitch.IsBold = false; //setTempBar.IsOffline = true; //setTempBar.Enable = false; //setTempBar.ProgressBarColor = CSS_Color.DividingLineColor; } System.Collections.Generic.Dictionary d = new System.Collections.Generic.Dictionary(); d.Add(FunctionAttributeKey.OnOff, device.trait_on_off.curValue.ToString()); Control.Ins.SendWriteCommand(device, d); }; } #endregion #region ■ 刷新界面状态_______________________ /// /// 刷新界面状态 /// private void RefreshFormStatu() { Application.RunOnMainThread(() => { //app自己控制的不用更新,会造成跳动 if (controlTime.AddSeconds(2) > DateTime.Now) { return; } else { //device = FunctionList.List.Functions.Find((obj) => obj.sid == device.sid); btnIndoorTemp.Text = Language.StringByID(StringId.Indoor) + " " + Convert.ToInt32(Convert.ToDouble(device.GetAttrState(FunctionAttributeKey.RoomTemp).Replace(",", "."))) + "°C"; btnMode.SelectedImagePath = acFunction.GetModeIconPath(device.GetAttrState(FunctionAttributeKey.Mode)); btnSwing.SelectedImagePath = acFunction.GetSwingIconPath(device.GetAttrState(FunctionAttributeKey.Swing)); btnWindSpeed.SelectedImagePath = acFunction.GetFanIconPath(device.GetAttrState(FunctionAttributeKey.FanSpeed)); btnMode.UnSelectedImagePath = acFunction.GetModeIconPath(device.GetAttrState(FunctionAttributeKey.Mode), false); btnSwing.UnSelectedImagePath = acFunction.GetSwingIconPath(device.GetAttrState(FunctionAttributeKey.Swing), false); btnWindSpeed.UnSelectedImagePath = acFunction.GetFanIconPath(device.GetAttrState(FunctionAttributeKey.FanSpeed), false); if (device.GetAttribute(FunctionAttributeKey.SetTemp).step == "0.5") { var t = Convert.ToDouble(device.GetAttrState(FunctionAttributeKey.SetTemp).Replace(",", ".")); var temp = (int)(t * 2); setTempBar.Progress = temp - device.GetAttribute(FunctionAttributeKey.SetTemp).min * 2; btnTemp.Text = Convert.ToDouble(t).ToString("0.0"); } else { var temp = Convert.ToInt32(Convert.ToDouble(device.GetAttrState(FunctionAttributeKey.SetTemp).Replace(",", "."))); setTempBar.Progress = temp - device.GetAttribute(FunctionAttributeKey.SetTemp).min; btnTemp.Text = temp.ToString(); } #if __IOS__ btnTemp.Width = btnTemp.GetTextWidth() + Application.GetRealWidth(10); #else btnTemp.Width = btnTemp.GetTextWidth() + Application.GetRealWidth(5); #endif btnTempUint.X = btnTemp.Right; if (device.trait_on_off.curValue.ToString() == "on") { btnMode.IsSelected = btnSwing.IsSelected = btnWindSpeed.IsSelected = true; setTempBar.Enable = true; setTempBar.ProgressBarColor = CSS_Color.MainColor; btnSwitch.IsSelected = true; if (device.GetAttrState(FunctionAttributeKey.Mode) == "fan") { setTempBar.IsClickable = false; } else { setTempBar.IsClickable = true; } } else { btnMode.IsSelected = btnSwing.IsSelected = btnWindSpeed.IsSelected = false; setTempBar.Enable = false; setTempBar.ProgressBarColor = CSS_Color.DividingLineColor; btnSwitch.IsSelected = false; setTempBar.IsClickable = false; } if (device.GetAttrState(FunctionAttributeKey.Mode) == "dry") { setTempBar.IsOffline = true; setTempBar.IsClickable = false; } } }); } #endregion } }