using Shared;
|
using HDL_ON.UI.CSS;
|
using System;
|
using System.Collections.Generic;
|
using System.Text;
|
|
namespace HDL_ON.Stan
|
{
|
/// <summary>
|
/// 底部时间选择控件
|
/// </summary>
|
public class BottomTimeSelectControl : BottomDialogCommon
|
{
|
#region ■ 变量声明___________________________
|
|
/// <summary>
|
/// 结束事件(0:点击了取消 1:点击了确定,第二,三参数为时和分)
|
/// </summary>
|
public Action<int, int, int> FinishEvent = null;
|
|
#endregion
|
|
#region ■ 初始化_____________________________
|
|
/// <summary>
|
/// 底部时间选择控件
|
/// </summary>
|
/// <param name="i_title">标题</param>
|
/// <param name="clickBackClose">点击背景时,是否关闭弹窗</param>
|
public BottomTimeSelectControl(string i_title = "", bool clickBackClose = true)
|
{
|
base.ClickBackClose = clickBackClose;
|
base.StrTitle = i_title;
|
}
|
|
/// <summary>
|
/// 初始化控件
|
/// </summary>
|
/// <param name="i_hour">默认选择时</param>
|
/// <param name="i_minute">默认选择分</param>
|
public void InitControl(int i_hour, int i_minute)
|
{
|
//已经初始化
|
if (base.btnCancel != null) { return; }
|
|
//初始化底层控件
|
var frameWhiteBack = base.InitBaseControl();
|
frameWhiteBack.Height = Application.GetRealHeight(297);
|
frameWhiteBack.Y = frameWhiteBack.Parent.Height - Application.GetRealHeight(297 + 20);
|
|
//选择的时与分
|
int selectHour = 0;
|
int selectMinute = 0;
|
|
//取消
|
base.btnCancel.ButtonClickEvent += (sender, e) =>
|
{
|
base.Close();
|
this.FinishEvent?.Invoke(0, 0, 0);
|
this.FinishEvent = null;
|
};
|
//确认
|
base.btnConfirm.ButtonClickEvent += (sender, e) =>
|
{
|
//有选择了才能点确认
|
if (selectHour != 0 || selectMinute != 0)
|
{
|
base.Close();
|
this.FinishEvent?.Invoke(1, selectHour, selectMinute);
|
this.FinishEvent = null;
|
}
|
};
|
|
//线
|
var btnLine = new NormalViewControl(frameWhiteBack.Width, HdlControlResourse.BottomLineHeight, false);
|
btnLine.BackgroundColor = CSS_Color.PromptingColor2;
|
btnLine.Y = btnCancel.Bottom;
|
frameWhiteBack.AddChidren(btnLine);
|
|
//时间控件
|
var pickerView = new UIPickerView();
|
//时
|
var strhour = Language.StringByID(StringId.h);
|
//分
|
var strMinute = Language.StringByID(StringId.m);
|
//XX时
|
var listHour = new List<string> { "00" + strhour };
|
//XX分
|
var listMinute = new List<string> { "00" + strMinute };
|
for (int i = 1; i <= 23; i++)
|
{
|
listHour.Add(i.ToString().PadLeft(2, '0') + strhour);
|
}
|
for (int i = 1; i <= 58; i++)
|
{
|
listMinute.Add(i.ToString().PadLeft(2, '0') + strMinute);
|
}
|
pickerView.Height = frameWhiteBack.Height - btnLine.Bottom;
|
pickerView.Width = frameWhiteBack.Width - Application.GetRealWidth(8) * 2;
|
pickerView.Y = btnLine.Bottom;
|
pickerView.Gravity = Gravity.CenterHorizontal;
|
frameWhiteBack.AddChidren(pickerView);
|
//默认索引
|
var index1 = listHour.IndexOf(i_hour.ToString().PadLeft(2, '0') + strhour);
|
if (index1 == -1) { index1 = 0; }
|
var index2 = listMinute.IndexOf(i_minute.ToString().PadLeft(2, '0') + strMinute);
|
if (index2 == -1) { index2 = 0; }
|
|
pickerView.setNPicker(listHour, listMinute, null);
|
pickerView.setCurrentItems(index1, index2, 0);
|
|
pickerView.OnSelectChangeEvent = (value1, value2, value3) =>
|
{
|
//更改索引
|
selectHour = Convert.ToInt32(listHour[value1].Substring(0, 2));
|
selectMinute = Convert.ToInt32(listMinute[value2].Substring(0, 2));
|
};
|
}
|
|
#endregion
|
|
#region ■ 一般方法___________________________
|
|
/// <summary>
|
/// 关闭界面
|
/// </summary>
|
public override void Close()
|
{
|
base.Close();
|
this.FinishEvent = null;
|
}
|
|
|
#endregion
|
}
|
}
|