using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using ZigBee.Device;
|
|
namespace Shared.Phone.UserCenter
|
{
|
/// <summary>
|
/// 晾衣架时间设置的控件
|
/// </summary>
|
public class AiererTimeControl : AirerTimeBaseLayout
|
{
|
#region ■ 变量声明___________________________
|
|
/// <summary>
|
/// 选择时间的事件
|
/// int总秒 int类型
|
/// </summary>
|
public Action<int, int> SelectTimeEvent = null;
|
/// <summary>
|
/// 选择时间的事件
|
/// int时间 int类型【1:烘干,2:风干;3:消毒】
|
/// </summary>
|
public Action<int, int> DetailCardActionTimeEvent = null;
|
/// <summary>
|
/// 显示文本
|
/// </summary>
|
private NormalViewControl btnTextView = null;
|
|
#endregion
|
|
#region ■ 初始化_____________________________
|
|
/// <summary>
|
/// 晾衣架时间设置的控件
|
/// </summary>
|
/// <param name="i_ChidrenYaxis">子控件Y轴偏移量(【列表控件的rowSpace/2】即可,不懂默认为0即可)</param>
|
public AiererTimeControl(int i_ChidrenYaxis = 0) : base(i_ChidrenYaxis)
|
{
|
}
|
|
/// <summary>
|
/// 初始化控件
|
/// </summary>
|
/// <param name="i_caption">标题文本</param>
|
/// <param name="i_text">文本显示</param>
|
/// <param name="type">晾衣架时间 :1烘干,2:风干;3消毒</param>
|
public void InitControl(Airer airer, NormalFrameLayout bodyFrameLayout, string i_caption, string i_text, int type)
|
{
|
//标题
|
var btnCaption = new NormalViewControl(270, 58, true);
|
btnCaption.X = ControlCommonResourse.XXLeft;
|
btnCaption.Gravity = Gravity.CenterVertical;
|
btnCaption.Text = i_caption + ":";
|
this.AddChidren(btnCaption, ChidrenBindMode.BindEvent);
|
|
//显示框
|
this.btnTextView = new NormalViewControl(700, true);
|
btnTextView.X = Application.GetRealWidth(294);
|
btnTextView.Gravity = Gravity.CenterVertical;
|
btnTextView.TextColor = UserCenterColor.Current.TextGrayColor1;
|
btnTextView.Text = i_text;
|
this.AddChidren(btnTextView, ChidrenBindMode.BindEvent);
|
|
if (chidrenYaxis != 0)
|
{
|
btnCaption.Y += chidrenYaxis;
|
btnTextView.Y += chidrenYaxis;
|
}
|
|
//右箭头 {烘干、风干和消毒的设置默认时间暂时取去掉,且倒计时也去掉,因为第三方设备不支持」
|
//默认最大3小时,所以下次要处理时为3,分钟不能操作大情况
|
//this.AddRightArrow();
|
|
//如果当前不是展示模板,则需要处理
|
//if (Common.Config.Instance.Home.IsShowTemplate == false)
|
//{
|
// this.ButtonClickEvent += (sender, e) =>
|
// {
|
//区域选择
|
//SelectTimeEvent = (min, curType) =>
|
//{
|
// switch (curType)
|
// {
|
// case 1:
|
// case 2:
|
// double result = min / 60.0;
|
// var hour = Math.Round(result, 2);
|
// var text = hour + Language.StringByID(R.MyInternationalizationString.AirerHour);
|
|
// if (min == 0)
|
// {
|
// text = Language.StringByID(R.MyInternationalizationString.AirerDefault) + 3 + Language.StringByID(R.MyInternationalizationString.AirerHour);
|
// }
|
// btnTextView.Text = text;
|
|
// break;
|
// case 3:
|
// int result2 = min;
|
// var text2 = result2 + Language.StringByID(R.MyInternationalizationString.AirerMin);
|
|
// if (min == 0)
|
// {
|
// text2 = Language.StringByID(R.MyInternationalizationString.AirerDefault) + 30 + Language.StringByID(R.MyInternationalizationString.AirerMin);
|
// }
|
// btnTextView.Text = text2;
|
// break;
|
// }
|
//};
|
//this.ShowSelectTime(airer, bodyFrameLayout, btnTextView, i_caption, type);
|
// };
|
//}
|
}
|
|
#endregion
|
|
#region ■ 时间选择___________________________
|
|
/// <summary>
|
/// 区域选择
|
/// </summary>
|
/// <param name="txtView"></param>
|
/// <param name="i_caption"></param>
|
/// <param name="type">晾衣架时间 :1烘干,2:风干;3消毒</param>
|
private void ShowSelectTime(Airer airer, NormalFrameLayout bodyFrameLayout, NormalViewControl txtView, string i_caption, int type)
|
{
|
bodyFrameLayout.AddChidren(this.shadowRadiusFrameLayout);
|
this.bottomRadiusFrameLayout.RemoveAll();
|
this.BottomRadiusFrameLayout(this);
|
this.btnBottomTitle.Text = i_caption;
|
var mUIPickerView = new UIPickerView()
|
{
|
X = Application.GetRealWidth(0),
|
Height = Application.GetRealHeight(440 - 140),
|
};
|
this.bottomRadiusFrameLayout.AddChidren(mUIPickerView);
|
mUIPickerView.Y = Application.GetRealWidth(207);
|
//小时列表名字
|
var listHourName = new List<string>();
|
//分钟名字
|
var listMinName = new List<string>();
|
int curH = 0;
|
int curM = 0;
|
if (type == 3)
|
{
|
curM = 1;
|
//名字和键收集
|
for (int i = 1; i < 31; i++)
|
{
|
listMinName.Add(i.ToString() + Language.StringByID(R.MyInternationalizationString.AirerMin));
|
}
|
mUIPickerView.setNPicker(listMinName, null, null);
|
mUIPickerView.setCurrentItems(curH, 0, 0);
|
mUIPickerView.OnSelectChangeEvent += (v1, v2, v3) =>
|
{
|
curM = v1 + 1;
|
};
|
}
|
else
|
{
|
//名字和键收集
|
for (int i = 0; i < 4; i++)
|
{
|
listHourName.Add(i.ToString() + Language.StringByID(R.MyInternationalizationString.AirerHour));
|
}
|
for (int i = 0; i < 60; i++)
|
{
|
listMinName.Add(i.ToString() + Language.StringByID(R.MyInternationalizationString.AirerMin));
|
}
|
mUIPickerView.setNPicker(listHourName, listMinName, null);
|
mUIPickerView.setCurrentItems(curH, curM, 0);
|
mUIPickerView.OnSelectChangeEvent += (h, m, s) =>
|
{
|
curH = h;
|
curM = m;
|
};
|
}
|
this.btnCancel.MouseUpEventHandler = (sender1, e1) =>
|
{
|
this.shadowRadiusFrameLayout.RemoveFromParent();
|
};
|
this.btnFinish.MouseUpEventHandler = async (sender1, e1) =>
|
{
|
int totalMin = 0;
|
switch (type)
|
{
|
case 1:
|
airer.DryTime = curH * 60 + curM;
|
airer.DryRemainTime = airer.DryTime * 60;
|
totalMin = airer.DryTime;
|
airer.SetAirerFunTimeDevice(airer.DryTime, 4);
|
this.DetailCardActionTimeEvent?.Invoke(airer.DryRemainTime, type);
|
break;
|
case 2:
|
airer.WindTime = curH * 60 + curM;
|
airer.WindRemainTime = airer.WindTime * 60;
|
totalMin = airer.WindTime;
|
airer.SetAirerFunTimeDevice(airer.WindTime, 3);
|
this.DetailCardActionTimeEvent?.Invoke(airer.WindRemainTime, type);
|
break;
|
case 3:
|
airer.DisinfectTime = curM;
|
airer.DisinfectRemainTime = airer.DisinfectTime * 60;
|
totalMin = airer.DisinfectTime;
|
airer.SetAirerFunTimeDevice(airer.DisinfectTime, 5);
|
this.DetailCardActionTimeEvent?.Invoke(airer.DisinfectRemainTime, type);
|
break;
|
}
|
//成功后更新外面文本
|
this.SelectTimeEvent?.Invoke(totalMin, type);
|
this.SelectTimeEvent = null;
|
|
this.shadowRadiusFrameLayout.RemoveFromParent();
|
};
|
this.shadowRadiusFrameLayout.MouseUpEventHandler += (sender1, e1) =>
|
{
|
this.shadowRadiusFrameLayout.RemoveFromParent();
|
};
|
}
|
#endregion
|
#region ■ 控件摧毁___________________________
|
|
/// <summary>
|
/// 控件摧毁
|
/// </summary>
|
public override void RemoveFromParent()
|
{
|
this.SelectTimeEvent = null;
|
|
base.RemoveFromParent();
|
}
|
|
#endregion
|
}
|
}
|