예제 #1
0
        /// <summary>
        ///     Do not buffer text if you draw i.e. FPS. Use buffer for player names, rank....
        /// </summary>
        /// <param name="text">The text.</param>
        /// <param name="font">The font.</param>
        /// <param name="brush">The brush.</param>
        /// <param name="x">The x.</param>
        /// <param name="y">The y.</param>
        /// <param name="bufferText">if set to <c>true</c> [buffer text].</param>
        public void DrawText(string text, TextFormat font, ID2DBrush brush, int x, int y, bool bufferText = true)
        {
            if (bufferText)
            {
                var bufferPos = -1;

                for (var i = 0; i < _layoutContainer.Count; i++)
                {
                    if (_layoutContainer[i].Text.Length != text.Length || _layoutContainer[i].Text != text)
                    {
                        continue;
                    }
                    bufferPos = i;
                    break;
                }

                if (bufferPos == -1)
                {
                    _layoutContainer.Add(new TextLayoutBuffer(text,
                                                              new TextLayout(_fontFactory, text, font, float.MaxValue, float.MaxValue)));
                    bufferPos = _layoutContainer.Count - 1;
                }

                _device.DrawTextLayout(new RawVector2(x, y), _layoutContainer[bufferPos].TextLayout,
                                       brush.GetBrush(), DrawTextOptions.NoSnap);
            }
            else
            {
                var layout = new TextLayout(_fontFactory, text, font, float.MaxValue, float.MaxValue);
                _device.DrawTextLayout(new RawVector2(x, y), layout, brush.GetBrush());
                layout.Dispose();
            }
        }
예제 #2
0
        /// <summary>
        ///     Draws the box3 d.
        /// </summary>
        /// <param name="x">The x.</param>
        /// <param name="y">The y.</param>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        /// <param name="length">The length.</param>
        /// <param name="stroke">The stroke.</param>
        /// <param name="brush">The brush.</param>
        /// <param name="interiorBrush">The interior brush.</param>
        public void DrawBox3D(int x, int y, int width, int height, int length, float stroke, ID2DBrush brush,
                              ID2DBrush interiorBrush)
        {
            var first  = new RawRectangleF(x, y, x + width, y + height);
            var second = new RawRectangleF(x + length, y - length, first.Right + length, first.Bottom - length);

            var lineStart = new RawVector2(x, y);
            var lineEnd   = new RawVector2(second.Left, second.Top);

            _device.DrawRectangle(first, brush.GetBrush(), stroke);
            _device.DrawRectangle(second, brush.GetBrush(), stroke);

            _device.FillRectangle(first, interiorBrush.GetBrush());
            _device.FillRectangle(second, interiorBrush.GetBrush());

            _device.DrawLine(lineStart, lineEnd, brush.GetBrush(), stroke);

            lineStart.X += width;
            lineEnd.X    = lineStart.X + length;

            _device.DrawLine(lineStart, lineEnd, brush.GetBrush(), stroke);

            lineStart.Y += height;
            lineEnd.Y   += height;

            _device.DrawLine(lineStart, lineEnd, brush.GetBrush(), stroke);

            lineStart.X -= width;
            lineEnd.X   -= width;

            _device.DrawLine(lineStart, lineEnd, brush.GetBrush(), stroke);
        }
예제 #3
0
        /// <summary>
        ///     Bordereds the circle.
        /// </summary>
        /// <param name="x">The x.</param>
        /// <param name="y">The y.</param>
        /// <param name="radius">The radius.</param>
        /// <param name="stroke">The stroke.</param>
        /// <param name="brush">The brush.</param>
        /// <param name="borderBrush">The border brush.</param>
        public void BorderedCircle(int x, int y, int radius, float stroke, ID2DBrush brush, ID2DBrush borderBrush)
        {
            _device.DrawEllipse(new Ellipse(new RawVector2(x, y), radius + stroke, radius + stroke),
                                borderBrush.GetBrush(), stroke);

            _device.DrawEllipse(new Ellipse(new RawVector2(x, y), radius, radius), brush.GetBrush(), stroke);

            _device.DrawEllipse(new Ellipse(new RawVector2(x, y), radius - stroke, radius - stroke),
                                borderBrush.GetBrush(), stroke);
        }
예제 #4
0
        /// <summary>
        ///     Draws the plus.
        /// </summary>
        /// <param name="x">The x.</param>
        /// <param name="y">The y.</param>
        /// <param name="length">The length.</param>
        /// <param name="stroke">The stroke.</param>
        /// <param name="brush">The brush.</param>
        public void DrawPlus(int x, int y, int length, float stroke, ID2DBrush brush)
        {
            var first  = new RawVector2(x - length, y);
            var second = new RawVector2(x + length, y);

            var third  = new RawVector2(x, y - length);
            var fourth = new RawVector2(x, y + length);

            _device.DrawLine(first, second, brush.GetBrush(), stroke);
            _device.DrawLine(third, fourth, brush.GetBrush(), stroke);
        }
예제 #5
0
        /// <summary>
        ///     Bordereds the line.
        /// </summary>
        /// <param name="startX">The start x.</param>
        /// <param name="startY">The start y.</param>
        /// <param name="endX">The end x.</param>
        /// <param name="endY">The end y.</param>
        /// <param name="stroke">The stroke.</param>
        /// <param name="brush">The brush.</param>
        /// <param name="borderBrush">The border brush.</param>
        public void BorderedLine(int startX, int startY, int endX, int endY, float stroke, ID2DBrush brush, ID2DBrush borderBrush)
        {
            _device.DrawLine(new RawVector2(startX, startY), new RawVector2(endX, endY), brush.GetBrush(), stroke);

            _device.DrawLine(new RawVector2(startX, startY - stroke), new RawVector2(endX, endY - stroke),
                             borderBrush.GetBrush(), stroke);
            _device.DrawLine(new RawVector2(startX, startY + stroke), new RawVector2(endX, endY + stroke),
                             borderBrush.GetBrush(), stroke);

            _device.DrawLine(new RawVector2(startX - stroke / 2, startY - stroke * 1.5f),
                             new RawVector2(startX - stroke / 2, startY + stroke * 1.5f), borderBrush.GetBrush(), stroke);
            _device.DrawLine(new RawVector2(endX - stroke / 2, endY - stroke * 1.5f),
                             new RawVector2(endX - stroke / 2, endY + stroke * 1.5f), borderBrush.GetBrush(), stroke);
        }
예제 #6
0
        /// <summary>
        ///     Bordereds the rectangle.
        /// </summary>
        /// <param name="x">The x.</param>
        /// <param name="y">The y.</param>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        /// <param name="stroke">The stroke.</param>
        /// <param name="borderStroke">The border stroke.</param>
        /// <param name="brush">The brush.</param>
        /// <param name="borderBrush">The border brush.</param>
        public void BorderedRectangle(int x, int y, int width, int height, float stroke, float borderStroke, ID2DBrush brush,
                                      ID2DBrush borderBrush)
        {
            _device.DrawRectangle(
                new RawRectangleF(x - (stroke - borderStroke), y - (stroke - borderStroke),
                                  x + width + stroke - borderStroke, y + height + stroke - borderStroke), borderBrush.GetBrush(),
                borderStroke);

            _device.DrawRectangle(new RawRectangleF(x, y, x + width, y + height), brush.GetBrush(), stroke);

            _device.DrawRectangle(
                new RawRectangleF(x + (stroke - borderStroke), y + (stroke - borderStroke),
                                  x + width - stroke + borderStroke, y + height - stroke + borderStroke), borderBrush.GetBrush(),
                borderStroke);
        }
예제 #7
0
        /// <summary>
        ///     Draws the bar v.
        /// </summary>
        /// <param name="x">The x.</param>
        /// <param name="y">The y.</param>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        /// <param name="value">The value.</param>
        /// <param name="stroke">The stroke.</param>
        /// <param name="brush">The brush.</param>
        /// <param name="interiorBrush">The interior brush.</param>
        public void DrawBarV(int x, int y, int width, int height, float value, float stroke, ID2DBrush brush,
                             ID2DBrush interiorBrush)
        {
            var first = new RawRectangleF(x, y, x + width, y + height);

            _device.DrawRectangle(first, brush.GetBrush(), stroke);

            if (Math.Abs(value) < 0)
            {
                return;
            }

            first.Right -= width - width / 100.0f * value;

            _device.FillRectangle(first, interiorBrush.GetBrush());
        }
예제 #8
0
        /// <summary>
        ///     Draws the edge.
        /// </summary>
        /// <param name="x">The x.</param>
        /// <param name="y">The y.</param>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        /// <param name="length">The length.</param>
        /// <param name="stroke">The stroke.</param>
        /// <param name="brush">The brush.</param>
        public void DrawEdge(int x, int y, int width, int height, int length, float stroke, ID2DBrush brush) //geht
        {
            var first  = new RawVector2(x, y);
            var second = new RawVector2(x, y + length);
            var third  = new RawVector2(x + length, y);

            _device.DrawLine(first, second, brush.GetBrush(), stroke);
            _device.DrawLine(first, third, brush.GetBrush(), stroke);

            first.Y += height;
            second.Y = first.Y - length;
            third.Y  = first.Y;
            third.X  = first.X + length;

            _device.DrawLine(first, second, brush.GetBrush(), stroke);
            _device.DrawLine(first, third, brush.GetBrush(), stroke);

            first.X  = x + width;
            first.Y  = y;
            second.X = first.X - length;
            second.Y = first.Y;
            third.X  = first.X;
            third.Y  = first.Y + length;

            _device.DrawLine(first, second, brush.GetBrush(), stroke);
            _device.DrawLine(first, third, brush.GetBrush(), stroke);

            first.Y  += height;
            second.X += length;
            second.Y  = first.Y - length;
            third.Y   = first.Y;
            third.X   = first.X - length;

            _device.DrawLine(first, second, brush.GetBrush(), stroke);
            _device.DrawLine(first, third, brush.GetBrush(), stroke);
        }
예제 #9
0
 public void FillCircle(int x, int y, int radius, ID2DBrush brush) => _device.FillEllipse(new Ellipse(new RawVector2(x, y), radius, radius), brush.GetBrush());
예제 #10
0
 public void FillRectangle(int x, int y, int width, int height, ID2DBrush brush) => _device.FillRectangle(new RawRectangleF(x, y, x + width, y + height), brush.GetBrush());
예제 #11
0
 /// <summary>
 ///     Draws the box2 d.
 /// </summary>
 /// <param name="x">The x.</param>
 /// <param name="y">The y.</param>
 /// <param name="width">The width.</param>
 /// <param name="height">The height.</param>
 /// <param name="stroke">The stroke.</param>
 /// <param name="brush">The brush.</param>
 /// <param name="interiorBrush">The interior brush.</param>
 public void DrawBox2D(int x, int y, int width, int height, float stroke, ID2DBrush brush, ID2DBrush interiorBrush)
 {
     _device.DrawRectangle(new RawRectangleF(x, y, x + width, y + height), brush.GetBrush(), stroke);
     _device.FillRectangle(new RawRectangleF(x + stroke, y + stroke, x + width - stroke, y + height - stroke),
                           interiorBrush.GetBrush());
 }
예제 #12
0
 public void DrawCircle(int x, int y, int radius, float stroke, ID2DBrush brush) => _device.DrawEllipse(new Ellipse(new RawVector2(x, y), radius, radius), brush.GetBrush(), stroke);
예제 #13
0
 public void DrawRectangle(int x, int y, int width, int height, float stroke, ID2DBrush brush) => _device.DrawRectangle(new RawRectangleF(x, y, x + width, y + height), brush.GetBrush(), stroke);
예제 #14
0
 public void DrawLine(int startX, int startY, int endX, int endY, float stroke, ID2DBrush brush) => _device.DrawLine(new RawVector2(startX, startY), new RawVector2(endX, endY), brush.GetBrush(), stroke);