Ejemplo n.º 1
0
        public override void Render()
        {
            if (_items.Count > 0)
            {
                if (ScrollOffset < 0 || ScrollOffset > _items.Count - 1)
                {
                    ScrollOffset = 0;
                }
                else
                {
                    KeyValuePair <ImageButton, Object> middle = _items[ScrollOffset];
                    middle.Key.Position =
                        new Point(ItemOffsets.Width + ClientArea.Left + (int)(ClientArea.Width / 2f - middle.Key.ClientArea.Width / 2f),
                                  ItemOffsets.Height + ClientArea.Top + (int)(ClientArea.Height / 2f - middle.Key.ClientArea.Height / 2f));
                    if (FadeItems)
                    {
                        middle.Key.Color = CluwneLib.SystemColorToSFML(Color.White);
                    }

                    if (_selectionGlow != null && Selected == ScrollOffset)
                    {
                        _selectionGlow.Position = new Point(ItemOffsets.Width + ClientArea.Left + (int)(ClientArea.Width / 2f - _selectionGlow.ClientArea.Width / 2f), middle.Key.ClientArea.Top + (int)(middle.Key.ClientArea.Height / 2f - _selectionGlow.ClientArea.Height / 2f));
                        _selectionGlow.Render();
                    }

                    middle.Key.Render();

                    int lastPosLeft  = middle.Key.ClientArea.Left - ItemSpacing;
                    int lastPosRight = middle.Key.ClientArea.Right + ItemSpacing;

                    for (int i = 1; i <= AdditionalColumns; i++)
                    {
                        float       alphaAdj  = 1 + AdditionalColumns - (AdditionalColumns / (float)i);
                        const float baseAlpha = 200;

                        //Left
                        if ((ScrollOffset - i) >= 0 && (ScrollOffset - i) <= _items.Count - 1)
                        {
                            KeyValuePair <ImageButton, Object> currLeft = _items[(ScrollOffset - i)];
                            currLeft.Key.Position = new Point(lastPosLeft - currLeft.Key.ClientArea.Width, ClientArea.Top + (int)(ClientArea.Height / 2f - currLeft.Key.ClientArea.Height / 2f));
                            lastPosLeft           = currLeft.Key.ClientArea.Left - ItemSpacing;

                            if (_selectionGlow != null && (ScrollOffset - i) == Selected)
                            {
                                _selectionGlow.Position = new Point(currLeft.Key.ClientArea.Left + (int)(currLeft.Key.ClientArea.Width / 2f - _selectionGlow.ClientArea.Width / 2f), currLeft.Key.ClientArea.Top + (int)(currLeft.Key.ClientArea.Height / 2f - _selectionGlow.ClientArea.Height / 2f));
                                _selectionGlow.Render();
                            }

                            if (FadeItems)
                            {
                                currLeft.Key.Color = CluwneLib.ColorFromARGB((byte)(baseAlpha / alphaAdj), Color.White);
                            }

                            currLeft.Key.Render();
                        }

                        //Right
                        if ((ScrollOffset + i) >= 0 && (ScrollOffset + i) <= _items.Count - 1)
                        {
                            KeyValuePair <ImageButton, Object> currRight = _items[(ScrollOffset + i)];
                            currRight.Key.Position = new Point(lastPosRight, ClientArea.Top + (int)(ClientArea.Height / 2f - currRight.Key.ClientArea.Height / 2f));
                            lastPosRight           = currRight.Key.ClientArea.Right + ItemSpacing;

                            if (_selectionGlow != null && (ScrollOffset + i) == Selected)
                            {
                                _selectionGlow.Position = new Point(currRight.Key.ClientArea.Left + (int)(currRight.Key.ClientArea.Width / 2f - _selectionGlow.ClientArea.Width / 2f), currRight.Key.ClientArea.Top + (int)(currRight.Key.ClientArea.Height / 2f - _selectionGlow.ClientArea.Height / 2f));
                                _selectionGlow.Render();
                            }

                            if (FadeItems)
                            {
                                currRight.Key.Color = CluwneLib.ColorFromARGB((byte)(baseAlpha / alphaAdj), Color.White);
                            }

                            currRight.Key.Render();
                        }
                    }
                }
            }

            if (ShowArrows && ScrollingNeeded())
            {
                _buttonLeft.Render();
                _buttonRight.Render();
            }
        }