• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Direct2D.D2dBrush类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Sce.Atf.Direct2D.D2dBrush的典型用法代码示例。如果您正苦于以下问题:C# D2dBrush类的具体用法?C# D2dBrush怎么用?C# D2dBrush使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



D2dBrush类属于Sce.Atf.Direct2D命名空间,在下文中一共展示了D2dBrush类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: DrawVerticalScaleGrid

        /// <summary>
        /// Draws grid lines corresponding to a vertical scale</summary>
        /// <param name="g">The Direct2D graphics object</param>
        /// <param name="transform">Graph (world) to window's client (screen) transform</param>
        /// <param name="graphRect">Graph rectangle</param>
        /// <param name="majorSpacing">Scale's major spacing</param>
        /// <param name="lineBrush">Grid line brush</param>
        public static void DrawVerticalScaleGrid(
            this D2dGraphics g,
            Matrix transform,
            RectangleF graphRect,
            int majorSpacing,
            D2dBrush lineBrush)
        {
            double xScale = transform.Elements[0];
            RectangleF clientRect = Transform(transform, graphRect);

            double min = Math.Min(graphRect.Left, graphRect.Right);
            double max = Math.Max(graphRect.Left, graphRect.Right);
            double tickAnchor = CalculateTickAnchor(min, max);
            double step = CalculateStep(min, max, Math.Abs(clientRect.Right - clientRect.Left), majorSpacing, 0.0);
            if (step > 0)
            {
                double offset = tickAnchor - min;
                offset = offset - MathUtil.Remainder(offset, step) + step;
                for (double x = tickAnchor - offset; x <= max; x += step)
                {
                    double cx = (x - graphRect.Left) * xScale + clientRect.Left;
                    g.DrawLine((float)cx, clientRect.Top, (float)cx, clientRect.Bottom, lineBrush);
                }
            }
        }
开发者ID:Joxx0r,项目名称:ATF,代码行数:32,代码来源:D2dUtil.cs


示例2: DrawExpander

 /// <summary>
 /// Draws a tree-control style expander, which looks like a square with
 /// a dash (expanded) or a cross (unexpanded)</summary>
 /// <param name="g">The Direct2D graphics object</param>
 /// <param name="x">X coordinate of expander top left corner</param>
 /// <param name="y">Y coordinate of expander top left corner</param>
 /// <param name="size">Size of expander, in pixels</param>
 /// <param name="brush">Brush</param>
 /// <param name="expanded">Whether or not expander should appear "expanded"</param>
 public static void DrawExpander(this D2dGraphics g, float x, float y, float size, D2dBrush brush, bool expanded)
 {
     s_expanderPoints[0] = new PointF(x, y + size);
     if (expanded)
     {                
         s_expanderPoints[1] = new PointF(x + size, y + size);
         s_expanderPoints[2] = new PointF(x + size, y);
         g.FillPolygon(s_expanderPoints, brush);
     }
     else
     {                
         s_expanderPoints[1] = new PointF(x + size, y + size / 2);
         s_expanderPoints[2] = new PointF(x, y);
         g.DrawPolygon(s_expanderPoints, brush, 1.0f);
     }
 }
开发者ID:sbambach,项目名称:ATF,代码行数:25,代码来源:D2dUtil.cs


示例3: DrawEyeIcon

        /// <summary>
        /// Draws the eye icon</summary>
        /// <param name="g">The D2dGraphics graphics object</param>
        /// <param name="rect">The rectangle to fit the eye icon in</param>
        /// <param name="pen">The pen used to draw the icon</param>
        /// <param name="strokeWidth">Width of the stroke</param>
        public static void DrawEyeIcon(this D2dGraphics g, RectangleF rect, D2dBrush pen, float strokeWidth)
        {
            float delta = rect.Width / 3;
            var p1 = new PointF(rect.X, rect.Y + rect.Height / 2);
            var p2 = new PointF(p1.X + delta, rect.Y);
            var p3 = new PointF(p1.X + 2 * delta, rect.Y);
            var p4 = new PointF(rect.X + rect.Width, rect.Y + rect.Height / 2);
            g.DrawBezier(p1, p2, p3, p4, pen, strokeWidth);// top lid
            p2 = new PointF(p2.X, rect.Y + rect.Height);
            p3 = new PointF(p3.X, rect.Y + rect.Height);
            g.DrawBezier(p1, p2, p3, p4, pen, strokeWidth); //bottom lid

            var irisCenter = new PointF(rect.X + rect.Width / 2, rect.Y + rect.Height / 2);
            float irisRadius = 0.2f * Math.Min(rect.Width, rect.Height);
            var irisRect = new RectangleF(irisCenter.X - irisRadius, irisCenter.Y - irisRadius, 2 * irisRadius, 2 * irisRadius);
            g.DrawEllipse(irisRect, pen, strokeWidth * 1.8f);
        }
开发者ID:sbambach,项目名称:ATF,代码行数:23,代码来源:D2dUtil.cs


示例4: DrawExpander

        /// <summary>
        /// Draws a tree-control style expander, which looks like a square with
        /// a dash (expanded) or a cross (unexpanded)</summary>
        /// <param name="g">The Direct2D graphics object</param>
        /// <param name="x">X coordinate of expander top left corner</param>
        /// <param name="y">Y coordinate of expander top left corner</param>
        /// <param name="size">Size of expander, in pixels</param>
        /// <param name="brush">Brush</param>
        /// <param name="expanded">Whether or not expander should appear "expanded"</param>
        public static void DrawExpander(this D2dGraphics g, float x, float y, float size, D2dBrush brush, bool expanded)
        {
            s_expanderPoints[0] = new PointF(x, y + size);
            if (expanded)
            {                
                s_expanderPoints[1] = new PointF(x + size, y + size);
                s_expanderPoints[2] = new PointF(x + size, y);
                g.FillPolygon(s_expanderPoints, brush);
            }
            else
            {                
                s_expanderPoints[1] = new PointF(x + size, y + size / 2);
                s_expanderPoints[2] = new PointF(x, y);
                g.DrawPolygon(s_expanderPoints, brush, 1.0f);
            }

            //g.DrawRectangle(new RectangleF(x, y, size, size), brush);           
            //float lineLength = size - 4;
            //float center = size / 2;
            //g.DrawLine(x + 2, y + center, x + 2 + lineLength, y + center, brush);
            //if (!expanded)
            //    g.DrawLine(x + center, y + 2, x + center, y + 2 + lineLength, brush);
        }
开发者ID:Joxx0r,项目名称:ATF,代码行数:32,代码来源:D2dUtil.cs


示例5: FillRectangle

 /// <summary>
 /// Paints the interior of the specified rectangle</summary>
 /// <param name="rect">Rectangle to paint, in pixels</param>
 /// <param name="brush">The brush used to paint the rectangle's interior</param>
 public void FillRectangle(RectangleF rect, D2dBrush brush)
 {
     m_renderTarget.FillRectangle(rect.ToSharpDX(), brush.NativeBrush);
 }
开发者ID:sbambach,项目名称:ATF,代码行数:8,代码来源:D2dGraphics.cs


示例6: FillOpacityMask

 /// <summary>
 /// Draws a solid rectangle with the specified brush while using the alpha channel of the given
 /// bitmap to control the opacity of each pixel.</summary>
 /// <param name="opacityMask">The opacity mask to apply to the brush. The alpha value of
 /// each pixel in the region specified by sourceRectangle is multiplied with the alpha value
 /// of the brush after the brush has been mapped to the area defined by destinationRectangle.</param>
 /// <param name="brush">The brush used to paint the region of the render target specified by destinationRectangle.</param>
 /// <param name="destRect">The region of the render target to paint, in device-independent pixels.</param>
 /// <param name="sourceRect">The region of the bitmap to use as the opacity mask, in device-independent pixels.</param>
 public void FillOpacityMask(D2dBitmap opacityMask, D2dBrush brush, RectangleF destRect, RectangleF sourceRect)
 {
     m_renderTarget.FillOpacityMask(opacityMask.NativeBitmap, brush.NativeBrush,
                                    OpacityMaskContent.Graphics,
                                    destRect.ToSharpDX(), sourceRect.ToSharpDX());
 }
开发者ID:sbambach,项目名称:ATF,代码行数:15,代码来源:D2dGraphics.cs


示例7: FillPolygon

        /// <summary>
        /// Fills the interior of a polygon defined by given points</summary>
        /// <param name="points">Array of PointF structures that represent the vertices of
        /// the polygon to fill</param>
        /// <param name="brush">Brush that determines the characteristics of the fill</param>
        public void FillPolygon(IEnumerable<PointF> points, D2dBrush brush)
        {
            var iter = points.GetEnumerator();
            if (!iter.MoveNext()) return;

            using (var geom = new PathGeometry(D2dFactory.NativeFactory))
            {
                var sink = geom.Open();
                var pt1 = iter.Current;
                sink.BeginFigure(pt1.ToSharpDX(), FigureBegin.Filled);
                while (iter.MoveNext())
                {
                    sink.AddLine(iter.Current.ToSharpDX());
                }
                sink.EndFigure(FigureEnd.Closed);
                sink.Close();
                sink.Dispose();

                m_renderTarget.FillGeometry(geom, brush.NativeBrush);
            }
        }
开发者ID:sbambach,项目名称:ATF,代码行数:26,代码来源:D2dGraphics.cs


示例8: DrawEllipse

 /// <summary>
 /// Draws the outline of the specified ellipse</summary>
 /// <param name="rect">The rectangle, in pixels, that encloses the ellipse to paint</param>
 /// <param name="brush">The brush used to paint the ellipse's outline</param>
 /// <param name="strokeWidth">The thickness of the ellipse's stroke. The stroke is centered on the ellipse's outline.</param>
 /// <param name="strokeStyle">The style of stroke to apply to the ellipse's outline or null to draw a solid line</param>
 public void DrawEllipse(RectangleF rect, D2dBrush brush, float strokeWidth = 1.0f, D2dStrokeStyle strokeStyle = null)
 {
     var tmpEllipse = new Ellipse();
     tmpEllipse.RadiusX = rect.Width * 0.5f;
     tmpEllipse.RadiusY = rect.Height * 0.5f;
     tmpEllipse.Point = new Vector2(rect.X + tmpEllipse.RadiusX, rect.Y + tmpEllipse.RadiusY);
     m_renderTarget.DrawEllipse(tmpEllipse, brush.NativeBrush, strokeWidth,
         strokeStyle != null ? strokeStyle.NativeStrokeStyle : null);
 }
开发者ID:sbambach,项目名称:ATF,代码行数:15,代码来源:D2dGraphics.cs


示例9: FillEllipse

 /// <summary>
 /// Paints the interior of the specified ellipse</summary>
 /// <param name="ellipse">The position and radius, in pixels, of the ellipse to paint</param>
 /// <param name="brush">The brush used to paint the interior of the ellipse</param>
 public void FillEllipse(D2dEllipse ellipse, D2dBrush brush)
 {
     m_renderTarget.FillEllipse(ellipse.ToSharpDX(), brush.NativeBrush);
 }
开发者ID:sbambach,项目名称:ATF,代码行数:8,代码来源:D2dGraphics.cs


示例10: DrawArc

        /// <summary>
        /// Draws an arc representing a portion of an ellipse specified by a D2dEllipse</summary>
        /// <param name="ellipse">Ellipse to draw</param>
        /// <param name="brush">The brush used to paint the arc's outline</param>
        /// <param name="startAngle">Starting angle in degrees measured clockwise from the x-axis 
        /// to the starting point of the arc</param>
        /// <param name="sweepAngle">Sweep angle in degrees measured clockwise from the startAngle 
        /// parameter to ending point of the arc</param>
        /// <param name="strokeWidth">The thickness of the ellipse's stroke. The stroke is centered 
        /// on the ellipse's outline.</param>
        /// <param name="strokeStyle">The style of stroke to apply to the arc's outline or null to draw a solid line</param>
        public void DrawArc(D2dEllipse ellipse, D2dBrush brush, float startAngle, float sweepAngle, float strokeWidth = 1.0f, D2dStrokeStyle strokeStyle = null)
        {
            // compute steps
            float step = Tessellation / m_scale.X;
            float angle1 = startAngle * ToRadian;
            float angle2 = (startAngle + sweepAngle) * ToRadian;
            if (angle1 > angle2)
            {
                float temp = angle1;
                angle1 = angle2;
                angle2 = temp;
            }

            float cx = ellipse.Center.X;
            float cy = ellipse.Center.Y;

            var v1 = new Vec2F();
            v1.X = ellipse.RadiusX * (float)Math.Cos(angle1);
            v1.Y = ellipse.RadiusY * (float)Math.Sin(angle1);

            var v2 = new Vec2F();
            v2.X = ellipse.RadiusX * (float)Math.Cos(angle2);
            v2.Y = ellipse.RadiusY * (float)Math.Sin(angle2);

            float arcLen = (v2 - v1).Length; // approx arc len.
            float numSegs = arcLen / step;
            float dtheta = (angle2 - angle1) / numSegs;

            m_tempPoints.Clear();
            for (float theta = angle1; theta < angle2; theta += dtheta)
            {
                var pt = new PointF();
                pt.X = cx + ellipse.RadiusX * (float)Math.Cos(theta);
                pt.Y = cy + ellipse.RadiusY * (float)Math.Sin(theta);
                m_tempPoints.Add(pt);
            }
            DrawLines(m_tempPoints, brush, strokeWidth, strokeStyle);
        }
开发者ID:sbambach,项目名称:ATF,代码行数:49,代码来源:D2dGraphics.cs


示例11: DrawHorizontalScale

        /// <summary>
        /// Draws a horizontal chart scale</summary>
        /// <param name="g">The Direct2D graphics object</param>
        /// <param name="transform">Graph (world) to window's client (screen) transform</param>
        /// <param name="graphRect">Graph rectangle</param>
        /// <param name="top">Whether or not the scale should be aligned along the top of the rectangle</param>
        /// <param name="majorSpacing">Spacing, in pixels, between major tick marks</param>
        /// <param name="minimumGraphStep">Minimum spacing, in graph (world) space, between ticks.
        /// For example, 1.0 would limit ticks to being drawn on whole integers.</param>
        /// <param name="lineBrush">Scale line pen</param>
        /// <param name="textFormat">Text format</param>
        /// <param name="textBrush">Text brush</param>
        public static void DrawHorizontalScale(
            this D2dGraphics g,
            Matrix transform,
            RectangleF graphRect,
            bool top,
            int majorSpacing,
            float minimumGraphStep,
            D2dBrush lineBrush,
            D2dTextFormat textFormat,
            D2dBrush textBrush)
        {
            double xScale = transform.Elements[0];
            RectangleF clientRect = Transform(transform, graphRect);

            double tickEnd, majorTickStart, minorTickStart, textStart;

            if (top)
            {
                tickEnd = clientRect.Top + 1;
                majorTickStart = tickEnd + 12;
                minorTickStart = tickEnd + 6;
                textStart = tickEnd + 8;
            }
            else
            {
                tickEnd = clientRect.Bottom - 1;
                majorTickStart = tickEnd - 12;
                minorTickStart = tickEnd - 6;
                textStart = tickEnd - 19;
            }

            double min = Math.Min(graphRect.Left, graphRect.Right);
            double max = Math.Max(graphRect.Left, graphRect.Right);

            double tickAnchor = CalculateTickAnchor(min, max);
            double majorGraphStep = CalculateStep(
                min, max, Math.Abs(clientRect.Right - clientRect.Left), majorSpacing, minimumGraphStep);
            int numMinorTicks = CalculateNumMinorTicks(majorGraphStep, minimumGraphStep, 5);
            double cMinorStep = (majorGraphStep / numMinorTicks) * xScale;
            if (majorGraphStep > 0)
            {
                double offset = tickAnchor - min;
                offset = offset - MathUtil.Remainder(offset, majorGraphStep);

                // draw leading minor ticks
                double cmx;
                cmx = ((tickAnchor - (offset + majorGraphStep)) - min) * xScale + clientRect.Left + cMinorStep;
                for (int i = 0; i < numMinorTicks - 1 && cmx < clientRect.Right; i++)
                {
                    // cull minor ticks outside of the view
                    if (cmx > clientRect.Left)
                    {
                        g.DrawLine((float)cmx, (float)minorTickStart, (float)cmx, (float)tickEnd, lineBrush);
                    }
                    cmx += cMinorStep;
                }

                for (double x = tickAnchor - offset; x < max; x += majorGraphStep)
                {
                    double cx = (x - min) * xScale + clientRect.Left;
                    g.DrawLine((float)cx, (float)majorTickStart, (float)cx, (float)tickEnd, lineBrush);
                    string xString = String.Format("{0:G8}", Math.Round(x, 6));
                    SizeF textSize = g.MeasureText(xString, textFormat);
                    var textRect = new RectangleF(new PointF((float)cx + 1, (float)textStart), textSize);
                    g.DrawText(xString, textFormat, textRect, textBrush);

                    // draw minor ticks
                    cmx = cx + cMinorStep;
                    for (int i = 0; i < numMinorTicks - 1 && cmx < clientRect.Right; i++)
                    {
                        g.DrawLine((float)cmx, (float)minorTickStart, (float)cmx, (float)tickEnd, lineBrush);
                        cmx += cMinorStep;
                    }
                }
            }
        }
开发者ID:Joxx0r,项目名称:ATF,代码行数:88,代码来源:D2dUtil.cs


示例12: DrawRoundedRectangle

 /// <summary>
 ///  Draws the outline of the specified rounded rectangle</summary>
 /// <param name="roundedRect">The dimensions of the rounded rectangle to draw, in pixels</param>
 /// <param name="brush">The brush used to paint the rounded rectangle's outline</param>
 /// <param name="strokeWidth">The width of the rounded rectangle's stroke. The stroke is centered on the
 /// rounded rectangle's outline.</param>
 /// <param name="strokeStyle">The style of the rounded rectangle's stroke, or null to paint a solid stroke</param>
 public void DrawRoundedRectangle(D2dRoundedRect roundedRect, D2dBrush brush, float strokeWidth = 1.0f, D2dStrokeStyle strokeStyle = null)
 {
     m_renderTarget.DrawRoundedRectangle(roundedRect.ToSharpDX(), brush.NativeBrush, strokeWidth,
         strokeStyle != null ? strokeStyle.NativeStrokeStyle : null);
 }
开发者ID:sbambach,项目名称:ATF,代码行数:12,代码来源:D2dGraphics.cs


示例13: DrawText

 /// <summary>
 /// Draws the specified text using the format information provided at the specified location</summary>
 /// <param name="text">The text string to draw</param>
 /// <param name="textFormat">The text format object to use</param>
 /// <param name="upperLeft">Upper left corner of the text</param>
 /// <param name="brush">The brush to use to draw the text</param>
 public void DrawText(string text, D2dTextFormat textFormat, PointF upperLeft, D2dBrush brush)
 {
     var rtsize = Size;
     using (var layout
         = new SharpDX.DirectWrite.TextLayout(D2dFactory.NativeDwFactory,
             text, textFormat.NativeTextFormat, rtsize.Width, rtsize.Height))
     {
         layout.TextAlignment = SharpDX.DirectWrite.TextAlignment.Leading;
         layout.ParagraphAlignment = SharpDX.DirectWrite.ParagraphAlignment.Near;
         if (textFormat.Underlined)
             layout.SetUnderline(true,new SharpDX.DirectWrite.TextRange(0, text.Length));
         if (textFormat.Strikeout)
             layout.SetStrikethrough(true,new SharpDX.DirectWrite.TextRange(0, text.Length));
         m_renderTarget.DrawTextLayout(upperLeft.ToSharpDX(),
             layout,
             brush.NativeBrush,
             (DrawTextOptions)textFormat.DrawTextOptions);
     }
 }
开发者ID:sbambach,项目名称:ATF,代码行数:25,代码来源:D2dGraphics.cs


示例14: DrawLines

        /// <summary>
        /// Draws a series of line segments that connect an array of System.Drawing.PointF</summary>
        /// <param name="points">Array of PointF that represent the points to connect</param>
        /// <param name="brush">The brush used to paint the line's stroke</param>
        /// <param name="strokeWidth">A value greater than or equal to 0.0f that specifies the width of the stroke</param>
        /// <param name="strokeStyle">The style of stroke to paint, or NULL to paint a solid line</param>
        public void DrawLines(IEnumerable<PointF> points, D2dBrush brush, float strokeWidth = 1.0f, D2dStrokeStyle strokeStyle = null)
        {
            var iter = points.GetEnumerator();
            if (!iter.MoveNext()) return;

            var transparent = brush.Opacity < 1.0f;
            if (!transparent)
            {
                var sbrush = brush as D2dSolidColorBrush;
                if (sbrush != null)
                    transparent = sbrush.Color.A < 255;
            }

            var nstroke = (strokeStyle ?? s_strokeStyle).NativeStrokeStyle;

            if (transparent)
            {
                using (var geom = new PathGeometry(D2dFactory.NativeFactory))
                {
                    var sink = geom.Open();
                    var pt1 = iter.Current;
                    sink.BeginFigure(pt1.ToSharpDX(), FigureBegin.Hollow);
                    while (iter.MoveNext())
                    {
                        sink.AddLine(iter.Current.ToSharpDX());
                    }
                    sink.EndFigure(FigureEnd.Open);
                    sink.Close();
                    sink.Dispose();

                    m_renderTarget.DrawGeometry(geom, brush.NativeBrush, strokeWidth, nstroke);
                }
            }
            else
            {
                var nbrush = brush.NativeBrush;
                var pt1 = iter.Current;
                while (iter.MoveNext())
                {
                    var pt2 = iter.Current;
                    m_renderTarget.DrawLine(pt1.ToSharpDX(), pt2.ToSharpDX(), nbrush,
                            strokeWidth, nstroke);
                    pt1 = pt2;
                }
            }
        }
开发者ID:sbambach,项目名称:ATF,代码行数:52,代码来源:D2dGraphics.cs


示例15: DrawPolygon

        /// <summary>
        /// Draws a polygon defined by an array of PointF structures</summary>
        /// <param name="points">Array of System.Drawing.PointF structures 
        /// that represent the vertices of the polygon</param>
        /// <param name="brush">The brush used to paint the polygon's stroke</param>
        /// <param name="strokeWidth">A value greater than or equal to 0.0f that specifies the width of the stroke</param>
        /// <param name="strokeStyle">The style of stroke to paint, or NULL to paint a solid line</param>
        public void DrawPolygon(IEnumerable<PointF> points, D2dBrush brush, float strokeWidth = 1.0f, D2dStrokeStyle strokeStyle = null)
        {
            var iter = points.GetEnumerator();
            if (!iter.MoveNext()) return;

            using (var geom = new PathGeometry(D2dFactory.NativeFactory))
            {
                var sink = geom.Open();
                var pt1 = iter.Current;
                sink.BeginFigure(pt1.ToSharpDX(), FigureBegin.Hollow);
                while (iter.MoveNext())
                {
                    sink.AddLine(iter.Current.ToSharpDX());
                }
                sink.EndFigure(FigureEnd.Closed);
                sink.Close();
                sink.Dispose();

                m_renderTarget.DrawGeometry(geom, brush.NativeBrush, strokeWidth,
                    strokeStyle != null ? strokeStyle.NativeStrokeStyle : null);
            }
        }
开发者ID:sbambach,项目名称:ATF,代码行数:29,代码来源:D2dGraphics.cs


示例16: DrawLine

 /// <summary>
 /// Draws a line between the specified points</summary>
 /// <param name="pt1">The start point of the line, in pixels</param>
 /// <param name="pt2">The end point of the line, in pixels</param>
 /// <param name="brush">The brush used to paint the line's stroke</param>
 /// <param name="strokeWidth">A value greater than or equal to 0.0f that specifies the width of the stroke</param>
 /// <param name="strokeStyle">The style of stroke to paint, or NULL to paint a solid line</param>
 public void DrawLine(PointF pt1, PointF pt2, D2dBrush brush, float strokeWidth = 1.0f, D2dStrokeStyle strokeStyle = null)
 {
     m_renderTarget.DrawLine(pt1.ToSharpDX(), pt2.ToSharpDX(),
         brush.NativeBrush, strokeWidth,
         strokeStyle != null ? strokeStyle.NativeStrokeStyle : null);
 }
开发者ID:sbambach,项目名称:ATF,代码行数:13,代码来源:D2dGraphics.cs


示例17: FillRoundedRectangle

 /// <summary>
 /// Paints the interior of the specified rounded rectangle</summary>
 /// <param name="roundedRect">The dimensions of the rounded rectangle to paint, in pixels</param>
 /// <param name="brush">The brush used to paint the interior of the rounded rectangle</param>
 public void FillRoundedRectangle(D2dRoundedRect roundedRect, D2dBrush brush)
 {
     var tmp = roundedRect.ToSharpDX();
     m_renderTarget.FillRoundedRectangle(ref tmp, brush.NativeBrush);
 }
开发者ID:sbambach,项目名称:ATF,代码行数:9,代码来源:D2dGraphics.cs


示例18: DrawPin

 /// <summary>
 /// Draws a pin button, which looks like a square with
 /// a dash (expanded) or a cross (unexpanded).</summary>
 /// <param name="x">X coordinate of pin top left corner</param>
 /// <param name="y">Y coordinate of pin top left corner</param>
 /// <param name="pinned">Whether or not pin should appear "pinned"</param>
 /// <param name="toLeft">Whether pin points left or right</param>
 /// <param name="pen">Pen, should be 1 pixel wide</param>
 /// <param name="g">Graphics object</param>
 public static void DrawPin(int x, int y, bool pinned, bool toLeft, D2dBrush pen, D2dGraphics g)
 {
     if (toLeft)
         DrawLeftPin(x, y, ThumbtackSize, pen, pinned, g);
     else
         DrawRightPin(x, y, ThumbtackSize, pen, pinned, g);
 }
开发者ID:Joxx0r,项目名称:ATF,代码行数:16,代码来源:D2dUtil.cs


示例19: DrawPath

        /// <summary>
        /// Draws a path defined by an enumeration of EdgeStyleData structures</summary>
        /// <param name="path">The enumeration of drawing primitives that describes the contents of the path</param>
        /// <param name="brush">The brush used to paint the path's stroke</param>
        /// <param name="strokeWidth">A value greater than or equal to 0.0f that specifies the width of the stroke</param>
        /// <remarks>Assume the end point of one primitive be coincident with the start point of the following primitive in a path</remarks>
        /// <param name="strokeStyle">The style of the rounded rectangle's stroke, or null to paint a solid stroke</param>
        public void DrawPath(IEnumerable<EdgeStyleData> path, D2dBrush brush, float strokeWidth = 1.0f, D2dStrokeStyle strokeStyle = null)
        {
            using (var geom = new PathGeometry(D2dFactory.NativeFactory))
            {
                var sink = geom.Open();
                var firstPoint = true;
                foreach (var edge in path)
                {
                    if (edge.ShapeType == EdgeStyleData.EdgeShape.Line)
                    {
                        var line = edge.EdgeData.As<PointF[]>();
                        if (firstPoint)
                        {
                            sink.BeginFigure(line[0].ToSharpDX(), FigureBegin.Hollow);
                            firstPoint = false;
                        }
                        for (var i = 1; i < line.Length; ++i)
                            sink.AddLine(line[i].ToSharpDX());

                    }
                    else if (edge.ShapeType == EdgeStyleData.EdgeShape.Bezier)
                    {
                        var curve = edge.EdgeData.As<BezierCurve2F>();
                        if (firstPoint)
                        {
                            sink.BeginFigure(curve.P1.ToSharpDX(), FigureBegin.Hollow);
                            firstPoint = false;
                        }
                        var seg = new BezierSegment
                        {
                            Point1 = curve.P2.ToSharpDX(),
                            Point2 = curve.P3.ToSharpDX(),
                            Point3 = curve.P4.ToSharpDX()
                        };
                        sink.AddBezier(seg);
                    }
                }
                sink.EndFigure(FigureEnd.Open);
                sink.Close();
                sink.Dispose();

                m_renderTarget.DrawGeometry(geom, brush.NativeBrush, strokeWidth,
                    strokeStyle != null ? strokeStyle.NativeStrokeStyle : null);
            }
        }
开发者ID:sbambach,项目名称:ATF,代码行数:52,代码来源:D2dGraphics.cs


示例20: DrawLink

        /// <summary>
        /// Draws an icon that indicates a linked (referenced) item</summary>
        /// <param name="g">The Direct2D graphics object</param>
        /// <param name="x">X coordinate of icon top left corner</param>
        /// <param name="y">Y coordinate of icon top left corner</param>
        /// <param name="size">Size of expander, in pixels</param>
        /// <param name="brush">Brush</param>
        public static void DrawLink(this D2dGraphics g, float x, float y, float size, D2dBrush brush)
        {
            var path = new EdgeStyleData[5];
            var pathData = new PointF[16];
            for (int i = 0; i < 16; ++i)
            {
                pathData[i] = new PointF(s_unitCurvedArrowData[i].X * size + x, s_unitCurvedArrowData[i].Y * size + y);
            }

            var edgeData = new EdgeStyleData
           {
               ShapeType = EdgeStyleData.EdgeShape.Line,
               EdgeData = new PointF[] { pathData[0], pathData[1], pathData[2], pathData[3] }
           };
            path[0] = edgeData;

            edgeData = new EdgeStyleData
            {
                ShapeType = EdgeStyleData.EdgeShape.Bezier,
                EdgeData = new BezierCurve2F(pathData[3], pathData[4], pathData[5], pathData[6])
            };
            path[1] = edgeData;

            edgeData = new EdgeStyleData
            {
                ShapeType = EdgeStyleData.EdgeShape.Bezier,
                EdgeData = new BezierCurve2F(pathData[6], pathData[7], pathData[8], pathData[9])
            };
            path[2] = edgeData;

            edgeData = new EdgeStyleData
            {
                ShapeType = EdgeStyleData.EdgeShape.Bezier,
                EdgeData = new BezierCurve2F(pathData[9], pathData[10], pathData[11], pathData[12])
            };
            path[3] = edgeData;

            edgeData = new EdgeStyleData
            {
                ShapeType = EdgeStyleData.EdgeShape.Bezier,
                EdgeData = new BezierCurve2F(pathData[12], pathData[13], pathData[14], pathData[15])
            };
            path[4] = edgeData;

            g.FillPath(path, brush);
        }
开发者ID:Joxx0r,项目名称:ATF,代码行数:53,代码来源:D2dUtil.cs



注:本文中的Sce.Atf.Direct2D.D2dBrush类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Dom.ChildEventArgs类代码示例发布时间:2022-05-26
下一篇:
C# Controls.TreeControl类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap