using Shared.SimpleControl.Phone; using System; namespace Shared.SimpleControl.Pad { public class SystemFan { public SystemFan () { } public void SystemFanShow (FanModule fanModule, Common fanDevice) { SystemMiddle.ThirdScrolView.RemoveAll (); #region top EditText textButton = new EditText () { X = Application.GetRealWidth (40), Height = Application.GetRealHeight (50), Width = Application.GetRealWidth (400), Text = fanModule.Name, Gravity = Gravity.CenterVertical, TextAlignment = TextAlignment.CenterLeft, SelectedBackgroundColor = 0xFF000000, TextSize = 15, Enable = false, }; SystemMiddle.ThirdScrolView.TitleView.AddChidren (textButton); Button editor = new Button () { Height = Application.GetRealHeight (90), Width = Application.GetRealWidth (70), UnSelectedImagePath = "Item/Editor.png", SelectedImagePath = "Item/EditorSelected.png", Gravity = Gravity.CenterVertical, X = Application.GetRealWidth (550) }; SystemMiddle.ThirdScrolView.TitleView.AddChidren (editor); editor.MouseUpEventHandler += (sender, e) => { if (editor.IsSelected) { MainPage.Loading.Start (); editor.IsSelected = textButton.IsSelected = textButton.Enable = false; byte [] remakeBytes = CommonPage.MyEncodingGB2312.GetBytes (textButton.Text.Trim ()); System.Threading.Tasks.Task.Run (() => { byte [] updateBytes = Control.ControlBytesSendHasReturn (Command.ReadDeviceLoopInfo, fanModule.SubnetID, fanModule.DeviceID, new byte [] { fanModule.BigClass,fanModule.MinClass,fanModule.LoopID }); if (updateBytes == null) { Application.RunOnMainThread (() => { new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.TipEquipmentNotOnline), Language.StringByID (R.MyInternationalizationString.Close)).Show (); MainPage.Loading.Hide (); }); return; } byte [] uBytes = new byte [20]; Array.Copy (remakeBytes, 0, uBytes, 0, remakeBytes.Length < 20 ? remakeBytes.Length : 20); Array.Copy (uBytes, 0, updateBytes, 3, 20 < uBytes.Length ? 20 : uBytes.Length); var reBytes = Control.ControlBytesSendHasReturn (Command.SetDeviceLoopInfo, fanModule.SubnetID, fanModule.DeviceID, updateBytes); if (reBytes != null) { Application.RunOnMainThread (() => { fanModule.Name = textButton.Text.Trim (); IO.FileUtils.SaveEquipmentMessage (fanModule, fanModule.LoopID.ToString ()); MainPage.Loading.Hide (); }); } else { Application.RunOnMainThread (() => { new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.TipEquipmentNotOnline), Language.StringByID (R.MyInternationalizationString.Close)).Show (); MainPage.Loading.Hide (); }); } }); } else { textButton.Enable = textButton.IsSelected = editor.IsSelected = true; } }; #endregion #region MyRegion FrameLayout frameLayoutBody = new FrameLayout () { Height = Application.GetRealHeight (700), Width = LayoutParams.MatchParent, }; SystemMiddle.ThirdScrolView.AddChidren (frameLayoutBody); Button btnWindSpeedTitle = new Button () { Width = Application.GetRealWidth (310), Height = Application.GetRealHeight (80), X = Application.GetRealWidth (30), TextAlignment = TextAlignment.CenterLeft, Y = Application.GetRealHeight (60), TextID = R.MyInternationalizationString.WindSpeed }; frameLayoutBody.AddChidren (btnWindSpeedTitle); Button btnWindSpeedReduce = new Button () { Width = Application.GetRealWidth (80), Height = Application.GetRealHeight (78), X = Application.GetRealWidth (135), Y = btnWindSpeedTitle.Bottom, UnSelectedImagePath = "Fan/Fan-.png", SelectedImagePath = "Fan/Fan-On.png", }; frameLayoutBody.AddChidren (btnWindSpeedReduce); Button btnWindSpeedText = new Button () { Width = Application.GetRealWidth (225), Height = Application.GetRealHeight (78), X = btnWindSpeedReduce.Right, Y = btnWindSpeedReduce.Y, BackgroundColor = 0xFF333333, Text = fanModule.WindSpeed.ToString (), TextSize = 12, }; frameLayoutBody.AddChidren (btnWindSpeedText); Button btnWindSpeedAdd = new Button () { Width = Application.GetRealWidth (80), Height = Application.GetRealHeight (78), X = btnWindSpeedText.Right, Y = btnWindSpeedReduce.Y, UnSelectedImagePath = "Fan/Fan+.png", SelectedImagePath = "Fan/Fan+On.png", }; frameLayoutBody.AddChidren (btnWindSpeedAdd); btnWindSpeedAdd.MouseDownEventHandler += (sender2, e2) => { btnWindSpeedAdd.IsSelected = true; if (fanModule.WindSpeed < 8) { fanModule.WindSpeed++; Control.ControlBytesSend (Command.SetSingleLight, fanModule.SubnetID, fanModule.DeviceID, new byte [] { fanModule.LoopID, fanModule.WindSpeed }); btnWindSpeedText.Text = fanModule.WindSpeed.ToString (); IO.FileUtils.SaveEquipmentMessage (fanModule, fanModule.LoopID.ToString ()); } }; btnWindSpeedAdd.MouseUpEventHandler += (sender2, e2) => { btnWindSpeedAdd.IsSelected = false; }; btnWindSpeedReduce.MouseDownEventHandler += (sender2, e2) => { btnWindSpeedReduce.IsSelected = true; if (fanModule.WindSpeed > 0) { fanModule.WindSpeed--; Control.ControlBytesSend (Command.SetSingleLight, fanModule.SubnetID, fanModule.DeviceID, new byte [] { fanModule.LoopID, fanModule.WindSpeed }); btnWindSpeedText.Text = fanModule.WindSpeed.ToString (); IO.FileUtils.SaveEquipmentMessage (fanModule, fanModule.LoopID.ToString ()); } }; btnWindSpeedReduce.MouseUpEventHandler += (sender2, e2) => { btnWindSpeedReduce.IsSelected = false; }; #endregion } } }