1
wxr
2023-03-31 7e42cc13a14b7de31c9f5d5c61cdf24f3246335d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
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);
            }
        }
 
 
        
    }
}