Exemplo n.º 1
0
        /// <summary>
        /// Fills a Polygon.
        /// </summary>
        /// <param name="color">The Color.</param>
        /// <param name="polygon">The Polygon.</param>
        public void FillPolygon(Color color, Polygon polygon)
        {
            var geometry = new PathGeometry(DirectXHelper.Direct2DFactory);

            using (GeometrySink sink = geometry.Open())
            {
                sink.BeginFigure(DirectXHelper.ConvertVector(polygon.Points[0]), FigureBegin.Filled);

                for (int i = 1; i < polygon.Points.Length; i++)
                {
                    sink.AddLine(DirectXHelper.ConvertVector(polygon.Points[i]));
                }

                sink.EndFigure(FigureEnd.Closed);
                sink.Close();

                _renderTarget.FillGeometry(geometry,
                                           new SolidColorBrush(DirectXHelper.RenderTarget, DirectXHelper.ConvertColor(color)));
            }

            geometry.Dispose();
        }
Exemplo n.º 2
0
 /// <summary>
 /// Fills a Ellipse.
 /// </summary>
 /// <param name="color">The Color.</param>
 /// <param name="ellipse">The Ellipse.</param>
 public void FillEllipse(Color color, Ellipse ellipse)
 {
     _renderTarget.FillEllipse(new SolidColorBrush(_renderTarget, DirectXHelper.ConvertColor(color)),
                               DirectXHelper.ConvertEllipse(ellipse));
 }
Exemplo n.º 3
0
        /// <summary>
        /// Draws a string.
        /// </summary>
        /// <param name="text">The Text.</param>
        /// <param name="font">The Font.</param>
        /// <param name="position">The Position.</param>
        /// <param name="color">The Color.</param>
        public void DrawString(string text, Font font, Vector2 position, Color color)
        {
            var dxFont = font.Instance as DirectXFont;

            if (dxFont == null)
            {
                throw new ArgumentException("DirectX10 expects a DirectXFont as resource.");
            }

            _renderTarget.DrawText(text, dxFont.GetFont(),
                                   new RectangleF(position.X, position.Y, 9999, 9999), DirectXHelper.ConvertSolidColorBrush(color));
        }
Exemplo n.º 4
0
 /// <summary>
 /// Fills a Rectangle.
 /// </summary>
 /// <param name="color">The Color.</param>
 /// <param name="rectangle">The Rectangle.</param>
 public void FillRectangle(Color color, Rectangle rectangle)
 {
     _renderTarget.FillRectangle(new SolidColorBrush(_renderTarget, DirectXHelper.ConvertColor(color)),
                                 DirectXHelper.ConvertRectangle(rectangle));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Begins the draw operation.
 /// </summary>
 public void Begin()
 {
     _renderTarget.BeginDraw();
     _renderTarget.Transform = Matrix3x2.Identity;
     _renderTarget.Clear(DirectXHelper.ConvertColor(_graphicsDevice.ClearColor));
 }