예제 #1
0
        public CustomWindow(INotifyCloseDone _parent,  UIView _content,bool _cancelable, nfloat _width, nfloat _height, ShowType _showType, UIView _anchor = null)
            : base(UIScreen.MainScreen.Bounds)
        {
            nfloat left = 0;
             	nfloat top = 0;

            cancelable = _cancelable;
            content = _content;
            anchor = _anchor;
            showType = _showType;
            CustomParent = _parent;
            nfloat width = _width + 4;
            nfloat height = _height + 4;

            UIColor bgrdColor = UIColor.FromRGBA (100, 100, 100, 100);

            //todo show at top bar notification
            switch(showType)
            {

                case ShowType.Dialog:
                    left =  (XFPopupConst.SCREEN_WIDTH  - width) * 0.5f;
                    top =  (XFPopupConst.SCREEN_HEIGHT - height) * 0.5f;
                    bgrdColor = UIColor.FromRGBA (100, 100, 100, 100);

                    break;

                case ShowType.DropDown:
                    CGPoint topleft = ConvertPointFromView (new CGPoint (0, 0), anchor);
                    //ConvertPointToWindow(new CGPoint(anchor.Frame.Left , anchor.Frame.Top),this);

                    left =  topleft.X;
                    if (topleft.Y + anchor.Frame.Height + height + 2 < this.Bounds.Height) {
                        top = topleft.Y + anchor.Frame.Height + 2;
                        topdown = true;
                    } else {
                        top = topleft.Y - height - 2;
                        topdown = false;
                    }
                    bgrdColor = UIColor.FromRGBA (0, 0, 0, 0);

                    break;
                default:
                    break;
            }

            wrap = new UIView (content.Bounds);
            wrap.BackgroundColor = UIColor.White;
            wrap.Layer.CornerRadius = 6f;
            wrap.Layer.ShadowOffset = SizeF.Empty;
            wrap.Layer.ShadowRadius = 3f;
            wrap.Layer.ShadowOpacity = 0.5f;
            wrap.Frame = new CGRect(left,top, _width,_height);
            wrap.AddSubview (content);

            AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            Opaque = false;

            BackgroundColor = bgrdColor;

            WindowLevel = UIKit.UIWindowLevel.Normal;
            AddSubview (wrap);
        }
예제 #2
0
        public CustomWindow(INotifyCloseDone _parent, UIView _content, bool _cancelable, nfloat _width, nfloat _height, ShowType _showType, UIView _anchor = null) : base(UIScreen.MainScreen.Bounds)
        {
            nfloat left = 0;
            nfloat top  = 0;


            cancelable   = _cancelable;
            content      = _content;
            anchor       = _anchor;
            showType     = _showType;
            CustomParent = _parent;
            nfloat width  = _width + 4;
            nfloat height = _height + 4;

            UIColor bgrdColor = UIColor.FromRGBA(100, 100, 100, 100);

            //todo show at top bar notification
            switch (showType)
            {
            case ShowType.Dialog:
                left      = (XFPopupConst.SCREEN_WIDTH - width) * 0.5f;
                top       = (XFPopupConst.SCREEN_HEIGHT - height) * 0.5f;
                bgrdColor = UIColor.FromRGBA(100, 100, 100, 100);

                break;

            case ShowType.DropDown:
                CGPoint topleft = ConvertPointFromView(new CGPoint(0, 0), anchor);
                //ConvertPointToWindow(new CGPoint(anchor.Frame.Left , anchor.Frame.Top),this);

                left = topleft.X;
                if (topleft.Y + anchor.Frame.Height + height + 2 < this.Bounds.Height)
                {
                    top     = topleft.Y + anchor.Frame.Height + 2;
                    topdown = true;
                }
                else
                {
                    top     = topleft.Y - height - 2;
                    topdown = false;
                }
                bgrdColor = UIColor.FromRGBA(0, 0, 0, 0);

                break;

            default:
                break;
            }

            wrap = new UIView(content.Bounds);
            wrap.BackgroundColor     = UIColor.White;
            wrap.Layer.CornerRadius  = 6f;
            wrap.Layer.ShadowOffset  = SizeF.Empty;
            wrap.Layer.ShadowRadius  = 3f;
            wrap.Layer.ShadowOpacity = 0.5f;
            wrap.Frame = new CGRect(left, top, _width, _height);
            wrap.AddSubview(content);

            AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            Opaque           = false;

            BackgroundColor = bgrdColor;

            WindowLevel = UIKit.UIWindowLevel.Normal;
            AddSubview(wrap);
        }