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
|
{
|
/// <summary>
|
/// 视频门锁的控制界面
|
/// </summary>
|
public class VideoDoorLockPage : FrameLayout
|
{
|
#region ■ 变量声明___________________________
|
/// <summary>
|
/// 设备
|
/// </summary>
|
private Function device;
|
/// <summary>
|
/// 上一级界面的设备名字控件
|
/// </summary>
|
private Button btnDeviceName;
|
/// <summary>
|
/// 上一级界面的房间名字控件
|
/// </summary>
|
private Button btnRoomName;
|
/// <summary>
|
/// 头部布局
|
/// </summary>
|
private TopView topView;
|
/// <summary>
|
///收藏图标
|
/// </summary>
|
private Button btnCollectIcon;
|
/// <summary>
|
/// 门锁状态
|
/// </summary>
|
private CustomFrameLayout doorLockFL;
|
/// <summary>
|
/// 实时视频
|
/// </summary>
|
private CustomFrameLayout rtvFL;
|
/// <summary>
|
/// 一键开锁
|
/// </summary>
|
private CustomFrameLayout openFL;
|
/// <summary>
|
/// 临时密码
|
/// </summary>
|
private CustomFrameLayout pswFL;
|
/// <summary>
|
/// 历史记录
|
/// </summary>
|
private CustomFrameLayout recordFL;
|
/// <summary>
|
/// 表示来自那个界面
|
/// </summary>
|
private Comerom Comerom;
|
#endregion
|
|
|
/// <summary>
|
/// 构造函数
|
/// </summary>
|
/// <param name="function">设备</param>
|
/// <param name="btnDeviceName">上一级界面的设备名字控件</param>
|
/// <param name="btnRoomName">上一级界面的房间名字控件</param>
|
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.Events();
|
|
|
}
|
/// <summary>
|
/// 初始化界面
|
/// </summary>
|
private void InitUI()
|
{
|
#region ---界面布局---
|
this.BackgroundColor = MusicColor.ViewColor;
|
this.topView = new TopView();
|
this.topView.setBtn.Visible = true;
|
this.topView.topNameBtn.Text = this.device.name;
|
this.AddChidren(topView.TopFLayoutView());
|
var middLayout = new FrameLayout
|
{
|
Y = topView.fLayout.Bottom,
|
Height = Application.GetRealHeight(H_W.H - H_W.T_Height),
|
};
|
this.AddChidren(middLayout);
|
btnCollectIcon = new Button
|
{
|
X = Application.GetRealWidth(273),
|
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"
|
};
|
middLayout.AddChidren(btnCollectIcon);
|
//门锁状态
|
doorLockFL = new CustomFrameLayout(CustomFrameLayout.widthFrameLayout, CustomFrameLayout.heightFrameLayout);
|
middLayout.AddChidren(doorLockFL);
|
doorLockFL.X = Application.GetRealWidth(40);
|
doorLockFL.Y = btnCollectIcon.Bottom + Application.GetRealHeight(20);
|
doorLockFL.AddImageView();
|
doorLockFL.AddTextButtonView();
|
doorLockFL.GetTextButton().TextID = StringId.shishishipin;
|
//实时视频
|
rtvFL = new CustomFrameLayout(CustomFrameLayout.widthFrameLayout, CustomFrameLayout.heightFrameLayout);
|
middLayout.AddChidren(rtvFL);
|
rtvFL.X = Application.GetRealWidth(20);
|
rtvFL.Y = Application.GetRealHeight(300);
|
rtvFL.AddImageView();
|
rtvFL.AddTextButtonView();
|
rtvFL.GetTextButton().TextID = StringId.shishishipin;
|
//一键开锁
|
openFL = new CustomFrameLayout(CustomFrameLayout.widthFrameLayout, CustomFrameLayout.heightFrameLayout);
|
middLayout.AddChidren(openFL);
|
openFL.X = rtvFL.Right + Application.GetRealWidth(20);
|
openFL.Y = Application.GetRealHeight(300);
|
openFL.AddImageView();
|
openFL.AddTextButtonView();
|
openFL.GetTextButton().TextID = StringId.yijiankaisuo;
|
//临时密码
|
pswFL = new CustomFrameLayout(CustomFrameLayout.widthFrameLayout, CustomFrameLayout.heightFrameLayout);
|
middLayout.AddChidren(pswFL);
|
pswFL.X = openFL.Right + Application.GetRealWidth(20);
|
pswFL.Y = Application.GetRealHeight(300);
|
pswFL.AddImageView();
|
pswFL.AddTextButtonView();
|
pswFL.GetTextButton().TextID = StringId.linshimima1;
|
//历史记录
|
recordFL = new CustomFrameLayout(CustomFrameLayout.widthFrameLayout, CustomFrameLayout.heightFrameLayout);
|
middLayout.AddChidren(recordFL);
|
recordFL.X = Application.GetRealWidth(20);
|
recordFL.Y = Application.GetRealHeight(300 + 100);
|
recordFL.AddImageView();
|
recordFL.AddTextButtonView();
|
recordFL.GetTextButton().TextID = StringId.lishijilu;
|
#endregion
|
|
}
|
/// <summary>
|
/// 注册事件
|
/// </summary>
|
private void Events()
|
{
|
//返回
|
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.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) => { });
|
|
|
}
|
|
}
|
/// <summary>
|
/// 自己弄一个FrameLayout
|
/// </summary>
|
class CustomFrameLayout : FrameLayout
|
{
|
public const int widthFrameLayout = 100;
|
public const int heightFrameLayout = 80;
|
public const int yFrameLayout = 300;
|
public const int xFrameLayout = 20;
|
public const int interval = 20;//行中的列间隔值
|
|
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(40),
|
Height = Application.GetRealWidth(40),
|
UnSelectedImagePath = "MusicIcon/collect.png",
|
SelectedImagePath = "MusicIcon/collectSelected.png",
|
Gravity = Gravity.CenterHorizontal,
|
Name = "btnStateImage",
|
|
};
|
Button btnStateText = new Button
|
{
|
Y = Application.GetRealHeight(20),
|
Width = Application.GetRealWidth(100),
|
Height = Application.GetRealWidth(20),
|
TextID = StringId.dangqianmenweiguan,
|
TextSize = TextSize.Text14,
|
TextColor = MusicColor.TextColor,
|
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;
|
}
|
|
/// <summary>
|
/// 事件监听方法
|
/// </summary>
|
/// <param name="action">回调(第一个是父类对象;第二个是图标对象;第三个是状态对象</param>
|
/// <param name="button1">注意:在SetClickListener()前面调用AddImageView()才有效</param>
|
/// <param name="button2">注意:在SetClickListener()前面调用AddImageView()才有效</param>
|
public void SetClickListener(Action<FrameLayout, Button, Button> action)
|
{
|
EventHandler<MouseEventArgs> click = (sender, e) =>
|
{
|
if (action == null)
|
{
|
return;
|
}
|
action(this, btnStateImage, btnStateText);
|
};
|
this.MouseUpEventHandler += click;
|
btnStateImage.MouseUpEventHandler += click;
|
btnStateText.MouseUpEventHandler += click;
|
|
}
|
|
|
|
/// <summary>
|
/// 在父布局查找子控件是否存在
|
/// </summary>
|
/// <param name="btn">查找对象</param>
|
/// <returns>存在为true,否则为false</returns>
|
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;
|
|
}
|
|
|
|
|
}
|
/// <summary>
|
/// 表示来自那个界面
|
/// </summary>
|
public enum Comerom
|
{
|
function,//功能
|
collect,//收藏
|
room,//房间
|
}
|
|
}
|