/// <summary> /// Draws the specified graphics. /// </summary> /// <param name="graphics">The graphics.</param> /// <param name="brush">The brush.</param> /// <param name="pen">The pen.</param> public void Draw(Graphics graphics, Brush?brush, Pen?pen) { if (brush is not null) { graphics.DrawString(Text, Font, brush, Bounds?.Location ?? PointF.Empty, StringFormat); } }
public RectangleElement(HexColumnType column, Rect rect, Brush brush, Pen?pen) { Canvas.SetTop(this, 0); Column = column; this.rect = rect; this.brush = brush; this.pen = pen; }
public StackedLabelProvider(IProvider provider, LabelStyle labelStyle, Pen?rectangleLine = null, Brush?rectangleFill = null) { _provider = provider; _labelStyle = labelStyle; _rectangleLine = rectangleLine ?? new Pen(Color.Gray); _rectangleFill = rectangleFill; }
public LineElement(LineElementKind kind, double x, double top, double bottom, Pen?pen) { Canvas.SetTop(this, top); Kind = kind; this.x = x; this.top = top; this.bottom = bottom; this.pen = pen; }
public Line( Point start, Point end, Pen?pen = null) { this.Start = start; this.End = end; this.Pen = pen; }
/// <summary> /// Initializes a new instance of the <see cref="TextElement" /> class. /// </summary> /// <param name="text">The text.</param> /// <param name="font">The font.</param> /// <param name="brush">The brush.</param> /// <param name="pen">The pen.</param> /// <param name="bounds">The bounds.</param> /// <param name="stringFormat">The string format.</param> public TextElement(string text, Font font, Brush?brush, Pen?pen, RectangleF bounds, StringFormat?stringFormat = default) { Text = text; Font = font; Brush = brush; Pen = pen; Bounds = bounds; StringFormat = stringFormat; }
public bool Equals(Pen?pen) { if (pen == null) { return(false); } // ReSharper disable once CompareOfFloatsByEqualityOperator if (Width != pen.Width) { return(false); } //if one or the other is null then they are not equal, but not when they are both null if ((Color == null) ^ (pen.Color == null)) { return(false); } if (Color != null && !Color.Equals(pen.Color)) { return(false); } if (PenStyle != pen.PenStyle) { return(false); } if (DashArray != pen.DashArray) { return(false); } if (DashOffset != pen.DashOffset) { return(false); } if (PenStrokeCap != pen.PenStrokeCap) { return(false); } if (StrokeJoin != pen.StrokeJoin) { return(false); } if (StrokeMiterLimit != pen.StrokeMiterLimit) { return(false); } return(true); }
/// <summary> /// Disposes of all resources used by <c>PieSlice</c> object. /// </summary> public virtual void Dispose() { if (Pen is not null) { Pen.Dispose(); Pen = null; } DisposeBrushes(); }
public SoundCloudBlockWaveFormSettings(Color topPeakColor, Color topSpacerStartColor, Color bottomPeakColor, Color bottomSpacerColor) { this._topSpacerStartColor = topSpacerStartColor; _topPen = new Pen(topPeakColor); _bottomPen = new Pen(bottomPeakColor); _bottomSpacerPen = new Pen(bottomSpacerColor); PixelsPerPeak = 4; SpacerPixels = 2; BackgroundColor = Color.White; TopSpacerGradientStartColor = Color.White; }
public void DrawLine(ILine line) { Pen?wpfPen = ToWpfNativePen(line); if (wpfPen != null) { _drawingContext !.DrawLine(wpfPen, new System.Windows.Point(line.X1, line.Y1), new System.Windows.Point(line.X2, line.Y2)); } }
public void DrawEllipse(IEllipse ellipse) { Brush?wpfBrush = ellipse.Fill.ToWpfBrush(); Pen? wpfPen = ToWpfNativePen(ellipse); double radiusX = ellipse.Width / 2; double radiusY = ellipse.Height / 2; var center = new System.Windows.Point(radiusX, radiusY); _drawingContext !.DrawEllipse(wpfBrush, wpfPen, center, radiusX, radiusY); }
private static Pen GetPen(object key, Color color) { Pen?Pen = (Pen?)Gdip.ThreadData[key]; if (Pen == null) { Pen = new Pen(color, true); Gdip.ThreadData[key] = Pen; } return(Pen); }
public RectangleF GetBounds(Matrix?matrix, Pen?pen) { RectangleF retval; IntPtr m = (matrix == null) ? IntPtr.Zero : matrix.NativeMatrix; IntPtr p = (pen == null) ? IntPtr.Zero : pen.NativePen; int s = Gdip.GdipGetPathWorldBounds(_nativePath, out retval, m, p); Gdip.CheckStatus(s); return(retval); }
public void DrawEllipse(IEllipse ellipse) { #if false Brush?wpfBrush = ellipse.Fill.ToWpfBrush(); Pen? wpfPen = ToWpfNativePen(ellipse); double radiusX = ellipse.Width / 2; double radiusY = ellipse.Height / 2; var center = new System.Windows.Point(radiusX, radiusY); _drawingContext !.DrawEllipse(wpfBrush, wpfPen, center, radiusX, radiusY); #endif throw new NotImplementedException("TODO: Implement DrawEllipse for WinUI"); }
/// <summary> /// Draws the specified graphics. /// </summary> /// <param name="graphics">The graphics.</param> /// <param name="brush">The brush.</param> /// <param name="pen">The pen.</param> public void Draw(Graphics graphics, Brush?brush, Pen?pen) { if (Bounds is RectangleF b && !b.IsEmpty) { if (brush is not null) { graphics.FillRectangle(brush, b); } if (pen is not null) { graphics.DrawRectangle(pen, b); } } }
public static Pen?ToPen(this Word.BorderType?border, Pen?defaultIfNull = null) { if (border is null) { return(defaultIfNull); } var color = border.Color.ToColor(); var width = border.Size.EpToPoint(); var val = border.Val?.Value ?? Word.BorderValues.Single; var pen = new Pen(color, width); pen.UpdateStyle(val); return(pen); }
private static PenCache.Scope GetPenScope(Color color) { if (color.IsKnownColor) { Pen?pen = color.IsSystemColor ? SystemPens.FromSystemColor(color) : PenFromKnownColor(color.ToKnownColor()); if (pen is not null) { return(new PenCache.Scope(pen)); } } return(PenCache.GetEntry(color)); }
public void DrawRectangle(IRectangle rectangle) { System.Windows.Rect wpfRect = new System.Windows.Rect(0, 0, rectangle.Width, rectangle.Height); Brush?wpfBurush = rectangle.Fill.ToWpfBrush(); Pen? wpfPen = ToWpfNativePen(rectangle); if (rectangle.RadiusX > 0 || rectangle.RadiusY > 0) { _drawingContext !.DrawRoundedRectangle(wpfBurush, wpfPen, wpfRect, rectangle.RadiusX, rectangle.RadiusY); } else { _drawingContext !.DrawRectangle(wpfBurush, wpfPen, wpfRect); } }
private static SKPaint?CreateLinePaint(Pen?outline, float opacity) { if (outline is null) { return(null); } return(new SKPaint { Color = outline.Color.ToSkia(opacity), StrokeWidth = (float)outline.Width, StrokeCap = outline.PenStrokeCap.ToSkia(), PathEffect = outline.PenStyle.ToSkia((float)outline.Width), Style = SKPaintStyle.Stroke, IsAntialias = true }); }
public RenderingOptions( bool hiddenChars = false, Pen?sectionBorders = null, Pen?headerBorders = null, Pen?footerBorders = null, Pen?paragraphBorders = null, Pen?lineBorders = null, Pen?wordBorders = null) { this.HiddenChars = hiddenChars; this.SectionBorders = sectionBorders ?? new Pen(Color.Transparent); this.HeaderBorders = headerBorders ?? new Pen(Color.Transparent); this.FooterBorders = footerBorders ?? new Pen(Color.Transparent); this.ParagraphBorders = paragraphBorders ?? new Pen(Color.Transparent); this.LineBorders = lineBorders ?? new Pen(Color.Transparent); this.WordBorders = wordBorders ?? new Pen(Color.Transparent); }
/// <summary> /// Initializes a new instance of <c>PieSlice</c> class with given /// bounds and visual style. /// </summary> /// <param name = "xBoundingRect"> /// x-coordinate of the upper-left corner of the rectangle that is /// used to draw the top surface of the pie slice. /// </param> /// <param name = "yBoundingRect"> /// y-coordinate of the upper-left corner of the rectangle that is /// used to draw the top surface of the pie slice. /// </param> /// <param name = "widthBoundingRect"> /// Width of the rectangle that is used to draw the top surface of /// the pie slice. /// </param> /// <param name = "heightBoundingRect"> /// Height of the rectangle that is used to draw the top surface of /// the pie slice. /// </param> /// <param name = "sliceHeight"> /// Height of the pie slice. /// </param> /// <param name = "startAngle"> /// Starting angle (in degrees) of the pie slice. /// </param> /// <param name = "sweepAngle"> /// Sweep angle (in degrees) of the pie slice. /// </param> /// <param name = "surfaceColor"> /// Color used to paint the pie slice. /// </param> /// <param name = "shadowStyle"> /// Shadow style used for slice rendering. /// </param> /// <param name = "edgeColorType"> /// Edge color style used for slice rendering. /// </param> public PieSlice( float xBoundingRect, float yBoundingRect, float widthBoundingRect, float heightBoundingRect, float sliceHeight, float startAngle, float sweepAngle, Color surfaceColor, ShadowStyle shadowStyle, EdgeColorType edgeColorType) { // set some persistent values _actualStartAngle = startAngle; _actualSweepAngle = sweepAngle; _surfaceColor = surfaceColor; _shadowStyle = shadowStyle; // create pens for rendering var edgeLineColor = EdgeColor.GetRenderingColor(edgeColorType, surfaceColor); Pen = new Pen(edgeLineColor) { LineJoin = LineJoin.Round }; InitializePieSlice(xBoundingRect, yBoundingRect, widthBoundingRect, heightBoundingRect, sliceHeight); }
/// <summary> /// Initializes a new instance of the <see cref="RectangleElement" /> class. /// </summary> /// <param name="location">The location.</param> /// <param name="size">The size.</param> /// <param name="brush">The brush.</param> /// <param name="pen">The pen.</param> public RectangleElement(PointF location, SizeF size, Brush?brush, Pen?pen) { Bounds = new RectangleF(location, size); Brush = brush; Pen = pen; }
public Paint(Brush?fill = null, Pen?stroke = null) { Fill = fill; Stroke = stroke; }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Graphics g = e.Graphics; if (this.image != null) { Rectangle r = e.ClipRectangle; g.DrawImage(this.image, r.X, r.Y, r, GraphicsUnit.Pixel); // Repaint the view window if any of it is invalid if (r.IntersectsWith(this.viewRect)) { Pen?disposablePen = null; try { Pen pen = SystemPens.Highlight; Rectangle penRect; if (this.UseTranslucentView) { // Set the alpha blend to 20% (51/256); const int TwentyPercentAlphaBlend = 51; using (SolidBrush b = new(Color.FromArgb(TwentyPercentAlphaBlend, SystemColors.Highlight))) { r.Intersect(this.viewRect); g.FillRectangle(b, r); } // Draw the pen border with view rect. penRect = this.viewRect; } else { // Create a two pixel wide highlight pen. pen = new Pen(SystemColors.Highlight, 2); disposablePen = pen; // Because the lines will go back up a pixel // we have to shrink the bounds of the rect. penRect = new Rectangle(this.viewRect.X + 1, this.viewRect.Y + 1, this.viewRect.Width - 1, this.viewRect.Height - 1); } // Draw a Highlight Pen border. In some cases, it will // draw a pixel too far (because we always round up), so // we'll check for that case here. If we're scrolled to // the bottom, I don't want the last line cut off. int viewHeight = penRect.Height - 1; int usableHeight = this.ClientSize.Height - penRect.Y - 1; int height = Math.Min(viewHeight, usableHeight); g.DrawRectangle(pen, penRect.X, penRect.Y, penRect.Width - 1, height); } finally { disposablePen?.Dispose(); } } } else { g.FillRectangle(SystemBrushes.Control, this.ClientRectangle); } }