Ejemplo n.º 1
0
 /// <summary>
 ///     Gets the additional boundaries.
 /// </summary>
 /// <param name="component">The <see cref="MenuSlider" /></param>
 /// <returns>The <see cref="Rectangle" /></returns>
 public Rectangle AdditionalBoundries(MenuSlider component)
 {
     return(LightUtilities.GetContainerRectangle(component));
 }
Ejemplo n.º 2
0
 /// <summary>
 ///     Gets the boundaries
 /// </summary>
 /// <param name="component">The <see cref="MenuSlider" /></param>
 /// <returns>The <see cref="Rectangle" /></returns>
 public Rectangle Bounding(MenuSlider component)
 {
     return(LightUtilities.GetContainerRectangle(component));
 }
Ejemplo n.º 3
0
        /// <summary>
        ///     Draw a <see cref="MenuList" />
        /// </summary>
        public override void Draw()
        {
            var dropdownMenuWidth = this.dropDownButtonWidth + (2 * TextSpacing) + this.Component.MaxStringWidth;
            var position          = this.Component.Position;
            var rectangleName     = LightUtilities.GetContainerRectangle(this.Component)
                                    .GetCenteredText(
                null,
                MenuSettings.Font,
                MultiLanguage.Translation(this.Component.DisplayName),
                CenteredFlags.VerticalCenter);

            MenuSettings.Font.DrawText(
                MenuManager.Instance.Sprite,
                MultiLanguage.Translation(this.Component.DisplayName),
                (int)(position.X + MenuSettings.ContainerTextOffset),
                (int)rectangleName.Y,
                MenuSettings.TextColor);

            MenuSettings.Font.DrawText(
                MenuManager.Instance.Sprite,
                "\u23EC",
                (int)(position.X + this.Component.MenuWidth - this.dropDownButtonWidth + ArrowSpacing),
                (int)rectangleName.Y,
                MenuSettings.TextColor);

            MenuSettings.Font.DrawText(
                MenuManager.Instance.Sprite,
                MultiLanguage.Translation(this.Component.SelectedValueAsObject.ToString()),
                (int)position.X + this.Component.MenuWidth - this.dropDownButtonWidth - TextSpacing
                - this.Component.MaxStringWidth,
                (int)rectangleName.Y,
                this.Component.Active ? new ColorBGRA(0, 186, 255, 255) : MenuSettings.TextColor);
            Line.Width = 1f;
            Line.Begin();
            Line.Draw(
                new[]
            {
                new Vector2(
                    position.X + this.Component.MenuWidth - this.dropDownButtonWidth - (2 * TextSpacing)
                    - this.Component.MaxStringWidth,
                    position.Y + 5),
                new Vector2(
                    position.X + this.Component.MenuWidth - this.dropDownButtonWidth - (2 * TextSpacing)
                    - this.Component.MaxStringWidth,
                    position.Y + MenuSettings.ContainerHeight - 5)
            },
                MenuSettings.ContainerSeparatorColor);
            Line.End();

            if (this.Component.Active)
            {
                var valueStrings       = this.Component.ValuesAsStrings;
                var dropdownMenuHeight = valueStrings.Length * MenuSettings.ContainerHeight;
                MenuManager.Instance.DrawDelayed(
                    delegate
                {
                    var color         = MenuSettings.RootContainerColor;
                    var dropdownColor = new ColorBGRA(color.R, color.G, color.B, 255);
                    Line.Width        = dropdownMenuWidth;
                    Line.Begin();
                    Line.Draw(
                        new[]
                    {
                        new Vector2(
                            position.X + this.Component.MenuWidth - (Line.Width / 2),
                            position.Y + MenuSettings.ContainerHeight),
                        new Vector2(
                            position.X + this.Component.MenuWidth - (Line.Width / 2),
                            position.Y + MenuSettings.ContainerHeight + dropdownMenuHeight)
                    },
                        dropdownColor);
                    Line.End();

                    var x =
                        (int)
                        (position.X + this.Component.MenuWidth - this.dropDownButtonWidth - TextSpacing
                         - this.Component.MaxStringWidth);
                    var y = (int)rectangleName.Y;
                    for (var i = 0; i < valueStrings.Length; i++)
                    {
                        if (i == this.Component.HoveringIndex)
                        {
                            Line.Width = MenuSettings.ContainerHeight;
                            Line.Begin();
                            Line.Draw(
                                new[]
                            {
                                new Vector2(
                                    position.X + this.Component.MenuWidth - dropdownMenuWidth,
                                    position.Y + ((i + 1) * MenuSettings.ContainerHeight)
                                    + MenuSettings.ContainerHeight / 2f),
                                new Vector2(
                                    position.X + this.Component.MenuWidth,
                                    position.Y + ((i + 1) * MenuSettings.ContainerHeight)
                                    + MenuSettings.ContainerHeight / 2f)
                            },
                                MenuSettings.HoverColor);
                            Line.End();
                        }

                        Line.Width = 1f;
                        Line.Begin();
                        Line.Draw(
                            new[]
                        {
                            new Vector2(
                                position.X + this.Component.MenuWidth - dropdownMenuWidth + 10,
                                position.Y + (MenuSettings.ContainerHeight * (i + 1))),
                            new Vector2(
                                position.X + this.Component.MenuWidth - 10,
                                position.Y + (MenuSettings.ContainerHeight * (i + 1)))
                        },
                            MenuSettings.ContainerSeparatorColor);
                        Line.End();
                        y += MenuSettings.ContainerHeight;
                        MenuSettings.Font.DrawText(
                            MenuManager.Instance.Sprite,
                            MultiLanguage.Translation(valueStrings[i]),
                            x,
                            y,
                            MenuSettings.TextColor);
                        if (this.Component.Index == i)
                        {
                            var checkmarkWidth = MenuSettings.Font.MeasureText(null, "\u2713", 0).Width;
                            MenuSettings.Font.DrawText(
                                MenuManager.Instance.Sprite,
                                "\u2713",
                                (int)(position.X + this.Component.MenuWidth - checkmarkWidth - TextSpacing),
                                y,
                                new ColorBGRA(1, 165, 226, 255));
                        }
                    }

                    Line.Width = 1f;
                    Line.Begin();
                    Line.Draw(
                        new[]
                    {
                        new Vector2(
                            position.X + this.Component.MenuWidth - dropdownMenuWidth,
                            position.Y + MenuSettings.ContainerHeight),
                        new Vector2(
                            position.X + this.Component.MenuWidth - dropdownMenuWidth,
                            position.Y + MenuSettings.ContainerHeight * (valueStrings.Length + 1)),
                        new Vector2(
                            position.X + this.Component.MenuWidth,
                            position.Y + MenuSettings.ContainerHeight * (valueStrings.Length + 1)),
                        new Vector2(
                            position.X + this.Component.MenuWidth,
                            position.Y + MenuSettings.ContainerHeight)
                    },
                        MenuSettings.ContainerSeparatorColor);
                    Line.End();
                });
            }
        }