using Shared;
|
using HDL_ON.UI.CSS;
|
using HDL_ON.Stan;
|
using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using HDL_ON.Entity;
|
|
namespace HDL_ON.UI
|
{
|
/// <summary>
|
/// 门锁常开自动化列表界面
|
/// </summary>
|
public class DoorLockAlwaysOnListPage : EditorCommonForm
|
{
|
#region ■ 变量声明___________________________
|
|
/// <summary>
|
/// 上部Frame的容器控件
|
/// </summary>
|
private FrameLayout frameTopBack = null;
|
/// <summary>
|
/// 下部Frame的容器控件
|
/// </summary>
|
private FrameLayout frameBottomBack = null;
|
/// <summary>
|
/// 自动化列表控件
|
/// </summary>
|
private VerticalListControl listView = null;
|
/// <summary>
|
/// 门锁信息
|
/// </summary>
|
private DoorLockAlwayOnInfo doorLockInfo = new DoorLockAlwayOnInfo();
|
/// <summary>
|
/// 门锁对象
|
/// </summary>
|
private Function doorDevice = null;
|
|
#endregion
|
|
#region ■ 初始化_____________________________
|
|
/// <summary>
|
/// 画面显示(底层会固定调用此方法,借以完成画面创建)
|
/// </summary>
|
/// <param name="i_doorDevice">门锁对象</param>
|
public void ShowForm(Function i_doorDevice)
|
{
|
this.doorDevice = i_doorDevice;
|
|
//常开
|
base.SetTitleText(Language.StringByID(StringId.AlwaysOn));
|
|
//初始化中部信息
|
this.InitMiddleFrame();
|
}
|
|
/// <summary>
|
/// 初始化中部信息
|
/// </summary>
|
private void InitMiddleFrame()
|
{
|
//清空bodyFrame
|
this.ClearBodyFrame();
|
|
//初始化上部控件
|
this.InitTopTopBackControl();
|
|
//初始化下部控件
|
this.InitBottomBackControl();
|
}
|
|
#endregion
|
|
#region ■ 初始化上部控件_____________________
|
|
/// <summary>
|
/// 初始化上部控件
|
/// </summary>
|
private void InitTopTopBackControl()
|
{
|
if (this.frameTopBack == null || this.frameTopBack.Parent == null)
|
{
|
this.frameTopBack = new FrameLayout();
|
frameTopBack.BackgroundColor = CSS_Color.MainBackgroundColor;
|
bodyFrameLayout.AddChidren(frameTopBack);
|
}
|
else
|
{
|
this.frameTopBack.RemoveAll();
|
}
|
|
//如果不处于常开模式
|
if (this.doorLockInfo.IsAlwayOpen == false)
|
{
|
//锁的图片
|
var btnPic = new PicViewControl(102, 102);
|
btnPic.Y = Application.GetRealHeight(28);
|
btnPic.Gravity = Gravity.CenterHorizontal;
|
btnPic.UnSelectedImagePath = "FunctionIcon/DoorLock/UnLockPictrue2.png";
|
this.frameTopBack.AddChidren(btnPic);
|
btnPic.ButtonClickEvent += (sender, e) =>
|
{
|
this.doorLockInfo.IsAlwayOpen = true;
|
//重新初始化上部控件
|
this.InitTopTopBackControl();
|
};
|
|
//时效性常开设置
|
var rowSettion = new FrameRowControl();
|
rowSettion.Y = btnPic.Bottom + Application.GetRealHeight(32);
|
this.frameTopBack.AddChidren(rowSettion);
|
rowSettion.AddLeftCaption(Language.StringByID(StringId.TimelyAlwaysOnSetting), 350);
|
rowSettion.AddRightArrow();
|
rowSettion.AddBottomLine();
|
rowSettion.ButtonClickEvent += (sender, e) =>
|
{
|
//设置常开模式后{0}您的门锁将处于打开状态{0}是否继续开启
|
HdlMessageLogic.Current.ShowMassage(ShowMsgType.Confirm, Language.StringByID(StringId.OpenAlwayOnConfirmMsg), () =>
|
{
|
var form = new DoorLockExpireTimeSettionPage();
|
form.ShowForm();
|
form.FinishEvent += (hour) =>
|
{
|
//已开启
|
//HdlMessageLogic.Current.ShowMassage(ShowMsgType.ConfirmSuccess, Language.StringByID(StringId.AlreadyOpened), () =>
|
//{
|
|
//});
|
//常开模式关闭设置失效,请重试
|
HdlMessageLogic.Current.ShowMassage(ShowMsgType.ConfirmFail, Language.StringByID(StringId.AlwayOnFailTimeSettionFailMsg), () =>
|
{
|
});
|
};
|
|
}, Language.StringByID(StringId.ConfirmOpen));
|
};
|
|
//变更容器高度
|
this.frameTopBack.Height = rowSettion.Bottom + Application.GetRealHeight(12);
|
}
|
//如果处于常开模式
|
else
|
{
|
//锁的图片
|
var btnPic = new PicViewControl(102, 102);
|
btnPic.Y = Application.GetRealHeight(28);
|
btnPic.Gravity = Gravity.CenterHorizontal;
|
btnPic.UnSelectedImagePath = "FunctionIcon/DoorLock/UnLockPictrue1.png";
|
this.frameTopBack.AddChidren(btnPic);
|
|
//关闭按钮
|
var btnClose = new BottomClickButton(220);
|
btnClose.Y = btnPic.Bottom + Application.GetRealHeight(28);
|
btnClose.TextID = StringId.Close;
|
this.frameTopBack.AddChidren(btnClose);
|
btnClose.ButtonClickEvent += (sender, e) =>
|
{
|
this.doorLockInfo.IsAlwayOpen = false;
|
//重新初始化上部控件
|
this.InitTopTopBackControl();
|
};
|
|
//常开模式将于{12.31 14:59}关闭
|
var listMsg = Language.StringByID(StringId.AlwaysOnWillCloseOnTime).Split(new string[] { "{0}" }, StringSplitOptions.None);
|
int widthCount = 0;
|
//常开模式将于
|
var btnMsg1 = new NormalViewControl(100, 20, true);
|
btnMsg1.Y = btnClose.Bottom + Application.GetRealHeight(32);
|
btnMsg1.TextColor = CSS_Color.FirstLevelTitleColor;
|
btnMsg1.Text = listMsg[0];
|
btnMsg1.Width = btnMsg1.GetRealWidthByText();
|
this.frameTopBack.AddChidren(btnMsg1);
|
widthCount += btnMsg1.Width;
|
//时间(12.31 14:59)
|
var startTime = this.doorLockInfo.StartTime.AddHours(this.doorLockInfo.AlwayOpenHour);
|
var btnMsgTime = new NormalViewControl(100, 20, true);
|
btnMsgTime.Y = btnMsg1.Y;
|
btnMsgTime.TextColor = CSS_Color.AuxiliaryColor2;
|
btnMsgTime.Text = HdlCommonLogic.Current.ConvertDayText(startTime.Month, startTime.Day, startTime.Year) + " " + startTime.ToString("HH:mm");
|
btnMsgTime.Width = btnMsgTime.GetRealWidthByText();
|
this.frameTopBack.AddChidren(btnMsgTime);
|
widthCount += btnMsgTime.Width;
|
|
NormalViewControl btnMsg2 = null;
|
if (listMsg.Length > 1)
|
{
|
//关闭
|
btnMsg2 = new NormalViewControl(100, 20, true);
|
btnMsg2.Y = btnMsg1.Y;
|
btnMsg2.TextColor = CSS_Color.FirstLevelTitleColor;
|
btnMsg2.Text = listMsg[1];
|
btnMsg2.Width = btnMsg2.GetRealWidthByText();
|
this.frameTopBack.AddChidren(btnMsg2);
|
widthCount += btnMsg2.Width;
|
}
|
//让这三个东西居中
|
int defultXX = (this.frameTopBack.Width - widthCount) / 2;
|
btnMsg1.X = defultXX;
|
btnMsgTime.X = btnMsg1.Right;
|
if (btnMsg2 != null)
|
{
|
btnMsg2.X = btnMsgTime.Right;
|
}
|
|
//变更容器高度
|
this.frameTopBack.Height = btnMsgTime.Bottom + Application.GetRealHeight(16);
|
}
|
//刷新下部Frame控件的坐标和高度
|
this.RefreshBottomFrameHeightAndLocation();
|
}
|
|
#endregion
|
|
#region ■ 初始化下部控件_____________________
|
|
/// <summary>
|
/// 初始化下部控件
|
/// </summary>
|
private void InitBottomBackControl()
|
{
|
if (this.frameBottomBack == null || this.frameBottomBack.Parent == null)
|
{
|
this.frameBottomBack = new FrameLayout();
|
frameBottomBack.BackgroundColor = CSS_Color.MainBackgroundColor;
|
bodyFrameLayout.AddChidren(frameBottomBack);
|
//常开自动化
|
var rowSettion = new FrameRowControl();
|
rowSettion.Y = Application.GetRealHeight(6);
|
frameBottomBack.AddChidren(rowSettion);
|
var btnCation = rowSettion.AddLeftCaption(Language.StringByID(StringId.AutomationAlwaysOn), 300);
|
btnCation.TextSize = CSS_FontSize.SubheadingFontSize;
|
btnCation.TextColor = CSS_Color.FirstLevelTitleColor;
|
btnCation.IsBold = true;
|
//添加图标
|
var btnAddIcon = rowSettion.AddMostRightEmptyIcon(38, 38);
|
btnAddIcon.UnSelectedImagePath = "Public/AddIcon.png";
|
btnAddIcon.ButtonClickEvent += (sender, e) =>
|
{
|
var form = new DoorLockAlwaysOnManagerPage();
|
form.AddForm(new object[] { null });
|
};
|
|
//列表控件
|
this.listView = new VerticalListControl();
|
frameBottomBack.AddChidren(listView);
|
}
|
else
|
{
|
this.frameBottomBack.RemoveAll();
|
this.listView.RemoveAll();
|
}
|
//刷新下部Frame控件的坐标和高度
|
this.RefreshBottomFrameHeightAndLocation();
|
|
//测试
|
for (int i = 0; i < 2; i++)
|
{
|
//添加自动化条件控件
|
this.AddAutomationControl(new AlwayOnAutomationInfo());
|
}
|
}
|
|
#endregion
|
|
#region ■ 添加自动化条件控件_________________
|
|
/// <summary>
|
/// 添加自动化条件控件
|
/// </summary>
|
/// <param name="i_info">自动化信息</param>
|
private void AddAutomationControl(AlwayOnAutomationInfo i_info)
|
{
|
//容器控件
|
var rowBack = new RowLayout();
|
rowBack.LineColor = CSS_Color.viewTranslucence;
|
rowBack.SubViewWidth = Application.GetRealWidth(80);
|
rowBack.Height = Application.GetRealHeight(100);
|
this.listView.AddChidren(rowBack);
|
|
//消息
|
var btnMsg = new NormalViewControl(rowBack.Width - HdlControlResourse.XXLeft * 2, Application.GetRealHeight(20), false);
|
btnMsg.X = HdlControlResourse.XXLeft;
|
btnMsg.Y = Application.GetRealHeight(10);
|
btnMsg.TextColor = CSS_Color.FirstLevelTitleColor;
|
if (i_info.IsOpenAlwayOn == true)
|
{
|
//9:00 - 打开常开模式
|
btnMsg.Text = i_info.Hour + ":" + i_info.Minute.ToString().PadLeft(2, '0') + " - " + Language.StringByID(StringId.OpenAlwaysOnModel);
|
}
|
else
|
{
|
//9:00 - 关闭常开模式
|
btnMsg.Text = i_info.Hour + ":" + i_info.Minute.ToString().PadLeft(2, '0') + " - " + Language.StringByID(StringId.CloseAlwaysOnModel);
|
}
|
rowBack.AddChidren(btnMsg);
|
|
//周期
|
var btnTimeLoop = new NormalViewControl(rowBack.Width - HdlControlResourse.XXLeft * 2, Application.GetRealHeight(18), false);
|
btnTimeLoop.X = btnMsg.X;
|
btnTimeLoop.Y = btnMsg.Bottom + Application.GetRealHeight(4);
|
btnTimeLoop.TextSize = CSS_FontSize.PromptFontSize_FirstLevel;
|
btnTimeLoop.TextColor = CSS_Color.PromptingColor1;
|
btnTimeLoop.Text = "周一 - 周五";
|
rowBack.AddChidren(btnTimeLoop);
|
|
//图标行控件
|
var rowIcon = new FrameRowControl();
|
rowIcon.Gravity = Gravity.BottomCenter;
|
rowBack.AddChidren(rowIcon);
|
|
//先画底线
|
rowIcon.AddBottomLine();
|
|
//固定的三个图标
|
var btnIcon1 = rowIcon.AddLeftIcon(28, "Phone/LogicIcon/selectTheTime.png");
|
var btnIcon2 = rowIcon.AddLeftIcon(20, "Phone/LogicIcon/link.png");
|
btnIcon2.X = btnIcon1.Right + Application.GetRealWidth(8);
|
var btnIcon3 = rowIcon.AddLeftIcon(28, "FunctionIcon/DoorLock/NormallyOpenIcon3.png");
|
btnIcon3.X = btnIcon2.Right + Application.GetRealWidth(8);
|
|
//开关
|
var btnSwitch = rowIcon.AddMostRightSwitchIcon();
|
btnSwitch.ButtonClickEvent += (sender, e) =>
|
{
|
btnSwitch.IsSelected = !btnSwitch.IsSelected;
|
};
|
|
//编辑
|
var btnEditor = new NormalViewControl(rowBack.SubViewWidth, rowBack.Height, false);
|
btnEditor.TextAlignment = TextAlignment.Center;
|
btnEditor.TextSize = CSS_FontSize.SubheadingFontSize;
|
btnEditor.TextColor = CSS_Color.MainBackgroundColor;
|
btnEditor.BackgroundColor = CSS_Color.AuxiliaryColor1;
|
btnEditor.TextID = StringId.Edit;
|
rowBack.AddRightView(btnEditor);
|
btnEditor.ButtonClickEvent += (sender, e) =>
|
{
|
//还原
|
rowBack.HideRightMenu();
|
var form = new DoorLockAlwaysOnManagerPage();
|
form.AddForm(new object[] { i_info });
|
};
|
//删除
|
var btnDelete = new NormalViewControl(rowBack.SubViewWidth, rowBack.Height, false);
|
btnDelete.TextAlignment = TextAlignment.Center;
|
btnDelete.TextSize = CSS_FontSize.SubheadingFontSize;
|
btnDelete.TextColor = CSS_Color.MainBackgroundColor;
|
btnDelete.BackgroundColor = CSS_Color.AuxiliaryColor2;
|
btnDelete.TextID = StringId.Del;
|
rowBack.AddRightView(btnDelete);
|
btnDelete.ButtonClickEvent += (sender, e) =>
|
{
|
//是否要删除自动化?
|
HdlMessageLogic.Current.ShowMassage(ShowMsgType.Confirm, Language.StringByID(StringId.delAutomation), () =>
|
{
|
rowBack.RemoveFromParent();
|
});
|
};
|
}
|
|
#endregion
|
|
#region ■ 一般方法___________________________
|
|
/// <summary>
|
/// 刷新下部Frame控件的坐标和高度
|
/// </summary>
|
private void RefreshBottomFrameHeightAndLocation()
|
{
|
if (this.frameBottomBack != null)
|
{
|
this.frameBottomBack.Y = this.frameTopBack.Bottom + Application.GetRealHeight(8);
|
this.frameBottomBack.Height = bodyFrameLayout.Height - this.frameBottomBack.Y;
|
}
|
if (this.listView != null)
|
{
|
//这个Y轴固定
|
this.listView.Y = Application.GetRealHeight(58);
|
this.listView.Height = this.frameBottomBack.Height - this.listView.Y;
|
}
|
}
|
|
#endregion
|
|
#region ■ 界面关闭___________________________
|
|
/// <summary>
|
/// 界面关闭
|
/// </summary>
|
public override void CloseFormBefore()
|
{
|
base.CloseFormBefore();
|
}
|
|
#endregion
|
}
|
}
|