using Shared.SimpleControl.Phone; using System; using System.Collections.Generic; namespace Shared.SimpleControl.Pad { /// /// 空调设备房间 /// public class UserDeviceToScene : Shared.Dialog { VerticalScrolViewLayout bodyScrolView; FrameLayout LongPressFrameLayout = new FrameLayout (); UserScenePage ControlBodyView; FrameLayout bordorView; VerticalScrolViewLayout RoomListScrolView; Button beforeClickButton = new Button (); Button btnGloba; /// /// 构造函数 /// public UserDeviceToScene () { BackgroundColor = 0xFF2f2f2f; showAllScene (); } public void Refresh () { Close (); new UserDeviceToScene ().Show (); } /// /// 显示房间的所有场景 /// void showAllScene () { #region 标题 var topView = new FrameLayout () { Y = Application.GetRealHeight (36), Height = Application.GetRealHeight (90), BackgroundColor = 0xFF2f2f2f }; AddChidren (topView); var title = new Button () { TextAlignment = TextAlignment.Center, Text = Language.StringByID (R.MyInternationalizationString.Scenes), TextSize = 19, }; topView.AddChidren (title); var back = new Button () { Height = Application.GetRealHeight (120), Width = Application.GetRealWidth (95), UnSelectedImagePath = "Item/Back.png", SelectedImagePath = "Item/BackSelected.png", Gravity = Gravity.CenterVertical, }; topView.AddChidren (back); back.MouseUpEventHandler += (sender, e) => { Close (); UserMiddle.DeviceMode (); }; var logo = new Button () { Width = Application.GetRealWidth (154), Height = Application.GetRealHeight (90), X = Application.GetRealWidth (486), UnSelectedImagePath = MainPage.LogoString, }; topView.AddChidren (logo); var btnl = new Button () { Height = 1, BackgroundColor = 0xFF2f2f2f, Y = topView.Height - 1 }; topView.AddChidren (btnl); #endregion bordorView = new FrameLayout () { Width = Application.GetRealWidth (480), Height = Application.GetRealHeight (Application.DesignHeight - 150), Y = Application.GetRealHeight (150), BackgroundColor = 0xFF2f2f2f }; AddChidren (bordorView); #region titelView var roomTitleView = new FrameLayout () { Height = Application.GetRealHeight (140), Width = Application.GetRealWidth (480), BackgroundColor = SkinStyle.Current.MainColor, }; bordorView.AddChidren (roomTitleView); btnGloba = new Button () { TextSize = 16, SelectedTextColor = SkinStyle.Current.SelectedColor, TextColor = SkinStyle.Current.TextColor1, TextID = R.MyInternationalizationString.GlobaScene, IsSelected = true }; roomTitleView.AddChidren (btnGloba); var btnLine1 = new Button () { Height = 1, Y = roomTitleView.Height - 1, BackgroundColor = 0xFF2f2f2f, }; roomTitleView.AddChidren (btnLine1); btnGloba.MouseUpEventHandler += (sender, e) => { btnGloba.IsSelected = true; for (int i = 0; i < RoomListScrolView.ChildrenCount; i++) { var view = RoomListScrolView.GetChildren (i); for (int j = 0; j < (view as FrameLayout).ChildrenCount; j++) { var btn = (view as FrameLayout).GetChildren (j); if (btn.GetType () == typeof (Button)) (btn as Button).IsSelected = false; } } if (ControlBodyView != null) { ControlBodyView.RemoveFromParent (); } ControlBodyView = new UserScenePage (null) { Width = Application.GetRealWidth (Application.DesignWidth) - bordorView.Width, Height = Application.GetRealHeight (Application.DesignHeight - 150), X = bordorView.Right, Y = bordorView.Y, BackgroundColor = SkinStyle.Current.MainColor }; AddChidren (ControlBodyView); ControlBodyView.ShowUserScene (null); }; #endregion FrameLayout bodyView = new FrameLayout () { Width = LayoutParams.MatchParent, Height = Application.GetRealHeight (Application.DesignHeight - 150 - 140), Y = roomTitleView.Bottom, }; bordorView.AddChidren (bodyView); bodyScrolView = new VerticalScrolViewLayout (); bodyView.AddChidren (bodyScrolView); InitView (); ControlBodyView = new UserScenePage (null) { Width = Application.GetRealWidth (Application.DesignWidth) - bordorView.Width, Height = Application.GetRealHeight (Application.DesignHeight - 150), X = bordorView.Right, Y = bordorView.Y, BackgroundColor = SkinStyle.Current.MainColor }; AddChidren (ControlBodyView); ControlBodyView.ShowUserScene (null); } void InitView () { bodyScrolView.RemoveAll (); RoomListScrolView = new VerticalScrolViewLayout () { Height = bodyScrolView.Height - Application.GetRealHeight (140), }; bodyScrolView.AddChidren (RoomListScrolView); FrameLayout bottomView = new FrameLayout () { Height = Application.GetRealHeight (140), //Y = bodyScrolView.Height - Application.GetRealHeight(90), }; bodyScrolView.AddChidren (bottomView); Button btnHideNullRoom = new Button () { Width = LayoutParams.MatchParent, Height = LayoutParams.MatchParent, TextID = UserConfig.Instance.HideInvalidRoomScene == true ? R.MyInternationalizationString.ShowAllRoomList : R.MyInternationalizationString.HideNullRoomScene, TextAlignment = TextAlignment.Center, IsSelected = UserConfig.Instance.HideInvalidRoomScene, }; bottomView.AddChidren (btnHideNullRoom); btnHideNullRoom.MouseUpEventHandler += (sender, e) => { btnHideNullRoom.IsSelected = !btnHideNullRoom.IsSelected; UserConfig.Instance.HideInvalidRoomScene = btnHideNullRoom.IsSelected; UserConfig.Instance.SaveUserConfig (); InitRoomScene (btnHideNullRoom.IsSelected); btnHideNullRoom.TextID = UserConfig.Instance.HideInvalidRoomScene == true ? R.MyInternationalizationString.ShowAllRoomList : R.MyInternationalizationString.HideNullRoomScene; }; InitRoomScene (btnHideNullRoom.IsSelected); Button btnLineNull = new Button () { Height = 1, BackgroundColor = 0xFB757575 }; bottomView.AddChidren (btnLineNull); } void InitRoomScene (bool hideNull) { RoomListScrolView.RemoveAll (); foreach (var room in Room.Lists) { if (room.Name == "") { continue; } if (hideNull && room.SceneFilePathList.Count == 0) continue; FrameLayout roomView = new FrameLayout () { Height = Application.GetRealHeight (140), Tag = room.Name }; RoomListScrolView.AddChidren (roomView); EventHandler ShowLightRoom = (button, mouseEventArgs) => { btnGloba.IsSelected = false; for (int i = 0; i < RoomListScrolView.ChildrenCount; i++) { var view = RoomListScrolView.GetChildren (i); if (view.Tag.ToString () == room.Name) { for (int j = 0; j < (view as FrameLayout).ChildrenCount; j++) { var btn = (view as FrameLayout).GetChildren (j); if (btn.GetType () == typeof (Button)) (btn as Button).IsSelected = true; } } else { for (int j = 0; j < (view as FrameLayout).ChildrenCount; j++) { var btn = (view as FrameLayout).GetChildren (j); if (btn.GetType () == typeof (Button)) (btn as Button).IsSelected = false; } } } if (ControlBodyView != null) { ControlBodyView.RemoveFromParent (); } ControlBodyView = new UserScenePage (room) { Width = Application.GetRealWidth (Application.DesignWidth) - bordorView.Width, Height = Application.GetRealHeight (Application.DesignHeight - 150), X = bordorView.Right, Y = bordorView.Y, BackgroundColor = SkinStyle.Current.MainColor }; AddChidren (ControlBodyView); ControlBodyView.ShowUserScene (room); }; var btnRoomName = new Button () { Height = Application.GetRealHeight (140), TextAlignment = TextAlignment.CenterLeft, SelectedTextColor = SkinStyle.Current.SelectedColor, TextColor = SkinStyle.Current.TextColor1, BackgroundColor = SkinStyle.Current.Transparent, SelectedBackgroundColor = SkinStyle.Current.MainColor, Padding = new Padding (0, 35, 0, 0), Text = room.Name }; roomView.AddChidren (btnRoomName); btnRoomName.MouseUpEventHandler += ShowLightRoom; var btnPoint = new Button () { Width = Application.GetRealWidth (10), Height = Application.GetRealHeight (10), X = Application.GetRealWidth (30), Gravity = Gravity.CenterVertical, UnSelectedImagePath = "Item/Point.png", SelectedImagePath = "Item/Point.png", }; roomView.AddChidren (btnPoint); var btnNumber = new EditText () { Width = Application.GetMinRealAverage (50), Height = Application.GetMinRealAverage (35), X = Application.GetRealWidth (410), Gravity = Gravity.CenterVertical, UnSelectedImagePath = "Item/LightingCount.png", SelectedImagePath = "Item/LightingCount.png", Enable = false, Text = room.SceneFilePathList.Count.ToString (), TextColor = SkinStyle.Current.TextColor1, //SelectedText42C, TextAlignment = TextAlignment.Center, Tag = room.Name }; roomView.AddChidren (btnNumber); } } } }