本文整理汇总了C#中IGraphics.FillPath方法的典型用法代码示例。如果您正苦于以下问题:C# IGraphics.FillPath方法的具体用法?C# IGraphics.FillPath怎么用?C# IGraphics.FillPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGraphics
的用法示例。
在下文中一共展示了IGraphics.FillPath方法的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);
}
示例2: 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);
}
示例3: SymbolizePaths
/// <summary>
/// Function to symbolize the graphics path to the graphics object
/// </summary>
/// <param name="g">The graphics object</param>
/// <param name="paths">The paths</param>
public void SymbolizePaths(IGraphics g, IEnumerable<GraphicsPath> paths)
{
foreach (var graphicsPath in paths)
{
var clonedPattern = (GraphicsPath)Pattern.Clone();
var warpedPath = WarpPathToPath.Warp(graphicsPath, clonedPattern, true, Interval);
if (warpedPath == null) continue;
if (Fill != null)
g.FillPath(Fill, warpedPath);
if (Line != null)
g.DrawPath(Line, warpedPath);
}
}
示例4: 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 );
}
}
}
}
示例5: 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);
}
}
示例6: 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));
}
示例7: 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);
}
示例8: OnRenderInternal
/// <summary>
/// Method that performs the symbolization of th feature
/// </summary>
/// <param name="pt">The point</param>
/// <param name="g">The graphics object</param>
internal override void OnRenderInternal(PointF pt, IGraphics g)
{
if (Halo > 0)
{
//need to look it up
using (var path = new GraphicsPath(FillMode.Winding))
{
path.AddString(_text, Font.FontFamily, (int) Font.Style, Font.Size, pt, StringFormat);
g.DrawPath(new Pen(HaloBrush, 2*Halo), path);
g.FillPath(Foreground, path);
}
}
else
{
g.DrawString(_text, Font, Foreground, (int) pt.X, (int) pt.Y, StringFormat);
}
}
示例9: DrawSmoothFilledCurve
/// <summary>
/// Draw the this <see cref="CurveItem"/> to the specified <see cref="Graphics"/>
/// device using the specified smoothing property (<see cref="ZedGraph.Line.SmoothTension"/>).
/// The routine draws the line segments and the area fill (if any, see <see cref="FillType"/>;
/// the symbols are drawn by the <see cref="Symbol.Draw"/> method. This method
/// is normally only called by the Draw method of the
/// <see cref="CurveItem"/> object. Note that the <see cref="StepType"/> property
/// is ignored for smooth lines (e.g., when <see cref="ZedGraph.Line.IsSmooth"/> is true).
/// </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="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>
/// <param name="pane">
/// A reference to the <see cref="GraphPane"/> object that is the parent or
/// owner of this object.
/// </param>
/// <param name="curve">A <see cref="LineItem"/> representing this
/// curve.</param>
public virtual void DrawSmoothFilledCurve( IGraphics g, GraphPane pane,
CurveItem curve, float scaleFactor )
{
Line source = this;
if ( curve.IsSelected )
source = Selection.Line;
PointF[] arrPoints;
int count;
IPointList points = curve.Points;
if ( this.IsVisible && !this.Color.IsEmpty && points != null &&
BuildPointsArray( pane, curve, out arrPoints, out count ) &&
count > 2 )
{
float tension = _isSmooth ? _smoothTension : 0f;
// Fill the curve if needed
if ( this.Fill.IsVisible )
{
Axis yAxis = curve.GetYAxis( pane );
using ( GraphicsPath path = new GraphicsPath( FillMode.Winding ) )
{
path.AddCurve( arrPoints, 0, count - 2, tension );
double yMin = yAxis._scale._min < 0 ? 0.0 : yAxis._scale._min;
CloseCurve( pane, curve, arrPoints, count, yMin, path );
RectangleF rect = path.GetBounds();
using ( Brush brush = source._fill.MakeBrush( rect ) )
{
if ( pane.LineType == LineType.Stack && yAxis.Scale._min < 0 &&
this.IsFirstLine( pane, curve ) )
{
float zeroPix = yAxis.Scale.Transform( 0 );
RectangleF tRect = pane.Chart._rect;
tRect.Height = zeroPix - tRect.Top;
if ( tRect.Height > 0 )
{
Region reg = g.Clip;
g.SetClip( tRect );
g.FillPath( brush, path );
g.SetClip( pane.Chart._rect );
}
}
else
g.FillPath( brush, path );
//brush.Dispose();
}
// restore the zero line if needed (since the fill tends to cover it up)
yAxis.FixZeroLine( g, pane, scaleFactor, rect.Left, rect.Right );
}
}
// If it's a smooth curve, go ahead and render the path. Otherwise, use the
// standard drawcurve method just in case there are missing values.
if (_isSmooth)
{
using (Pen pen = GetPen(pane, scaleFactor))
{
// Stroke the curve
g.DrawCurve(pen, arrPoints, 0, count - 2, tension);
//pen.Dispose();
}
}
else
{
DrawCurve(g, pane, curve, scaleFactor, GetPoints(curve, pane));
}
}
}
示例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();
}
示例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);
}
}
}
示例12: DrawPlay
/// <summary>
/// Draw play over the iframe if we found link url.
/// </summary>
private void DrawPlay(IGraphics g, Rectangle rect)
{
if (_isVideo && _imageWord.Width > 70 && _imageWord.Height > 50)
{
var smooth = g.SmoothingMode;
g.SmoothingMode = SmoothingMode.AntiAlias;
var size = new Size(60, 40);
var left = rect.Left + (rect.Width - size.Width)/2;
var top = rect.Top + (rect.Height - size.Height)/2;
g.FillRectangle(RenderUtils.GetSolidBrush(System.Drawing.Color.FromArgb(160, 0, 0, 0)), left, top, size.Width, size.Height);
using (var path = new GraphicsPath())
{
path.AddLine(left + size.Width/3f + 1, top + 3*size.Height/4f, left + size.Width/3f + 1, top + size.Height/4f);
path.AddLine(left + size.Width/3f + 1, top + size.Height/4f, left + 2*size.Width/3f + 1, top + size.Height/2f);
path.CloseFigure();
g.FillPath(Brushes.White, path);
}
g.SmoothingMode = smooth;
}
}
示例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);
}
}
示例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);
}
}
示例15: 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;
}
}