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); }
internal override void Render(GaugeGraphics g) { if (Common == null || !base.Visible || GetScale() == null) { return; } Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceStartRendering(Name)); g.StartHotRegion(this); GetScale().SetDrawRegion(g); RectangleF rectangleF = CalculateRangeRectangle(); CircularScale scale = GetScale(); double valueLimit = scale.GetValueLimit(StartValue); double valueLimit2 = scale.GetValueLimit(EndValue); float positionFromValue = scale.GetPositionFromValue(valueLimit); float num = scale.GetPositionFromValue(valueLimit2) - positionFromValue; if (Math.Round(num, 4) == 0.0) { g.RestoreDrawRegion(); g.EndHotRegion(); Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceRenderingComplete(Name)); return; } Pen pen = null; Brush brush = null; GraphicsPath graphicsPath = null; try { graphicsPath = g.GetCircularRangePath(rectangleF, positionFromValue + 90f, num, StartWidth, EndWidth, Placement); if (graphicsPath == null) { g.RestoreDrawRegion(); g.EndHotRegion(); Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceRenderingComplete(Name)); return; } RectangleF rect = rectangleF; if (Placement != 0) { float num2 = StartWidth; if (num2 < EndWidth) { num2 = EndWidth; } if (Placement == Placement.Outside) { rect.Inflate(num2, num2); } else { rect.Inflate(num2 / 2f, num2 / 2f); } } RangeGradientType fillGradientType = base.FillGradientType; brush = g.GetCircularRangeBrush(rect, positionFromValue + 90f, num, base.FillColor, base.FillHatchStyle, "", GaugeImageWrapMode.Unscaled, Color.Empty, GaugeImageAlign.TopLeft, fillGradientType, base.FillGradientEndColor); pen = new Pen(base.BorderColor, 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) { graphicsPath?.Dispose(); pen?.Dispose(); brush?.Dispose(); g.RestoreDrawRegion(); throw; } Common.GaugeCore.HotRegionList.SetHotRegion(this, g.GetAbsolutePoint(GetScale().GetPivotPoint()), graphicsPath); g.RestoreDrawRegion(); g.EndHotRegion(); Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceRenderingComplete(Name)); }
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)); } } }
internal void RenderGlassEffect(GaugeGraphics g) { if (GlassEffect == GlassEffect.None || FrameStyle == BackFrameStyle.None) { return; } if (IsCustomXamlFrame()) { GetCachedXamlRenderer(g).Layers[2].Render(g); return; } RectangleF bounds; using (GraphicsPath graphicsPath = GetFramePath(g, FrameWidth - 1f)) { bounds = graphicsPath.GetBounds(); using (Brush brush = new LinearGradientBrush(bounds, Color.FromArgb(15, Color.Black), Color.FromArgb(128, Color.Black), LinearGradientMode.ForwardDiagonal)) { if (bounds.Height > 0f && bounds.Width > 0f) { g.FillPath(brush, graphicsPath); } } } if (FrameShape == BackFrameShape.Rectangular || FrameShape == BackFrameShape.RoundedRectangular) { _ = g.GetAbsoluteSize(new SizeF(8f, 0f)).Width; GraphicsPath graphicsPath2 = new GraphicsPath(); float absoluteDimension = g.GetAbsoluteDimension(30f); float absoluteDimension2 = g.GetAbsoluteDimension(10f); float absoluteDimension3 = g.GetAbsoluteDimension(50f); float absoluteDimension4 = g.GetAbsoluteDimension(5f); g.GetAbsoluteDimension(30f); g.GetAbsoluteDimension(5f); PointF[] points = new PointF[4] { new PointF(bounds.X, bounds.Y + absoluteDimension), new PointF(bounds.X + absoluteDimension, bounds.Y), new PointF(bounds.X + absoluteDimension + absoluteDimension2, bounds.Y), new PointF(bounds.X, bounds.Y + absoluteDimension + absoluteDimension2) }; PointF[] points2 = new PointF[4] { new PointF(bounds.X, bounds.Y + absoluteDimension3), new PointF(bounds.X + absoluteDimension3, bounds.Y), new PointF(bounds.X + absoluteDimension3 + absoluteDimension4, bounds.Y), new PointF(bounds.X, bounds.Y + absoluteDimension3 + absoluteDimension4) }; graphicsPath2.AddPolygon(points); graphicsPath2.AddPolygon(points2); Brush brush2 = new SolidBrush(Color.FromArgb(148, Color.White)); g.FillPath(brush2, graphicsPath2); } else if ((FrameShape == BackFrameShape.Circular || FrameShape == BackFrameShape.AutoShape) && GlassEffect == GlassEffect.Simple) { float absoluteDimension5 = g.GetAbsoluteDimension(15f); bounds.X += absoluteDimension5; bounds.Y += absoluteDimension5; bounds.Width -= absoluteDimension5 * 2f; bounds.Height -= absoluteDimension5 * 2f; GraphicsPath circularRangePath = g.GetCircularRangePath(g.GetRelativeRectangle(bounds), 226f, 30f, 6f, 6f, Placement.Inside); GraphicsPath circularRangePath2 = g.GetCircularRangePath(g.GetRelativeRectangle(bounds), 224f, -30f, 6f, 6f, Placement.Inside); Brush brush3 = new SolidBrush(Color.FromArgb(200, Color.White)); g.FillPath(brush3, circularRangePath); g.FillPath(brush3, circularRangePath2); } }