public void DrawCross(IPen pen, PointF p, float size) { PointF p1 = new PointF(p.X, p.Y + size/2.0f); PointF p2 = new PointF(p.X, p.Y - size/2.0f); PointF p3 = new PointF(p.X + size/2.0f, p.Y); PointF p4 = new PointF(p.X - size/2.0f, p.Y); DrawLine(pen, p1, p2); DrawLine(pen, p3, p4); }
public override void SetPen(IPen pen) { if (pen.Width <= 1) { Graphics.UseDefaultPen(); Graphics.SetDefaultPenColor(pen.Color); return; } CurrentPen = new GDIPen(PenType.Geometric, PenStyle.Solid, pen.JoinStyle, pen.EndCap, pen.Color, pen.Width, Guid.NewGuid()); Graphics.SetPen(CurrentPen); }
public void DrawBezier(IPen pen, PointF pt1, PointF pt2, PointF pt3, PointF pt4) { CubicBezier cb = new CubicBezier(Utility.ToCoord(pt1), Utility.ToCoord(pt2), Utility.ToCoord(pt3), Utility.ToCoord(pt4)); ApplyPen(pen); Gl.glBegin(Gl.GL_LINE_STRIP); //iterate this bitch for (double i = 0; i < 1.0; i += .025) { PointF p = Utility.ToPointF(cb.Bt(i)); Gl.glVertex2f(p.X, p.Y); } PointF p1 = Utility.ToPointF(cb.Bt(1)); Gl.glVertex2f(p1.X, p1.Y); Gl.glEnd(); }
public virtual void SetPen(IPen aPen) { }
//public virtual void SelectStockObject(int objIndex) //{ // if (null != SelectStockObjectHandler) // SelectStockObjectHandler(objIndex); //} public virtual void DrawRoundRect(IPen aPen, Rectangle rect, int xRadius, int yRadius) { if (null != DrawRoundRectHandler) DrawRoundRectHandler(aPen, rect, xRadius, yRadius); }
private ChartItemCollection CreateChartItemCollection(ChartItemType type, IEnumerable<ChartItem> chartItems, CollectionId id, IPen pen1, IPen pen2) { ChartItemCollection coll = null; if (type == ChartItemType.Linear) { coll = new ChartItemCollection(id, chartItems, pen1, null, true); } else if (type == ChartItemType.Candle) { coll = new StockItemCollection(id, chartItems.OfType<StockItem>(), pen1, pen2, null); } else if (type == ChartItemType.Volumn) { coll = new VolumnItemCollection(id, chartItems.OfType<VolumnItem>(), pen1, pen2); } else if (type == ChartItemType.Time) { coll = new SymmetricChartItemCollection(id, chartItems, pen1, null, SymmetricCommonSettings.CNSettings2); } else if (type == ChartItemType.TimeVolumn) { coll = new SymmetricVolumnItemCollection(id, chartItems != null ? chartItems.OfType<VolumnItem>() : null, pen1, pen2, SymmetricCommonSettings.CNSettings2); } return coll; }
private async Task QueryMultipleCollection(string id) { var chartItems = await loader.GetStockItems(id); if (chartItems == null || chartItems.Prices == null) { Debug.WriteLine("Can not load chart items"); return; } var maColls = CreateMACollections(chartItems.Prices).ToArray(); IEnumerable<ChartItem>[] cItemsList = new IEnumerable<ChartItem>[maColls.Count() + 1]; IPen[] pens = new IPen[maColls.Count() + 1]; cItemsList[0] = chartItems.Prices; pens[0] = DrawingObjectFactory.CreatePen(model.RaiseBrush, 1); for(int i = 1; i < cItemsList.Length; i ++) { cItemsList[i] = maColls[i - 1].Items; pens[i] = maColls[i - 1].Pen; } var collection = CreateCollection(id, cItemsList, pens); price.SetMainCollection(collection); SetAttritues(); price.ForceDraw(true); }
public override void DrawPath(IPen aPen, GPath aPath) { BufferChunk chunk = new BufferChunk(aPath.Vertices.Length * 8 + 128); chunk += GDI32.EMR_POLYDRAW; ChunkUtils.Pack(chunk, aPath.Vertices); for (int i = 0; i < aPath.Vertices.Length; i++) chunk += aPath.Commands[i]; // Pack the pen ChunkUtils.Pack(chunk, aPen); SendCommand(chunk); }
/// <summary> /// Draws the outline of the rectangle with the provided pen. /// </summary> /// <param name="source">The image this method extends.</param> /// <param name="options">The options.</param> /// <param name="pen">The pen.</param> /// <param name="shape">The shape.</param> /// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns> public static IImageProcessingContext Draw( this IImageProcessingContext source, ShapeGraphicsOptions options, IPen pen, RectangleF shape) => source.Draw(options, pen, new RectangularPolygon(shape.X, shape.Y, shape.Width, shape.Height));
private void ApplyPen(IPen pen) { float width = pen.Width*transform.Scale; if (width < 1.0f) width = 1.0f; Gl.glColor4f(pen.Color.R/255.0f, pen.Color.G/255.0f, pen.Color.B/255.0f, pen.Color.A/255.0f); Gl.glLineWidth(width*1.5f); switch (pen.DashStyle) { case DashStyle.Dash: Gl.glLineStipple(0, (short)0x00FF); break; case DashStyle.Dot: Gl.glLineStipple(0, (short)0x3333); break; case DashStyle.DashDot: case DashStyle.DashDotDot: Gl.glLineStipple(0, (short)0x7F33); break; case DashStyle.Solid: default: Gl.glLineStipple(0, -1); break; } }
public override void DrawArc(IPen pen, float x, float y, float width, float height, float startAngle, float sweepAngle) { Pen sdPen = ((PenHandler)pen).Handle; fCanvas.DrawArc(sdPen, x, y, width, height, startAngle, sweepAngle); }
public override void DrawLine(IPen pen, float x1, float y1, float x2, float y2) { Pen sdPen = ((PenHandler)pen).Handle; fCanvas.DrawLine(sdPen, x1, y1, x2, y2); }
/// <summary> /// Constructor /// </summary> /// <param name="ordinateValue">ordinate (Y) value of line.</param> /// <param name="pen">Pen to use to draw the line.</param> public HorizontalLine(double ordinateValue, IPen pen) { OrdinateValue = ordinateValue; Pen = pen; }
/// <summary> /// Draws the outline of the polygon with the provided pen. /// </summary> /// <typeparam name="TColor">The type of the color.</typeparam> /// <param name="source">The image this method extends.</param> /// <param name="pen">The pen.</param> /// <param name="shape">The shape.</param> /// <returns>The <see cref="Image{TColor}"/>.</returns> public static Image <TColor> Draw <TColor>(this Image <TColor> source, IPen <TColor> pen, IShape shape) where TColor : struct, IPackedPixel, IEquatable <TColor> { return(source.Draw(pen, shape, GraphicsOptions.Default)); }
/// <summary> /// Draws the outline of the polygon with the provided pen. /// </summary> /// <typeparam name="TColor">The type of the color.</typeparam> /// <param name="source">The image this method extends.</param> /// <param name="pen">The pen.</param> /// <param name="shape">The shape.</param> /// <param name="options">The options.</param> /// <returns>The <see cref="Image{TColor}"/>.</returns> public static Image <TColor> Draw <TColor>(this Image <TColor> source, IPen <TColor> pen, IShape shape, GraphicsOptions options) where TColor : struct, IPackedPixel, IEquatable <TColor> { return(source.Draw(pen, new ShapePath(shape), options)); }
/// <summary> /// Draws the provided Points as an open Bezier path with the supplied pen /// </summary> /// <typeparam name="TPixel">The type of the color.</typeparam> /// <param name="source">The image this method extends.</param> /// <param name="pen">The pen.</param> /// <param name="points">The points.</param> /// <param name="options">The options.</param> /// <returns>The <see cref="Image{TPixel}"/>.</returns> public static IImageProcessingContext <TPixel> DrawBeziers <TPixel>(this IImageProcessingContext <TPixel> source, IPen <TPixel> pen, PointF[] points, GraphicsOptions options) where TPixel : struct, IPixel <TPixel> { return(source.Draw(pen, new Path(new CubicBezierLineSegment(points)), options)); }
/// <summary> /// Draws the outline of the rectangle with the provided pen. /// </summary> /// <param name="source">The image this method extends.</param> /// <param name="pen">The pen.</param> /// <param name="shape">The shape.</param> /// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns> public static IImageProcessingContext Draw(this IImageProcessingContext source, IPen pen, RectangleF shape) => source.Draw(source.GetShapeGraphicsOptions(), pen, shape);
public static void Pack(BufferChunk chunk, IPen aPen) { chunk += GDI32.EMR_CREATEPEN; chunk += (int)aPen.Style; chunk += 1; chunk += aPen.Color; Pack(chunk, aPen.UniqueID); }
public void DrawPolygon(IPen pen, PointF[] pts) { ApplyPen(pen); Gl.glBegin(Gl.GL_LINE_LOOP); foreach (PointF p in pts) { Gl.glVertex2f(p.X, p.Y); } Gl.glEnd(); }
/// <inheritdoc /> public void DrawRectangle(IBrush brush, IPen pen, RoundedRect rrect, BoxShadows boxShadow = default) { var rc = rrect.Rect.ToDirect2D(); var rect = rrect.Rect; var radiusX = Math.Max(rrect.RadiiTopLeft.X, Math.Max(rrect.RadiiTopRight.X, Math.Max(rrect.RadiiBottomRight.X, rrect.RadiiBottomLeft.X))); var radiusY = Math.Max(rrect.RadiiTopLeft.Y, Math.Max(rrect.RadiiTopRight.Y, Math.Max(rrect.RadiiBottomRight.Y, rrect.RadiiBottomLeft.Y))); var isRounded = !MathUtilities.IsZero(radiusX) || !MathUtilities.IsZero(radiusY); if (brush != null) { using (var b = CreateBrush(brush, rect.Size)) { if (b.PlatformBrush != null) { if (isRounded) { _deviceContext.FillRoundedRectangle( new RoundedRectangle { Rect = new RawRectangleF( (float)rect.X, (float)rect.Y, (float)rect.Right, (float)rect.Bottom), RadiusX = (float)radiusX, RadiusY = (float)radiusY }, b.PlatformBrush); } else { _deviceContext.FillRectangle(rc, b.PlatformBrush); } } } } if (pen?.Brush != null) { using (var wrapper = CreateBrush(pen.Brush, rect.Size)) using (var d2dStroke = pen.ToDirect2DStrokeStyle(_deviceContext)) { if (wrapper.PlatformBrush != null) { if (isRounded) { _deviceContext.DrawRoundedRectangle( new RoundedRectangle { Rect = rc, RadiusX = (float)radiusX, RadiusY = (float)radiusY }, wrapper.PlatformBrush, (float)pen.Thickness, d2dStroke); } else { _deviceContext.DrawRectangle( rc, wrapper.PlatformBrush, (float)pen.Thickness, d2dStroke); } } } } }
public void DrawBeziers(IPen pen, PointF[] pts) { throw new NotSupportedException(); }
private const int PaddingFactor = 1; // needs to been the same or greater than AntialiasFactor /// <summary> /// Initializes a new instance of the <see cref="DrawPathProcessor{TPixel}" /> class. /// </summary> /// <param name="pen">The details how to draw the outline/path.</param> /// <param name="drawable">The details of the paths and outlines to draw.</param> /// <param name="options">The drawing configuration options.</param> public DrawPathProcessor(IPen <TPixel> pen, Drawable drawable, GraphicsOptions options) { this.Path = drawable; this.Pen = pen; this.Options = options; }
//public override void DrawBezier(GDIPen aPen, Point[] points) //{ // BufferChunk chunk = new BufferChunk(points.Length * 8 + 16); // chunk += GDI32.EMR_POLYBEZIER; // Pack(chunk, points); // SendCommand(chunk); //} public override void DrawLine(IPen aPen, Point startPoint, Point endPoint) { BufferChunk chunk = new BufferChunk(1024); chunk += GDI32.EMR_LINETO; ChunkUtils.Pack(chunk, startPoint); ChunkUtils.Pack(chunk, endPoint); // Pack the pen ChunkUtils.Pack(chunk, aPen); SendCommand(chunk); }
/// <summary> /// Draws the provided points as a closed linear polygon with the provided pen. /// </summary> /// <param name="source">The image this method extends.</param> /// <param name="pen">The pen.</param> /// <param name="points">The points.</param> /// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns> public static IImageProcessingContext DrawPolygon( this IImageProcessingContext source, IPen pen, params PointF[] points) => source.Draw(source.GetDrawingOptions(), pen, new Polygon(new LinearLineSegment(points)));
public override void DrawRoundRect(IPen aPen, Rectangle rect, int xRadius, int yRadius) { BufferChunk chunk = new BufferChunk(128); chunk += GDI32.EMR_ROUNDRECT; ChunkUtils.Pack(chunk, rect.X, rect.Y, rect.Width, rect.Height); ChunkUtils.Pack(chunk, xRadius, yRadius); ChunkUtils.Pack(chunk, aPen); SendCommand(chunk); }
public StockValuesItemCollection(CollectionId id, IEnumerable <StockValuesItem> items, IPen penRaise, IPen penFall, Brush fill, IPen[] pens, bool isItemDynamic = false) : base(id, items, penRaise, penFall, fill, isItemDynamic) { if (pens != null && pens.Length >= 1) { Pens = new IPen[pens.Length]; for (int i = 0; i < pens.Length; i++) { Pens[i] = CopyPen(pens[i], PenLineCap.Round); } } }
private ChartItemCollection CreateCollection(string id, IEnumerable<ChartItem> chartItems, IEnumerable<ChartItem> chartItems2, ChartItemType type, IPen pen1, IPen pen2, IPen[] otherPens) { CollectionId cId = new CollectionId(id); ChartItemCollection coll = CreateSingleStockCollection(type, chartItems, chartItems2, cId, pen1, pen2, otherPens); return coll; }
Draw(this IImageProcessingContext source, IPen pen, IPathCollection paths) => source.Draw(source.GetShapeGraphicsOptions(), pen, paths);
private ChartItemCollection CreateSingleStockCollection(ChartItemType type, IEnumerable<ChartItem> chartItems, IEnumerable<ChartItem> chartItems2, CollectionId id, IPen pen1, IPen pen2, IPen[] otherPens) { List<StockValuesItem> ssItems = new List<StockValuesItem>(chartItems.Count()); var it = chartItems2.GetEnumerator(); foreach (var cItem in chartItems) { it.MoveNext(); var sItem = cItem as StockItem; StockValuesItem ssItem = new StockValuesItem() { Date = sItem.Date, High = sItem.High, Low = sItem.Low, Open = sItem.Open, Close = sItem.Close, CloseChange = sItem.CloseChange, Values = new List<double>(new double[] { it.Current.Value }), ValueChanges = new List<double>(new double[] { it.Current.ValueChange }) }; ssItems.Add(ssItem); } var coll = new StockValuesItemCollection(id, ssItems, pen1, pen2, null, otherPens); return coll; }
public override void DrawPath(IPen pen, IBrush brush, IGfxPath path) { }
/// <summary> /// Constructor /// </summary> /// <param name="abscissaValue">abscissa (X) value of line.</param> /// <param name="pen">Pen to use to draw the line.</param> public VerticalLine(double abscissaValue, IPen pen) { AbscissaValue = abscissaValue; Pen = pen; }
/// <summary> /// Draws the provided points as an open Bezier path with the supplied pen /// </summary> /// <param name="source">The image this method extends.</param> /// <param name="pen">The pen.</param> /// <param name="points">The points.</param> /// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns> public static IImageProcessingContext DrawBeziers( this IImageProcessingContext source, IPen pen, params PointF[] points) => source.Draw(pen, new Path(new CubicBezierLineSegment(points)));
public abstract void SetPen(IPen pen);
/// <summary> /// Draws the provided Points as a closed Linear Polygon with the provided Pen. /// </summary> /// <param name="source">The image this method extends.</param> /// <param name="options">The options.</param> /// <param name="pen">The pen.</param> /// <param name="points">The points.</param> /// <returns>The <see cref="Image{TPixel}"/>.</returns> public static IImageProcessingContext DrawPolygon( this IImageProcessingContext source, ShapeGraphicsOptions options, IPen pen, params PointF[] points) => source.Draw(options, pen, new Polygon(new LinearLineSegment(points)));
public void DrawLine(IPen pen, PointF pt1, PointF pt2) { ApplyPen(pen); Gl.glBegin(Gl.GL_LINE_STRIP); Gl.glVertex2f(pt1.X, pt1.Y); Gl.glVertex2f(pt2.X, pt2.Y); Gl.glEnd(); }
public void DrawLine(IPen pen, Point p1, Point p2) { }
public void DrawRectangle(IPen pen, RectangleF rect) { ApplyPen(pen); Gl.glBegin(Gl.GL_LINE_LOOP); Gl.glVertex2f(rect.Left, rect.Top); Gl.glVertex2f(rect.Right, rect.Top); Gl.glVertex2f(rect.Right, rect.Bottom); Gl.glVertex2f(rect.Left, rect.Bottom); Gl.glEnd(); }
public void DrawGeometry(IBrush brush, IPen pen, IGeometryImpl geometry) { }
public void DrawEllipse(IPen pen, RectangleF rect) { ApplyPen(pen); Gl.glPushMatrix(); Gl.glTranslatef(rect.Left+rect.Width /2, rect.Top + rect.Height /2, 0); Gl.glBegin(Gl.GL_LINE_LOOP); for (double i = 0; i < Math.PI * 2; i += 0.05) Gl.glVertex2f((float)(Math.Cos(i) * rect.Width/2), (float)(Math.Sin(i) * rect.Height/2)); Gl.glEnd(); Gl.glPopMatrix(); }
/// <summary> /// Creates a new pen with the specified <paramref name="color"/> and <paramref name="thickness"/> /// </summary> /// <param name="color">Color for the new pen</param> /// <param name="thickness">Thickness of the new pen</param> /// <param name="generator">Generator to create the pen for</param> public Pen (Color color, float thickness = 1f, Generator generator = null) { handler = generator.CreateShared<IPen> (); ControlObject = handler.Create (color, thickness); }
public void DrawRectangle(IBrush brush, IPen pen, RoundedRect rect, BoxShadows boxShadows = default) { }
/// <summary> /// Initializes a new instance of the <see cref="DrawTextProcessor{TPixel}"/> class. /// </summary> /// <param name="options">The options</param> /// <param name="text">The text we want to render</param> /// <param name="font">The font we want to render with</param> /// <param name="brush">The brush to source pixel colors from.</param> /// <param name="pen">The pen to outline text with.</param> /// <param name="location">The location on the image to start drawign the text from.</param> public DrawTextProcessor(TextGraphicsOptions options, string text, Font font, IBrush <TPixel> brush, IPen <TPixel> pen, PointF location) { Guard.NotNull(text, nameof(text)); Guard.NotNull(font, nameof(font)); if (brush == null && pen == null) { throw new ArgumentNullException($"at least one of {nameof(brush)} or {nameof(pen)} must not be null"); } this.Options = options; this.Text = text; this.Font = font; this.Location = location; this.Brush = brush; this.Pen = pen; }
Pen (IPen handler, object control) { this.handler = handler; this.ControlObject = control; }
public void DrawEllipse(IBrush brush, IPen pen, Rect rect) { }
// Gradient Fills //public override void DrawGradientRectangle(GradientRect gRect) //{ // BufferChunk chunk = new BufferChunk(1024); // chunk += GDI32.EMR_GRADIENTFILL; // // Pack the vertices // ChunkUtils.Pack(chunk, gRect.Vertices); // // Pack the gradient mesh // ChunkUtils.Pack(chunk, gRect.Boundary); // // pack the mode // chunk += (int)gRect.Direction; // SendCommand(chunk); //} /// DrawEllipse /// public override void DrawEllipse(IPen aPen, Rectangle rect) { BufferChunk chunk = new BufferChunk(128); chunk += GDI32.EMR_ELLIPSE; ChunkUtils.Pack(chunk, rect.X, rect.Y, rect.Width, rect.Height); SendCommand(chunk); }
public HomeController(IPen myPenService, IAccount myAccService) { _myPenService = myPenService; _myAccService = myAccService; }
public override void DrawLines(IPen aPen, Point[] points) { BufferChunk chunk = new BufferChunk(points.Length * 8 + 128); chunk += GDI32.EMR_POLYLINE; // Pack the pen ChunkUtils.Pack(chunk, aPen); // Pack the points ChunkUtils.Pack(chunk, points); SendCommand(chunk); }
public static void DrawControlPoint(IGraphics g, Coordinates loc, Color color, string label, ContentAlignment align, ControlPointStyle style, bool drawTextBox, WorldTransform wt) { // figure out the size the control box needs to be in world coordinates to make it // show up as appropriate in view coordinates // invert the scale float scaled_size = 0; if (style == ControlPointStyle.LargeBox || style == ControlPointStyle.LargeCircle || style == ControlPointStyle.LargeX) { scaled_size = cp_large_size / wt.Scale; } else { scaled_size = cp_small_size / wt.Scale; } float scaled_offset = 1 / wt.Scale; // assume that the world transform is currently applied correctly to the graphics RectangleF rect = new RectangleF(-scaled_size / 2, -scaled_size / 2, scaled_size, scaled_size); rect.Offset(Utility.ToPointF(loc)); if (style == ControlPointStyle.LargeBox) { g.FillRectangle(Color.White, rect); // shrink the rect down a little (nominally 1 pixel) rect.Inflate(-scaled_offset, -scaled_offset); g.FillRectangle(color, rect); } else if (style == ControlPointStyle.LargeCircle) { g.FillEllipse(Color.White, rect); // shrink the rect down a little (nominally 1 pixel) rect.Inflate(-scaled_offset, -scaled_offset); g.FillEllipse(color, rect); } else if (style == ControlPointStyle.LargeX) { using (IPen p = g.CreatePen()) { p.Width = 3 / wt.Scale; p.Color = Color.White; g.DrawLine(p, new PointF(rect.Left, rect.Top), new PointF(rect.Right, rect.Bottom)); g.DrawLine(p, new PointF(rect.Left, rect.Bottom), new PointF(rect.Right, rect.Top)); p.Width = scaled_offset; p.Color = color; g.DrawLine(p, new PointF(rect.Left, rect.Top), new PointF(rect.Right, rect.Bottom)); g.DrawLine(p, new PointF(rect.Left, rect.Bottom), new PointF(rect.Right, rect.Top)); } } else if (style == ControlPointStyle.SmallBox) { g.FillRectangle(color, rect); } else if (style == ControlPointStyle.SmallCircle) { g.FillEllipse(color, rect); } else if (style == ControlPointStyle.SmallX) { using (IPen p = g.CreatePen()) { p.Width = 3 / wt.Scale; p.Color = color; g.DrawLine(p, new PointF(rect.Left, rect.Top), new PointF(rect.Right, rect.Bottom)); g.DrawLine(p, new PointF(rect.Left, rect.Bottom), new PointF(rect.Right, rect.Top)); } } if (!string.IsNullOrEmpty(label)) { SizeF strSize = g.MeasureString(label, label_font); float x = 0, y = 0; if (align == ContentAlignment.BottomRight || align == ContentAlignment.MiddleRight || align == ContentAlignment.TopRight) { x = (float)loc.X + cp_label_space / wt.Scale; } else if (align == ContentAlignment.BottomCenter || align == ContentAlignment.MiddleCenter || align == ContentAlignment.TopCenter) { x = (float)loc.X - strSize.Width / (2 * wt.Scale); } else if (align == ContentAlignment.BottomLeft || align == ContentAlignment.MiddleLeft || align == ContentAlignment.TopLeft) { x = (float)loc.X - (strSize.Width + cp_label_space) / wt.Scale; } if (align == ContentAlignment.BottomCenter || align == ContentAlignment.BottomLeft || align == ContentAlignment.BottomRight) { y = (float)loc.Y - cp_label_space / wt.Scale; } else if (align == ContentAlignment.MiddleCenter || align == ContentAlignment.MiddleLeft || align == ContentAlignment.MiddleRight) { y = (float)loc.Y + strSize.Height / (2 * wt.Scale); } else if (align == ContentAlignment.TopCenter || align == ContentAlignment.TopLeft || align == ContentAlignment.TopRight) { y = (float)loc.Y + (strSize.Height + cp_label_space) / wt.Scale; } PointF text_loc = new PointF(x, y); if (drawTextBox) { RectangleF text_rect = new RectangleF(text_loc.X - 4 / wt.Scale, text_loc.Y - 4 / wt.Scale, strSize.Width / wt.Scale, strSize.Height / wt.Scale); g.FillRectangle(Color.FromArgb(127, Color.White), text_rect); } g.DrawString(label, label_font, color, text_loc); } }
public override void SetPen(IPen aPen) { SelectUniqueObject(aPen.UniqueID); }
public string Stuff(IPen stuff) { return(stuff.Write()); }
/// <inheritdoc /> public void DrawRectangle(IBrush brush, IPen pen, RoundedRect rect, BoxShadows boxShadows = default) { if (rect.Rect.Height <= 0 || rect.Rect.Width <= 0) { return; } // Arbitrary chosen values // On OSX Skia breaks OpenGL context when asked to draw, e. g. (0, 0, 623, 6666600) rect if (rect.Rect.Height > 8192 || rect.Rect.Width > 8192) { boxShadows = default; } var rc = rect.Rect.ToSKRect(); var isRounded = rect.IsRounded; var needRoundRect = rect.IsRounded || (boxShadows.HasInsetShadows); using var skRoundRect = needRoundRect ? new SKRoundRect() : null; if (needRoundRect) { skRoundRect.SetRectRadii(rc, new[] { rect.RadiiTopLeft.ToSKPoint(), rect.RadiiTopRight.ToSKPoint(), rect.RadiiBottomRight.ToSKPoint(), rect.RadiiBottomLeft.ToSKPoint(), }); } foreach (var boxShadow in boxShadows) { if (!boxShadow.IsEmpty && !boxShadow.IsInset) { using (var shadow = BoxShadowFilter.Create(_boxShadowPaint, boxShadow, _currentOpacity)) { var spread = (float)boxShadow.Spread; if (boxShadow.IsInset) { spread = -spread; } Canvas.Save(); if (isRounded) { using var shadowRect = new SKRoundRect(skRoundRect); if (spread != 0) { shadowRect.Inflate(spread, spread); } Canvas.ClipRoundRect(skRoundRect, shadow.ClipOperation, true); var oldTransform = Transform; Transform = oldTransform * Matrix.CreateTranslation(boxShadow.OffsetX, boxShadow.OffsetY); Canvas.DrawRoundRect(shadowRect, shadow.Paint); Transform = oldTransform; } else { var shadowRect = rc; if (spread != 0) { shadowRect.Inflate(spread, spread); } Canvas.ClipRect(rc, shadow.ClipOperation); var oldTransform = Transform; Transform = oldTransform * Matrix.CreateTranslation(boxShadow.OffsetX, boxShadow.OffsetY); Canvas.DrawRect(shadowRect, shadow.Paint); Transform = oldTransform; } Canvas.Restore(); } } } if (brush != null) { using (var paint = CreatePaint(_fillPaint, brush, rect.Rect.Size)) { if (isRounded) { Canvas.DrawRoundRect(skRoundRect, paint.Paint); } else { Canvas.DrawRect(rc, paint.Paint); } } } foreach (var boxShadow in boxShadows) { if (!boxShadow.IsEmpty && boxShadow.IsInset) { using (var shadow = BoxShadowFilter.Create(_boxShadowPaint, boxShadow, _currentOpacity)) { var spread = (float)boxShadow.Spread; var offsetX = (float)boxShadow.OffsetX; var offsetY = (float)boxShadow.OffsetY; var outerRect = AreaCastingShadowInHole(rc, (float)boxShadow.Blur, spread, offsetX, offsetY); Canvas.Save(); using var shadowRect = new SKRoundRect(skRoundRect); if (spread != 0) { shadowRect.Deflate(spread, spread); } Canvas.ClipRoundRect(skRoundRect, shadow.ClipOperation, true); var oldTransform = Transform; Transform = oldTransform * Matrix.CreateTranslation(boxShadow.OffsetX, boxShadow.OffsetY); using (var outerRRect = new SKRoundRect(outerRect)) Canvas.DrawRoundRectDifference(outerRRect, shadowRect, shadow.Paint); Transform = oldTransform; Canvas.Restore(); } } } if (pen?.Brush != null) { using (var paint = CreatePaint(_strokePaint, pen, rect.Rect.Size)) { if (isRounded) { Canvas.DrawRoundRect(skRoundRect, paint.Paint); } else { Canvas.DrawRect(rc, paint.Paint); } } } }
/// <summary> /// Draws the outline of the rectangle with the provided pen. /// </summary> /// <typeparam name="TPixel">The type of the color.</typeparam> /// <param name="source">The image this method extends.</param> /// <param name="options">The options.</param> /// <param name="pen">The pen.</param> /// <param name="shape">The shape.</param> /// <returns>The <see cref="Image{TPixel}"/>.</returns> public static IImageProcessingContext <TPixel> Draw <TPixel>(this IImageProcessingContext <TPixel> source, GraphicsOptions options, IPen <TPixel> pen, RectangleF shape) where TPixel : struct, IPixel <TPixel> => source.Draw(options, pen, new RectangularPolygon(shape.X, shape.Y, shape.Width, shape.Height));
private ChartItemCollection CreateCollection(string id, IEnumerable<ChartItem> chartItems, ChartItemType type, IPen pen1, IPen pen2) { CollectionId cId = new CollectionId(id); ChartItemCollection coll = CreateChartItemCollection(type, chartItems, cId, pen1, pen2); return coll; }
/// <summary> /// Draws the outline of the rectangle with the provided pen. /// </summary> /// <typeparam name="TPixel">The type of the color.</typeparam> /// <param name="source">The image this method extends.</param> /// <param name="pen">The pen.</param> /// <param name="shape">The shape.</param> /// <returns>The <see cref="Image{TPixel}"/>.</returns> public static IImageProcessingContext <TPixel> Draw <TPixel>(this IImageProcessingContext <TPixel> source, IPen <TPixel> pen, RectangleF shape) where TPixel : struct, IPixel <TPixel> => source.Draw(GraphicsOptions.Default, pen, shape);
private ChartItemCollection CreateCollection(string id, IEnumerable<ChartItem>[] chartItemsList, IPen[] pens) { CollectionId cId = new CollectionId(id); ChartItemCollection coll = CreateMultipleItemCollection(chartItemsList, cId, pens); return coll; }
/// <summary> /// 构造函数。 /// </summary> /// <param name="id">集合ID。</param> /// <param name="items">数据项列表。</param> /// <param name="penRaise">上升画笔。<see cref="DrawingObjectFactory.CreatePen(Brush, double)"/></param> /// <param name="penFall">下降画笔。<see cref="DrawingObjectFactory.CreatePen(Brush, double)"/></param> /// <param name="fill">填充画刷。</param> /// <param name="isItemDynamic">是否动态加载数据集合中的数据项。缺省值是false,表示不动态加载。</param> public StockItemCollection(CollectionId id, IEnumerable <StockItem> items, IPen penRaise, IPen penFall, Brush fill, bool isItemDynamic = false) : base(id, items, penRaise, fill, false, isItemDynamic) { if (penFall == null) { throw new ArgumentNullException("penFall"); } RaisePen = penRaise; FallPen = penFall; }
private ChartItemCollection CreateMultipleItemCollection(IEnumerable<ChartItem>[] chartItemsList, CollectionId id, IPen[] pens) { List<MultipleChartItem> mItems = new List<MultipleChartItem>(chartItemsList[0].Count()); IEnumerator<ChartItem>[] its = new IEnumerator<ChartItem>[chartItemsList.Length]; for (int i = 1; i < chartItemsList.Length; i++) { its[i] = chartItemsList[i].GetEnumerator(); its[i].MoveNext(); } double[] invalidValues = new double[chartItemsList.Length - 1]; for(int i = 0; i < invalidValues.Length; i ++) { invalidValues[i] = ChartItemCollection.valueNA; } foreach (var cItem in chartItemsList[0]) { MultipleChartItem mItem = new MultipleChartItem() { Date = cItem.Date, Value = cItem.Value, ValueChange = cItem.ValueChange, Values = new List<double>(invalidValues), ValueChanges = new List<double>(invalidValues) }; for(int i = 1; i < chartItemsList.Length; i ++) { if (its[i].Current.Date > cItem.Date) { continue; } mItem.Values[i - 1] = its[i].Current.Value; mItem.ValueChanges[i - 1] = its[i].Current.ValueChange; its[i].MoveNext(); } mItems.Add(mItem); } return new MultipleChartItemCollection(id, mItems, pens); }
/// <summary> /// Initializes a new instance of the <see cref="DrawTextProcessor"/> class. /// </summary> /// <param name="options">The options</param> /// <param name="text">The text we want to render</param> /// <param name="font">The font we want to render with</param> /// <param name="brush">The brush to source pixel colors from.</param> /// <param name="pen">The pen to outline text with.</param> /// <param name="location">The location on the image to start drawing the text from.</param> public DrawTextProcessorCopy(TextGraphicsOptionsCopy options, string text, Font font, SolidBrushCopy brush, IPen pen, PointF location) { // Guard.NotNull(text, nameof(text)); // Guard.NotNull(font, nameof(font)); if (brush is null && pen is null) { throw new ArgumentNullException($"Expected a {nameof(brush)} or {nameof(pen)}. Both were null"); } this.Options = options; this.Text = text; this.Font = font; this.Location = location; this.Brush = brush; this.Pen = pen; }
public GUIStyle() { fBorderWidth = 2; fBaseColor = (Colorref)Colorrefs.LtGray; fHighlightColor = GUIStyle.brighter(fBaseColor); fShadowColor = GUIStyle.darker(fBaseColor); fBackground = GUIStyle.brighter(fHighlightColor); fForeground = (Colorref)Colorrefs.LtGray; fTextBackground = fBaseColor; fBottomShadow = GUIStyle.darker(fForeground); // 0x00616161; fBottomShadowTopLiner = GUIStyle.brighter(fBottomShadow); //fForeground; fTopShadow = GUIStyle.brighter(fForeground); // 0x00cbcbcb; fBackground = GUIStyle.brighter((Colorref)Colorrefs.DarkGray); //0x009e9e9e; fBasePen = new GDIPen(fBaseColor); fHighlightPen = new GDIPen(fHighlightColor); fShadowPen = new GDIPen(fShadowColor); fBottomShadowBottomLinerPen = new GDIPen(fBottomShadowBottomLiner); fBaseColorBrush = new GDIBrush(fBaseColor); GUIStyle.Default = this; }
public virtual void SetPen(IPen aPen) { if (null != SetPenHandler) SetPenHandler(aPen); }