Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
 internal void Fill(RenderContext context, ID2DBrush brush, float offsetX, float offsetY)
 {
     context.PushTransform2D();
     context.Translate2D(offsetX, offsetY);
     Fill(context, brush);
     context.PopTransform2D();
 }
Exemplo n.º 3
0
 public static void FillPath(this RenderContext context, ID2DBrush brush, D2DPathData path, float offsetX, float offsetY)
 {
     context.PushTransform2D();
     context.Translate2D(offsetX, offsetY);
     context.RenderTarget.DeviceContext2D.FillPath(brush, path);
     context.PopTransform2D();
 }
Exemplo n.º 4
0
 public D2DPen(ID2DBrush brush, float strokeWidth, StrokeStyle style)
 {
     Brush            = brush;
     StrokeWidth      = strokeWidth;
     StrokeStyle      = style;
     _isExternalBrush = true;
 }
Exemplo n.º 5
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();
            }
        }
Exemplo n.º 6
0
 public static void FillPolygon(this SharpDX.Direct2D1.RenderTarget target, ID2DBrush brush, FillMode fillMode, params PointF[] points)
 {
     if (points == null)
     {
         throw new ArgumentNullException(nameof(points));
     }
     if (points.Length == 0)
     {
         return;
     }
     using (var path = new PathGeometry(target.Factory)) {
         using (var sink = path.Open()) {
             sink.SetFillMode((SharpDX.Direct2D1.FillMode)fillMode);
             sink.BeginFigure(new RawVector2(points[0].X, points[0].Y), FigureBegin.Filled);
             var len = points.Length;
             for (var i = 1; i < len; ++i)
             {
                 var pt = points[i];
                 sink.AddLine(new RawVector2(pt.X, pt.Y));
             }
             sink.EndFigure(FigureEnd.Closed);
             sink.Close();
         }
         target.FillGeometry(path, brush.NativeBrush);
     }
 }
 public OverlayNotification(D2DDevice device, ID2DBrush background, ID2DBrush foreground, D2DFont font)
 {
     _device         = device;
     BackgroundBrush = background;
     ForegroundBrush = foreground;
     Font            = font;
 }
Exemplo n.º 8
0
 /// <summary>
 /// Fills a <see cref="D2DFontPathData"/> to current <see cref="RenderContext"/>.
 /// </summary>
 /// <param name="context">The <see cref="RenderContext"/> to fill to.</param>
 /// <param name="brush">The <see cref="D2DBrushBase"/> to use.</param>
 /// <param name="path">The <see cref="D2DFontPathData"/> to fill.</param>
 /// <param name="offsetX">The X offset on target <see cref="RenderContext"/>.</param>
 /// <param name="offsetY">The Y offset on target <see cref="RenderContext"/>.</param>
 /// <param name="yCorrection">If <see langword="true"/>, apply automatic Y correction: y(real) = offsetY + lineHeight. If <see langword="false"/>, the Y value stays untouched.</param>
 public static void FillPath(this RenderContext context, ID2DBrush brush, D2DFontPathData path, float offsetX, float offsetY, bool yCorrection)
 {
     if (yCorrection)
     {
         offsetY += path.LineHeight;
     }
     path.Fill(context, brush, offsetX, offsetY);
 }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
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);
        }
Exemplo n.º 11
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);
        }
Exemplo n.º 12
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());
        }
Exemplo n.º 13
0
        internal void Fill(RenderContext context, ID2DBrush brush)
        {
            const float offsetX       = 0;
            var         offsetY       = 0f;
            var         pathDataArray = _pathDataArray;
            var         lineHeights   = _lineHeights;
            var         len           = pathDataArray.Length;

            for (var i = 0; i < len; ++i)
            {
                var pathData = pathDataArray[i];
                if (pathData != null)
                {
                    context.FillPath(brush, pathData, offsetX, offsetY);
                }
                offsetY += lineHeights[i];
            }
        }
Exemplo n.º 14
0
 public static void FillPath(this RenderContext context, ID2DBrush brush, D2DPathData path)
 {
     context.RenderTarget.DeviceContext2D.FillPath(brush, path);
 }
Exemplo n.º 15
0
 public static void DrawText(this RenderContext context, string text, ID2DBrush brush, D2DFont font, float destX, float destY)
 {
     context.RenderTarget.DeviceContext2D.DrawText(text, brush, font, destX, destY);
 }
Exemplo n.º 16
0
 public static void FillPolygon(this RenderContext context, ID2DBrush brush, FillMode fillMode, params PointF[] points)
 {
     context.RenderTarget.DeviceContext2D.FillPolygon(brush, fillMode, points);
 }
Exemplo n.º 17
0
 public static void FillEllipse(this RenderContext context, ID2DBrush brush, float x, float y, float width, float height)
 {
     context.RenderTarget.DeviceContext2D.FillEllipse(brush, x, y, width, height);
 }
Exemplo n.º 18
0
 public void Fill(ID2DBrush brush)
 {
     _device.FillGeometry(_geometry, brush);
 }
Exemplo n.º 19
0
 public void DrawDashed(float stroke, ID2DBrush brush)
 {
     _device.DrawDashedGeometry(_geometry, stroke, brush);
 }
Exemplo n.º 20
0
 public static void FillPath(this RenderContext context, ID2DBrush brush, D2DFontPathData path)
 {
     path.Fill(context, brush);
 }
Exemplo n.º 21
0
 public static void FillPath(this RenderContext context, ID2DBrush brush, D2DFontPathData path, PointF offset, bool yCorrection)
 {
     context.FillPath(brush, path, offset.X, offset.Y, yCorrection);
 }
Exemplo n.º 22
0
 public static void FillCircle(this RenderContext context, ID2DBrush brush, float x, float y, float radius)
 {
     context.RenderTarget.DeviceContext2D.FillCircle(brush, x, y, radius);
 }
Exemplo n.º 23
0
 public static void FillPath(this RenderContext context, ID2DBrush brush, D2DPathData path, PointF offset)
 {
     context.FillPath(brush, path, offset.X, offset.Y);
 }
Exemplo n.º 24
0
        public static void FillCircle(this SharpDX.Direct2D1.RenderTarget target, ID2DBrush brush, PointF center, float radius)
        {
            var w = radius + radius;

            target.FillEllipse(brush, center.X - radius, center.Y - radius, w, w);
        }
Exemplo n.º 25
0
        public static void FillCircle(this SharpDX.Direct2D1.RenderTarget target, ID2DBrush brush, float x, float y, float radius)
        {
            var w = radius + radius;

            target.FillEllipse(brush, x - radius, y - radius, w, w);
        }
Exemplo n.º 26
0
 public static void FillMesh(this SharpDX.Direct2D1.RenderTarget target, ID2DBrush brush, D2DMesh mesh)
 {
     target.FillMesh(mesh.Native, brush.NativeBrush);
 }
Exemplo n.º 27
0
 public static void FillMesh(this RenderContext context, ID2DBrush brush, D2DMesh mesh)
 {
     context.RenderTarget.DeviceContext2D.FillMesh(brush, mesh);
 }
Exemplo n.º 28
0
 public static void FillPath(this RenderContext context, ID2DBrush brush, D2DFontPathData path, float offsetX, float offsetY)
 {
     context.FillPath(brush, path, offsetX, offsetY, true);
 }
Exemplo n.º 29
0
 public static void FillCircle(this RenderContext context, ID2DBrush brush, PointF center, float radius)
 {
     context.RenderTarget.DeviceContext2D.FillCircle(brush, center, radius);
 }
Exemplo n.º 30
0
 public static void FillPath(this RenderContext context, ID2DBrush brush, D2DFontPathData path, Point offset)
 {
     context.FillPath(brush, path, offset, true);
 }