DrawLine() public static method

Draws a line from X to Y with a width and a color
public static DrawLine ( float xa, float ya, float xb, float yb, float dwWidth, Color color ) : void
xa float Position X1
ya float Position Y1
xb float Position X2
yb float Position Y2
dwWidth float Width
color Color Color
return void
Beispiel #1
0
        /// <summary>
        ///     The draw slider.
        /// </summary>
        /// <param name="position">
        ///     The position.
        /// </param>
        /// <param name="item">
        ///     The item.
        /// </param>
        /// <param name="min">
        ///     The min.
        /// </param>
        /// <param name="max">
        ///     The max.
        /// </param>
        /// <param name="value">
        ///     The value.
        /// </param>
        /// <param name="width">
        ///     The width.
        /// </param>
        /// <param name="drawText">
        ///     The draw text.
        /// </param>
        internal static void DrawSlider(
            Vector2 position,
            MenuItem item,
            int min,
            int max,
            int value,
            int width,
            bool drawText)
        {
            width = width > 0 ? width : item.Width;
            var percentage = 100 * (value - min) / (max - min);
            var x          = position.X + 3 + percentage * (width - 3) / 100;
            var x2D        = 3 + percentage * (width - 3) / 100;

            MenuUtils.DrawLine(
                x,
                position.Y,
                x,
                position.Y + item.Height - 2,
                2,
                Color.FromArgb(200, 120, 60).ToSharpDxColor());
            MenuUtils.DrawBoxFilled(
                position.X,
                position.Y - 1,
                x2D - 1f,
                item.Height,
                Color.FromArgb(15, 150, 110, 0).ToSharpDxColor());

            if (!drawText)
            {
                return;
            }

            var textSize = Drawing.MeasureText(
                value.ToString(),
                "Arial",
                new Vector2((float)(item.Height * 0.45), (float)item.Width / 2),
                FontFlags.AntiAlias);
            var textPos = position
                          + new Vector2(
                (float)(item.Width - item.Height * 0.5 - 2 - textSize.X * 0.5),
                (float)(+(item.Height * 0.5) - textSize.Y * 0.5));

            Drawing.DrawText(
                value.ToString(),
                textPos,
                new Vector2((float)(item.Height * 0.48), (float)item.Width / 2),
                Color.DarkOrange.ToSharpDxColor(),
                FontFlags.AntiAlias);
        }