public override void Render(GaugeGraphics g) { if (this.Common != null && base.Visible && this.GetScale() != null && !double.IsNaN(this.StartValue) && !double.IsNaN(this.EndValue)) { this.Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceStartRendering(this.Name)); g.StartHotRegion(this); LinearScale scale = this.GetScale(); Pen pen = null; Brush brush = null; GraphicsPath graphicsPath = null; try { graphicsPath = g.GetLinearRangePath(scale.GetPositionFromValue(this.StartValue), scale.GetPositionFromValue(this.EndValue), this.StartWidth, this.EndWidth, scale.Position, this.GetGauge().GetOrientation(), this.DistanceFromScale, this.Placement, scale.Width); if (graphicsPath != null && g.Graphics.VisibleClipBounds.IntersectsWith(graphicsPath.GetBounds())) { brush = g.GetLinearRangeBrush(graphicsPath.GetBounds(), base.FillColor, base.FillHatchStyle, base.FillGradientType, base.FillGradientEndColor, this.GetGauge().GetOrientation(), this.GetScale().GetReversed(), this.StartValue, this.EndValue); 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); } goto end_IL_0069; } g.EndHotRegion(); this.Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceRenderingComplete(this.Name)); return; end_IL_0069 :; } catch (Exception) { if (graphicsPath != null) { graphicsPath.Dispose(); } if (pen != null) { pen.Dispose(); } if (brush != null) { brush.Dispose(); } throw; } this.Common.GaugeCore.HotRegionList.SetHotRegion(this, PointF.Empty, graphicsPath); g.EndHotRegion(); this.Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceRenderingComplete(this.Name)); } }
public Pen GetPen(GaugeGraphics g) { if (this.BorderWidth > 0 && this.BorderStyle != 0) { Color borderColor2 = this.BorderColor; int borderWidth2 = this.BorderWidth; GaugeDashStyle borderStyle2 = this.BorderStyle; Pen pen = new Pen(this.BorderColor, (float)this.BorderWidth); pen.DashStyle = g.GetPenStyle(this.BorderStyle); pen.Alignment = PenAlignment.Center; return(pen); } return(null); }
internal Pen GetPen(GaugeGraphics g) { if (BorderWidth <= 0 || BorderStyle == GaugeDashStyle.NotSet) { return(null); } _ = BorderColor; _ = BorderWidth; _ = BorderStyle; return(new Pen(BorderColor, BorderWidth) { DashStyle = g.GetPenStyle(BorderStyle), Alignment = PenAlignment.Center }); }
internal override void Render(GaugeGraphics g) { if (Common == null || !base.Visible || GetScale() == null || double.IsNaN(StartValue) || double.IsNaN(EndValue)) { return; } Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceStartRendering(Name)); g.StartHotRegion(this); LinearScale scale = GetScale(); Pen pen = null; Brush brush = null; GraphicsPath graphicsPath = null; try { graphicsPath = g.GetLinearRangePath(scale.GetPositionFromValue(StartValue), scale.GetPositionFromValue(EndValue), StartWidth, EndWidth, scale.Position, GetGauge().GetOrientation(), DistanceFromScale, Placement, scale.Width); if (graphicsPath == null || !g.Graphics.VisibleClipBounds.IntersectsWith(graphicsPath.GetBounds())) { g.EndHotRegion(); Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceRenderingComplete(Name)); return; } brush = g.GetLinearRangeBrush(graphicsPath.GetBounds(), base.FillColor, base.FillHatchStyle, base.FillGradientType, base.FillGradientEndColor, GetGauge().GetOrientation(), GetScale().GetReversed(), StartValue, EndValue); 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(); throw; } Common.GaugeCore.HotRegionList.SetHotRegion(this, PointF.Empty, graphicsPath); g.EndHotRegion(); Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceRenderingComplete(Name)); }
internal override void Render(GaugeGraphics g) { if (Common == null || !Visible || GetScale() == null) { return; } Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceStartRendering(Name)); g.StartHotRegion(this); if (Image != "") { DrawImage(g, drawShadow: false); SetAllHotRegions(g); g.EndHotRegion(); Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceRenderingComplete(Name)); return; } Pen pen = new Pen(base.BorderColor, base.BorderWidth); pen.DashStyle = g.GetPenStyle(base.BorderStyle); if (pen.DashStyle != 0) { pen.Alignment = PenAlignment.Center; } if (Type == LinearPointerType.Bar) { BarStyleAttrib barStyleAttrib = GetBarStyleAttrib(g); try { if (barStyleAttrib.primaryPath != null) { g.FillPath(barStyleAttrib.primaryBrush, barStyleAttrib.primaryPath); } if (barStyleAttrib.secondaryPaths != null) { int num = 0; GraphicsPath[] secondaryPaths = barStyleAttrib.secondaryPaths; foreach (GraphicsPath graphicsPath in secondaryPaths) { if (graphicsPath != null && barStyleAttrib.secondaryBrushes[num] != null) { g.FillPath(barStyleAttrib.secondaryBrushes[num], graphicsPath); } num++; } } if (base.BorderWidth > 0 && barStyleAttrib.primaryBrush != null && base.BorderStyle != 0) { g.DrawPath(pen, barStyleAttrib.primaryPath); } } catch (Exception) { barStyleAttrib.Dispose(); } if (barStyleAttrib.primaryPath != null) { AddHotRegion(barStyleAttrib.primaryPath, primary: true); } } else if (Type == LinearPointerType.Thermometer) { BarStyleAttrib thermometerStyleAttrib = GetThermometerStyleAttrib(g); try { if (thermometerStyleAttrib.totalPath != null) { g.FillPath(thermometerStyleAttrib.totalBrush, thermometerStyleAttrib.totalPath); } if (thermometerStyleAttrib.primaryPath != null) { g.FillPath(thermometerStyleAttrib.primaryBrush, thermometerStyleAttrib.primaryPath); } if (thermometerStyleAttrib.secondaryPaths != null) { int num2 = 0; GraphicsPath[] secondaryPaths = thermometerStyleAttrib.secondaryPaths; foreach (GraphicsPath graphicsPath2 in secondaryPaths) { if (graphicsPath2 != null && thermometerStyleAttrib.secondaryBrushes[num2] != null) { g.FillPath(thermometerStyleAttrib.secondaryBrushes[num2], graphicsPath2); } num2++; } } if (base.BorderWidth > 0 && thermometerStyleAttrib.primaryBrush != null && base.BorderStyle != 0) { g.DrawPath(pen, thermometerStyleAttrib.totalPath); } } catch (Exception) { thermometerStyleAttrib.Dispose(); } if (thermometerStyleAttrib.primaryPath != null) { AddHotRegion(thermometerStyleAttrib.primaryPath, primary: true); } } else { MarkerStyleAttrib markerStyleAttrib = GetMarkerStyleAttrib(g); try { if (markerStyleAttrib.path != null) { bool circularFill = (MarkerStyle == MarkerStyle.Circle) ? true : false; g.FillPath(markerStyleAttrib.brush, markerStyleAttrib.path, 0f, useBrushOffset: true, circularFill); } if (base.BorderWidth > 0 && markerStyleAttrib.path != null && base.BorderStyle != 0) { g.DrawPath(pen, markerStyleAttrib.path); } } catch (Exception) { markerStyleAttrib.Dispose(); } if (markerStyleAttrib.path != null) { AddHotRegion(markerStyleAttrib.path, primary: true); } } SetAllHotRegions(g); 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)); } } }
public override void Render(GaugeGraphics g) { if (this.Common != null && this.Visible && this.GetScale() != null) { this.Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceStartRendering(this.Name)); g.StartHotRegion(this); if (this.Image != "") { this.DrawImage(g, false); this.SetAllHotRegions(g); g.EndHotRegion(); this.Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceRenderingComplete(this.Name)); } else { Pen pen = new Pen(base.BorderColor, (float)base.BorderWidth); pen.DashStyle = g.GetPenStyle(base.BorderStyle); if (pen.DashStyle != 0) { pen.Alignment = PenAlignment.Center; } if (this.Type == LinearPointerType.Bar) { BarStyleAttrib barStyleAttrib = this.GetBarStyleAttrib(g); try { if (barStyleAttrib.primaryPath != null) { g.FillPath(barStyleAttrib.primaryBrush, barStyleAttrib.primaryPath); } if (barStyleAttrib.secondaryPaths != null) { int num = 0; GraphicsPath[] secondaryPaths = barStyleAttrib.secondaryPaths; foreach (GraphicsPath graphicsPath in secondaryPaths) { if (graphicsPath != null && barStyleAttrib.secondaryBrushes[num] != null) { g.FillPath(barStyleAttrib.secondaryBrushes[num], graphicsPath); } num++; } } if (base.BorderWidth > 0 && barStyleAttrib.primaryBrush != null && base.BorderStyle != 0) { g.DrawPath(pen, barStyleAttrib.primaryPath); } } catch (Exception) { barStyleAttrib.Dispose(); } if (barStyleAttrib.primaryPath != null) { this.AddHotRegion(barStyleAttrib.primaryPath, true); } } else if (this.Type == LinearPointerType.Thermometer) { BarStyleAttrib thermometerStyleAttrib = this.GetThermometerStyleAttrib(g); try { if (thermometerStyleAttrib.totalPath != null) { g.FillPath(thermometerStyleAttrib.totalBrush, thermometerStyleAttrib.totalPath); } if (thermometerStyleAttrib.primaryPath != null) { g.FillPath(thermometerStyleAttrib.primaryBrush, thermometerStyleAttrib.primaryPath); } if (thermometerStyleAttrib.secondaryPaths != null) { int num2 = 0; GraphicsPath[] secondaryPaths2 = thermometerStyleAttrib.secondaryPaths; foreach (GraphicsPath graphicsPath2 in secondaryPaths2) { if (graphicsPath2 != null && thermometerStyleAttrib.secondaryBrushes[num2] != null) { g.FillPath(thermometerStyleAttrib.secondaryBrushes[num2], graphicsPath2); } num2++; } } if (base.BorderWidth > 0 && thermometerStyleAttrib.primaryBrush != null && base.BorderStyle != 0) { g.DrawPath(pen, thermometerStyleAttrib.totalPath); } } catch (Exception) { thermometerStyleAttrib.Dispose(); } if (thermometerStyleAttrib.primaryPath != null) { this.AddHotRegion(thermometerStyleAttrib.primaryPath, true); } } else { MarkerStyleAttrib markerStyleAttrib = this.GetMarkerStyleAttrib(g); try { if (markerStyleAttrib.path != null) { bool circularFill = (byte)((this.MarkerStyle == MarkerStyle.Circle) ? 1 : 0) != 0; g.FillPath(markerStyleAttrib.brush, markerStyleAttrib.path, 0f, true, circularFill); } if (base.BorderWidth > 0 && markerStyleAttrib.path != null && base.BorderStyle != 0) { g.DrawPath(pen, markerStyleAttrib.path); } } catch (Exception) { markerStyleAttrib.Dispose(); } if (markerStyleAttrib.path != null) { this.AddHotRegion(markerStyleAttrib.path, true); } } this.SetAllHotRegions(g); g.EndHotRegion(); this.Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceRenderingComplete(this.Name)); } } }
public override void Render(GaugeGraphics g) { if (this.Common != null && this.Visible && this.GetScale() != null) { g.StartHotRegion(this); this.GetScale().SetDrawRegion(g); if (this.Image != "" && this.CapImage != "") { this.DrawImage(g, true, false); this.DrawImage(g, false, false); this.SetAllHotRegions(g); g.RestoreDrawRegion(); g.EndHotRegion(); } else { if (this.Image != "") { this.DrawImage(g, true, false); } float positionFromValue = this.GetScale().GetPositionFromValue(base.Position); PointF absolutePoint = g.GetAbsolutePoint(this.GetScale().GetPivotPoint()); Pen pen = new Pen(base.BorderColor, (float)base.BorderWidth); pen.DashStyle = g.GetPenStyle(base.BorderStyle); if (pen.DashStyle != 0) { pen.Alignment = PenAlignment.Center; } KnobStyleAttrib knobStyleAttrib = this.GetKnobStyleAttrib(g, absolutePoint, positionFromValue); try { if (knobStyleAttrib.paths != null) { for (int i = 0; i < knobStyleAttrib.paths.Length; i++) { if (knobStyleAttrib.brushes[i] != null && knobStyleAttrib.paths[i] != null) { g.FillPath(knobStyleAttrib.brushes[i], knobStyleAttrib.paths[i]); } } if (base.BorderWidth > 0 && knobStyleAttrib.paths[0] != null) { g.DrawPath(pen, knobStyleAttrib.paths[0]); } if (knobStyleAttrib.paths[0] != null) { this.AddHotRegion((GraphicsPath)knobStyleAttrib.paths[0].Clone(), true); } } } finally { knobStyleAttrib.Dispose(); } if (this.CapImage != "") { this.DrawImage(g, false, false); } this.SetAllHotRegions(g); g.RestoreDrawRegion(); g.EndHotRegion(); } } }
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)); }
internal void RenderFrame(GaugeGraphics g) { if (Image.Length != 0) { Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceStartRenderingImageFrame); DrawFrameImage(g); Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceImageFrameRenderingComplete); } else { if (FrameStyle == BackFrameStyle.None) { return; } Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceStartRenderingFrame); ResetCachedXamlRenderer(); if (IsCustomXamlFrame()) { RenderShadow(g); XamlRenderer cachedXamlRenderer = GetCachedXamlRenderer(g); cachedXamlRenderer.Layers[0].Render(g); cachedXamlRenderer.Layers[1].Render(g); } else { RenderShadow(g); Brush brush = null; GraphicsPath graphicsPath = null; GraphicsPath graphicsPath2 = null; GraphicsPath graphicsPath3 = null; Brush brush2 = null; Brush brush3 = null; Pen pen = null; Pen pen2 = null; try { graphicsPath = GetFramePath(g, 0f); graphicsPath3 = GetFramePath(g, FrameWidth); brush = GetBrush(g, graphicsPath3.GetBounds(), backHatchStyle, BackGradientType, BackColor, BackGradientEndColor, frame: false, 0f); g.FillPath(brush, graphicsPath3, 0f, useBrushOffset: false, FrameShape == BackFrameShape.Circular); if (FrameStyle == BackFrameStyle.Simple) { using (GraphicsPath graphicsPath4 = new GraphicsPath()) { graphicsPath4.AddPath(graphicsPath, connect: false); graphicsPath4.AddPath(graphicsPath3, connect: false); graphicsPath4.CloseFigure(); brush2 = GetBrush(g, graphicsPath4.GetBounds(), FrameHatchStyle, FrameGradientType, FrameColor, FrameGradientEndColor, frame: true, frameWidth); pen = new Pen(brush, 2f); g.DrawPath(pen, graphicsPath3); g.FillPath(brush2, graphicsPath4, 0f, useBrushOffset: false, FrameShape == BackFrameShape.Circular); } } else if (FrameStyle == BackFrameStyle.Edged) { float num = FrameWidth * 0.7f; using (GraphicsPath addingPath = GetFramePath(g, num)) { using (GraphicsPath graphicsPath5 = new GraphicsPath()) { using (GraphicsPath graphicsPath6 = new GraphicsPath()) { graphicsPath5.AddPath(graphicsPath, connect: false); graphicsPath5.AddPath(addingPath, connect: false); graphicsPath6.AddPath(addingPath, connect: false); graphicsPath6.AddPath(graphicsPath3, connect: false); brush2 = GetBrush(g, graphicsPath5.GetBounds(), FrameHatchStyle, FrameGradientType, FrameColor, FrameGradientEndColor, frame: true, num); g.FillPath(brush2, graphicsPath5, 0f, useBrushOffset: false, FrameShape == BackFrameShape.Circular); brush3 = ((FrameGradientType != 0 || FrameHatchStyle != 0) ? GetBrush(g, graphicsPath6.GetBounds(), FrameHatchStyle, FrameGradientType, FrameGradientEndColor, FrameColor, frame: true, frameWidth - num) : GetBrush(g, graphicsPath6.GetBounds(), FrameHatchStyle, FrameGradientType, FrameColor, FrameColor, frame: true, frameWidth - num)); if (FrameWidth > 0f) { pen = new Pen(brush3, 2f); g.DrawPath(pen, graphicsPath6); } g.FillPath(brush3, graphicsPath6, 0f, useBrushOffset: false, FrameShape == BackFrameShape.Circular); } } } } if (BorderWidth > 0 && BorderStyle != 0) { pen2 = new Pen(BorderColor, BorderWidth); pen2.DashStyle = g.GetPenStyle(BorderStyle); pen2.Alignment = PenAlignment.Center; g.DrawPath(pen2, graphicsPath); } } finally { brush?.Dispose(); graphicsPath?.Dispose(); graphicsPath2?.Dispose(); brush2?.Dispose(); brush3?.Dispose(); pen?.Dispose(); pen2?.Dispose(); } } Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceFrameRenderingComplete); } }
internal void DrawFrameImage(GaugeGraphics g) { GraphicsPath graphicsPath = null; Pen pen = null; Region region = null; try { graphicsPath = GetFramePath(g, 0f); RectangleF frameRectangle = GetFrameRectangle(g); Region clip = null; if (ClipImage) { RenderShadow(g); region = new Region(graphicsPath); clip = g.Clip; g.Clip = region; } else if (ShadowOffset != 0f) { using (Brush brush = g.GetShadowBrush()) { RectangleF rect = frameRectangle; rect.Offset(ShadowOffset, ShadowOffset); g.FillRectangle(brush, rect); } } ImageAttributes imageAttributes = new ImageAttributes(); if (ImageTransColor != Color.Empty) { imageAttributes.SetColorKey(ImageTransColor, ImageTransColor, ColorAdjustType.Default); } Image image = Common.ImageLoader.LoadImage(Image); Rectangle destRect = new Rectangle((int)Math.Round(frameRectangle.X), (int)Math.Round(frameRectangle.Y), (int)Math.Round(frameRectangle.Width), (int)Math.Round(frameRectangle.Height)); if (!ImageHueColor.IsEmpty) { Color color = g.TransformHueColor(ImageHueColor); ColorMatrix colorMatrix = new ColorMatrix(); colorMatrix.Matrix00 = (float)(int)color.R / 255f; colorMatrix.Matrix11 = (float)(int)color.G / 255f; colorMatrix.Matrix22 = (float)(int)color.B / 255f; imageAttributes.SetColorMatrix(colorMatrix); } ImageSmoothingState imageSmoothingState = new ImageSmoothingState(g); imageSmoothingState.Set(); g.DrawImage(image, destRect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imageAttributes); imageSmoothingState.Restore(); if (ClipImage) { g.Clip = clip; } if (BorderWidth > 0 && BorderStyle != 0) { pen = new Pen(BorderColor, BorderWidth); pen.DashStyle = g.GetPenStyle(BorderStyle); pen.Alignment = PenAlignment.Center; if (ClipImage) { g.DrawPath(pen, graphicsPath); } else { g.DrawRectangle(pen, frameRectangle.X, frameRectangle.Y, frameRectangle.Width, frameRectangle.Height); } } } finally { graphicsPath?.Dispose(); pen?.Dispose(); region?.Dispose(); } }
internal override void Render(GaugeGraphics g) { if (Common == null || !Visible || GetScale() == null) { return; } g.StartHotRegion(this); GetScale().SetDrawRegion(g); if (Image != "" && CapImage != "") { DrawImage(g, primary: true, drawShadow: false); DrawImage(g, primary: false, drawShadow: false); SetAllHotRegions(g); g.RestoreDrawRegion(); g.EndHotRegion(); return; } if (Image != "") { DrawImage(g, primary: true, drawShadow: false); } float positionFromValue = GetScale().GetPositionFromValue(base.Position); PointF absolutePoint = g.GetAbsolutePoint(GetScale().GetPivotPoint()); Pen pen = new Pen(base.BorderColor, base.BorderWidth); pen.DashStyle = g.GetPenStyle(base.BorderStyle); if (pen.DashStyle != 0) { pen.Alignment = PenAlignment.Center; } KnobStyleAttrib knobStyleAttrib = GetKnobStyleAttrib(g, absolutePoint, positionFromValue); try { if (knobStyleAttrib.paths != null) { for (int i = 0; i < knobStyleAttrib.paths.Length; i++) { if (knobStyleAttrib.brushes[i] != null && knobStyleAttrib.paths[i] != null) { g.FillPath(knobStyleAttrib.brushes[i], knobStyleAttrib.paths[i]); } } if (base.BorderWidth > 0 && knobStyleAttrib.paths[0] != null) { g.DrawPath(pen, knobStyleAttrib.paths[0]); } if (knobStyleAttrib.paths[0] != null) { AddHotRegion((GraphicsPath)knobStyleAttrib.paths[0].Clone(), primary: true); } } } finally { knobStyleAttrib.Dispose(); } if (CapImage != "") { DrawImage(g, primary: false, drawShadow: false); } SetAllHotRegions(g); g.RestoreDrawRegion(); g.EndHotRegion(); }
public void RenderFrame(GaugeGraphics g) { if (this.Image.Length != 0) { this.Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceStartRenderingImageFrame); this.DrawFrameImage(g); this.Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceImageFrameRenderingComplete); } else if (this.FrameStyle != 0) { this.Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceStartRenderingFrame); this.ResetCachedXamlRenderer(); if (this.IsCustomXamlFrame()) { this.RenderShadow(g); XamlRenderer cachedXamlRenderer = this.GetCachedXamlRenderer(g); cachedXamlRenderer.Layers[0].Render(g); cachedXamlRenderer.Layers[1].Render(g); } else { this.RenderShadow(g); Brush brush = null; GraphicsPath graphicsPath = null; GraphicsPath graphicsPath2 = null; GraphicsPath graphicsPath3 = null; Brush brush2 = null; Brush brush3 = null; Pen pen = null; Pen pen2 = null; try { graphicsPath = this.GetFramePath(g, 0f); graphicsPath3 = this.GetFramePath(g, this.FrameWidth); brush = this.GetBrush(g, graphicsPath3.GetBounds(), this.backHatchStyle, this.BackGradientType, this.BackColor, this.BackGradientEndColor, false, 0f); g.FillPath(brush, graphicsPath3, 0f, false, this.FrameShape == BackFrameShape.Circular); if (this.FrameStyle == BackFrameStyle.Simple) { using (GraphicsPath graphicsPath4 = new GraphicsPath()) { graphicsPath4.AddPath(graphicsPath, false); graphicsPath4.AddPath(graphicsPath3, false); graphicsPath4.CloseFigure(); brush2 = this.GetBrush(g, graphicsPath4.GetBounds(), this.FrameHatchStyle, this.FrameGradientType, this.FrameColor, this.FrameGradientEndColor, true, this.frameWidth); pen = new Pen(brush, 2f); g.DrawPath(pen, graphicsPath3); g.FillPath(brush2, graphicsPath4, 0f, false, this.FrameShape == BackFrameShape.Circular); } } else if (this.FrameStyle == BackFrameStyle.Edged) { float num = (float)(this.FrameWidth * 0.699999988079071); using (GraphicsPath addingPath = this.GetFramePath(g, num)) { using (GraphicsPath graphicsPath5 = new GraphicsPath()) { using (GraphicsPath graphicsPath6 = new GraphicsPath()) { graphicsPath5.AddPath(graphicsPath, false); graphicsPath5.AddPath(addingPath, false); graphicsPath6.AddPath(addingPath, false); graphicsPath6.AddPath(graphicsPath3, false); brush2 = this.GetBrush(g, graphicsPath5.GetBounds(), this.FrameHatchStyle, this.FrameGradientType, this.FrameColor, this.FrameGradientEndColor, true, num); g.FillPath(brush2, graphicsPath5, 0f, false, this.FrameShape == BackFrameShape.Circular); brush3 = ((this.FrameGradientType != 0 || this.FrameHatchStyle != 0) ? this.GetBrush(g, graphicsPath6.GetBounds(), this.FrameHatchStyle, this.FrameGradientType, this.FrameGradientEndColor, this.FrameColor, true, this.frameWidth - num) : this.GetBrush(g, graphicsPath6.GetBounds(), this.FrameHatchStyle, this.FrameGradientType, this.FrameColor, this.FrameColor, true, this.frameWidth - num)); if (this.FrameWidth > 0.0) { pen = new Pen(brush3, 2f); g.DrawPath(pen, graphicsPath6); } g.FillPath(brush3, graphicsPath6, 0f, false, this.FrameShape == BackFrameShape.Circular); } } } } if (this.BorderWidth > 0 && this.BorderStyle != 0) { pen2 = new Pen(this.BorderColor, (float)this.BorderWidth); pen2.DashStyle = g.GetPenStyle(this.BorderStyle); pen2.Alignment = PenAlignment.Center; g.DrawPath(pen2, graphicsPath); } } finally { if (brush != null) { brush.Dispose(); } if (graphicsPath != null) { graphicsPath.Dispose(); } if (graphicsPath2 != null) { graphicsPath2.Dispose(); } if (brush2 != null) { brush2.Dispose(); } if (brush3 != null) { brush3.Dispose(); } if (pen != null) { pen.Dispose(); } if (pen2 != null) { pen2.Dispose(); } } } this.Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceFrameRenderingComplete); } }