internal override void DrawTickMark(GaugeGraphics g, CustomTickMark tickMark, double value, float offset) { float num = GetPositionFromValueNormalized(value); PointF absolutePoint = g.GetAbsolutePoint(GetPoint(num, offset)); using (Matrix matrix = new Matrix()) { matrix.RotateAt(num, absolutePoint); if (tickMark.Placement == Placement.Inside) { matrix.RotateAt(180f, absolutePoint); } DrawTickMark(g, tickMark, value, offset, matrix); } }
public GraphicsPath GetPointerPath(GaugeGraphics g) { if (!this.Visible) { return(null); } GraphicsPath graphicsPath = new GraphicsPath(); float positionFromValue = this.GetScale().GetPositionFromValue(base.Position); PointF absolutePoint = g.GetAbsolutePoint(this.GetScale().GetPivotPoint()); KnobStyleAttrib knobStyleAttrib = this.GetKnobStyleAttrib(g, absolutePoint, positionFromValue); if (knobStyleAttrib.paths != null && knobStyleAttrib.paths[0] != null) { graphicsPath.AddPath(knobStyleAttrib.paths[0], false); } return(graphicsPath); }
public override void RenderStaticElements(GaugeGraphics g) { if (base.Visible) { g.StartHotRegion(this); base.BackFrame.RenderFrame(g); GraphicsState gstate = g.Save(); if (base.ClipContent && base.BackFrame.FrameStyle != 0 && base.BackFrame.Image == string.Empty) { GraphicsPath graphicsPath = null; try { graphicsPath = base.BackFrame.GetBackPath(g); g.SetClip(graphicsPath, CombineMode.Intersect); } finally { if (graphicsPath != null) { graphicsPath.Dispose(); } } } this.Common.GaugeCore.HotRegionList.SetHotRegion(this, g.GetAbsolutePoint(this.PivotPoint.ToPoint()), base.BackFrame.GetFramePath(g, 0f)); g.EndHotRegion(); g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f)); this.RenderStaticShadows(g); foreach (CircularRange range in this.Ranges) { range.Render(g); } foreach (CircularScale scale in this.Scales) { scale.RenderStaticElements(g); } foreach (CircularPointer pointer in this.Pointers) { pointer.ResetCachedXamlRenderer(); } if (base.ClipContent && base.BackFrame.FrameStyle != 0 && base.BackFrame.Image == string.Empty) { g.Restore(gstate); } } }
internal override void DrawTickMark(GaugeGraphics g, CustomTickMark tickMark, double value, float offset) { float num = GetPositionFromValue(value); PointF absolutePoint = g.GetAbsolutePoint(GetPoint(num, offset)); using (Matrix matrix = new Matrix()) { if (ParentGauge.GetOrientation() == GaugeOrientation.Vertical) { matrix.RotateAt(90f, absolutePoint); } if (tickMark.Placement == Placement.Outside) { matrix.RotateAt(180f, absolutePoint); } DrawTickMark(g, tickMark, value, offset, matrix); } }
internal MarkerStyleAttrib GetMarkerStyleAttrib(GaugeGraphics g) { MarkerStyleAttrib markerStyleAttrib = new MarkerStyleAttrib(); float absoluteDimension = g.GetAbsoluteDimension(MarkerLength); float absoluteDimension2 = g.GetAbsoluteDimension(Width); markerStyleAttrib.path = g.CreateMarker(new PointF(0f, 0f), absoluteDimension2, absoluteDimension, MarkerStyle); float num = 0f; if (Placement == Placement.Cross || Placement == Placement.Inside) { num += 180f; } if (GetGauge().GetOrientation() == GaugeOrientation.Vertical) { num += 270f; } if (num > 0f) { using (Matrix matrix = new Matrix()) { matrix.Rotate(num); markerStyleAttrib.path.Transform(matrix); } } float num2 = CalculateMarkerDistance(); LinearScale scale = GetScale(); float positionFromValue = scale.GetPositionFromValue(scale.GetValueLimit(base.Position)); PointF pointF = Point.Empty; pointF = ((GetGauge().GetOrientation() != 0) ? g.GetAbsolutePoint(new PointF(num2, positionFromValue)) : g.GetAbsolutePoint(new PointF(positionFromValue, num2))); markerStyleAttrib.brush = g.GetMarkerBrush(markerStyleAttrib.path, MarkerStyle, pointF, 0f, FillColor, FillGradientType, FillGradientEndColor, FillHatchStyle); using (Matrix matrix2 = new Matrix()) { matrix2.Translate(pointF.X, pointF.Y, MatrixOrder.Append); markerStyleAttrib.path.Transform(matrix2); return(markerStyleAttrib); } }
public MarkerStyleAttrib GetMarkerStyleAttrib(GaugeGraphics g) { MarkerStyleAttrib markerStyleAttrib = new MarkerStyleAttrib(); float absoluteDimension = g.GetAbsoluteDimension(this.MarkerLength); float absoluteDimension2 = g.GetAbsoluteDimension(this.Width); markerStyleAttrib.path = g.CreateMarker(new PointF(0f, 0f), absoluteDimension2, absoluteDimension, this.MarkerStyle); float num = 0f; if (this.Placement == Placement.Cross || this.Placement == Placement.Inside) { num = (float)(num + 180.0); } if (this.GetGauge().GetOrientation() == GaugeOrientation.Vertical) { num = (float)(num + 270.0); } if (num > 0.0) { using (Matrix matrix = new Matrix()) { matrix.Rotate(num); markerStyleAttrib.path.Transform(matrix); } } float num2 = this.CalculateMarkerDistance(); ScaleBase scale = this.GetScale(); float positionFromValue = scale.GetPositionFromValue(scale.GetValueLimit(base.Position)); PointF pointOrigin = Point.Empty; pointOrigin = ((this.GetGauge().GetOrientation() != 0) ? g.GetAbsolutePoint(new PointF(num2, positionFromValue)) : g.GetAbsolutePoint(new PointF(positionFromValue, num2))); markerStyleAttrib.brush = g.GetMarkerBrush(markerStyleAttrib.path, this.MarkerStyle, pointOrigin, 0f, this.FillColor, this.FillGradientType, this.FillGradientEndColor, this.FillHatchStyle); using (Matrix matrix2 = new Matrix()) { matrix2.Translate(pointOrigin.X, pointOrigin.Y, MatrixOrder.Append); markerStyleAttrib.path.Transform(matrix2); return(markerStyleAttrib); } }
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(); }
internal void DrawImage(GaugeGraphics g, bool drawShadow) { if (!Visible || (drawShadow && base.ShadowOffset == 0f)) { return; } Image image = Common.ImageLoader.LoadImage(Image); if (image.Width == 0 || image.Height == 0) { return; } Point point = new Point(ImageOrigin.X, ImageOrigin.Y); if (point.X == 0) { point.X = image.Width / 2; } if (point.Y == 0) { point.Y = image.Height / 2; } float absoluteDimension = g.GetAbsoluteDimension(Width); float absoluteDimension2 = g.GetAbsoluteDimension(MarkerLength); float num = absoluteDimension / (float)image.Width; float num2 = absoluteDimension2 / (float)image.Height; float num3 = CalculateMarkerDistance(); float positionFromValue = GetScale().GetPositionFromValue(base.Position); PointF pointF = Point.Empty; pointF = ((GetGauge().GetOrientation() != 0) ? g.GetAbsolutePoint(new PointF(num3, positionFromValue)) : g.GetAbsolutePoint(new PointF(positionFromValue, num3))); Matrix transform = g.Transform; Matrix matrix = g.Transform.Clone(); Rectangle rectangle = new Rectangle((int)(pointF.X - (float)point.X * num) + 1, (int)(pointF.Y - (float)point.Y * num2) + 1, (int)((float)image.Width * num) + 1, (int)((float)image.Height * num2) + 1); ImageAttributes imageAttributes = new ImageAttributes(); if (ImageTransColor != Color.Empty) { imageAttributes.SetColorKey(ImageTransColor, ImageTransColor, ColorAdjustType.Default); } if (drawShadow) { ColorMatrix colorMatrix = new ColorMatrix(); colorMatrix.Matrix00 = 0f; colorMatrix.Matrix11 = 0f; colorMatrix.Matrix22 = 0f; colorMatrix.Matrix33 = Common.GaugeCore.ShadowIntensity / 100f; imageAttributes.SetColorMatrix(colorMatrix); matrix.Translate(base.ShadowOffset, base.ShadowOffset, MatrixOrder.Append); } else { ColorMatrix colorMatrix2 = new ColorMatrix(); if (!ImageHueColor.IsEmpty) { Color color = g.TransformHueColor(ImageHueColor); colorMatrix2.Matrix00 = (float)(int)color.R / 255f; colorMatrix2.Matrix11 = (float)(int)color.G / 255f; colorMatrix2.Matrix22 = (float)(int)color.B / 255f; } colorMatrix2.Matrix33 = 1f - ImageTransparency / 100f; imageAttributes.SetColorMatrix(colorMatrix2); } g.Transform = matrix; g.DrawImage(image, rectangle, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imageAttributes); g.Transform = transform; if (!drawShadow) { GraphicsPath graphicsPath = new GraphicsPath(); graphicsPath.AddRectangle(rectangle); AddHotRegion(graphicsPath, primary: true); } }
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 void DrawImage(GaugeGraphics g, string imageName, bool drawShadow) { if (drawShadow && this.ShadowOffset == 0.0) { return; } Image image = this.Common.ImageLoader.LoadImage(imageName); if (image.Width != 0 && image.Height != 0) { RectangleF absoluteRectangle = g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f)); Rectangle rectangle = Rectangle.Empty; if (this.ResizeMode == ResizeMode.AutoFit) { rectangle = new Rectangle((int)absoluteRectangle.X, (int)absoluteRectangle.Y, (int)absoluteRectangle.Width, (int)absoluteRectangle.Height); } else { rectangle = new Rectangle(0, 0, image.Width, image.Height); PointF absolutePoint = g.GetAbsolutePoint(new PointF(50f, 50f)); rectangle.X = (int)(absolutePoint.X - (float)(rectangle.Size.Width / 2)); rectangle.Y = (int)(absolutePoint.Y - (float)(rectangle.Size.Height / 2)); } ImageAttributes imageAttributes = new ImageAttributes(); if (this.ImageTransColor != Color.Empty) { imageAttributes.SetColorKey(this.ImageTransColor, this.ImageTransColor, ColorAdjustType.Default); } float num = (float)((100.0 - this.Transparency) / 100.0); float num2 = (float)(this.Common.GaugeCore.ShadowIntensity / 100.0); if (drawShadow) { ColorMatrix colorMatrix = new ColorMatrix(); colorMatrix.Matrix00 = 0f; colorMatrix.Matrix11 = 0f; colorMatrix.Matrix22 = 0f; colorMatrix.Matrix33 = num2 * num; imageAttributes.SetColorMatrix(colorMatrix); } else if (this.Transparency > 0.0) { ColorMatrix colorMatrix2 = new ColorMatrix(); colorMatrix2.Matrix33 = num; imageAttributes.SetColorMatrix(colorMatrix2); } if (this.Angle != 0.0) { PointF point = new PointF((float)(absoluteRectangle.X + absoluteRectangle.Width / 2.0), (float)(absoluteRectangle.Y + absoluteRectangle.Height / 2.0)); Matrix transform = g.Transform; Matrix matrix = g.Transform.Clone(); float offsetX = matrix.OffsetX; float offsetY = matrix.OffsetY; point.X += offsetX; point.Y += offsetY; matrix.RotateAt(this.Angle, point, MatrixOrder.Append); if (drawShadow) { matrix.Translate(this.ShadowOffset, this.ShadowOffset, MatrixOrder.Append); } g.Transform = matrix; ImageSmoothingState imageSmoothingState = new ImageSmoothingState(g); imageSmoothingState.Set(); g.DrawImage(image, rectangle, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imageAttributes); imageSmoothingState.Restore(); g.Transform = transform; } else { if (drawShadow) { rectangle.X += (int)this.ShadowOffset; rectangle.Y += (int)this.ShadowOffset; } ImageSmoothingState imageSmoothingState2 = new ImageSmoothingState(g); imageSmoothingState2.Set(); g.DrawImage(image, rectangle, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imageAttributes); imageSmoothingState2.Restore(); } if (!drawShadow) { GraphicsPath graphicsPath = new GraphicsPath(); graphicsPath.AddRectangle(rectangle); if (this.Angle != 0.0) { PointF point2 = new PointF((float)(absoluteRectangle.X + absoluteRectangle.Width / 2.0), (float)(absoluteRectangle.Y + absoluteRectangle.Height / 2.0)); using (Matrix matrix2 = new Matrix()) { matrix2.RotateAt(this.Angle, point2, MatrixOrder.Append); graphicsPath.Transform(matrix2); } } this.Common.GaugeCore.HotRegionList.SetHotRegion(this, Point.Empty, graphicsPath); } } }
private void BuildCircularGaugeAutoFrame(GaugeGraphics g, GraphicsPath path, CircularGauge gauge, float shrinkBy) { float startAngle = gauge.Scales[0].StartAngle; float num = gauge.Scales[0].StartAngle + gauge.Scales[0].SweepAngle; float radius = gauge.Scales[0].Radius; float num2 = gauge.Scales[0].GetLargestRadius(g); if (gauge.Scales.Count > 1) { for (int i = 1; i < gauge.Scales.Count; i++) { if (startAngle > gauge.Scales[i].StartAngle) { startAngle = gauge.Scales[i].StartAngle; } if (num < gauge.Scales[i].StartAngle + gauge.Scales[i].SweepAngle) { num = gauge.Scales[i].StartAngle + gauge.Scales[i].SweepAngle; } if (radius < gauge.Scales[i].Radius) { radius = gauge.Scales[i].Radius; } float largestRadius = gauge.Scales[i].GetLargestRadius(g); if (num2 < largestRadius) { num2 = largestRadius; } } } float num3 = 0f; foreach (CircularPointer pointer in gauge.Pointers) { if (pointer.Visible && pointer.Type == CircularPointerType.Needle) { float num4 = pointer.CapWidth / 2f * pointer.GetScale().Radius / 100f; if (pointer.CapVisible && num4 > num3) { num3 = num4; } float num5 = pointer.GetNeedleTailLength() * pointer.GetScale().Radius / 100f; if (num5 > num3) { num3 = num5; } } } foreach (Knob knob in gauge.Knobs) { if (knob.Visible) { float num6 = knob.Width * knob.GetScale().Radius / 100f; if (num6 > num3) { num3 = num6; } } } num3 = g.GetAbsoluteDimension(num3); float absoluteDimension = g.GetAbsoluteDimension(radius / 5f); float absoluteDimension2 = g.GetAbsoluteDimension(FrameWidth * radius / 100f); float absoluteDimension3 = g.GetAbsoluteDimension(shrinkBy * radius / 100f); absoluteDimension += absoluteDimension2; absoluteDimension -= absoluteDimension3; float num7 = num - startAngle; PointF absolutePoint = g.GetAbsolutePoint(gauge.PivotPoint); float absoluteDimension4 = g.GetAbsoluteDimension(num2); float num8 = startAngle * (float)Math.PI / 180f; float num9 = (360f - startAngle - num7) * (float)Math.PI / 180f; PointF pointF = default(PointF); pointF.X = absolutePoint.X - absoluteDimension4 * (float)Math.Sin(num8); pointF.Y = absolutePoint.Y + absoluteDimension4 * (float)Math.Cos(num8); PointF pointF2 = default(PointF); pointF2.X = absolutePoint.X + absoluteDimension4 * (float)Math.Sin(num9); pointF2.Y = absolutePoint.Y + absoluteDimension4 * (float)Math.Cos(num9); RectangleF rect = new RectangleF(pointF.X, pointF.Y, 0f, 0f); rect.Inflate(absoluteDimension, absoluteDimension); RectangleF rect2 = new RectangleF(pointF2.X, pointF2.Y, 0f, 0f); rect2.Inflate(absoluteDimension, absoluteDimension); RectangleF rect3 = new RectangleF(absolutePoint.X, absolutePoint.Y, 0f, 0f); rect3.Inflate(absoluteDimension + num3, absoluteDimension + num3); RectangleF rect4 = new RectangleF(absolutePoint.X, absolutePoint.Y, 0f, 0f); rect4.Inflate(absoluteDimension4 + absoluteDimension, absoluteDimension4 + absoluteDimension); if (num7 < 270f) { path.AddArc(rect, startAngle + 270f + 90f, 90f); path.AddArc(rect4, startAngle + 90f, num7); path.AddArc(rect2, startAngle + num7 + 90f, 90f); path.AddArc(rect3, startAngle + num7 + 90f + 45f, 360f - num7 - 90f); } else if (num7 >= 320f) { path.AddEllipse(rect4); } else { float num10 = 90f - (360f - num7) / 2f; path.AddArc(rect, startAngle + 270f + 90f + num10, 90f - num10); path.AddArc(rect4, startAngle + 90f, num7); path.AddArc(rect2, startAngle + num7 + 90f, 90f - num10); } path.CloseFigure(); }
private void DrawLabel(Placement placement, string labelStr, double position, float labelPos, float rotateLabelAngle, Font font, Color color, bool rotateLabels, bool allowUpsideDown, FontUnit fontUnit) { float num = GetPositionFromValueNormalized(position); if (rotateLabels) { rotateLabelAngle += num + 180f; rotateLabelAngle %= 360f; if (!allowUpsideDown && rotateLabelAngle > 90f && rotateLabelAngle < 270f) { rotateLabelAngle += 180f; rotateLabelAngle %= 360f; } } MarkerPosition markerPosition = new MarkerPosition((float)Math.Round(num), position, placement); if (MarkerPosition.IsExistsInArray(labels, markerPosition)) { return; } if (labelStr.Length > 0) { labels.Add(markerPosition); } GaugeGraphics graph = Common.Graph; StringFormat stringFormat = new StringFormat(); stringFormat.Alignment = StringAlignment.Center; stringFormat.LineAlignment = StringAlignment.Center; using (Brush brush2 = new SolidBrush(color)) { Font resizedFont = GetResizedFont(font, fontUnit); try { SizeF relativeSize = graph.GetRelativeSize(graph.MeasureString(labelStr, resizedFont)); relativeSize.Height -= relativeSize.Height / 8f; float contactPointOffset = Utils.GetContactPointOffset(relativeSize, num - rotateLabelAngle); float offset = labelPos; switch (placement) { case Placement.Inside: offset = labelPos - Math.Max(0f, contactPointOffset); break; case Placement.Outside: offset = labelPos + Math.Max(0f, contactPointOffset); break; } PointF absolutePoint = graph.GetAbsolutePoint(GetPoint(num, offset)); relativeSize = graph.GetAbsoluteSize(relativeSize); RectangleF layoutRectangle = new RectangleF(absolutePoint, new SizeF(0f, 0f)); layoutRectangle.Inflate(relativeSize.Width / 2f, relativeSize.Height / 2f); Matrix transform = graph.Transform; Matrix matrix = graph.Transform.Clone(); try { TextRenderingHint textRenderingHint = graph.TextRenderingHint; try { if (textRenderingHint == TextRenderingHint.ClearTypeGridFit) { graph.TextRenderingHint = TextRenderingHint.AntiAlias; } if (base.ShadowOffset != 0f) { using (Brush brush = graph.GetShadowBrush()) { using (Matrix matrix2 = matrix.Clone()) { matrix2.Translate(base.ShadowOffset, base.ShadowOffset); matrix2.RotateAt(rotateLabelAngle, absolutePoint); graph.Transform = matrix2; graph.DrawString(labelStr, resizedFont, brush, layoutRectangle, stringFormat); } } } matrix.RotateAt(rotateLabelAngle, absolutePoint); graph.Transform = matrix; graph.DrawString(labelStr, resizedFont, brush2, layoutRectangle, stringFormat); } finally { graph.TextRenderingHint = textRenderingHint; } } finally { matrix.Dispose(); graph.Transform = transform; } } finally { if (resizedFont != font) { resizedFont.Dispose(); } } } }
public void SetAllHotRegions(GaugeGraphics g) { this.Common.GaugeCore.HotRegionList.SetHotRegion(this, g.GetAbsolutePoint(this.GetScale().GetPivotPoint()), this.hotRegions[0], this.hotRegions[1]); this.hotRegions[0] = null; this.hotRegions[1] = null; }
private void SetScaleHitTestPath(GaugeGraphics g) { Gap gap = new Gap(GetRadius()); gap.SetOffset(Placement.Cross, Width); gap.SetBase(); if (MajorTickMark.Visible) { gap.SetOffsetBase(MajorTickMark.Placement, MajorTickMark.Length); if (MajorTickMark.Placement == Placement.Outside) { gap.Outside = Math.Max(gap.Outside, MajorTickMark.DistanceFromScale + MajorTickMark.Length + Width / 2f); gap.Inside = Math.Max(gap.Inside, 0f - MajorTickMark.DistanceFromScale); } else if (MajorTickMark.Placement == Placement.Cross) { gap.Outside = Math.Max(gap.Outside, 0f - MajorTickMark.DistanceFromScale + MajorTickMark.Length / 2f); gap.Inside = Math.Max(gap.Inside, MajorTickMark.DistanceFromScale + MajorTickMark.Length / 2f); } else { gap.Outside = Math.Max(gap.Outside, 0f - MajorTickMark.DistanceFromScale); gap.Inside = Math.Max(gap.Inside, MajorTickMark.DistanceFromScale + MajorTickMark.Length + Width / 2f); } } if (MinorTickMark.Visible) { gap.SetOffsetBase(MinorTickMark.Placement, MinorTickMark.Length); if (MinorTickMark.Placement == Placement.Outside) { gap.Outside = Math.Max(gap.Outside, MinorTickMark.DistanceFromScale + MinorTickMark.Length + Width / 2f); gap.Inside = Math.Max(gap.Inside, 0f - MinorTickMark.DistanceFromScale); } else if (MinorTickMark.Placement == Placement.Cross) { gap.Outside = Math.Max(gap.Outside, 0f - MinorTickMark.DistanceFromScale + MinorTickMark.Length / 2f); gap.Inside = Math.Max(gap.Inside, MinorTickMark.DistanceFromScale + MinorTickMark.Length / 2f); } else { gap.Outside = Math.Max(gap.Outside, 0f - MinorTickMark.DistanceFromScale); gap.Inside = Math.Max(gap.Inside, MinorTickMark.DistanceFromScale + MinorTickMark.Length + Width / 2f); } } if (LabelStyle.Visible) { if (LabelStyle.Placement == Placement.Outside) { gap.Outside = Math.Max(gap.Outside, LabelStyle.DistanceFromScale + (float)LabelStyle.Font.Height + Width / 2f); gap.Inside = Math.Max(gap.Inside, 0f - LabelStyle.DistanceFromScale); } else if (LabelStyle.Placement == Placement.Cross) { gap.Outside = Math.Max(gap.Outside, 0f - LabelStyle.DistanceFromScale + (float)LabelStyle.Font.Height / 2f); gap.Inside = Math.Max(gap.Inside, LabelStyle.DistanceFromScale + (float)LabelStyle.Font.Height / 2f); } else { gap.Outside = Math.Max(gap.Outside, 0f - LabelStyle.DistanceFromScale); gap.Inside = Math.Max(gap.Inside, LabelStyle.DistanceFromScale + (float)LabelStyle.Font.Height + Width / 2f); } } GraphicsPath barPath = GetBarPath(gap.Inside, gap.Outside, 0f); Common.GaugeCore.HotRegionList.SetHotRegion(this, g.GetAbsolutePoint(GetPivotPoint()), barPath); }
internal void SetAllHotRegions(GaugeGraphics g) { Common.GaugeCore.HotRegionList.SetHotRegion(this, g.GetAbsolutePoint(GetScale().GetPivotPoint()), hotRegions[0], hotRegions[1]); hotRegions[0] = null; hotRegions[1] = null; }
public void DrawImage(GaugeGraphics g, bool primary, bool drawShadow) { if (this.Visible) { if (drawShadow && base.ShadowOffset == 0.0) { return; } float width = this.Width; width = g.GetAbsoluteDimension(width); Image image = null; image = ((!primary) ? this.Common.ImageLoader.LoadImage(this.CapImage) : this.Common.ImageLoader.LoadImage(this.Image)); if (image.Width != 0 && image.Height != 0) { Point point = Point.Empty; point = ((!primary) ? this.CapImageOrigin : this.ImageOrigin); if (point.IsEmpty) { point.X = image.Width / 2; point.Y = image.Height / 2; } int num = (image.Height <= image.Width) ? image.Width : image.Height; if (num != 0) { float num2 = (!primary) ? (g.GetAbsoluteDimension((float)(this.CapWidth * 2.0)) / (float)num) : (g.GetAbsoluteDimension((float)(this.Width * 2.0)) / (float)num); Rectangle rectangle = new Rectangle(0, 0, (int)((float)image.Width * num2), (int)((float)image.Height * num2)); ImageAttributes imageAttributes = new ImageAttributes(); if (primary && this.ImageTransColor != Color.Empty) { imageAttributes.SetColorKey(this.ImageTransColor, this.ImageTransColor, ColorAdjustType.Default); } if (!primary && this.CapImageTransColor != Color.Empty) { imageAttributes.SetColorKey(this.CapImageTransColor, this.CapImageTransColor, ColorAdjustType.Default); } Matrix transform = g.Transform; Matrix matrix = g.Transform.Clone(); float positionFromValue = this.GetScale().GetPositionFromValue(base.Position); PointF absolutePoint = g.GetAbsolutePoint(this.GetScale().GetPivotPoint()); PointF pointF = new PointF((float)point.X * num2, (float)point.Y * num2); float offsetX = matrix.OffsetX; float offsetY = matrix.OffsetY; matrix.Translate(absolutePoint.X - pointF.X, absolutePoint.Y - pointF.Y, MatrixOrder.Append); absolutePoint.X += offsetX; absolutePoint.Y += offsetY; matrix.RotateAt(positionFromValue, absolutePoint, MatrixOrder.Append); if (drawShadow) { ColorMatrix colorMatrix = new ColorMatrix(); colorMatrix.Matrix00 = 0f; colorMatrix.Matrix11 = 0f; colorMatrix.Matrix22 = 0f; colorMatrix.Matrix33 = (float)(this.Common.GaugeCore.ShadowIntensity / 100.0); imageAttributes.SetColorMatrix(colorMatrix); matrix.Translate(base.ShadowOffset, base.ShadowOffset, MatrixOrder.Append); } else if (primary && !this.ImageHueColor.IsEmpty) { Color color = g.TransformHueColor(this.ImageHueColor); ColorMatrix colorMatrix2 = new ColorMatrix(); colorMatrix2.Matrix00 = (float)((float)(int)color.R / 255.0); colorMatrix2.Matrix11 = (float)((float)(int)color.G / 255.0); colorMatrix2.Matrix22 = (float)((float)(int)color.B / 255.0); imageAttributes.SetColorMatrix(colorMatrix2); } else if (!primary && !this.CapImageHueColor.IsEmpty) { Color color2 = g.TransformHueColor(this.CapImageHueColor); ColorMatrix colorMatrix3 = new ColorMatrix(); colorMatrix3.Matrix00 = (float)((float)(int)color2.R / 255.0); colorMatrix3.Matrix11 = (float)((float)(int)color2.G / 255.0); colorMatrix3.Matrix22 = (float)((float)(int)color2.B / 255.0); imageAttributes.SetColorMatrix(colorMatrix3); } g.Transform = matrix; ImageSmoothingState imageSmoothingState = new ImageSmoothingState(g); imageSmoothingState.Set(); g.DrawImage(image, rectangle, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imageAttributes); imageSmoothingState.Restore(); g.Transform = transform; if (!drawShadow) { matrix.Translate((float)(0.0 - offsetX), (float)(0.0 - offsetY), MatrixOrder.Append); GraphicsPath graphicsPath = new GraphicsPath(); graphicsPath.AddRectangle(rectangle); graphicsPath.Transform(matrix); this.AddHotRegion(graphicsPath, primary); } } } } }
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)); }
private void DrawLabel(Placement placement, string labelStr, double value, float labelPos, float rotateLabelAngle, Font font, Color color, FontUnit fontUnit) { StringFormat stringFormat = new StringFormat(); stringFormat.Alignment = StringAlignment.Center; stringFormat.LineAlignment = StringAlignment.Near; float num = GetPositionFromValue(value); MarkerPosition markerPosition = new MarkerPosition((float)Math.Round(num), value, placement); if (MarkerPosition.IsExistsInArray(labels, markerPosition)) { return; } if (labelStr.Length > 0) { labels.Add(markerPosition); } GaugeGraphics graph = Common.Graph; using (Brush brush2 = new SolidBrush(color)) { Font resizedFont = GetResizedFont(font, fontUnit); try { float num2 = 0f; if (ParentGauge.GetOrientation() == GaugeOrientation.Vertical) { num2 = 90f; } SizeF size = graph.MeasureString(labelStr, resizedFont); float contactPointOffset = Utils.GetContactPointOffset(size, rotateLabelAngle - num2); PointF absolutePoint = graph.GetAbsolutePoint(GetPoint(num, labelPos)); switch (placement) { case Placement.Inside: if (ParentGauge.GetOrientation() == GaugeOrientation.Vertical) { absolutePoint.X -= contactPointOffset; } else { absolutePoint.Y -= contactPointOffset; } break; case Placement.Outside: if (ParentGauge.GetOrientation() == GaugeOrientation.Vertical) { absolutePoint.X += contactPointOffset; } else { absolutePoint.Y += contactPointOffset; } break; } RectangleF rectangleF = new RectangleF(absolutePoint, new SizeF(0f, 0f)); rectangleF.Inflate(size.Width / 2f, size.Height / 2f); Matrix transform = graph.Transform; Matrix matrix = graph.Transform.Clone(); try { if (rotateLabelAngle == 0f) { if (base.ShadowOffset != 0f) { using (Brush brush = graph.GetShadowBrush()) { RectangleF layoutRectangle = rectangleF; layoutRectangle.Offset(base.ShadowOffset, base.ShadowOffset); graph.DrawString(labelStr, resizedFont, brush, layoutRectangle, stringFormat); } } graph.DrawString(labelStr, resizedFont, brush2, rectangleF, stringFormat); return; } TextRenderingHint textRenderingHint = graph.TextRenderingHint; try { if (textRenderingHint == TextRenderingHint.ClearTypeGridFit) { graph.TextRenderingHint = TextRenderingHint.AntiAlias; } if (base.ShadowOffset != 0f) { using (Brush brush3 = graph.GetShadowBrush()) { using (Matrix matrix2 = matrix.Clone()) { matrix2.Translate(base.ShadowOffset, base.ShadowOffset); matrix2.RotateAt(rotateLabelAngle, absolutePoint); graph.Transform = matrix2; graph.DrawString(labelStr, resizedFont, brush3, rectangleF, stringFormat); } } } matrix.RotateAt(rotateLabelAngle, absolutePoint); graph.Transform = matrix; graph.DrawString(labelStr, resizedFont, brush2, rectangleF, stringFormat); } finally { graph.TextRenderingHint = textRenderingHint; } } finally { matrix.Dispose(); graph.Transform = transform; } } finally { if (resizedFont != font) { resizedFont.Dispose(); } } } }