/// <summary> /// Draws a sample box. /// </summary> public void BeginBox(XGraphics gfx, int number) { //obracene XY gfx.RotateAtTransform(90.0, new XPoint(height / 4, width / 4)); gfx.TranslateTransform(+62, +63); //const int dEllipse = 15; XRect rect = new XRect(0, 0, height /2 -2, width/2 -2); if (number % 2 == 0) rect.X += height/2 +2; rect.Y = ((number - 1) / 2) * (-width/2 - 3); //rect.Inflate(-10, -10); //XRect rect2 = rect; XPen pen = new XPen(XColors.Black, 1); gfx.DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height); //rect2.Offset(this.borderWidth, this.borderWidth); //gfx.DrawRoundedRectangle(new XSolidBrush(this.shadowColor), rect2, new XSize(dEllipse + 8, dEllipse + 8)); //XLinearGradientBrush brush = new XLinearGradientBrush(rect, this.backColor, this.backColor2, XLinearGradientMode.Vertical); //gfx.DrawRoundedRectangle(this.borderPen, brush, rect, new XSize(dEllipse, dEllipse)); //rect.Inflate(-5, -5); //rect.Inflate(-10, -5); //rect.Y += 20; //rect.Height -= 20; ////gfx.DrawRectangle(XPens.Red, rect); // gfx.TranslateTransform(rect.X, rect.Y); this.state = gfx.Save(); }
/// <summary> /// Demonstrates the use of XGraphics.DrawBeziers. /// </summary> public override void RenderPage(XGraphics gfx) { base.RenderPage(gfx); int n = 2; int count = 1 + 3 * n; XPoint[] points = new XPoint[count]; Random rnd = new Random(42); for (int idx = 0; idx < count; idx++) { points[idx].X = 20 + rnd.Next(600); points[idx].Y = 50 + rnd.Next(800); } // Draw the points XPen pen = new XPen(XColors.Red, 0.5); pen.DashStyle = XDashStyle.Dash; for (int idx = 0; idx + 3 < count; idx += 3) { gfx.DrawEllipse(XBrushes.Red, MakeRect(points[idx])); gfx.DrawEllipse(XBrushes.Red, MakeRect(points[idx + 1])); gfx.DrawEllipse(XBrushes.Red, MakeRect(points[idx + 2])); gfx.DrawEllipse(XBrushes.Red, MakeRect(points[idx + 3])); gfx.DrawLine(pen, points[idx], points[idx + 1]); gfx.DrawLine(pen, points[idx + 2], points[idx + 3]); } // Draw the curve gfx.DrawBeziers(properties.Pen2.Pen, points); }
/// <summary> /// Draws a clock on a square page. /// Inspired by Charles Petzold's AnalogClock sample in /// 'Programming Microsoft Windows with C#'. /// </summary> void RenderClock(XGraphics gfx) { // Clocks should always look happy on hardcopies... //this.time = new DateTime(2005, 1, 1, 11, 6, 22, 500); XColor strokeColor = XColors.DarkBlue; XColor fillColor = XColors.DarkOrange; XPen pen = new XPen(strokeColor, 5); XBrush brush = new XSolidBrush(fillColor); strokeColor.A = 0.8; fillColor.A = 0.8; XPen handPen = new XPen(strokeColor, 5); XBrush handBrush = new XSolidBrush(fillColor); DrawText(gfx, pen, brush); double width = gfx.PageSize.Width; double height = gfx.PageSize.Height; gfx.TranslateTransform(width / 2, height / 2); double scale = Math.Min(width, height); gfx.ScaleTransform(scale / 2000); DrawFace(gfx, pen, brush); DrawHourHand(gfx, handPen, handBrush); DrawMinuteHand(gfx, handPen, handBrush); DrawSecondHand(gfx, new XPen(XColors.Red, 7)); }
/// <summary> /// Draws Arcs. /// </summary> void RenderArcs(XGraphics gfx) { gfx.TranslateTransform(15, 20); XPen pen = new XPen(XColors.Plum, 4.7); gfx.DrawArc(pen, 0, 0, 250, 140, 190, 200); }
/// <summary> /// Draws simple lines. /// </summary> void RenderLines(XGraphics gfx) { gfx.TranslateTransform(15, 20); gfx.DrawLine(XPens.Red, new XPoint(10, 10), new XPoint(300, 300)); gfx.DrawLine(XPens.DarkGreen, 0, 0, 250, 0); gfx.DrawLine(XPens.Gold, 15, 7, 230, 15); XPen pen = new XPen(XColors.Navy, 4); gfx.DrawLine(pen, 0, 20, 250, 20); pen = new XPen(XColors.Firebrick, 6); pen.DashStyle = XDashStyle.Dash; gfx.DrawLine(pen, 0, 40, 250, 40); pen.Width = 7.3; pen.DashStyle = XDashStyle.DashDotDot; gfx.DrawLine(pen, 0, 60, 250, 60); pen = new XPen(XColors.Goldenrod, 10); pen.LineCap = XLineCap.Flat; gfx.DrawLine(pen, 10, 90, 240, 90); gfx.DrawLine(XPens.Black, 10, 90, 240, 90); pen = new XPen(XColors.Goldenrod, 10); pen.LineCap = XLineCap.Square; gfx.DrawLine(pen, 10, 110, 240, 110); gfx.DrawLine(XPens.Black, 10, 110, 240, 110); pen = new XPen(XColors.Goldenrod, 10); pen.LineCap = XLineCap.Round; gfx.DrawLine(pen, 10, 130, 240, 130); gfx.DrawLine(XPens.Black, 10, 130, 240, 130); }
/// <summary> /// Draws simple lines. /// </summary> void DrawLine(XGraphics gfx, int number) { BeginBox(gfx, number, "DrawLine"); gfx.DrawLine(XPens.DarkGreen, 0, 0, 250, 0); gfx.DrawLine(XPens.Gold, 15, 7, 230, 15); XPen pen = new XPen(XColors.Navy, 4); gfx.DrawLine(pen, 0, 20, 250, 20); pen = new XPen(XColors.Firebrick, 6); pen.DashStyle = XDashStyle.Dash; gfx.DrawLine(pen, 0, 40, 250, 40); pen.Width = 7.3; pen.DashStyle = XDashStyle.DashDotDot; gfx.DrawLine(pen, 0, 60, 250, 60); pen = new XPen(XColors.Goldenrod, 10); pen.LineCap = XLineCap.Flat; gfx.DrawLine(pen, 10, 90, 240, 90); gfx.DrawLine(XPens.Black, 10, 90, 240, 90); pen = new XPen(XColors.Goldenrod, 10); pen.LineCap = XLineCap.Square; gfx.DrawLine(pen, 10, 110, 240, 110); gfx.DrawLine(XPens.Black, 10, 110, 240, 110); pen = new XPen(XColors.Goldenrod, 10); pen.LineCap = XLineCap.Round; gfx.DrawLine(pen, 10, 130, 240, 130); gfx.DrawLine(XPens.Black, 10, 130, 240, 130); EndBox(gfx); }
/// <summary> /// Draws curves. /// </summary> void RenderCurves(XGraphics gfx) { gfx.TranslateTransform(15, 20); XPoint[] points = { new XPoint(20, 30), new XPoint(60, 120), new XPoint(90, 20), new XPoint(170, 90), new XPoint(230, 40) }; XPen pen = new XPen(XColors.RoyalBlue, 3.5); gfx.DrawCurve(pen, points, 1); }
private void DrawDebuggingCrosshair(XGraphics context) { var pen = new XPen(XColors.Red); var w = form.Size.Width; var h = form.Size.Height; context.DrawLine(pen, 0, 0, w, h); context.DrawLine(pen, w, 0, 0, h); }
void RenderClosedCurves(XGraphics gfx) { gfx.TranslateTransform(15, 20); XPen pen = new XPen(XColors.DarkBlue, 2.5); gfx.DrawClosedCurve(pen, XBrushes.SkyBlue, new XPoint[] { new XPoint(10, 120), new XPoint(80, 30), new XPoint(220, 20), new XPoint(170, 110), new XPoint(100, 90) }, XFillMode.Winding, 0.7); }
void RenderPolygons(XGraphics gfx) { gfx.TranslateTransform(15, 20); XPen pen = new XPen(XColors.DarkBlue, 2.5); gfx.DrawPolygon(pen, XBrushes.LightCoral, GeometryObjects.GetPentagram(50, new XPoint(60, 70)), XFillMode.Winding); gfx.DrawPolygon(pen, XBrushes.LightCoral, GeometryObjects.GetPentagram(50, new XPoint(180, 70)), XFillMode.Alternate); }
private static XPen MakePen(bool dotted) { var pen = new XPen(XColors.Black); if (dotted) { pen.DashStyle = XDashStyle.Dash; } return pen; }
/// <summary> /// Draws Bézier curves. /// </summary> void RenderBéziers(XGraphics gfx) { gfx.TranslateTransform(15, 20); XPoint[] points = {new XPoint(20, 30), new XPoint(40, 120), new XPoint(80, 20), new XPoint(110, 90), new XPoint(180, 40), new XPoint(210, 40), new XPoint(220, 80)}; XPen pen = new XPen(XColors.Firebrick, 4); //pen.DashStyle = XDashStyle.Dot; gfx.DrawBeziers(pen, points); }
void RenderRoundedRectangles(XGraphics gfx) { gfx.TranslateTransform(15, 20); XPen pen = new XPen(XColors.RoyalBlue, Math.PI); gfx.DrawRoundedRectangle(pen, 10, 0, 100, 60, 30, 20); gfx.DrawRoundedRectangle(XBrushes.Orange, 130, 0, 100, 60, 30, 20); gfx.DrawRoundedRectangle(pen, XBrushes.Orange, 10, 80, 100, 60, 30, 20); gfx.DrawRoundedRectangle(pen, XBrushes.Orange, 150, 80, 60, 60, 20, 20); }
void RenderEllipses(XGraphics gfx) { gfx.TranslateTransform(15, 20); XPen pen = new XPen(XColors.Navy, Math.PI); gfx.DrawRectangle(pen, 10, 0, 100, 60); gfx.DrawRectangle(XBrushes.DarkOrange, 130, 0, 100, 60); gfx.DrawRectangle(pen, XBrushes.DarkOrange, 10, 80, 100, 60); gfx.DrawRectangle(pen, XBrushes.DarkOrange, 150, 80, 60, 60); }
void RenderPies(XGraphics gfx) { gfx.TranslateTransform(15, 20); XPen pen = new XPen(XColors.DarkBlue, 2.5); gfx.DrawPie(pen, 10, 0, 100, 90, -120, 75); gfx.DrawPie(XBrushes.Gold, 130, 0, 100, 90, -160, 150); gfx.DrawPie(pen, XBrushes.Gold, 10, 50, 100, 90, 80, 70); gfx.DrawPie(pen, XBrushes.Gold, 150, 80, 60, 60, 35, 290); }
/// <summary> /// Initializes a new instance of the <see cref="XPen"/> class. /// </summary> public XPen(XPen pen) { this.color = pen.color; this.width = pen.width; this.lineJoin = pen.lineJoin; this.lineCap = pen.lineCap; this.dashStyle = pen.dashStyle; this.dashOffset = pen.dashOffset; this.dashPattern = pen.dashPattern; if (this.dashPattern != null) this.dashPattern = (double[])this.dashPattern.Clone(); }
/// <summary> /// Initializes a new instance of the <see cref="XPen"/> class. /// </summary> public XPen(XPen pen) { _color = pen._color; _width = pen._width; _lineJoin = pen._lineJoin; _lineCap = pen._lineCap; _dashStyle = pen._dashStyle; _dashOffset = pen._dashOffset; _dashPattern = pen._dashPattern; if (_dashPattern != null) _dashPattern = (double[])_dashPattern.Clone(); }
protected Base() { this.backColor = XColors.Ivory; this.backColor2 = XColors.WhiteSmoke; this.backColor = XColor.FromArgb(212, 224, 240); this.backColor2 = XColor.FromArgb(253, 254, 254); this.shadowColor = XColors.Gainsboro; this.borderWidth = 4.5; this.borderPen = new XPen(XColor.FromArgb(94, 118, 151), this.borderWidth);//new XPen(XColors.SteelBlue, this.borderWidth); }
/// <summary> /// Draws rounded rectangles. /// </summary> void DrawRoundedRectangle(XGraphics gfx, int number) { BeginBox(gfx, number, "DrawRoundedRectangle"); XPen pen = new XPen(XColors.RoyalBlue, Math.PI); gfx.DrawRoundedRectangle(pen, 10, 0, 100, 60, 30, 20); gfx.DrawRoundedRectangle(XBrushes.Orange, 130, 0, 100, 60, 30, 20); gfx.DrawRoundedRectangle(pen, XBrushes.Orange, 10, 80, 100, 60, 30, 20); gfx.DrawRoundedRectangle(pen, XBrushes.Orange, 150, 80, 60, 60, 20, 20); EndBox(gfx); }
/// <summary> /// Draws rectangles. /// </summary> void DrawRectangle(XGraphics gfx, int number) { BeginBox(gfx, number, "DrawRectangle"); XPen pen = new XPen(XColors.Navy, Math.PI); gfx.DrawRectangle(pen, 10, 0, 100, 60); gfx.DrawRectangle(XBrushes.DarkOrange, 130, 0, 100, 60); gfx.DrawRectangle(pen, XBrushes.DarkOrange, 10, 80, 100, 60); gfx.DrawRectangle(pen, XBrushes.DarkOrange, 150, 80, 60, 60); EndBox(gfx); }
void RenderOpenPath(XGraphics gfx) { gfx.TranslateTransform(15, 20); XPen pen = new XPen(XColors.Navy, Math.PI); pen.DashStyle = XDashStyle.Dash; XGraphicsPath path = new XGraphicsPath(); path.AddLine(10, 120, 50, 60); path.AddArc(50, 20, 110, 80, 180, 180); path.AddLine(160, 60, 220, 100); gfx.DrawPath(pen, path); }
public static void DrawEllipse(XGraphics gfx, int number) { // BeginBox(gfx, number, "DrawEllipse"); XPen pen = new XPen(XColors.DarkBlue, 2.5); gfx.DrawEllipse(pen, 10, 0, 100, 60); gfx.DrawEllipse(XBrushes.Goldenrod, 130, 0, 100, 60); gfx.DrawEllipse(pen, XBrushes.Goldenrod, 10, 80, 100, 60); gfx.DrawEllipse(pen, XBrushes.Goldenrod, 150, 80, 60, 60); EndBox(gfx); }
public override void RenderPage(XGraphics gfx) { base.RenderPage(gfx); #if true__ XPen pen = new XPen(XColors.DarkGreen, 20); gfx.DrawLine(pen, 0, 0, 1000, 1000); #endif XGraphicsPath path = new XGraphicsPath(); path.AddString("@", new XFontFamily("Times New Roman"), XFontStyle.BoldItalic, 500, new XPoint(90, 60), XStringFormats.Default); gfx.DrawPath(properties.Pen2.Pen, properties.Brush2.Brush, path); }
/// <summary> /// Strokes an open path. /// </summary> void DrawPathOpen(XGraphics gfx, int number) { BeginBox(gfx, number, "DrawPath (open)"); XPen pen = new XPen(XColors.Navy, Math.PI); pen.DashStyle = XDashStyle.Dash; XGraphicsPath path = new XGraphicsPath(); path.AddLine(10, 120, 50, 60); path.AddArc(50, 20, 110, 80, 180, 180); path.AddLine(160, 60, 220, 100); gfx.DrawPath(pen, path); EndBox(gfx); }
public override void RenderPage(XGraphics gfx) { base.RenderPage(gfx); this.dt = DateTime.Now; XPen pen = new XPen(XColors.DarkBlue, 5); XBrush brush = new XSolidBrush(properties.Brush2.Brush); InitializeCoordinates(gfx); DrawFace(gfx, pen, brush); DrawHourHand(gfx, pen, brush); DrawMinuteHand(gfx, pen, brush); DrawSecondHand(gfx, new XPen(XColors.Red, 7)); }
public override void RenderPage(XGraphics gfx) { base.RenderPage(gfx); XGraphicsPath path = new XGraphicsPath(); path.AddLine(50, 150, 50, 100); path.AddArc(50, 50, 100, 100, -180, 180); path.AddLine(150, 70, 200, 70); path.AddLine(200, 70, 200, 150); path.CloseFigure(); XPen pen = new XPen(XColors.Red, 50); path.Widen(pen, new XMatrix(), 3); path.FillMode = this.properties.General.FillMode; gfx.DrawPath(properties.Pen2.Pen, properties.Brush2.Brush, path); }
void RenderAlternatePath(XGraphics gfx) { gfx.TranslateTransform(15, 20); XPen pen = new XPen(XColors.Navy, 2.5); // Alternate fill mode XGraphicsPath path = new XGraphicsPath(); path.FillMode = XFillMode.Alternate; path.AddLine(10, 130, 10, 40); path.AddBeziers(new XPoint[]{new XPoint(10, 40), new XPoint(30, 0), new XPoint(40, 20), new XPoint(60, 40), new XPoint(80, 60), new XPoint(100, 60), new XPoint(120, 40)}); path.AddLine(120, 40, 120, 130); path.CloseFigure(); path.AddEllipse(40, 80, 50, 40); gfx.DrawPath(pen, XBrushes.DarkOrange, path); }
/// <summary> /// Initializes a new instance of the <see cref="XPen"/> class. /// </summary> public XPen(XPen pen) { color = pen.color; width = pen.width; lineJoin = pen.lineJoin; lineCap = pen.lineCap; dashStyle = pen.dashStyle; dashOffset = pen.dashOffset; dashPattern = pen.dashPattern; if (dashPattern != null) { dashPattern = (double[])dashPattern.Clone(); } }
/// <summary> /// Initializes a new instance of the <see cref="XPen"/> class. /// </summary> public XPen(XPen pen) { _color = pen._color; _width = pen._width; _lineJoin = pen._lineJoin; _lineCap = pen._lineCap; _dashStyle = pen._dashStyle; _dashOffset = pen._dashOffset; _dashPattern = pen._dashPattern; if (_dashPattern != null) { _dashPattern = (double[])_dashPattern.Clone(); } }
/// <summary> /// Initializes a new instance of the <see cref="XPen"/> class. /// </summary> public XPen(XPen pen) { this.color = pen.color; this.width = pen.width; this.lineJoin = pen.lineJoin; this.lineCap = pen.lineCap; this.dashStyle = pen.dashStyle; this.dashOffset = pen.dashOffset; this.dashPattern = pen.dashPattern; if (this.dashPattern != null) { this.dashPattern = (double[])this.dashPattern.Clone(); } }
/// <summary> /// Replaces this path with curves that enclose the area that is filled when this path is drawn /// by the specified pen. /// </summary> public void Widen(XPen pen, XMatrix matrix) { // Just do nothing. }
/// <summary> /// Replaces this path with curves that enclose the area that is filled when this path is drawn /// by the specified pen. /// </summary> public void Widen(XPen pen) { // Just do nothing. }
/// <summary> /// Replaces this path with curves that enclose the area that is filled when this path is drawn /// by the specified pen. /// </summary> public void Widen(XPen pen, XMatrix matrix, double flatness) { }
private static void DrawLineInternal(XGraphics gfx, XPen pen, bool isStroked, ref XPoint p0, ref XPoint p1) { if (isStroked) { gfx.DrawLine(pen, p0, p1); } }
public void Render(XGraphics gfx, FixedElement element) { var spec = element.Specification; var penTop = new XPen(XColor.FromArgb(spec.Borders.Color), spec.Borders.Top.Points); var penLeft = new XPen(XColor.FromArgb(spec.Borders.Color), spec.Borders.Left.Points); var penRight = new XPen(XColor.FromArgb(spec.Borders.Color), spec.Borders.Right.Points); var penBottom = new XPen(XColor.FromArgb(spec.Borders.Color), spec.Borders.Bottom.Points); var midBorderTop = element.InnerBox.Top - spec.Borders.Top / 2; var midBorderRight = element.InnerBox.Right + spec.Borders.Right / 2; var midBorderBottom = element.InnerBox.Bottom + spec.Borders.Bottom / 2; var midBorderLeft = element.InnerBox.Left - spec.Borders.Left / 2; if (spec.Borders.Top != Unit.Zero) gfx.DrawLine(penTop, element.InnerBox.Left.Points, midBorderTop.Points, element.InnerBox.Right.Points, midBorderTop.Points); if (spec.Borders.Right != Unit.Zero) gfx.DrawLine(penRight, midBorderRight.Points, element.MarginBox.Top.Points, midBorderRight.Points, element.MarginBox.Bottom.Points); if (spec.Borders.Bottom != Unit.Zero) gfx.DrawLine(penBottom, element.InnerBox.Left.Points, midBorderBottom.Points, element.InnerBox.Right.Points, midBorderBottom.Points); if (spec.Borders.Left != Unit.Zero) gfx.DrawLine(penLeft, midBorderLeft.Points, element.MarginBox.Top.Points, midBorderLeft.Points, element.MarginBox.Bottom.Points); }
public static void BeginBox(XGraphics gfx, int number, string title, double borderWidth, double borderHeight, XColor shadowColor, XColor backColor, XColor backColor2, XPen borderPen) { const int dEllipse = 15; XRect rect = new XRect(0, 20, 300, 200); if (number % 2 == 0) rect.X = 300 - 5; rect.Y = 40 + ((number - 1) / 2) * (200 - 5); rect.Inflate(-10, -10); XRect rect2 = rect; rect2.Offset(borderWidth, borderHeight); gfx.DrawRoundedRectangle(new XSolidBrush(shadowColor), rect2, new XSize(dEllipse + 8, dEllipse + 8)); XLinearGradientBrush brush = new XLinearGradientBrush(rect, backColor, backColor2, XLinearGradientMode.Vertical); gfx.DrawRoundedRectangle(borderPen, brush, rect, new XSize(dEllipse, dEllipse)); rect.Inflate(-5, -5); XFont font = new XFont("Verdana", 12, XFontStyle.Regular); gfx.DrawString(title, font, XBrushes.Navy, rect, XStringFormats.TopCenter); rect.Inflate(-10, -5); rect.Y += 20; rect.Height -= 20; state = gfx.Save(); gfx.TranslateTransform(rect.X, rect.Y); }