using System;
|
|
using Com.Hdl.Widget.Pickerview.View;
|
using Com.Hdl.Widget.Pickerview.Listener;
|
using System.Collections.Generic;
|
using Java.Util;
|
|
|
namespace Shared
|
{
|
|
|
|
/// <summary>
|
/// UIPickerView
|
/// </summary>
|
public class UIPickerView : View
|
{
|
/// <summary>
|
/// 当前视图
|
/// </summary>
|
/// <value>The UIPickerView.</value>
|
HDLPickerViewNT mPickerViewNT
|
{
|
get
|
{
|
return AndroidView as HDLPickerViewNT;
|
}
|
set
|
{
|
AndroidView = value;
|
}
|
}
|
|
/// <summary>
|
/// 构造函数
|
/// </summary>
|
public UIPickerView()
|
{
|
mPickerViewNT = new HDLPickerViewNT(Application.Activity);
|
|
mOnSelectChangeListener = new OnSelectChangeListener(this);
|
mPickerViewNT.SetOptionsSelectChangeListener(mOnSelectChangeListener);
|
}
|
|
|
/// <summary>
|
/// 设置PickerView 默认选中项
|
/// </summary>
|
public void setCurrentItems(int option1, int option2, int option3)
|
{
|
|
mPickerViewNT.SetCurrentItems(option1, option2, option3);
|
|
}
|
|
|
/// <summary>
|
/// 设置PickerView数据
|
/// </summary>
|
//public void setPicker(List<string> mFirstList, List<List<string>> mSecondList, List<List<List<string>>> mThirdList)
|
//{
|
|
// mPickerViewNT.SetPicker(mFirstList, mSecondList, mThirdList);
|
|
private static string SPLIT_FLAG = ">-<";
|
|
//}
|
/// <summary>
|
/// 设置PickerView数据 联动效果
|
/// </summary>
|
public void setPicker(List<string> mFirstList, List<List<string>> mSecondList)
|
{
|
|
if (mFirstList == null)
|
{
|
return;
|
}
|
|
if (mFirstList.Count != mSecondList.Count)
|
{
|
return;
|
}
|
|
|
var mSpliceList = new List<string>();//拼接后的数组
|
for (int i = 0; i < mSecondList.Count; i++)
|
{
|
string mDataStr = "";
|
for (int j = 0; j < mSecondList[i].Count; j++)
|
{
|
mDataStr += mSecondList[i][j] + SPLIT_FLAG;
|
}
|
mSpliceList.Add(mDataStr);
|
|
}
|
|
mPickerViewNT.SetPickerString(mFirstList, mSpliceList);
|
|
|
//IList<IList<string>> newSecondList = new List<IList<string>>();
|
|
|
//foreach (List<string> mm in mSecondList)
|
//{
|
// newSecondList.Add(mm);
|
//}
|
|
|
//mPickerViewNT.SetPicker(mFirstList, newSecondList);
|
|
|
|
//IDictionary<string, IList<string>> newSecondListDictionary = new Dictionary<string, IList<string>>();
|
|
////foreach (List<string> mm in mSecondList)
|
////{
|
//// newSecondListDictionary.Add(mFirstList );
|
////}
|
|
//for(int i=0;i< mFirstList.Count;i++)
|
//{
|
// newSecondListDictionary.Add(mFirstList[i], mSecondList[i]);
|
//}
|
|
//mPickerViewNT.SetPickerHashMap(mFirstList, newSecondListDictionary);
|
|
}
|
|
|
|
|
|
/// <summary>
|
/// 设置PickerView数据 不联动
|
/// </summary>
|
public void setNPicker(List<string> mFirstList, List<string> mSecondList, List<string> mThirdList)
|
{
|
|
mPickerViewNT.SetNPicker(mFirstList, mSecondList, mThirdList);
|
|
}
|
|
|
/// <summary>
|
/// 设置PickerView 选中文字的颜色
|
/// </summary>
|
public void setTextColorCenter(uint mColor , int indexID) {
|
|
byte r, g, b, a;
|
r = (byte)(mColor / 256 / 256 % 256);
|
g = (byte)(mColor / 256 % 256);
|
b = (byte)(mColor % 256);
|
a = (byte)(mColor / 256 / 256 / 256 % 256);
|
|
mPickerViewNT.SetTextColorCenter(Android.Graphics.Color.Argb(a, r, g, b), indexID);
|
}
|
|
|
public Action<int, int, int> OnSelectChangeEvent;
|
|
/// <summary>
|
/// OnProgressChangeListener 继承响应事件
|
/// </summary>
|
OnSelectChangeListener mOnSelectChangeListener;
|
|
public class OnSelectChangeListener : Java.Lang.Object, IOnOptionsSelectChangeListener
|
{
|
|
UIPickerView _UIPickerView;
|
|
public OnSelectChangeListener(UIPickerView view)
|
{
|
_UIPickerView = view;
|
}
|
|
public void OnOptionsSelectChanged(int selectIndex1, int selectIndex2, int selectIndex3)
|
{
|
_UIPickerView.OnSelectChangeEvent?.Invoke(selectIndex1, selectIndex2, selectIndex3);
|
}
|
}
|
|
|
|
}
|
}
|