| | |
| | | frameLayout.AddChidren(btnLine); |
| | | } |
| | | /// <summary> |
| | | /// 选中时间的方法 |
| | | /// 选中时间的方法(时,分) |
| | | /// </summary> |
| | | /// <param name="fLayout">父控件</param> |
| | | /// <param name="currState">之前状态值</param> |
| | |
| | | string hour = GethStringList()[index1].Split(' ')[0]; |
| | | string minuet = GetmStringList()[index2].Split(' ')[0]; |
| | | timepoint = hour + ":" + minuet; |
| | | }; |
| | | //确定点击事件 |
| | | btnConfirm.MouseUpEventHandler += (sender, e3) => |
| | | { |
| | | action(timepoint); |
| | | //移除fLayout界面 |
| | | fLayout.RemoveFromParent(); |
| | | |
| | | }; |
| | | } |
| | | /// <summary> |
| | | /// 选中时间的方法(时,分,秒) |
| | | /// </summary> |
| | | /// <param name="fLayout">父控件</param> |
| | | /// <param name="currState">之前状态值</param> |
| | | /// <param name="action">返回时间值</param> |
| | | public void Time(FrameLayout fLayout, string currState, Action<string> action) |
| | | { |
| | | //取消点击事件 |
| | | btnCancel.MouseUpEventHandler += (sender, e1) => |
| | | { |
| | | //移除fLayout界面 |
| | | fLayout.RemoveFromParent(); |
| | | }; |
| | | //加载数据界面的设置方法(列表互不联动) |
| | | mUIPickerView.setNPicker(GethStringList(), GetmStringList(), GetsStringList()); |
| | | var systemHour = DateTime.Now.Hour; //获取小时 |
| | | var systeMinute = DateTime.Now.Minute;//获取分钟 |
| | | var systeSecond = DateTime.Now.Second;//获取秒 |
| | | |
| | | int systemHourIndex = 0; |
| | | int systeMinuteIndex = 0; |
| | | int systeSecondIndex = 0; |
| | | for (int i = 0; i < GethIntList().Count; i++) |
| | | { |
| | | var currhour = GethIntList()[i]; |
| | | if (systemHour == currhour) |
| | | { |
| | | systemHourIndex = i; |
| | | break; |
| | | } |
| | | } |
| | | for (int i = 0; i < GetmIntList().Count; i++) |
| | | { |
| | | var currminute = GetmIntList()[i]; |
| | | if (systeMinute == currminute) |
| | | { |
| | | systeMinuteIndex = i; |
| | | break; |
| | | } |
| | | } |
| | | for (int i = 0; i < GetsIntList().Count; i++) |
| | | { |
| | | var currsecond= GetsIntList()[i]; |
| | | if (systeSecond == currsecond) |
| | | { |
| | | systeSecondIndex = i; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | //默认初始选中状态 |
| | | mUIPickerView.setCurrentItems(systemHourIndex, systeMinuteIndex, systeSecondIndex); |
| | | string currH = ""; |
| | | string currM = ""; |
| | | string currS = ""; |
| | | if (systemHour < 10) |
| | | { |
| | | currH = "0" + systemHour.ToString(); |
| | | } |
| | | else |
| | | { |
| | | currH = systemHour.ToString(); |
| | | } |
| | | if (systeMinute < 10) |
| | | { |
| | | currM = "0" + systeMinute.ToString(); |
| | | } |
| | | else |
| | | { |
| | | currM = systeMinute.ToString(); |
| | | } |
| | | if (systeSecond < 10) |
| | | { |
| | | currS = "0" + systeMinute.ToString(); |
| | | } |
| | | else |
| | | { |
| | | currS = systeMinute.ToString(); |
| | | } |
| | | //定义一个局部变量记录选中时间 |
| | | string timepoint = currH + ":" + currM + ":" + currS; |
| | | if (!string.IsNullOrEmpty(currState)) |
| | | { |
| | | int hIndex = GetValueIndex(currState, 0, 1, GethIntList()); |
| | | int mIndex = GetValueIndex(currState, 1, 0, GetmIntList()); |
| | | int sIndex = GetValueIndex(currState, 2, 0, GetsIntList()); |
| | | //更新初始状态 |
| | | mUIPickerView.setCurrentItems(hIndex, mIndex, sIndex); |
| | | timepoint = currState; |
| | | } |
| | | |
| | | |
| | | //选中时间回调方法,时间变化一次回调一次 |
| | | mUIPickerView.OnSelectChangeEvent += (index1, index2, index3) => |
| | | { |
| | | try |
| | | { |
| | | string hour = GethStringList()[index1].Split(' ')[0]; |
| | | string minuet = GetmStringList()[index2].Split(' ')[0]; |
| | | string second = GetmStringList()[index3].Split(' ')[0]; |
| | | timepoint = hour + ":" + minuet + ":" + second; |
| | | } |
| | | catch { } |
| | | }; |
| | | //确定点击事件 |
| | | btnConfirm.MouseUpEventHandler += (sender, e3) => |
| | |
| | | } |
| | | return mList; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取60秒列表 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public List<int> GetsIntList() |
| | | { |
| | | //初始化列表 |
| | | var mList = new List<int>(); |
| | | for (int i = 0; i < 60; i++) |
| | | { |
| | | //添加数据 |
| | | mList.Add(i); |
| | | } |
| | | return mList; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取时间值 |
| | | /// </summary> |
| | |
| | | /// <returns></returns> |
| | | public int GetValueIndex(string str, int digit, int startIndex, List<int> list) |
| | | { |
| | | if (string.IsNullOrEmpty(str)) |
| | | { |
| | | return 0; |
| | | } |
| | | int index = 0; |
| | | int value = 0; |
| | | if (str.Contains(":")) |