Esempio n. 1
0
        public override void Draw(Entity ent, SpriteBatch batch)
        {
            // Debug Drawing
            if (BeyondAge.TheGame.Debugging)
            {
                var rect    = ent.Get <Body>();
                var physics = ent.Get <PhysicsBody>();

                primitives.DrawLineRect(rect.Region, Color.Red);

                var direction = (new Vector2((float)Math.Cos(physics.Direction), (float)Math.Sin(physics.Direction)));
                primitives.DrawLine(
                    rect.Center,
                    rect.Center + direction * 100,
                    Color.LightPink
                    );

                var font = BeyondAge.Assets.GetFont("Font");
                batch.DrawString(
                    font,
                    $"X: {rect.X} Y: {rect.Y}",
                    rect.Position + new Vector2(0, rect.Height + 4),
                    Color.White,
                    0,
                    Vector2.Zero,
                    0.5f,
                    SpriteEffects.None,
                    1);

                foreach (var poly in polygons)
                {
                    var last = poly.Points[0];
                    for (int i = 1; i < poly.Points.Count; i++)
                    {
                        var now = poly.Points[i];
                        primitives.DrawLine(last + poly.Position, now + poly.Position, Color.Red);
                        last = now;
                    }
                }

                foreach (var body in solids)
                {
                    primitives.DrawLineRect(body.Region, Color.Red);
                }
            }
        }
        /// <summary>
        /// Draws the control.
        /// </summary>
        public override void Draw()
        {
            mouseOverIndex = -1;
            Color outerBorderColor = Skin.OuterBorderColor;
            Color innerBorderColor = Skin.InnerBorderColor;
            Color innerButtonColor = Skin.WhiteBackgroundColor;

            Primitives.FillRectangle(Rectangle, this.IsActive ? Skin.InnerBorderColorMouseOver : innerBorderColor);
            Primitives.DrawRectangle(Rectangle, outerBorderColor, Skin.OuterBorderThickness);
            Primitives.DrawAndFillRectangle(InnerRectangleWithBorder, innerButtonColor, outerBorderColor, Skin.OuterBorderThickness);
            int maxItems = InnerRectangle.Height / Skin.ListItemHeight;
            int colsize  = (InnerRectangle.Width - 2) / 3;

            for (int i = TopOfList; i < Items.Count; i++)
            {
                Rectangle rectItem = new Rectangle(InnerRectangle.X + 1, InnerRectangle.Y + Skin.ListItemHeight * (i - TopOfList) + 1, InnerRectangle.Width - 2, Skin.ListItemHeight);
                if (ThreeColumn)
                {
                    if (i < maxItems)
                    {
                        rectItem = new Rectangle(InnerRectangle.X + 1, InnerRectangle.Y + Skin.ListItemHeight * (i - TopOfList) + 1, colsize, Skin.ListItemHeight);
                    }
                    else if (i < maxItems * 2)
                    {
                        rectItem = new Rectangle(InnerRectangle.X + 1 + colsize, InnerRectangle.Y + Skin.ListItemHeight * (i - TopOfList - maxItems) + 1,
                                                 colsize, Skin.ListItemHeight);
                    }
                    else
                    {
                        rectItem = new Rectangle(InnerRectangle.X + 1 + colsize * 2, InnerRectangle.Y + Skin.ListItemHeight * (i - TopOfList - maxItems * 2) + 1,
                                                 colsize, Skin.ListItemHeight);
                    }
                }


                if (Root.IsMouseOver(rectItem))
                {
                    mouseOverIndex = i;
                }

                if (selectedIndex == i || (Multiselect && SelectedIndices.Contains(i)))
                {
                    Primitives.FillRectangle(rectItem, Skin.ItemSelectedBackgroundColor);
                }
                else if (mouseOverIndex == i)
                {
                    Primitives.FillRectangle(rectItem, Skin.ItemMouseOverBackgroundColor);
                }
                if ((Multiselect && SelectedIndices.Contains(i)))
                {
                    Primitives.FillCircleQuick(new Vector2(rectItem.Right - rectItem.Height / 2 - 4, rectItem.Y + rectItem.Height / 2), rectItem.Height / 2 - 1, Color.Black);
                }
                Primitives.DrawSingleLineText(Items[i].ToString(), new Vector2(rectItem.X + 4, rectItem.Y + 1), Skin.TextColor, Skin.Font);
                Primitives.DrawLine(new Vector2(rectItem.X - 1, rectItem.Bottom - 1),
                                    new Vector2(rectItem.Right + 1, rectItem.Bottom - 1),
                                    outerBorderColor, Skin.OuterBorderThickness);
            }
        }