using System;
using System.Collections.Generic;
using HDL_ON.UI.Music;
using HDL_ON.UI.UI2.FuntionControlView.Aks.CommonView;
using HDL_ON.UI.UI2.FuntionControlView.Aks.Entity;
using HDL_ON.UI.UI2.FuntionControlView.VideoDoorLock;
using Shared;
using static HDL_ON.UI.UI2.FuntionControlView.Aks.AksPage;
namespace HDL_ON.UI.UI2.FuntionControlView.Aks
{
///
/// 电视界面
///
public class TvPage : BaseFramLayout
{
///
///
///
/// 遥控器对象
/// 时序器列表
public TvPage(RemoteControlEntity remoteControlEntity, List sequencerList)
{
this.remoteControl = remoteControlEntity;
this.sequencerList = sequencerList;
}
///
/// 时序器列表
///
private List sequencerList;
///
/// 当前的遥控器对象
///
private RemoteControlEntity remoteControl;
public Action action;
///
/// 最上面功能键容器
///
CornerFramLayout cornerTopFram;
///
/// 数字按键容器
///
CornerFramLayout numberFrame;
///
/// 菜单容器
///
MenuFramLayout menuFram;
///
/// 切换设备容器
///
TypeMultiFramLayout typeMultiFramLayout;
TypeSingleFramLayout tvSingleFramLayout;
public void Show()
{
//初始化UI
this.InitUI();
//初始化事件监听器
this.EventListener();
//读取数据
this.ReadData();
}
private void ReadData()
{
}
///
/// 事件监听器
///
private void EventListener()
{
//功能键控制
cornerTopFram.selectKeyAction += (keypadEntity) =>
{
KeyControl(keypadEntity.keypad, keypadEntity.name, keypadEntity.isClicked);
};
//数字键控制
numberFrame.selectKeyAction += (keypadEntity) =>
{
KeyControl(keypadEntity.keypad, keypadEntity.name, keypadEntity.isClicked);
};
//菜单上按键
menuFram.SetTopClickListener((keypadEntity) =>
{
KeyControl(keypadEntity.keypad, keypadEntity.name, keypadEntity.isClicked);
});
//菜单下按键
menuFram.SetBottomClickListener((keypadEntity) =>
{
KeyControl(keypadEntity.keypad, keypadEntity.name, keypadEntity.isClicked);
});
//菜单左按键
menuFram.SetLeftClickListener((keypadEntity) =>
{
KeyControl(keypadEntity.keypad, keypadEntity.name, keypadEntity.isClicked);
});
//菜单右按键
menuFram.SetRightClickListener((keypadEntity) =>
{
KeyControl(keypadEntity.keypad, keypadEntity.name, keypadEntity.isClicked);
});
//菜单ok按键
menuFram.SetOkClickListener((keypadEntity) =>
{
KeyControl(keypadEntity.keypad, keypadEntity.name, keypadEntity.isClicked);
});
if (tvSingleFramLayout != null)
{
//设备切换
tvSingleFramLayout.SetClickListener((f) =>
{
action?.Invoke(IntType.TV);
});
}
if (typeMultiFramLayout != null)
{
//时序器
typeMultiFramLayout.SetLeftFlClickListener((f) =>
{
SxqPage sxqPage = new SxqPage(this.sequencerList, this.remoteControl.deviceId);
MainPage.BasePageView.AddChidren(sxqPage);
MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
sxqPage.Show();
});
//设备切换
typeMultiFramLayout.SetRightFlClickListener((f) =>
{
action?.Invoke(IntType.TV);
});
}
}
private void InitUI()
{
this.BackgroundColor = MusicColor.ViewColor;
Button btnTitle = new Button
{
Y = Application.GetRealHeight(16),
X = Application.GetRealWidth(16),
Height = Application.GetRealHeight(22),
Width = Application.GetRealWidth(200),
TextAlignment = TextAlignment.CenterLeft,
TextColor = MusicColor.TextColor,
TextSize = TextSize.Text16,
Text= this.remoteControl.name,
IsBold = true,
};
this.AddChidren(btnTitle);
cornerTopFram = new CornerFramLayout(343, 368-24, 17);
cornerTopFram.X = Application.GetRealWidth(16);
cornerTopFram.Y = btnTitle.Bottom + Application.GetRealHeight(16);
this.AddChidren(cornerTopFram);
cornerTopFram.SetMargin(16, 0, 16, 0);
cornerTopFram.LoadButtonPage(AksCommonMethod.Current.GetTvKeypadList(this.remoteControl),new List { 5, 6 });
#region ----频道 控制----
FrameLayout middLayout = new FrameLayout
{
Y = cornerTopFram.Bottom,
Height = Application.GetRealHeight(61),
};
this.AddChidren(middLayout);
FrameLayout leftLayout = new FrameLayout
{
X = Application.GetRealWidth(105),
Y = Application.GetRealHeight(16),
Height = Application.GetRealHeight(29),
Width = Application.GetRealWidth(32),
};
middLayout.AddChidren(leftLayout);
Button leftBtnTitle = new Button
{
Height = Application.GetRealHeight(22),
Width = leftLayout.Width,
TextAlignment = TextAlignment.Center,
TextColor = MusicColor.TextColor,
SelectedTextColor = MusicColor.MusicTxet14SelectedColor,
TextSize = TextSize.Text16,
TextID = StringId.pindao,
Padding = new Padding(0, 0, 0, 0),
IsBold = true,
};
leftLayout.AddChidren(leftBtnTitle);
Button leftBtnLine = new Button
{
Y = leftBtnTitle.Bottom + Application.GetRealHeight(4),
Height = Application.GetRealHeight(2),
Width = leftBtnTitle.GetTextWidth(),
BackgroundColor = MusicColor.TextColor,
SelectedBackgroundColor = MusicColor.MusicTxet14SelectedColor,
Gravity = Gravity.CenterHorizontal,
};
leftLayout.AddChidren(leftBtnLine);
//频道点击控件
FrameLayout clickLeftLayout = new FrameLayout
{
Height = leftLayout.Height,
Width = leftLayout.Width,
};
leftLayout.AddChidren(clickLeftLayout);
FrameLayout rightLayout = new FrameLayout
{
X = leftLayout.Right + Application.GetRealWidth(100),
Y = leftLayout.Y,
Height = leftLayout.Height,
Width = leftLayout.Width,
};
middLayout.AddChidren(rightLayout);
Button rightBtnTitle = new Button
{
Height = Application.GetRealHeight(22),
Width = rightLayout.Width,
TextAlignment = TextAlignment.Center,
TextColor = MusicColor.TextColor,
SelectedTextColor = MusicColor.MusicTxet14SelectedColor,
TextSize = TextSize.Text16,
TextID = StringId.kongzhi,
Padding = new Padding(0, 0, 0, 0),
IsBold = true,
};
rightLayout.AddChidren(rightBtnTitle);
Button rightBtnLine = new Button
{
Y = rightBtnTitle.Bottom + Application.GetRealHeight(4),
Height = Application.GetRealHeight(2),
Width = rightBtnTitle.GetTextWidth(),
BackgroundColor = MusicColor.TextColor,
SelectedBackgroundColor = MusicColor.MusicTxet14SelectedColor,
Gravity = Gravity.CenterHorizontal,
};
rightLayout.AddChidren(rightBtnLine);
//电视点击控件
FrameLayout clickRightLayout = new FrameLayout
{
Height = leftLayout.Height,
Width = leftLayout.Width,
};
rightLayout.AddChidren(clickRightLayout);
#endregion
//数字按键容器
numberFrame = new CornerFramLayout(343, 368-24, 17);
numberFrame.X = Application.GetRealWidth(16);
numberFrame.Y = middLayout.Bottom;
numberFrame.BackgroundColor = MusicColor.WhiteColor;
numberFrame.SetMargin(16,0,16,0);
numberFrame.LoadNumberButtonPage(AksCommonMethod.Current.GetNumberKeypadList(this.remoteControl));
this.AddChidren(numberFrame);
//菜单容器
CornerFramLayout cornerBottomFram = new CornerFramLayout(343, 292-30, 17);
cornerBottomFram.X = Application.GetRealWidth(16);
cornerBottomFram.Y = middLayout.Bottom;
cornerBottomFram.BackgroundColor = MusicColor.WhiteColor;
this.AddChidren(cornerBottomFram);
menuFram = new MenuFramLayout();
menuFram.Y = Application.GetRealHeight(24);
menuFram.AddView(cornerBottomFram);
if (sequencerList.Count == 0)
{
//没有时序器
tvSingleFramLayout = new TypeSingleFramLayout();
tvSingleFramLayout.AddView(cornerBottomFram);
tvSingleFramLayout.singleFramLayout.Y = menuFram.Bottom + Application.GetRealHeight(32);
tvSingleFramLayout.singleFramLayout.X = Application.GetRealWidth(226);
tvSingleFramLayout.singleFramLayout.Width = Application.GetRealWidth(101);
tvSingleFramLayout.btnName.Text = this.remoteControl.name;
tvSingleFramLayout.btnName.X = Application.GetRealWidth(16);
tvSingleFramLayout.btnName.Width = Application.GetRealWidth(48);
tvSingleFramLayout.btnRightImage.X = tvSingleFramLayout.btnName.Right + Application.GetRealWidth(8);
tvSingleFramLayout.btnRightImage.Width = Application.GetRealWidth(16);
tvSingleFramLayout.btnRightImage.Height = Application.GetRealWidth(16);
tvSingleFramLayout.btnRightImage.UnSelectedImagePath = "AksIcon/xuanze.png";
tvSingleFramLayout.btnRightImage.Gravity = Gravity.CenterVertical;
tvSingleFramLayout.btnLeftImage.Visible = false;
tvSingleFramLayout.CustomCalculationWidth(TypeSingleFramLayout.Orientation.right,
tvSingleFramLayout.singleFramLayout,
tvSingleFramLayout.btnName,
tvSingleFramLayout.btnRightImage,
48, 200);
}
else
{
typeMultiFramLayout = new TypeMultiFramLayout();
typeMultiFramLayout.multiFramLayout.Y = menuFram.Bottom + Application.GetRealHeight(32);
typeMultiFramLayout.AddView(cornerBottomFram);
typeMultiFramLayout.btnRightName.Text = this.remoteControl.name;
}
//初始值
leftBtnTitle.IsSelected = true;
leftBtnLine.IsSelected = true;
leftBtnLine.Visible = true;
rightBtnTitle.IsSelected = false;
rightBtnLine.IsSelected = false;
rightBtnLine.Visible = false;
numberFrame.Visible = true;
cornerBottomFram.Visible = false;
//频道点击事件
clickLeftLayout.MouseDownEventHandler += (sen, e) =>
{
leftBtnTitle.IsSelected = true;
leftBtnLine.IsSelected = true;
leftBtnLine.Visible = true;
rightBtnTitle.IsSelected = false;
rightBtnLine.IsSelected = false;
rightBtnLine.Visible = false;
numberFrame.Visible = true;
cornerBottomFram.Visible = false;
this.AdjustRealHeight(16);
};
//控制点击事件
clickRightLayout.MouseDownEventHandler += (sen, e) =>
{
leftBtnTitle.IsSelected = false;
leftBtnLine.IsSelected = false;
leftBtnLine.Visible = false;
rightBtnTitle.IsSelected = true;
rightBtnLine.IsSelected = true;
rightBtnLine.Visible = true;
numberFrame.Visible = false;
cornerBottomFram.Visible = true;
this.AdjustRealHeight(-60);
};
this.AdjustRealHeight(16);
}
///
/// 按键控制
///
/// <按键标识/param>
/// <按键名称(打印用的)/param>
/// <是否支持控制/param>
private void KeyControl(string keypad, string keyName,bool isSupport)
{
//CommonMethod.Current.Loading.Start();
CommonMethod.Current.SunThread(() =>
{
try
{
SendMethod.Current.KeypadExecute(remoteControl.deviceId, remoteControl.rcId, keypad, keyName, isSupport);
}
catch { }
finally
{
CommonMethod.Current.MainThread(() =>
{
//CommonMethod.Current.Loading.Hide();
});
}
});
}
}
}