using Shared; using System; using System.Collections.Generic; using System.Text; using HDL_ON.UI.CSS; using HDL_ON.Entity; using HDL_ON.DriverLayer; using HDL_ON.UI.Music; namespace HDL_ON.UI { /// /// 视频门锁的控制界面 /// public class VideoDoorLockPage : FrameLayout { #region ■ 变量声明___________________________ /// /// 设备 /// private Function device; /// /// 上一级界面的设备名字控件 /// private Button btnDeviceName; /// /// 上一级界面的房间名字控件 /// private Button btnRoomName; /// /// 头部布局 /// private TopView topView; /// /// 当前设备名称 /// private Button btnCurrDeviceName; /// /// 区域 /// private Button btnCurrDeviceRoom; /// /// 电量 /// private Button btnCell; /// ///收藏图标 /// private Button btnCollectIcon; /// /// 门锁状态 /// private Button btnDoorLockIcon; /// /// 实时视频 /// private CustomFrameLayout rtvFL; /// /// 一键开锁 /// private CustomFrameLayout openFL; /// /// 临时密码 /// private CustomFrameLayout pswFL; /// /// 历史记录 /// private CustomFrameLayout recordFL; /// /// 表示来自那个界面 /// private Comerom Comerom; #endregion /// /// 构造函数 /// /// 设备 /// 上一级界面的设备名字控件 /// 上一级界面的房间名字控件 public VideoDoorLockPage(Function function, Button btnDeviceName, Button btnRoomName, Comerom comerom) { this.device = function; this.btnDeviceName = btnDeviceName; this.btnRoomName = btnRoomName; this.Comerom = comerom; } public void Show() { //初始化UI this.InitUI(); //初始化事件 this.EventListener (); } /// /// 初始化界面 /// private void InitUI() { #region ---界面布局--- this.BackgroundColor = MusicColor.ViewColor; this.topView = new TopView(); this.topView.setBtn.Visible = true; this.topView.topNameBtn.TextID =StringId.shipinmensuo; this.AddChidren(topView.TopFLayoutView()); var middleFl=new FrameLayout { Y = topView.fLayout.Bottom, Height = Application.GetRealHeight(H_W.H - H_W.T_Height), }; this.AddChidren(middleFl); var whiteFl = new FrameLayout { Y = Application.GetRealHeight(24), X = Application.GetRealWidth(24), Height = Application.GetRealHeight(526), Width = Application.GetRealWidth(327), BackgroundImagePath = "MusicIcon/playBj.png", Name = "fl", }; middleFl.AddChidren(whiteFl); btnCurrDeviceName= new Button { TextSize = TextSize.Text24, TextColor = MusicColor.Text18Color, Width = Application.GetRealWidth(160), Height = Application.GetRealHeight(33), Y = Application.GetRealHeight(16), X = Application.GetRealWidth(16), Text = this.device.name, TextAlignment=TextAlignment.CenterLeft, }; whiteFl.AddChidren(btnCurrDeviceName); btnCurrDeviceRoom = new Button { TextSize = TextSize.Text12, TextColor = MusicColor.MusicNoTxetColor, Width = Application.GetRealWidth(160), Height = Application.GetRealHeight(33), Y = btnCurrDeviceName.Bottom+ Application.GetRealHeight(4), X = Application.GetRealWidth(16), Text = this.device.GetRoomListName(), TextAlignment = TextAlignment.CenterLeft, }; whiteFl.AddChidren(btnCurrDeviceRoom); btnCurrDeviceRoom.Width=btnCurrDeviceName.GetTextWidth(); btnCell = new Button { TextSize = TextSize.Text10, TextColor = MusicColor.TextColor, Y = Application.GetRealHeight(43), X = btnCurrDeviceRoom.Right+Application.GetRealWidth(17), //Text ="60"+"%", //TextAlignment = TextAlignment.Center, Width = Application.GetRealWidth(36), Height = Application.GetRealWidth(36), UnSelectedImagePath ="FunctionIcon/DoorLock/Cell.png", }; whiteFl.AddChidren(btnCell); btnCollectIcon = new Button { X = Application.GetRealWidth(264), Y = Application.GetRealHeight(14), Width = Application.GetRealWidth(40), Height = Application.GetRealWidth(40), UnSelectedImagePath = "MusicIcon/collect.png", SelectedImagePath = "MusicIcon/collectSelected.png", IsSelected= this.device.collect, Name = "collect" }; whiteFl.AddChidren(btnCollectIcon); //门锁状态 btnDoorLockIcon = new Button { X = Application.GetRealWidth(65), Y = Application.GetRealHeight(108), Width = Application.GetRealWidth(198), Height = Application.GetRealWidth(200), UnSelectedImagePath = "FunctionIcon/DoorLock/UnLocked.png", SelectedImagePath = "FunctionIcon/DoorLock/UnLocking.png", }; whiteFl.AddChidren(btnDoorLockIcon); //实时视频 rtvFL = new CustomFrameLayout(CustomFrameLayout.widthFrameLayout, CustomFrameLayout.heightFrameLayout); whiteFl.AddChidren(rtvFL); rtvFL.Y = btnDoorLockIcon.Bottom+ Application.GetRealHeight(45); rtvFL.X = Application.GetRealWidth(68); rtvFL.AddImageView(); rtvFL.AddTextButtonView(); rtvFL.GetImageButton().UnSelectedImagePath = "FunctionIcon/DoorLock/RTV.png"; rtvFL.GetTextButton().TextID = StringId.shishishipin; //历史记录 recordFL = new CustomFrameLayout(CustomFrameLayout.widthFrameLayout, CustomFrameLayout.heightFrameLayout); whiteFl.AddChidren(recordFL); recordFL.Y = btnDoorLockIcon.Bottom + Application.GetRealHeight(45); recordFL.X = rtvFL.Right + Application.GetRealHeight(CustomFrameLayout.interval); recordFL.AddImageView(); recordFL.AddTextButtonView(); recordFL.GetImageButton().UnSelectedImagePath = "FunctionIcon/DoorLock/HistoryList.png"; recordFL.GetTextButton().TextID = StringId.lishijilu; //一键开锁 openFL = new CustomFrameLayout(CustomFrameLayout.widthFrameLayout, CustomFrameLayout.heightFrameLayout); whiteFl.AddChidren(openFL); openFL.X = rtvFL.X; openFL.Y = rtvFL.Bottom+Application.GetRealHeight(14); openFL.AddImageView(); openFL.AddTextButtonView(); openFL.GetImageButton().UnSelectedImagePath = "FunctionIcon/DoorLock/OneOpenLock.png"; openFL.GetTextButton().TextID = StringId.yijiankaisuo; //临时密码 pswFL = new CustomFrameLayout(CustomFrameLayout.widthFrameLayout, CustomFrameLayout.heightFrameLayout); whiteFl.AddChidren(pswFL); pswFL.X = recordFL.X; pswFL.Y = rtvFL.Bottom + Application.GetRealHeight(14); pswFL.AddImageView(); pswFL.AddTextButtonView(); pswFL.GetImageButton().UnSelectedImagePath = "FunctionIcon/DoorLock/OneOpenLock.png"; pswFL.GetTextButton().TextID = StringId.linshimima1; #endregion } /// /// 注册事件 /// private void EventListener() { //返回 this.topView.clickBackBtn.MouseUpEventHandler += (sender, e) => { RemoveFromParent(); }; //设置 this.topView.clickSetBtn.MouseUpEventHandler += (sender, e) => { //调用秀绕的界面 var infoView = new UI.FunctionBaseInfoSetPage(this.device, () => { if (this.btnDeviceName == null || this.btnRoomName == null) { return; } ////刷新显示 this.btnDeviceName.Text = this.device.name; this.btnRoomName.Text = this.device.GetRoomListName(); this.topView.topNameBtn.Text = this.device.name; this.btnCurrDeviceName.Text = this.device.name; this.btnCurrDeviceRoom.Text= this.device.GetRoomListName(); ////从新计算宽度 //this.btnDeviceName.Text = btnDeviceName.Text; //this.btnDeviceName.Width = this.btnDeviceName.GetTextWidth(); //this.btnRoomName.Text = btnRoomName.Text; //this.btnRoomName.Width = this.btnRoomName.GetTextWidth(); ////回调事件 //this.SettionFinishEvent?.Invoke(); }); MainPage.BasePageView.AddChidren(infoView); infoView.LoadPage(); MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; }; //收藏 btnCollectIcon.MouseUpEventHandler += (sender, e) => { btnCollectIcon.IsSelected = this.device.collect = !btnCollectIcon.IsSelected; this.device.CollectFunction(); }; //实时视频 rtvFL.SetClickListener((fl, btnStateImage, btnStateText) => { }); //一键开锁 openFL.SetClickListener((fl, btnStateImage, btnStateText) => { }); //临时密码 pswFL.SetClickListener((fl, btnStateImage, btnStateText) => { }); //历史记录 recordFL.SetClickListener((fl, btnStateImage, btnStateText) => { }); } } /// /// 自己弄一个FrameLayout /// class CustomFrameLayout : FrameLayout { public const int widthFrameLayout = 74; public const int heightFrameLayout = 70; public const int yFrameLayout = 353; public const int xFrameLayout = 68; public const int interval = 47;//行中的列间隔值 public CustomFrameLayout(int width, int height, int x = 0, int y = 0) { this.Width = Application.GetRealWidth(width); this.Height = Application.GetRealHeight(height); this.X = Application.GetRealWidth(x); this.Y = Application.GetRealHeight(y); } Button btnStateImage = new Button { Width = Application.GetRealWidth(32), Height = Application.GetRealWidth(32), Gravity = Gravity.TopCenter, Name = "btnStateImage", }; Button btnStateText = new Button { Y = Application.GetRealHeight(4), Width = Application.GetRealWidth(100), Height = Application.GetRealWidth(20), TextID = StringId.dangqianmenweiguan, TextSize = TextSize.Text12, TextColor = MusicColor.TextCancelColor, TextAlignment=TextAlignment.Center, Gravity = Gravity.CenterHorizontal, Name = "btnStateText" }; public void AddImageView() { this.AddChidren(btnStateImage); } public void AddTextButtonView() { btnStateText.Y += btnStateImage.Bottom; this.AddChidren(btnStateText); } public Button GetImageButton() { //if (!this.AddWithout(this.btnStateImage)) //{ // this.AddImageView(); //} return this.btnStateImage; } public Button GetTextButton() { //if (!this.AddWithout(this.btnStateText)) //{ // this.AddTextButtonView(); //} return this.btnStateText; } /// /// 事件监听方法 /// /// 回调(第一个是父类对象;第二个是图标对象;第三个是状态对象 /// 注意:在SetClickListener()前面调用AddImageView()才有效 /// 注意:在SetClickListener()前面调用AddImageView()才有效 public void SetClickListener(Action action) { EventHandler click = (sender, e) => { if (action == null) { return; } action(this, btnStateImage, btnStateText); }; this.MouseUpEventHandler += click; btnStateImage.MouseUpEventHandler += click; btnStateText.MouseUpEventHandler += click; } /// /// 在父布局查找子控件是否存在 /// /// 查找对象 /// 存在为true,否则为false private bool AddWithout(View btn) { if (this.ChildrenCount <= 0 || btn == null) { return false; } for (int i = 0; i < this.ChildrenCount; i++) { View view = this.GetChildren(i); if (view == null) { continue; } if (view is Button) { if (view.Name == btn.Name) { return true; } } } return false; } } /// /// 表示来自那个界面 /// public enum Comerom { function,//功能 collect,//收藏 room,//房间 } }