Esempio n. 1
0
        void ShowNextMessage()
        {
            if (MessageBarQueue.Count > 0)
            {
                MessageVisible = true;
                MessageView messageView = MessageBarQueue.Dequeue();
                messageView.Frame  = new RectangleF(0, -messageView.Height, messageView.Width, messageView.Height);
                messageView.Hidden = false;
                messageView.SetNeedsDisplay();

                var gest = new UITapGestureRecognizer(MessageTapped);
                messageView.AddGestureRecognizer(gest);
                if (messageView == null)
                {
                    return;
                }

                UIView.Animate(DismissAnimationDuration,
                               () =>
                               messageView.Frame = new RectangleF(messageView.Frame.X,
                                                                  MessageBarOffset + messageView.Frame.Y + messageView.Height,
                                                                  messageView.Width, messageView.Height)
                               );

                //Need a better way of dissmissing the method
                var dismiss = new Timer(DismissMessage, messageView, TimeSpan.FromSeconds(DisplayDelay),
                                        TimeSpan.FromMilliseconds(-1));
            }
        }
        void ShowNextMessage()
        {
            MessageView messageView = GetNextMessage();

            if (messageView != null)
            {
                MessageVisible = true;

                if (ShowAtTheBottom)
                {
                    initialPosition = MessageWindowView.Bounds.Height + messageView.Height;
                    showPosition    = MessageWindowView.Bounds.Height - messageView.Height;
                }
                else
                {
                    initialPosition = MessageWindowView.Bounds.Y - messageView.Height;
                    showPosition    = MessageWindowView.Bounds.Y + MessageBarOffset;
                }

                messageView.Frame  = new CGRect(0, initialPosition, messageView.Width, messageView.Height);
                messageView.Hidden = false;
                messageView.SetNeedsDisplay();

                var gest = new UITapGestureRecognizer(MessageTapped);
                messageView.AddGestureRecognizer(gest);
                if (messageView == null)
                {
                    return;
                }

                UIView.Animate(DismissAnimationDuration,
                               () =>
                               messageView.Frame = new CGRect(messageView.Frame.X,
                                                              showPosition,
                                                              messageView.Width, messageView.Height)
                               );

                //Need a better way of dissmissing the method
                var dismiss = new Timer(DismissMessage, messageView, TimeSpan.FromSeconds(DisplayDelay),
                                        TimeSpan.FromMilliseconds(-1));
            }
        }
        void ShowNextMessage(double duration = DisplayDelay)
        {
            MessageView messageView = GetNextMessage();

            if (messageView != null)
            {
                MessageVisible = true;

                if (ShowAtTheBottom)
                {
                    initialPosition = MessageWindowView.Bounds.Height + messageView.Height;
                    showPosition    = MessageWindowView.Bounds.Height - messageView.Height - messageView.Margin;
                }
                else
                {
                    initialPosition = MessageWindowView.Bounds.Y - messageView.Height;
                    showPosition    = MessageWindowView.Bounds.Y;
                }

                messageView.Frame  = new CGRect(messageView.Margin, initialPosition, messageView.Width, messageView.Height);
                messageView.Hidden = false;
                messageView.SetNeedsDisplay();

                var gest = new UITapGestureRecognizer(MessageTapped);
                messageView.AddGestureRecognizer(gest);
                if (messageView == null)
                {
                    return;
                }

                //messageView.Alpha = 0f;
                UIView.Animate(AnimationDuration, 0, UIViewAnimationOptions.CurveEaseIn, () =>
                {
                    //messageView.Alpha = 1f;
                    messageView.Frame = new CGRect(messageView.Frame.X, showPosition, messageView.Width, messageView.Height);
                }, null);

                //Need a better way of dissmissing the method
                new Timer(DismissMessage, messageView, TimeSpan.FromSeconds(duration), TimeSpan.FromMilliseconds(-1));
            }
        }