using System; namespace Shared.SimpleControl.Phone { public class ACMerrillRowView : FrameLayout { uint MLTextColor = 0xFFEB5C19; public Button btnName; public Button tempSiwtch; public Button btnIndoorTempValues; public Button btnIndoorHumidityValues; public Button btnTempIcon; public Button btnHumidityIcon; //ACMerrillLoop mACMerrillLoop; string TempTypeString = "°C"; string HumidityTypeString = "%"; public ACMerrillRowView (ACMerrillLoop mACMerrillLoop, EventHandler openACMerrillDevicePage = null) { try { //mACMerrillLoop = mmACMerrillLoop; Tag = mACMerrillLoop.CommonLoopID; btnName = new Button () { Width = Application.GetRealWidth (400), Height = Application.GetRealHeight (26), TextAlignment = TextAlignment.CenterLeft, Y = Application.GetRealWidth (32), X = Application.GetRealWidth (34), TextColor = SkinStyle.Current.TextColor1, TextSize = 14, Tag = "Name" }; AddChidren (btnName); btnName.Text = mACMerrillLoop.Name; tempSiwtch = new Button () { Width = Application.GetMinRealAverage (90), Height = Application.GetMinRealAverage (53), X = Application.GetRealWidth (640 - 90 - 32), Y = Application.GetRealHeight (18), UnSelectedImagePath = "Item/SwitchClose.png", SelectedImagePath = "Item/SwitchOpen.png", Tag = "Switch" }; AddChidren (tempSiwtch); if (0 < mACMerrillLoop.Power) { tempSiwtch.IsSelected = true; } btnTempIcon = new Button () { X = Application.GetRealWidth (23), Y = Application.GetRealHeight (86), Width = Application.GetMinRealAverage (44), Height = Application.GetMinRealAverage (44), UnSelectedImagePath = "ACMerrill/ACTempG.png", SelectedImagePath = "ACMerrill/ACTemp.png", }; AddChidren (btnTempIcon); btnIndoorTempValues = new Button () { X = Application.GetRealWidth (78), Width = Application.GetRealWidth (120), Height = Application.GetMinRealAverage (36), Y = Application.GetRealHeight (90), //Text = mACMerrillLoop.IndoorTemperature.ToString () + "°C", TextColor = MLTextColor, TextAlignment = TextAlignment.CenterLeft, TextSize = 18, Tag = "Temp" }; AddChidren (btnIndoorTempValues); btnHumidityIcon = new Button () { X = Application.GetRealWidth (203), Y = Application.GetRealHeight (86), Width = Application.GetMinRealAverage (44), Height = Application.GetMinRealAverage (44), UnSelectedImagePath = "ACMerrill/ACHumidityG.png", SelectedImagePath = "ACMerrill/ACHumidity.png", }; AddChidren (btnHumidityIcon); btnIndoorHumidityValues = new Button () { X = Application.GetRealWidth (258), Width = Application.GetRealWidth (120), Height = Application.GetMinRealAverage (36), Y = Application.GetRealHeight (90), //Text = mACMerrillLoop.IndoorHumidity.ToString () + "%", TextColor = MLTextColor, TextAlignment = TextAlignment.CenterLeft, TextSize = 18, Tag = "Humidity" }; AddChidren (btnIndoorHumidityValues); //if (isAcList) { MouseUpEventHandler += openACMerrillDevicePage; btnName.MouseUpEventHandler += openACMerrillDevicePage; //btnTempIcon.MouseUpEventHandler += openACMerrillDevicePage; //btnTempValues.MouseUpEventHandler += openACMerrillDevicePage; //btnHumidityIcon.MouseUpEventHandler += openACMerrillDevicePage; //btnHumidityValues.MouseUpEventHandler += openACMerrillDevicePage; string TempTypeString; //if (mACMerrillLoop.TemperatureMode == 0) { // TempTypeString = "°C"; //} else { // TempTypeString = "°F"; //} TempTypeString = "°C"; if (mACMerrillLoop.IndoorTemperature <= 0) { btnIndoorTempValues.Text = "--" + TempTypeString; } else { btnIndoorTempValues.Text = mACMerrillLoop.IndoorTemperature.ToString () + TempTypeString; } if (mACMerrillLoop.IndoorHumidity <= 0) { btnIndoorHumidityValues.Text = "--" + HumidityTypeString; } else { btnIndoorHumidityValues.Text = mACMerrillLoop.IndoorHumidity.ToString () + HumidityTypeString; } if (mACMerrillLoop.Power > 0) { btnTempIcon.IsSelected = true; btnHumidityIcon.IsSelected = true; btnIndoorTempValues.Visible = true; btnIndoorHumidityValues.Visible = true; } else { btnTempIcon.IsSelected = false; btnHumidityIcon.IsSelected = false; btnIndoorTempValues.Visible = false; btnIndoorHumidityValues.Visible = false; } var btnDeviceRowLine = new Button () { Height = 1, BackgroundColor = SkinStyle.Current.LineColor, }; AddChidren (btnDeviceRowLine); tempSiwtch.MouseUpEventHandler += (sender3, e3) => { try { tempSiwtch.IsSelected = !tempSiwtch.IsSelected; mACMerrillLoop.Power = tempSiwtch.IsSelected ? (byte)1 : (byte)0; if (mACMerrillLoop.Power > 0) { btnTempIcon.IsSelected = true; btnHumidityIcon.IsSelected = true; btnIndoorTempValues.Visible = true; btnIndoorHumidityValues.Visible = true; } else { btnTempIcon.IsSelected = false; btnHumidityIcon.IsSelected = false; btnIndoorTempValues.Visible = false; btnIndoorHumidityValues.Visible = false; } //发送控制指令 Control.ControlBytesSend (Command.SetACMode, mACMerrillLoop.SubnetID, mACMerrillLoop.DeviceID, mACMerrillLoop.GetACSendBytes ()); } catch { } //System.Console.WriteLine ($"============>tempSiwtch: { mACMerrillLoop.Name}"); }; } catch { } } /// /// 刷新 室内温度和室内湿度 /// /// public void UpdateButton (ACMerrillLoop ac) { if (0 < ac.Power) { tempSiwtch.IsSelected = true; } else { tempSiwtch.IsSelected = false; } if (ac.IndoorTemperature <= 0) { btnIndoorTempValues.Text = "--" + TempTypeString; } else { btnIndoorTempValues.Text = ac.IndoorTemperature.ToString () + TempTypeString; } if (ac.IndoorHumidity <= 0) { btnIndoorHumidityValues.Text = "--" + HumidityTypeString; } else { btnIndoorHumidityValues.Text = ac.IndoorHumidity.ToString () + HumidityTypeString; } if (ac.Power > 0) { btnTempIcon.IsSelected = true; btnHumidityIcon.IsSelected = true; btnIndoorTempValues.Visible = true; btnIndoorHumidityValues.Visible = true; } else { btnTempIcon.IsSelected = false; btnHumidityIcon.IsSelected = false; btnIndoorTempValues.Visible = false; btnIndoorHumidityValues.Visible = false; } } } }