public Bitmap GetMarkerBitmap(Graphics g, GaugeMarkerStyle style, GradientFillColor fillColor, int width, int length) { Bitmap bitmap = FindBitmap(fillColor); if (bitmap == null) { width = Math.Max(width, 3); length = Math.Max(length, 3); bitmap = new Bitmap(width, length, g); _Bitmaps.Add(new BitmapEntry(fillColor, bitmap)); using (Graphics gBmp = Graphics.FromImage(bitmap)) { gBmp.SmoothingMode = SmoothingMode.AntiAlias; Rectangle r = new Rectangle(); r.Height = length; r.Width = width; using (GraphicsPath path = GetMarkerPath(style, r)) FillMarkerPath(gBmp, path, r, style, fillColor); } } return (bitmap); }
public GaugeTickMark(GaugeScale scale, GaugeTickMarkRank rank, GaugeMarkerStyle style, float width, float length, double interval) : base(scale, rank, style, width, length) { _Interval = interval; _DefaultInterval = interval; }
public TickMarkLayout(GaugeMarkerStyle style, float width, float length) { _Style = style; _Width = width; _Length = length; _DefaultStyle = style; _DefaultWidth = width; _DefaultLength = length; _Placement = DisplayPlacement.Center; FillColor = new GradientFillColor(Color.DarkGray, Color.White); FillColor.BorderColor = Color.DimGray; FillColor.BorderWidth = 1; _Overlap = GaugeTickMarkOverlap.ReplaceAll; }
public GaugeTickMarkBase(GaugeScale scale, GaugeTickMarkRank rank, GaugeMarkerStyle style, float width, float length) : this(scale, rank, new TickMarkLayout(style, width, length)) { }
internal void FillMarkerPath(Graphics g, GraphicsPath path, Rectangle r, GaugeMarkerStyle style, GradientFillColor fillColor) { GradientFillType fillType = GetMarkerFillType(style, fillColor); switch (fillType) { case GradientFillType.Angle: using (Brush br = fillColor.GetBrush(r)) { if (br is LinearGradientBrush) ((LinearGradientBrush)br).WrapMode = WrapMode.TileFlipXY; g.FillPath(br, path); } break; case GradientFillType.StartToEnd: using (Brush br = fillColor.GetBrush(r, 90)) { if (br is LinearGradientBrush) ((LinearGradientBrush)br).WrapMode = WrapMode.TileFlipXY; g.FillPath(br, path); } break; case GradientFillType.HorizontalCenter: r.Height /= 2; if (r.Height <= 0) r.Height = 1; using (LinearGradientBrush br = new LinearGradientBrush(r, fillColor.Start, fillColor.End, 90)) { br.WrapMode = WrapMode.TileFlipXY; g.FillPath(br, path); } break; case GradientFillType.VerticalCenter: r.Width /= 2; if (r.Width <= 0) r.Width = 1; using (LinearGradientBrush br = new LinearGradientBrush(r, fillColor.Start, fillColor.End, 0f)) { br.WrapMode = WrapMode.TileFlipXY; g.FillPath(br, path); } break; case GradientFillType.Center: using (PathGradientBrush br = new PathGradientBrush(path)) { br.CenterColor = fillColor.Start; br.SurroundColors = new Color[] { fillColor.End }; g.FillPath(br, path); } break; default: using (Brush br = new SolidBrush(fillColor.Start)) g.FillPath(br, path); break; } if (fillColor.BorderWidth > 0) { using (Pen pen = new Pen(fillColor.BorderColor, fillColor.BorderWidth)) { pen.Alignment = PenAlignment.Inset; g.DrawPath(pen, path); } } }
internal GraphicsPath GetMarkerPath(GaugeMarkerStyle style, Rectangle r) { r.Inflate(-1, -1); if (r.Width > 0 && r.Height > 0) { switch (style) { case GaugeMarkerStyle.Circle: return (GetCirclePath(r)); case GaugeMarkerStyle.Diamond: return (GetDiamondPath(r)); case GaugeMarkerStyle.Hexagon: return (GetPolygonPath(r, 6, 90)); case GaugeMarkerStyle.Pentagon: return (GetPolygonPath(r, 5, 90)); case GaugeMarkerStyle.Rectangle: return (GetRectanglePath(r)); case GaugeMarkerStyle.Star5: return (GetStarPath(r, 5)); case GaugeMarkerStyle.Star7: return (GetStarPath(r, 7)); case GaugeMarkerStyle.Trapezoid: return (GetTrapezoidPath(r)); case GaugeMarkerStyle.Triangle: return (GetTrianglePath(r)); case GaugeMarkerStyle.Wedge: return (GetWedgePath(r)); default: return (GetRectanglePath(r)); } } return (null); }
private GradientFillType GetMarkerFillType(GaugeMarkerStyle style, GradientFillColor fillColor) { if (fillColor.End.IsEmpty == true) return (GradientFillType.None); if (fillColor.GradientFillType == GradientFillType.Auto) { switch (style) { case GaugeMarkerStyle.Circle: case GaugeMarkerStyle.Star5: case GaugeMarkerStyle.Star7: return (GradientFillType.Center); default: return (GradientFillType.VerticalCenter); } } return (fillColor.GradientFillType); }
public void ResetStyle() { Style = _DefaultStyle; }