public void Remove(ScrollingBoxItem value)
 {
     base.InnerList.Remove(value);
     if (OnCollectionChanged != null)
     {
         OnCollectionChanged(this, new EventArgs());
     }
 }
 public void InsertAt(int index, ScrollingBoxItem value)
 {
     base.InnerList.Insert(index, value);
     if (OnCollectionChanged != null)
     {
         OnCollectionChanged(this, new EventArgs());
     }
 }
        public int Add(ScrollingBoxItem value)
        {
            int index = base.InnerList.Add(value);

            if (OnCollectionChanged != null)
            {
                OnCollectionChanged(this, new EventArgs());
            }
            return(index);
        }
Example #4
0
        protected virtual void PositionItems()
        {
            for (int i = 0; i < Items.Count; i++)
            {
                ScrollingBoxItem item = Items[i];

                if (MovingDirection == ArrowDirection.Up)
                {
                    if (item.rectF.Y + item.rectF.Height < 0)
                    {
                        if (i == 0)
                        {
                            // Goto the bottom of the screen list items
                            item.rectF.Y = Items[Items.Count - 1].rectF.Y + Height + item.rectF.Height;
                        }
                        else
                        {
                            item.rectF.Y = Items[i - 1].rectF.Bottom;
                        }
                    }
                    else
                    {
                        // Move up the screen
                        item.rectF.Y -= 1;
                    }
                }
                else if (MovingDirection == ArrowDirection.Down)
                {
                    if (item.rectF.Y > this.Height)
                    {
                        if (i == Items.Count - 1)
                        {
                            // Goto the top of the screen list items
                            item.rectF.Y = Items[0].rectF.Y - Height - item.rectF.Height;
                        }
                        else
                        {
                            item.rectF.Y = Items[i + 1].rectF.Y - item.rectF.Height;
                        }
                    }
                    else
                    {
                        // Move down the screen
                        item.rectF.Y += 1;
                    }
                }
            }

            this.Invalidate();
        }
Example #5
0
        public override void OnPaint(IGUIContext ctx, RectangleF bounds)
        {
            base.OnPaint(ctx, bounds);

            if (Font == null)
            {
                return;
            }
            for (int i = 0; i < Items.Count; i++)
            {
                ScrollingBoxItem item = Items[i];

                RectangleF r = item.rectF;
                r.Offset(bounds.Left, bounds.Top);
                if (i == 0)
                {
                    r.Offset(0, Padding.Top);
                }

                if (bounds.IntersectsWith(r))
                {
                    var txt = item as ScrollingBoxText;
                    if (txt != null)
                    {
                        ctx.DrawString(txt.Text, Font, Style.ForeColorBrush, r, Format);
                    }
                    else
                    {
                        ScrollingBoxImage img = item as ScrollingBoxImage;
                        if (img != null)
                        {
                            img.Image.Paint(ctx, new RectangleF(
                                                r.X + ImagePadding.Left,
                                                r.Top + ImagePadding.Top,
                                                r.Width - ImagePadding.Left - ImagePadding.Right,
                                                r.Height - ImagePadding.Top - ImagePadding.Bottom));
                        }
                    }
                }
            }
        }
Example #6
0
        protected virtual void RecalculateItems()
        {
            SizeF sizeF      = new SizeF();
            float availWidth = Width - Padding.Width;

            TotalItemHeight = 0;

            for (int i = 0; i < Items.Count; i++)
            {
                ScrollingBoxItem item = Items[i];

                item.rectF.X     = Padding.Left;
                item.rectF.Width = (float)availWidth;

                if (item.GetType() == typeof(ScrollingBoxText))
                {
                    ScrollingBoxText textItem = (ScrollingBoxText)item;
                    if (String.IsNullOrEmpty(textItem.Text))
                    {
                        sizeF = new SizeF(availWidth, Font.LineHeight);
                    }
                    else
                    {
                        SizeF sz = Font.Measure(textItem.Text, availWidth, Format);
                        sizeF = new SizeF(sz.Width, sz.Height + Font.LineHeight - Font.Height);
                    }
                }
                else if (item.GetType() == typeof(ScrollingBoxImage))
                {
                    ScrollingBoxImage imgItem = (ScrollingBoxImage)item;
                    sizeF = imgItem.Image.Size;
                    sizeF = new SizeF(sizeF.Width + ImagePadding.Left + ImagePadding.Right, sizeF.Height + ImagePadding.Top + ImagePadding.Bottom);

                    imgItem.rectF.Width = sizeF.Width;
                    switch (Alignment)
                    {
                    case StringAlignment.Near:
                        item.rectF.X = Padding.Left + ImagePadding.Left;
                        break;

                    case StringAlignment.Center:
                        item.rectF.X = (availWidth / 2) - (sizeF.Width / 2) + Padding.Left + ImagePadding.Left;
                        break;

                    case StringAlignment.Far:
                        item.rectF.X = Width - sizeF.Width - Padding.Right - ImagePadding.Right;
                        break;
                    }
                }

                if (i == 0)
                {
                    sizeF = new SizeF(sizeF.Width, sizeF.Height + Padding.Top);
                }

                item.rectF.Height = sizeF.Height;
                TotalItemHeight  += sizeF.Height;

                if (i == 0)
                {
                    if (!startingPositionHasBeenSetAfterHeight)
                    {
                        item.rectF.Y = Height;
                        startingPositionHasBeenSetAfterHeight = true;
                    }
                }
                else
                {
                    item.rectF.Y = Items[i - 1].rectF.Bottom;
                }
            }
        }