public DropDownView(string Title, IList <string> data, nfloat fSize,
                            nfloat cellHeight, float layoutHeight, UIColor cellSelectedBackgroundColor, UIColor cellSelectedTextColor,
                            UIColor borderColor)
        {
            BorderColor = borderColor;
            NSNotificationCenter.DefaultCenter.AddObserver(UIDevice.OrientationDidChangeNotification, OrientationChanged);
            this.Title       = Title;
            this._CellHeight = cellHeight;
            this.IsShowing   = false;

            this.ControlHeight    = layoutHeight;
            this._DropDownControl = new DropDownControl(this, fSize);

            this._TblView = new DropDownTable(data, cellHeight, fSize, cellSelectedBackgroundColor, cellSelectedTextColor);

            // DropDown PopupView
            this._MainView = new UIView();
            this._MainView.Layer.MasksToBounds = false;
            this._MainView.Layer.BorderColor   = this.BorderColor.CGColor;
            this._MainView.Layer.BorderWidth   = 1;

            _MainView.UserInteractionEnabled      = true;
            this._MainView.UserInteractionEnabled = true;
            this.MultipleTouchEnabled             = true;
            this._TblView.MultipleTouchEnabled    = true;

            // add DropDownControl
            Add(this._DropDownControl);

            if (this._IsXamarinForms == false)
            {
                this.Add(this._MainView);
            }

            _MainView.Add(_TblView);
            _MainView.Hidden = true;



            // handle selected Text
            this._TblView.SelectedText = (x) => {
                this._SelectedText = x;
                this._DropDownControl.SelectedText(x);
                if (SelectedText != null)
                {
                    SelectedText(x);
                }
                HideDropDown();
            };
        }
예제 #2
0
        public DropDownView(string Title, IList <string> data, nfloat fSize,
                            nint cellHeight, float layoutHeight, UIColor cellSelectedBackgroundColor, UIColor cellSelectedTextColor,
                            UIColor borderColor,
                            string iOSTitle     = "",
                            string selectedText = "")
        {
            _Values = new DropDownConstants();
            _Values.HeaderHeight     = 20;
            _Values.HeaderFontHeight = 12;

            BorderColor = borderColor;
            NSNotificationCenter.DefaultCenter.AddObserver(UIDevice.OrientationDidChangeNotification, OrientationChanged);
            this.Title       = Title;
            this._CellHeight = cellHeight;
            this._IsShowing  = false;

            this.ControlHeight    = layoutHeight;
            this._DropDownControl = new DropDownControl(this, fSize);

            this._TblView = new DropDownTable(data, cellHeight, fSize, cellSelectedBackgroundColor, cellSelectedTextColor, selectedText);

            this._OverLayView = new UIView();

            // DropDown PopupView
            this._MainView = new UIView();
            this._MainView.Layer.MasksToBounds = false;
            this._MainView.Layer.BorderColor   = this.BorderColor.CGColor;
            this._MainView.Layer.BorderWidth   = this._Values.BorderWidth;

            _MainView.UserInteractionEnabled      = true;
            this._MainView.UserInteractionEnabled = true;
            this.MultipleTouchEnabled             = true;
            this._TblView.MultipleTouchEnabled    = true;


            this._HeaderView = new DropDownViewHeader(this, iOSTitle);

            // add DropDownControl
            Add(this._DropDownControl);

            if (this._IsXamarinForms == false)
            {
                //this.Add (this._MainView);
            }

            this._OverLayView.Add(this._MainView);
            this._Tap = new UITapGestureRecognizer(() => {
                HideDropDown();
            });

            this._Tap.ShouldReceiveTouch = (recognizer, touch) => {
                var view = UIApplication.SharedApplication.KeyWindow.RootViewController.View;
                var pos  = touch.LocationInView(view);

                var f = this._MainView.Frame;
                if (f.Contains(pos) == false)
                {
                    return(true);
                }

                return(false);
            };
            // hide if tapped
            this._OverLayView.AddGestureRecognizer(this._Tap);

            _MainView.Add(this._HeaderView);
            _MainView.AddSubview(_TblView);
            _OverLayView.Hidden = true;

            //AddSubview (this.overlay);

            var w = UIApplication.SharedApplication.KeyWindow;
            var v = w.RootViewController.View;

            v.Add(this._OverLayView);

            // handle selected Text
            this._TblView.SelectedText = (x) => {
                this._SelectedText = x;
                this._DropDownControl.SelectedText(x);
                if (SelectedText != null)
                {
                    SelectedText(x);
                }
                HideDropDown();
            };
        }