public GraphicsPath GetPath(GaugeGraphics g, bool getShadowPath) { if (getShadowPath && (!base.Visible || base.ShadowOffset == 0.0)) { return(null); } this.GetScale().SetDrawRegion(g); CircularScale scale = this.GetScale(); RectangleF rect = this.CalculateRangeRectangle(); double valueLimit = scale.GetValueLimit(this.StartValue); double valueLimit2 = scale.GetValueLimit(this.EndValue); float positionFromValue = scale.GetPositionFromValue(valueLimit); float positionFromValue2 = scale.GetPositionFromValue(valueLimit2); float num = positionFromValue2 - positionFromValue; if (Math.Round((double)num, 4) == 0.0) { g.RestoreDrawRegion(); return(null); } GraphicsPath circularRangePath = g.GetCircularRangePath(rect, (float)(positionFromValue + 90.0), positionFromValue2 - positionFromValue, this.StartWidth, this.EndWidth, this.Placement); if (circularRangePath != null && getShadowPath) { using (Matrix matrix = new Matrix()) { matrix.Translate(base.ShadowOffset, base.ShadowOffset); circularRangePath.Transform(matrix); } } PointF pointF = new PointF(g.Graphics.Transform.OffsetX, g.Graphics.Transform.OffsetY); g.RestoreDrawRegion(); PointF pointF2 = new PointF(g.Graphics.Transform.OffsetX, g.Graphics.Transform.OffsetY); if (circularRangePath != null) { using (Matrix matrix2 = new Matrix()) { matrix2.Translate(pointF.X - pointF2.X, pointF.Y - pointF2.Y); circularRangePath.Transform(matrix2); return(circularRangePath); } } return(circularRangePath); }
public override void Render(GaugeGraphics g) { if (this.Common != null && base.Visible && this.GetScale() != null) { this.Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceStartRendering(this.Name)); g.StartHotRegion(this); this.GetScale().SetDrawRegion(g); RectangleF rectangleF = this.CalculateRangeRectangle(); CircularScale scale = this.GetScale(); double valueLimit = scale.GetValueLimit(this.StartValue); double valueLimit2 = scale.GetValueLimit(this.EndValue); float positionFromValue = scale.GetPositionFromValue(valueLimit); float positionFromValue2 = scale.GetPositionFromValue(valueLimit2); float num = positionFromValue2 - positionFromValue; if (Math.Round((double)num, 4) == 0.0) { g.RestoreDrawRegion(); g.EndHotRegion(); this.Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceRenderingComplete(this.Name)); } else { Pen pen = null; Brush brush = null; GraphicsPath graphicsPath = null; try { graphicsPath = g.GetCircularRangePath(rectangleF, (float)(positionFromValue + 90.0), num, this.StartWidth, this.EndWidth, this.Placement); if (graphicsPath == null) { g.RestoreDrawRegion(); g.EndHotRegion(); this.Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceRenderingComplete(this.Name)); return; } RectangleF rect = rectangleF; if (this.Placement != 0) { float num2 = this.StartWidth; if (num2 < this.EndWidth) { num2 = this.EndWidth; } if (this.Placement == Placement.Outside) { rect.Inflate(num2, num2); } else { rect.Inflate((float)(num2 / 2.0), (float)(num2 / 2.0)); } } RangeGradientType fillGradientType = base.FillGradientType; brush = g.GetCircularRangeBrush(rect, (float)(positionFromValue + 90.0), num, base.FillColor, base.FillHatchStyle, "", GaugeImageWrapMode.Unscaled, Color.Empty, GaugeImageAlign.TopLeft, fillGradientType, base.FillGradientEndColor); pen = new Pen(base.BorderColor, (float)base.BorderWidth); pen.DashStyle = g.GetPenStyle(base.BorderStyle); g.FillPath(brush, graphicsPath); if (base.BorderStyle != 0 && base.BorderWidth > 0) { g.DrawPath(pen, graphicsPath); } } catch (Exception) { if (graphicsPath != null) { graphicsPath.Dispose(); } if (pen != null) { pen.Dispose(); } if (brush != null) { brush.Dispose(); } g.RestoreDrawRegion(); throw; } this.Common.GaugeCore.HotRegionList.SetHotRegion(this, g.GetAbsolutePoint(this.GetScale().GetPivotPoint()), graphicsPath); g.RestoreDrawRegion(); g.EndHotRegion(); this.Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceRenderingComplete(this.Name)); } } }