예제 #1
0
        void CreatePicker()
        {
            if (!m_init)
            {
                Forms.Init();
                SfPickerRenderer.Init();
                m_init = true;
            }

            m_picker = new SfPicker();
            ViewX    = UtilsiOS.ConvertFormsToNative(m_picker, m_rect);

            string str1 = "", str2 = "", str3 = "", str4 = "";

            Utils.Extract(m_data, ref str1, ref str2, ref str3, ref str4);
            if (!string.IsNullOrEmpty(str1))
            {
                double rowHeight = Utils.ConvertToDouble(str1);
                if (rowHeight > 0)
                {
                    rowHeight = AutoScaleFunction.TransformSize((int)rowHeight,
                                                                (int)UtilsiOS.GetScreenSize().Width);
                    m_picker.ItemHeight = rowHeight;
                }
            }

            m_picker.ShowHeader = !string.IsNullOrEmpty(str2);
            if (m_picker.ShowHeader)
            {
                m_picker.HeaderHeight = 40;
                m_picker.HeaderText   = str2;
            }
            m_picker.ShowColumnHeader = !string.IsNullOrEmpty(str3);
            if (m_picker.ShowColumnHeader)
            {
                m_picker.ColumnHeaderHeight = 40;
                m_picker.ColumnHeaderText   = str3;
            }

            m_picker.ShowFooter    = false;
            m_picker.SelectedIndex = 0;

            m_picker.PickerMode   = PickerMode.Default;
            m_picker.PickerWidth  = m_rect.Width;
            m_picker.PickerHeight = m_rect.Height;

            m_picker.BackgroundColor             = Color.Transparent;
            m_picker.HeaderBackgroundColor       = Color.Transparent;
            m_picker.ColumnHeaderBackgroundColor = Color.Transparent;
            m_picker.HeaderTextColor             = Color.Black;
            m_picker.UnSelectedItemTextColor     = Color.LightGray;
            m_picker.SelectedItemTextColor       = Color.Black;

            m_picker.SelectionChanged += (sender, e) => {
                ActionDelegate?.Invoke(WidgetName, e.NewValue.ToString());
            };

            m_picker.OnPickerItemLoaded += (sender, e) => {
                if (m_pics == null)
                {
                    return;
                }
                int row = e.Row;

                CustomRowView view = new CustomRowView(m_rect.Width);

                if (m_pics.Count > row)
                {
                    UIImageView rowPic = new UIImageView(m_pics[row]);
                    view.AddSubview(rowPic);
                }

                if (m_strings != null && m_strings.Count > row)
                {
                    UILabel rowText = new UILabel();
                    rowText.Text            = m_strings[row];
                    rowText.TextAlignment   = m_alignment;
                    rowText.BackgroundColor = m_bgColor;
                    //rowText.BackgroundColor = UIColor.Clear;
                    rowText.TextColor = m_fontColor;
                    view.AddSubview(rowText);
                }

                e.View = view.ToView();
            };

            m_picker.HeaderFontSize           = m_picker.ColumnHeaderFontSize =
                m_picker.SelectedItemFontSize = m_picker.UnSelectedItemFontSize = 15;
        }