当前位置: 首页>>代码示例>>C#>>正文


C# IGraphics.DrawPath方法代码示例

本文整理汇总了C#中IGraphics.DrawPath方法的典型用法代码示例。如果您正苦于以下问题:C# IGraphics.DrawPath方法的具体用法?C# IGraphics.DrawPath怎么用?C# IGraphics.DrawPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IGraphics的用法示例。


在下文中一共展示了IGraphics.DrawPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DrawEndCap

		protected override void DrawEndCap(IGraphics g, bool onScreen, Style style)
		{
			linePen.Color = style.RelationshipColor;
			linePen.Width = style.RelationshipWidth;

			g.FillPath(Brushes.White, Arrowhead.ClosedArrowPath);
			g.DrawPath(linePen, Arrowhead.ClosedArrowPath);
		}
开发者ID:gbaychev,项目名称:NClass,代码行数:8,代码来源:Realization.cs

示例2: Draw

        /// <summary>
        ///     Draws this object to the <see cref="T:EscherTiler.Graphics.IGraphics" /> provided.
        /// </summary>
        /// <param name="graphics">The graphics object to use to draw this object.</param>
        public override void Draw(IGraphics graphics)
        {
            if (_resourceManager == null) throw new ObjectDisposedException(nameof(ShapeController));

            graphics.ResourceManager = _resourceManager;

            foreach (Shape shape in Shapes)
            {
                using (IGraphicsPath path = graphics.CreatePath())
                {
                    bool first = true;
                    foreach (Vertex vertex in shape.Vertices)
                    {
                        if (first) path.Start(vertex.Location);
                        else path.AddLine(vertex.Location);
                        first = false;
                    }

                    path.End();

                    graphics.DrawPath(path);
                }
            }
        }
开发者ID:billings7,项目名称:EscherTilier,代码行数:28,代码来源:ShapeController.cs

示例3: OnRenderInternal

        /// <summary>
        /// Function that actually renders the linestring
        /// </summary>
        /// <param name="map">The map</param>
        /// <param name="lineString">The line string to symbolize.</param>
        /// <param name="graphics">The graphics</param>
        protected override void OnRenderInternal(Map map, ILineString lineString, IGraphics graphics)
        {
            var clonedPattern = (GraphicsPath) Pattern.Clone();
            var graphicsPath = WarpPathToPath.Warp(LineStringToPath(lineString, map), clonedPattern, true, Interval);
            
            if (graphicsPath == null) return;

            // Fill?
            if (Fill != null)
                graphics.FillPath(Fill, graphicsPath);
            
            // Outline
            if (Line != null)
                graphics.DrawPath(Line, graphicsPath);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:21,代码来源:WarpedLineSymbolizer.cs

示例4: SymbolizePaths

 /// <summary>
 /// Function to symbolize the graphics path to the graphics object
 /// </summary>
 /// <param name="g">The graphics object</param>
 /// <param name="path">The Path</param>
 public void SymbolizePaths(IGraphics g, IEnumerable<GraphicsPath> path)
 {
     foreach (var graphicsPath in path)
         g.DrawPath(Line, graphicsPath);
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:10,代码来源:CachedLineSymbolizer.cs

示例5: Draw

        /// <summary>
        /// Render this object to the specified <see cref="Graphics"/> device.
        /// </summary>
        /// <remarks>
        /// This method is normally only called by the Draw method
        /// of the parent <see cref="GraphObjList"/> collection object.
        /// </remarks>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="PaneBase"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="GraphPane"/> object using the
        /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        public override void Draw( IGraphics g, PaneBase pane, float scaleFactor )
        {
            if ( _points != null && _points.Length > 1 )
            {
                using ( GraphicsPath path = MakePath( pane ) )
                {
                    // Fill or draw the symbol as required
                    if ( _fill.IsVisible )
                    {
                        using ( Brush brush = this.Fill.MakeBrush( path.GetBounds() ) )
                            g.FillPath( brush, path );
                    }

                    if ( _border.IsVisible )
                    {
                        using ( Pen pen = _border.GetPen( pane, scaleFactor ) )
                            g.DrawPath( pen, path );
                    }
                }
            }
        }
开发者ID:konrad-zielinski,项目名称:ZedGraph,代码行数:42,代码来源:PolyObj.cs

示例6: OnRenderInternal

        /// <summary>
        /// Function that does the actual rendering
        /// </summary>
        /// <param name="pt">The point</param>
        /// <param name="g">The graphics object</param>
        internal override void OnRenderInternal(PointF pt, IGraphics g)
        {
            var f = new SizeF(pt);
            foreach (var pathDefinition in _paths)
            {
                var ppts = pathDefinition.Path.PathPoints;
                var pptsnew = new PointF[pathDefinition.Path.PointCount];
                for (int i = 0; i < pptsnew.Length; i++)
                    pptsnew[i] = PointF.Add(ppts[i], f);

                GraphicsPath ptmp = new GraphicsPath(pptsnew, pathDefinition.Path.PathTypes, pathDefinition.Path.FillMode);
                if (pathDefinition.Fill != null)
                    g.FillPath(pathDefinition.Fill, ptmp);
                if (pathDefinition.Line != null)
                    g.DrawPath(pathDefinition.Line, ptmp);

            }
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:23,代码来源:PathPointSymbolizer.cs

示例7: DrawBorder

        /// <summary>
        /// Draw specific border (top/bottom/left/right) with the box data (style/width/rounded).<br/>
        /// </summary>
        /// <param name="border">desired border to draw</param>
        /// <param name="box">the box to draw its borders, contain the borders data</param>
        /// <param name="g">the device to draw into</param>
        /// <param name="rect">the rectangle the border is enclosing</param>
        /// <param name="isLineStart">Specifies if the border is for a starting line (no bevel on left)</param>
        /// <param name="isLineEnd">Specifies if the border is for an ending line (no bevel on right)</param>
        private static void DrawBorder(Border border, CssBox box, IGraphics g, RectangleF rect, bool isLineStart, bool isLineEnd)
        {
            var style = GetStyle(border, box);
            var color = GetColor(border, box, style);

            var borderPath = GetRoundedBorderPath(border, box, rect);
            if (borderPath != null)
            {
                // rounded border need special path
                var smooth = g.SmoothingMode;
                if (box.HtmlContainer != null && !box.HtmlContainer.AvoidGeometryAntialias && box.IsRounded)
                    g.SmoothingMode = SmoothingMode.AntiAlias;

                var pen = GetPen(style, color, GetWidth(border, box));
                using (borderPath)
                    g.DrawPath(pen, borderPath);

                g.SmoothingMode = smooth;
            }
            else
            {
                // non rounded border
                if( style == CssConstants.Inset || style == CssConstants.Outset )
                {
                    // inset/outset border needs special rectangle
                    SetInOutsetRectanglePoints(border, box, rect, isLineStart, isLineEnd);
                    g.FillPolygon(RenderUtils.GetSolidBrush(color), _borderPts);
                }
                else
                {
                    // solid/dotted/dashed border draw as simple line
                    var pen = GetPen(style, color, GetWidth(border, box));
                    switch (border)
                    {
                        case Border.Top:
                            g.DrawLine(pen, rect.Left, rect.Top + box.ActualBorderTopWidth / 2, rect.Right -1, rect.Top + box.ActualBorderTopWidth / 2);
                            break;
                        case Border.Left:
                            g.DrawLine(pen, rect.Left + box.ActualBorderLeftWidth / 2, rect.Top, rect.Left + box.ActualBorderLeftWidth / 2, rect.Bottom);
                            break;
                        case Border.Bottom:
                            g.DrawLine(pen, rect.Left, rect.Bottom - box.ActualBorderBottomWidth / 2, rect.Right -1, rect.Bottom - box.ActualBorderBottomWidth / 2);
                            break;
                        case Border.Right:
                            g.DrawLine(pen, rect.Right - box.ActualBorderRightWidth / 2, rect.Top, rect.Right - box.ActualBorderRightWidth / 2, rect.Bottom);
                            break;
                    }
                }
            }
        }
开发者ID:havlenapetr,项目名称:HTMLRenderer,代码行数:59,代码来源:BordersDrawHandler.cs

示例8: DrawSymbol

        /// <summary>
        /// Draw the <see cref="Symbol"/> to the specified <see cref="Graphics"/> device
        /// at the specified location.  This routine draws a single symbol.
        /// </summary>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="x">The x position of the center of the symbol in
        /// pixel units</param>
        /// <param name="y">The y position of the center of the symbol in
        /// pixel units</param>
        /// <param name="path">A <see cref="GraphicsPath"/> previously constructed by
        /// <see cref="MakePath"/> for this symbol</param>
        /// <param name="pen">A <see cref="Pen"/> class representing the standard pen for this symbol</param>
        /// <param name="brush">A <see cref="Brush"/> class representing a default solid brush for this symbol
        /// If this symbol uses a <see cref="LinearGradientBrush"/>, it will be created on the fly for
        /// each point, since it has to be scaled to the individual point coordinates.</param>
        private void DrawSymbol( IGraphics g, int x, int y, GraphicsPath path,
							Pen pen, Brush brush )
        {
            // Only draw if the symbol is visible
            if ( _isVisible &&
                    this.Type != SymbolType.None &&
                    x < 100000 && x > -100000 &&
                    y < 100000 && y > -100000 )
            {
                Matrix saveMatrix = g.Transform;
                g.TranslateTransform( x, y );

                // Fill or draw the symbol as required
                if ( _fill.IsVisible )
                    g.FillPath( brush, path );
                //FillPoint( g, x, y, scaleFactor, pen, brush );

                if ( _border.IsVisible )
                    g.DrawPath( pen, path );
                //DrawPoint( g, x, y, scaleFactor, pen );

                g.Transform = saveMatrix;
            }
        }
开发者ID:konrad-zielinski,项目名称:ZedGraph,代码行数:42,代码来源:Symbol.cs

示例9: Render

        /// <summary>
        /// 
        /// </summary>
        /// <param name="g"></param>
        /// <param name="map"></param>
        public void Render(IGraphics g, Map map)
        {
            //Is this map decoration enabled?
            if (!Enabled)
                return;

            //Preparing rendering
            OnRendering(g, map);

            //Draw border
            GraphicsPath gp;
            if (RoundedEdges && !BorderMargin.IsEmpty)
                gp = CreateRoundedRectangle(_boundingRectangle, BorderMargin);
            else
            {
                gp = new GraphicsPath();
                gp.AddRectangle(_boundingRectangle);
            }
            g.DrawPath(new Pen(OpacityColor(BorderColor), BorderWidth), gp);
            g.FillPath(new SolidBrush(OpacityColor(BackgroundColor)), gp);

            //Clip region
            RectangleF oldClip = g.Clip;
            g.Clip = GetClipRegion(map);

            //Actually render the Decoration
            OnRender(g, map);

            //Restore old clip region
            g.Clip = oldClip;


            //Finished rendering
            OnRendered(g, map);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:40,代码来源:MapDecoration.cs

示例10: DrawRoundedSurface

        private void DrawRoundedSurface(IGraphics g, bool onScreen, Style style)
        {
            int diameter = GetRoundingSize(style) * 2;

            GraphicsPath borderPath = new GraphicsPath();
            borderPath.AddArc(Left, Top, diameter, diameter, 180, 90);
            borderPath.AddArc(Right - diameter, Top, diameter, diameter, 270, 90);
            borderPath.AddArc(Right - diameter, Bottom - diameter, diameter, diameter, 0, 90);
            borderPath.AddArc(Left, Bottom - diameter, diameter, diameter, 90, 90);
            borderPath.CloseFigure();

            // Draw shadow
            if ((!onScreen || !IsSelected) && !style.ShadowOffset.IsEmpty)
            {
                shadowBrush.Color = style.ShadowColor;
                g.TranslateTransform(style.ShadowOffset.Width, style.ShadowOffset.Height);
                g.FillPath(shadowBrush, borderPath);
                g.TranslateTransform(-style.ShadowOffset.Width, -style.ShadowOffset.Height);
            }

            // Draw background
            g.FillPath(backgroundBrush, borderPath);

            // Draw header background
            Region oldClip = g.Clip;
            g.SetClip(borderPath, CombineMode.Intersect);
            DrawHeaderBackground(g, style);
            g.Clip.Dispose();
            g.Clip = oldClip;

            // Draw border
            g.DrawPath(borderPen, borderPath);

            borderPath.Dispose();
        }
开发者ID:BachelorEric,项目名称:ModelFirst,代码行数:35,代码来源:TypeShape.cs

示例11: DrawRotatedText

        /// <summary>
        /// Method to draw <paramref name="text"/>, rotated by <paramref name="angle"/> around <paramref name="pointCenter"/>.
        /// </summary>
        /// <param name="gr">The <see cref="Graphics"/> object to use.</param>
        /// <param name="text">The text string</param>
        /// <param name="angle">The rotation angle</param>
        /// <param name="pointCenter">The center point around which to rotate</param>
        private void DrawRotatedText(IGraphics gr, string text, float angle, PointF pointCenter)
        {
            angle -= RotateDegree;
            var stringFormat =  new StringFormat { Alignment = StringAlignment.Center };

            //gr.SmoothingMode = SmoothingMode.HighQuality;
            //gr.CompositingQuality = CompositingQuality.HighQuality;
            //gr.TextRenderingHint = TextRendering.AntiAlias;
            using (var graphicsPath = new GraphicsPath())
            {
                var x = (int) pointCenter.X;
                var y = (int) pointCenter.Y;
                var pOrigin = new Point();
                switch (TextPathPathPosition)
                {
                    case TextPathPosition.OverPath:
                        pOrigin = new Point(x, (int) (y - _font.Size));
                        graphicsPath.AddString(text, _font.FontFamily, (int) _font.Style, _font.Size,
                                               new Point(x, (int) (y - _font.Size)), stringFormat);
                        break;
                    case TextPathPosition.CenterPath:
                        pOrigin = new Point(x, (int) (y - _font.Size/2));
                        graphicsPath.AddString(text, _font.FontFamily, (int) _font.Style, _font.Size,
                                               new Point(x, (int) (y - _font.Size/2)), stringFormat);
                        break;
                    case TextPathPosition.UnderPath:
                        pOrigin = new Point(x, y);
                        graphicsPath.AddString(text, _font.FontFamily, (int) _font.Style, _font.Size, new Point(x, y),
                                               stringFormat);
                        break;
                }


                var rotationMatrix = gr.Transform.Clone(); // new Matrix();
                rotationMatrix.RotateAt(angle, new PointF(x, y));
                graphicsPath.Transform(rotationMatrix);
                if (!_measureString)
                {
                    if (_colorHalo != null)
                    {
                        gr.DrawPath(_colorHalo, graphicsPath);
                    }
                    gr.FillPath(_fillBrush, graphicsPath);

                }
                else
                {
                    _regionList.Add(graphicsPath.GetBounds());
                    _angles.Add(angle);
                    _pointText.Add(pointCenter);
                    _pointTextUp.Add(pOrigin);
                }
            }
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:61,代码来源:TextOnPath.cs

示例12: DrawLineString

        /// <summary>
        /// Renders a LineString to the map.
        /// </summary>
        /// <param name="g">IGraphics reference</param>
        /// <param name="line">LineString to render</param>
        /// <param name="pen">Pen style used for rendering</param>
        /// <param name="map">Map reference</param>
        /// <param name="offset">Offset by which line will be moved to right</param>
        public void DrawLineString(IGraphics g, ILineString line, Pen pen, Map map, float offset)
        {
            var points = line.TransformToImage(map);
            if (points.Length > 1)
            {
                var gp = new GraphicsPath();
                if (offset != 0d)
                    points = RendererHelper.OffsetRight(points, offset);
                gp.AddLines(/*LimitValues(*/points/*, ExtremeValueLimit)*/);

                g.DrawPath(pen, gp);
            }
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:21,代码来源:VectorRenderer.cs

示例13: DrawLabel

        public void DrawLabel(IGraphics g, PointF labelPoint, PointF offset, Font font, Color forecolor,
                                     Brush backcolor, Pen halo, float rotation, string text, Map map,
                                     LabelStyle.HorizontalAlignmentEnum alignment = LabelStyle.HorizontalAlignmentEnum.Left,
                                     PointF? rotationPoint = null)
        {
            //Calculate the size of the text
            var labelSize = RendererHelper.SizeOfString(g, text, font);

            //Add label offset
            labelPoint.X += offset.X;
            labelPoint.Y += offset.Y;

            //Translate alignment to stringalignment
            StringAlignment salign;
            switch (alignment)
            {
                case LabelStyle.HorizontalAlignmentEnum.Left:
                    salign = StringAlignment.Near;
                    break;
                case LabelStyle.HorizontalAlignmentEnum.Center:
                    salign = StringAlignment.Center;
                    break;
                default:
                    salign = StringAlignment.Far;
                    break;
            }

            if (rotation != 0 && !float.IsNaN(rotation))
            {
                rotationPoint = rotationPoint ?? labelPoint;

                PointF pt = rotationPoint.Value;
                g.FillEllipse(Brushes.LawnGreen, (int)(pt.X - 1), (int)(pt.Y - 1), 2, 2);

                var t = g.Transform.Clone();
                g.TranslateTransform(pt.X, pt.Y);
                g.RotateTransform(rotation);
                //g.TranslateTransform(-labelSize.Width/2, -labelSize.Height/2);

                labelPoint = new PointF(labelPoint.X - pt.X,
                                        labelPoint.Y - pt.Y);

                //labelSize = new SizeF(labelSize.Width*0.74f + 1f, labelSize.Height*0.74f);
                if (backcolor != null && backcolor != Brushes.Transparent)
                    g.FillRectangle(backcolor,
                        (int)labelPoint.X, (int)labelPoint.Y,
                        (int)labelSize.Width, (int)labelSize.Height);

                var path = new GraphicsPath();
                path.AddString(text, font.FontFamily, (int)font.Style, font.Size,
                               new RectangleF(labelPoint, labelSize) /* labelPoint*/,
                               new StringFormat { Alignment = salign } /*null*/);
                if (halo != null)
                    g.DrawPath(halo, path);

                g.FillPath(new SolidBrush(forecolor), path);
                //g.DrawString(text, font, new System.Drawing.SolidBrush(forecolor), 0, 0);        
                g.Transform = t;
            }
            else
            {
                if (backcolor != null && backcolor != Brushes.Transparent)
                    g.FillRectangle(backcolor,
                        (int)labelPoint.X, (int)labelPoint.Y,
                        (int)labelSize.Width, (int)labelSize.Height);

                var path = new GraphicsPath();
                path.AddString(text, font.FontFamily, (int)font.Style, font.Size,
                               new RectangleF(labelPoint, labelSize) /* labelPoint*/,
                               new StringFormat { Alignment = salign } /*null*/);
                if (halo != null)
                    g.DrawPath(halo, path);
                g.FillPath(new SolidBrush(forecolor), path);
                //g.DrawString(text, font, new System.Drawing.SolidBrush(forecolor), LabelPoint.X, LabelPoint.Y);
            }
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:76,代码来源:VectorRenderer.cs

示例14: DrawPolygon

        public void DrawPolygon(IGraphics g, IPolygon pol, Brush brush, Pen pen, bool clip, Map map)
        {
            if (pol.ExteriorRing == null)
                return;

            var points = pol.ExteriorRing.TransformToImage(map);
            if (points.Length > 2)
            {
                //Use a graphics path instead of DrawPolygon. DrawPolygon has a problem with several interior holes
                var gp = new GraphicsPath();

                //Add the exterior polygon
                if (!clip)
                    gp.AddPolygon(/*LimitValues(*/points/*, ExtremeValueLimit)*/);
                else
                    DrawPolygonClipped(gp, /*LimitValues(*/points/*, ExtremeValueLimit)*/, map.Size.Width, map.Size.Height);

                //Add the interior polygons (holes)
                if (pol.NumInteriorRings > 0)
                {
                    foreach (ILinearRing ring in pol.InteriorRings)
                    {
                        points = ring.TransformToImage(map);
                        if (!clip)
                            gp.AddPolygon(/*LimitValues(*/points/*, ExtremeValueLimit)*/);
                        else
                            DrawPolygonClipped(gp, /*LimitValues(*/points/*, ExtremeValueLimit)*/, map.Size.Width,
                                               map.Size.Height);
                    }
                }


                // Only render inside of polygon if the brush isn't null or isn't transparent
                if (brush != null && brush != Brushes.Transparent)
                    g.FillPath(brush, gp);

                // Create an outline if a pen style is available
                if (pen != null)
                    g.DrawPath(pen, gp);
            }
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:41,代码来源:VectorRenderer.cs

示例15: Draw

        void Draw(IGraphics g, DrawingMode mode)
        {
            g.SmoothingMode = checkBoxAntialiasing.Checked ? SmoothingMode.HighQuality : SmoothingMode.None;
            g.Clear(Color.White);

            DrawMillimeterGridInPixels(g, tabControl1.SelectedTab.Controls[0].ClientRectangle);

            g.PageUnit = GraphicsUnit.Millimeter;

            var points = _noisePoints;

            DrawLines(g, points, mode);

            g.ResetTransform();

            var path = CreateRoundedRectanglePath(new RectangleF(10, 10, 100, 40), 10);

            g.FillPath(new SolidBrush(Color.FromArgb(120, Color.LightSlateGray)), path);
            g.DrawPath(new Pen(Color.LightSlateGray, 0.0f), path);

            g.FillPie(new SolidBrush(Color.FromArgb(120, Color.CadetBlue)), new Rectangle(30, 20, 100, 100), 45.0f, 90.0f);
            g.DrawPie(new Pen(Color.CadetBlue, 0.0f), new Rectangle(30, 20, 100, 100), 45.0f, 90.0f);

            //GLGraphics gl = g as GLGraphics;
            //if (gl != null)
            //    gl.FillTextBackground = gl.FillTextBackground_glReadPixels;

            g.PageUnit = GraphicsUnit.Pixel;
            RectangleF rect = new RectangleF(30.0f, 15.0f, _testImage.Width, _testImage.Height);
            g.DrawImage(_testImage, rect);
            g.DrawRectangle(Pens.Black, rect.X, rect.Y, rect.Width, rect.Height);

            g.PageUnit = GraphicsUnit.Millimeter;

            g.HintTextBackgroundAction((gdi, textLocation, textRect) =>
            {
                _millimeterGridBrush.ResetTransform();
                _millimeterGridBrush.TranslateTransform(-textLocation.X, -textLocation.Y);
                gdi.FillRectangle(_millimeterGridBrush, textRect);
            });

            g.DrawString("Testovací řetězec pro odzkoušení správné implementace IGraphics - metody DrawString.",
                new Font("Arial", 12.0f), Brushes.Black, new PointF(100.0f, 58.0f));
        }
开发者ID:filipkunc,项目名称:GLGraphics,代码行数:44,代码来源:Form1.cs


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