using System;
using System.Collections.Generic;
using System.Text;
using ZigBee.Device;
namespace Shared.Phone.UserCenter.Safety
{
///
/// 灯光类的安防报警设置界面
///
public class LightAlarmSettionForm : EditorCommonForm
{
#region ■ 变量声明___________________________
///
/// 画面关闭事件
///
public Action> ActionFormClose = null;
///
/// 动作信息 1 开关/ 3亮度调节
///
private Dictionary dicTaskinfo = new Dictionary();
#endregion
#region ■ 初始化_____________________________
///
/// 画面显示(底层会固定调用此方法,借以完成画面创建)
///
///
///
public void ShowForm(CommonDevice device, List i_listTaskInfo)
{
UserView.HomePage.Instance.ScrollEnabled = false;
if (i_listTaskInfo != null)
{
foreach (var data in i_listTaskInfo)
{
//以防万一,剔除不合法数据
if (data.TaskType == 1 || data.TaskType == 3)
{
dicTaskinfo[data.TaskType] = data;
}
}
}
//设置头部信息
base.SetTitleText(Common.LocalDevice.Current.GetDeviceEpointName(device));
//初始化中部信息
this.InitMiddleFrame();
}
///
/// 初始化中部信息
///
private void InitMiddleFrame()
{
//清空bodyFrame
this.ClearBodyFrame();
var frameTemp = new FrameLayout();
frameTemp.Height = Application.GetRealHeight(6);
frameTemp.BackgroundColor = UserCenterColor.Current.White;
bodyFrameLayout.AddChidren(frameTemp);
var listView = new VerticalListControl(29);
listView.Y = frameTemp.Bottom;
listView.BackgroundColor = UserCenterColor.Current.White;
listView.Height = Application.GetRealHeight(700 - 256 + 46);
if (dicTaskinfo.ContainsKey(5) == true)
{
//展开百分比调节
listView.Height = Application.GetRealHeight(700);
}
bodyFrameLayout.AddChidren(listView);
//开
var btnOpenRow = new FrameRowControl(listView.rowSpace / 2);
listView.AddChidren(btnOpenRow);
//图标
var btnOpenIcon = btnOpenRow.AddLeftIcon(81);
btnOpenIcon.UnSelectedImagePath = "Item/OpenIcon.png";
//文字
var btnOpenView = btnOpenRow.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uSimpleOpen), 400);
btnOpenView.TextSize = 15;
//状态
var btnOpenStatu = btnOpenRow.AddMostRightEmptyIcon(58, 58);
if (dicTaskinfo.ContainsKey(1) == false || dicTaskinfo[1].Data1 != 1)
{
btnOpenStatu.Visible = false;
}
btnOpenStatu.UnSelectedImagePath = "Item/ItemSelected.png";
//底线
btnOpenRow.AddBottomLine();
//===========================================================================
//关
var btnCloseRow = new FrameRowControl(listView.rowSpace / 2);
listView.AddChidren(btnCloseRow);
//图标
var btnCloseIcon = btnCloseRow.AddLeftIcon(81);
btnCloseIcon.UnSelectedImagePath = "Item/CloseIcon.png";
//文字
var btnCloseView = btnCloseRow.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uSimpleClose), 400);
btnCloseView.TextSize = 15;
//状态
var btnCloseStatu = btnCloseRow.AddMostRightEmptyIcon(58, 58);
if (dicTaskinfo.ContainsKey(1) == false || dicTaskinfo[1].Data1 != 0)
{
btnCloseStatu.Visible = false;
}
btnCloseStatu.UnSelectedImagePath = "Item/ItemSelected.png";
//底线
btnCloseRow.AddBottomLine();
//===========================================================================
//百分比调节
var btnPersentRow = new FrameRowControl(listView.rowSpace / 2);
btnPersentRow.UseClickStatu = false;
listView.AddChidren(btnPersentRow);
//图标
var btnPersentIcon = btnPersentRow.AddLeftIcon(81);
btnPersentIcon.UnSelectedImagePath = "Item/PersentIcon.png";
//文字
var btnPersentView = btnPersentRow.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uPersentAdjust), 400);
btnPersentView.TextSize = 15;
//右图标
var btnPersentRight = btnPersentRow.AddMostRightEmptyIcon(58, 58);
btnPersentRight.UnSelectedImagePath = "Item/Next.png";
btnPersentRight.SelectedImagePath = "Item/Down.png";
if (dicTaskinfo.ContainsKey(3) == true)
{
//展开百分比调节
btnPersentRight.IsSelected = true;
}
//===========================================================================
//进度条的背景容器
var frameProfra = new FrameLayout();
frameProfra.Height = Application.GetRealHeight(256);
listView.AddChidren(frameProfra);
//当前XX%
string persentText = Language.StringByID(R.MyInternationalizationString.uNow1);
var nowProValue = 0;
if (dicTaskinfo.ContainsKey(3) == true)
{
//3:亮度调节
nowProValue = dicTaskinfo[3].Data1;
}
var btnPersentValue = new NormalViewControl(400, 49, true);
btnPersentValue.Text = persentText + nowProValue + "%";
btnPersentValue.X = btnPersentView.X;
btnPersentValue.Y = Application.GetRealHeight(35);
btnPersentValue.TextColor = UserCenterColor.Current.TextGrayColor2;
btnPersentValue.TextSize = 12;
frameProfra.AddChidren(btnPersentValue);
//进度条
var seekBar = new HorizontalSeekBar();
seekBar.X = btnPersentValue.X;
seekBar.Y = btnPersentValue.Bottom + Application.GetRealHeight(46);
seekBar.Width = Application.GetRealWidth(850);
seekBar.Height = Application.GetRealHeight(60);
seekBar.Max = 100;
seekBar.BackgroundColor = 0xfff5f5f5;
seekBar.ThumbColor = Common.ZigbeeColor.Current.GXCButtonBlueColor;
seekBar.ProgressColor = 0xff232323;
seekBar.Progress = nowProValue;
frameProfra.AddChidren(seekBar);
seekBar.ProgressChanged += (sender, value) =>
{
nowProValue = value;
btnPersentValue.Text = persentText + value + "%";
};
//百分比调节点击
btnPersentRow.ButtonClickEvent += (sender, e) =>
{
btnPersentRight.IsSelected = !btnPersentRight.IsSelected;
if (btnPersentRight.IsSelected == true)
{
listView.Height += frameProfra.Height - Application.GetRealHeight(23);
}
else
{
listView.Height -= frameProfra.Height - Application.GetRealHeight(23);
}
};
//开
btnOpenRow.ButtonClickEvent += (sender, e) =>
{
if (btnOpenStatu.Visible == true)
{
//取消
dicTaskinfo.Remove(1);
btnOpenStatu.Visible = false;
}
else
{
//添加
btnOpenStatu.Visible = true;
btnCloseStatu.Visible = false;
dicTaskinfo[1] = new Safeguard.TaskListInfo();
dicTaskinfo[1].TaskType = 1;
dicTaskinfo[1].Data1 = 1;
}
};
//关
btnCloseRow.ButtonClickEvent += (sender, e) =>
{
if (btnCloseStatu.Visible == true)
{
//取消
dicTaskinfo.Remove(1);
}
else
{
//添加
btnOpenStatu.Visible = false;
btnCloseStatu.Visible = true;
dicTaskinfo[1] = new Safeguard.TaskListInfo();
dicTaskinfo[1].TaskType = 1;
dicTaskinfo[1].Data1 = 0;
}
};
//完成
var btnFinish = new BottomClickButton();
btnFinish.TextID = R.MyInternationalizationString.uFinish;
bodyFrameLayout.AddChidren(btnFinish);
btnFinish.ButtonClickEvent += (sender, e) =>
{
if (this.ActionFormClose != null)
{
if (btnPersentRight.IsSelected == false || seekBar.Progress == 0)
{
dicTaskinfo.Remove(3);
}
else
{
//百分比调节
dicTaskinfo[3] = new Safeguard.TaskListInfo();
dicTaskinfo[3].TaskType = 3;
dicTaskinfo[3].Data1 = seekBar.Progress;
}
var listData = new List();
foreach (var data in dicTaskinfo.Values)
{
listData.Add(data);
}
dicTaskinfo = null;
//获取状态的显示文本
string statuText = HdlSafeguardLogic.Current.GetLightAlarmStatuText(listData);
this.ActionFormClose(statuText, listData);
}
this.CloseForm();
};
}
#endregion
#region ■ 界面关闭___________________________
///
/// 界面关闭
///
public override void CloseForm()
{
UserView.HomePage.Instance.ScrollEnabled = true;
ActionFormClose = null;
base.CloseForm();
}
#endregion
}
}