Example #1
0
        public void RunThemeUpdate()
        {
            UIThemeNotifications notifTheme = UIHandler.theme.notifs;

            this.SetWidth(notifTheme.ItemWidth);
            this.SetHeight(notifTheme.ContainerHeight);
            this.SetRelativePosition(notifTheme.xOffset, notifTheme.yOffset, notifTheme.xRel, notifTheme.yRel);

            // Set notifications to move from bottom to top if the container is linked to the bottom of parent.
            this.comesFromTop = notifTheme.yRel != UIVertPosition.Bottom;

            // Determine the starting position for each notification:
            this.startY = this.trueY + (this.comesFromTop == true ? 0 : this.height);
        }
Example #2
0
        // Draw All Notifications
        public void Draw()
        {
            if (this.notifications.Count == 0 && this.incomingNotif is UIGroupNotify == false)
            {
                return;
            }

            UIThemeNotifications theme = UIHandler.theme.notifs;

            int posY = this.startY;

            // Update starting position if notifications start at the bottom and there's at least one notification.
            if (!this.comesFromTop && this.notifications.Count > 0)
            {
                posY -= this.notifications.First.Value.height;
            }

            // Draw Incoming Notification (if applicable)
            if (this.incomingNotif is UIGroupNotify)
            {
                // Determine the starting position for the incoming notification:
                int incPosY = this.startY + (this.comesFromTop ? -this.incomingNotif.height + this.incomingMoved : -this.incomingMoved);

                // Draw the Incoming Notification
                this.incomingNotif.Draw(incPosY);

                // Adjust the position of the next notification in line.
                if (this.notifications.Count > 0)
                {
                    if (this.comesFromTop)
                    {
                        posY = incPosY + this.incomingNotif.height + theme.NotifGap;
                    }
                    else
                    {
                        posY = incPosY - this.notifications.First.Value.height - theme.NotifGap;
                    }
                }
            }

            // Loop through Notifications
            for (var i = 0; i < this.notifications.Count; i++)
            {
                UIGroupNotify notif = this.notifications.ElementAt(i);

                notif.Draw(posY);

                // Update the position of the next notification.
                if (this.comesFromTop)
                {
                    posY = posY + notif.height + theme.NotifGap;
                }
                else
                {
                    if (i + 1 < this.notifications.Count)
                    {
                        UIGroupNotify next = this.notifications.ElementAt(i + 1);
                        posY = posY - next.height - theme.NotifGap;
                    }
                }
            }
        }