コード例 #1
0
        private void DismissComplete(bool cleanup)
        {
            this._IsVisible = false;

            this.TearDown();

            SetCurrentAlertView(null);

            SIAlertView nextAlertView = null;
            int         index         = SharedQueue.IndexOf(this);

            if (index > -1 && index < SharedQueue.Count() - 1)
            {
                nextAlertView = SharedQueue[index + 1];
            }

            if (cleanup)
            {
                SharedQueue.Remove(this);
            }

            SetAnimating(false);

            if (_IsVisible)
            {
                if (this.DidDismissHandler != null)
                {
                    this.DidDismissHandler.Invoke(this);
                }
                NSNotificationCenter.DefaultCenter.PostNotificationName(Constants.SIAlertViewDidDismissNotification, this, null);
            }

            // check if we should show next alert
            if (_IsVisible)
            {
                return;
            }

            if (nextAlertView != null)
            {
                nextAlertView.Show();
            }
            else
            {
                // show last alert view
                if (SharedQueue.Count > 0)
                {
                    SIAlertView alert = SharedQueue.Last();
                    alert.Show();
                }
            }
        }
コード例 #2
0
        public void Show()
        {
            _OldKeyWindow = UIApplication.SharedApplication.KeyWindow;

            if (!SharedQueue.Contains(this))
            {
                SharedQueue.Add(this);
            }

            if (IsAnimating)
            {
                return; // wait for next turn
            }

            if (_IsVisible)
            {
                return;
            }

            if (CurrentAlertView != null && CurrentAlertView.IsVisible)
            {
                SIAlertView alert = CurrentAlertView;
                alert.DismissAnimated(true, false);
                return;
            }

            if (this.WillShowHandler != null)
            {
                this.WillShowHandler.Invoke(this);
            }

            NSNotificationCenter.DefaultCenter.PostNotificationName(Constants.SIAlertViewWillShowNotification, this, null);

            this._IsVisible = true;

            SetAnimating(true);
            SetCurrentAlertView(this);

            // transition background
            this.ShowBackground();

            SIAlertVIewController viewController = new SIAlertVIewController();

            viewController.AlertView = this;

            if (this._AlertWindow == null)
            {
                UIWindow window = new UIWindow(UIScreen.MainScreen.Bounds);
                window.AutoresizingMask   = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
                window.Opaque             = false;
                window.WindowLevel        = Constants.UIWindowLevelSIAlert;
                window.RootViewController = viewController;
                this._AlertWindow         = window;
            }

            this._AlertWindow.MakeKeyAndVisible();

            this.ValidateLayout();

            this.TransitionInCompletion(() =>
            {
                if (this.DidShowHandler != null)
                {
                    this.DidShowHandler.Invoke(this);
                }

                NSNotificationCenter.DefaultCenter.PostNotificationName(Constants.SIAlertViewDidShowNotification, this, null);

                SetAnimating(false);

                int index = SharedQueue.IndexOf(this);
                if (index < SharedQueue.Count - 1)
                {
                    this.DismissAnimated(true, false);
                }
            });
        }