internal void RenderStaticShadows(GaugeGraphics g) { using (GraphicsPath graphicsPath = new GraphicsPath()) { foreach (CircularRange range in Ranges) { GraphicsPath path = range.GetPath(g, getShadowPath: true); if (path != null) { graphicsPath.AddPath(path, connect: false); } } foreach (CircularScale scale in Scales) { GraphicsPath shadowPath = scale.GetShadowPath(g); if (shadowPath != null) { graphicsPath.AddPath(shadowPath, connect: false); } } graphicsPath.FillMode = FillMode.Winding; using (Brush brush = g.GetShadowBrush()) { g.FillPath(brush, graphicsPath); } } }
public void RenderStaticShadows(GaugeGraphics g) { using (GraphicsPath graphicsPath = new GraphicsPath()) { foreach (LinearRange range in this.Ranges) { GraphicsPath path = range.GetPath(g, true); if (path != null) { graphicsPath.AddPath(path, false); } } foreach (LinearScale scale in this.Scales) { GraphicsPath shadowPath = scale.GetShadowPath(); if (shadowPath != null) { graphicsPath.AddPath(shadowPath, false); } } graphicsPath.FillMode = FillMode.Winding; using (Brush brush = g.GetShadowBrush()) { g.FillPath(brush, graphicsPath); } } }
public void RenderDynamicShadows(GaugeGraphics g) { using (GraphicsPath graphicsPath = new GraphicsPath()) { foreach (Knob knob in this.Knobs) { GraphicsPath shadowPath = knob.GetShadowPath(g); if (shadowPath != null) { graphicsPath.AddPath(shadowPath, false); } } foreach (CircularPointer pointer in this.Pointers) { GraphicsPath shadowPath2 = pointer.GetShadowPath(g); if (shadowPath2 != null) { graphicsPath.AddPath(shadowPath2, false); } } graphicsPath.FillMode = FillMode.Winding; using (Brush brush = g.GetShadowBrush()) { g.FillPath(brush, graphicsPath); } } }
public void RenderShadow(GaugeGraphics g) { if (this.ShadowOffset != 0.0) { using (GraphicsPath path = this.GetShadowPath(g)) { using (Brush brush = g.GetShadowBrush()) { g.FillPath(brush, path); } } } }
internal void RenderShadow(GaugeGraphics g) { if (ShadowOffset == 0f) { return; } using (GraphicsPath path = GetShadowPath(g)) { using (Brush brush = g.GetShadowBrush()) { g.FillPath(brush, path); } } }
internal void RenderDynamicShadows(GaugeGraphics g) { using (GraphicsPath graphicsPath = new GraphicsPath()) { foreach (LinearPointer pointer in Pointers) { GraphicsPath shadowPath = pointer.GetShadowPath(g); if (shadowPath != null) { graphicsPath.AddPath(shadowPath, connect: false); } } graphicsPath.FillMode = FillMode.Winding; using (Brush brush = g.GetShadowBrush()) { g.FillPath(brush, graphicsPath); } } }
void IRenderable.RenderDynamicElements(GaugeGraphics g) { if (this.Visible) { g.StartHotRegion(this); GraphicsPath graphicsPath = null; GraphicsPath graphicsPath2 = null; Brush brush = null; Brush brush2 = null; Brush brush3 = null; Pen pen = null; try { graphicsPath = this.GetBackPath(g); graphicsPath2 = this.GetTextPath(g); if (graphicsPath != null) { if (this.BackShadowOffset != 0) { using (Matrix matrix = new Matrix()) { brush3 = g.GetShadowBrush(); matrix.Translate((float)this.BackShadowOffset, (float)this.BackShadowOffset, MatrixOrder.Append); graphicsPath.Transform(matrix); g.FillPath(brush3, graphicsPath); matrix.Reset(); matrix.Translate((float)(-this.BackShadowOffset), (float)(-this.BackShadowOffset), MatrixOrder.Append); graphicsPath.Transform(matrix); } } brush2 = this.GetBackBrush(g); g.FillPath(brush2, graphicsPath); pen = this.GetPen(g); if (pen != null) { g.DrawPath(pen, graphicsPath); } this.Common.GaugeCore.HotRegionList.SetHotRegion(this, Point.Empty, (GraphicsPath)graphicsPath.Clone()); } if (graphicsPath2 != null) { if (this.TextShadowOffset != 0) { using (Matrix matrix2 = new Matrix()) { brush3 = g.GetShadowBrush(); matrix2.Translate((float)this.TextShadowOffset, (float)this.TextShadowOffset, MatrixOrder.Append); graphicsPath2.Transform(matrix2); g.FillPath(brush3, graphicsPath2); matrix2.Reset(); matrix2.Translate((float)(-this.TextShadowOffset), (float)(-this.TextShadowOffset), MatrixOrder.Append); graphicsPath2.Transform(matrix2); } } brush = new SolidBrush(this.TextColor); AntiAliasing antiAliasing = this.Common.GaugeContainer.AntiAliasing; AntiAliasing antiAliasing2 = g.AntiAliasing; if (this.Common.GaugeContainer.AntiAliasing == AntiAliasing.Text) { antiAliasing = AntiAliasing.Graphics; } else if (this.Common.GaugeContainer.AntiAliasing == AntiAliasing.Graphics) { antiAliasing = AntiAliasing.None; } g.AntiAliasing = antiAliasing; g.FillPath(brush, graphicsPath2); g.AntiAliasing = antiAliasing2; } } finally { if (graphicsPath != null) { graphicsPath.Dispose(); } if (graphicsPath2 != null) { graphicsPath2.Dispose(); } if (brush3 != null) { brush3.Dispose(); } if (brush2 != null) { brush2.Dispose(); } if (brush != null) { brush.Dispose(); } if (pen != null) { pen.Dispose(); } g.EndHotRegion(); } } }
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 KnobStyleAttrib GetKnobStyleAttrib(GaugeGraphics g, PointF pointOrigin, float angle) { KnobStyleAttrib knobStyleAttrib = new KnobStyleAttrib(); if (this.Image != "" && this.CapImage != "") { return(knobStyleAttrib); } float absoluteDimension = g.GetAbsoluteDimension(this.Width); float num = (float)(this.CapWidth / 100.0 * absoluteDimension); knobStyleAttrib.paths = new GraphicsPath[6]; knobStyleAttrib.brushes = new Brush[6]; if (this.Image == "") { knobStyleAttrib.paths[0] = this.GetKnobPath(g, absoluteDimension, (float)(absoluteDimension * 0.5)); } else { knobStyleAttrib.paths[0] = null; } if (this.CapVisible && this.CapImage == "") { if (this.CapShadowOffset != 0.0) { knobStyleAttrib.paths[1] = new GraphicsPath(); knobStyleAttrib.paths[1].AddEllipse((float)(0.0 - num + this.CapShadowOffset), (float)(0.0 - num + this.CapShadowOffset), (float)(num * 2.0), (float)(num * 2.0)); using (Matrix matrix = new Matrix()) { matrix.Translate(pointOrigin.X, pointOrigin.Y, MatrixOrder.Append); knobStyleAttrib.paths[1].Transform(matrix); } } knobStyleAttrib.paths[2] = new GraphicsPath(); knobStyleAttrib.paths[2].AddEllipse((float)(0.0 - num), (float)(0.0 - num), (float)(num * 2.0), (float)(num * 2.0)); } else { if (this.CapShadowOffset == 0.0) { knobStyleAttrib.paths[1] = null; } knobStyleAttrib.paths[2] = null; } float y = (float)(this.MarkerPosition / 100.0 * absoluteDimension * 2.0); float num2 = (float)(this.MarkerWidth / 100.0 * absoluteDimension * 2.0); float markerHeight = (float)(this.MarkerLength / 100.0 * absoluteDimension * 2.0); PointF point = new PointF(0f, y); knobStyleAttrib.paths[3] = g.CreateMarker(point, num2, markerHeight, this.MarkerStyle); using (Matrix matrix2 = new Matrix()) { matrix2.RotateAt(180f, point, MatrixOrder.Append); if (!this.MarkerRotateGradient) { matrix2.Rotate(angle, MatrixOrder.Append); matrix2.Translate(pointOrigin.X, pointOrigin.Y, MatrixOrder.Append); } knobStyleAttrib.paths[3].Transform(matrix2); } if (this.Image == "" && knobStyleAttrib.paths[0] != null) { float angle2 = (float)(this.RotateGradient ? angle : 0.0); knobStyleAttrib.brushes[0] = this.GetFillBrush(g, knobStyleAttrib.paths[0], pointOrigin, angle2, this.FillColor, this.FillGradientType, this.FillGradientEndColor, this.FillHatchStyle); } else { knobStyleAttrib.brushes[0] = null; } if (this.CapVisible && this.CapImage == "") { if (this.CapShadowOffset != 0.0) { knobStyleAttrib.brushes[1] = g.GetShadowBrush(); } float angle3 = (float)(this.CapRotateGradient ? angle : 0.0); knobStyleAttrib.brushes[2] = this.GetFillBrush(g, knobStyleAttrib.paths[2], pointOrigin, angle3, this.CapFillColor, this.CapFillGradientType, this.CapFillGradientEndColor, this.CapFillHatchStyle); } else { if (this.CapShadowOffset == 0.0) { knobStyleAttrib.brushes[1] = null; } knobStyleAttrib.brushes[2] = null; } float angle4 = (float)(this.MarkerRotateGradient ? angle : 0.0); PointF pointOrigin2 = pointOrigin; if (!this.MarkerRotateGradient) { pointOrigin2 = new PointF(0f, 0f); } knobStyleAttrib.brushes[3] = g.GetMarkerBrush(knobStyleAttrib.paths[3], this.MarkerStyle, pointOrigin2, angle4, this.MarkerFillColor, this.MarkerFillGradientType, this.MarkerFillGradientEndColor, this.MarkerFillHatchStyle); if (this.CapVisible && this.CapReflection && this.CapImage == "") { g.GetCircularEdgeReflection(knobStyleAttrib.paths[2].GetBounds(), 135f, 200, pointOrigin, out knobStyleAttrib.paths[4], out knobStyleAttrib.brushes[4]); g.GetCircularEdgeReflection(knobStyleAttrib.paths[2].GetBounds(), 315f, 128, pointOrigin, out knobStyleAttrib.paths[5], out knobStyleAttrib.brushes[5]); } else { knobStyleAttrib.paths[4] = null; knobStyleAttrib.paths[5] = null; knobStyleAttrib.brushes[4] = null; knobStyleAttrib.brushes[5] = null; } using (Matrix matrix3 = new Matrix()) { matrix3.Rotate(angle, MatrixOrder.Append); matrix3.Translate(pointOrigin.X, pointOrigin.Y, MatrixOrder.Append); if (knobStyleAttrib.paths[0] != null) { knobStyleAttrib.paths[0].Transform(matrix3); } if (knobStyleAttrib.paths[2] != null) { knobStyleAttrib.paths[2].Transform(matrix3); } if (knobStyleAttrib.paths[3] != null) { if (this.MarkerRotateGradient) { knobStyleAttrib.paths[3].Transform(matrix3); return(knobStyleAttrib); } return(knobStyleAttrib); } return(knobStyleAttrib); } }
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(); } } } }
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(); } }