internal GraphicsPath GetCompoundPath(GaugeGraphics g) { GraphicsPath graphicsPath = new GraphicsPath(); PointF location = new PointF(GetPivotPoint().X - GetRadius(), GetPivotPoint().Y - GetRadius()); RectangleF relative = new RectangleF(location, new SizeF(GetRadius() * 2f, GetRadius() * 2f)); float num = 0f; if (MajorTickMark.Visible) { num = (float)Math.Atan(MajorTickMark.Width / 2f / GetRadius()); } if (MinorTickMark.Visible) { num = (float)Math.Max(num, Math.Atan(MinorTickMark.Width / 2f / GetRadius())); } num = Utils.Rad2Deg(num); float startAngle = Utils.ToGDIAngle(base.StartPosition - num); float startAngle2 = Utils.ToGDIAngle(base.EndPosition + num); float num2 = base.EndPosition - base.StartPosition + num * 2f; graphicsPath.StartFigure(); graphicsPath.AddArc(g.GetAbsoluteRectangle(relative), startAngle, num2); relative.Inflate((0f - relative.Width) / 2f, (0f - relative.Height) / 2f); RectangleF absoluteRectangle = g.GetAbsoluteRectangle(relative); absoluteRectangle.Inflate(15f, 15f); graphicsPath.AddArc(absoluteRectangle, startAngle2, 360f - num2); graphicsPath.CloseAllFigures(); return(graphicsPath); }
private GraphicsPath GetBarPath(float barOffsetInside, float barOffsetOutside, float angularMargin) { GaugeGraphics graph = Common.Graph; GraphicsPath graphicsPath = new GraphicsPath(); PointF location = new PointF(GetPivotPoint().X - GetRadius(), GetPivotPoint().Y - GetRadius()); RectangleF relative = new RectangleF(location, new SizeF(GetRadius() * 2f, GetRadius() * 2f)); float num = 0f; if (MajorTickMark.Visible) { num = (float)Math.Atan(MajorTickMark.Width / 2f / GetRadius()); } if (MinorTickMark.Visible) { num = (float)Math.Max(num, Math.Atan(MinorTickMark.Width / 2f / GetRadius())); } num = Utils.Rad2Deg(num); num += angularMargin; float startAngle = Utils.ToGDIAngle(base.StartPosition - num); float startAngle2 = Utils.ToGDIAngle(base.EndPosition + num); float num2 = base.EndPosition - base.StartPosition + num * 2f; graphicsPath.StartFigure(); relative.Inflate(barOffsetOutside, barOffsetOutside); graphicsPath.AddArc(graph.GetAbsoluteRectangle(relative), startAngle, num2); relative.Inflate(0f - (barOffsetInside + barOffsetOutside), 0f - (barOffsetInside + barOffsetOutside)); RectangleF absoluteRectangle = graph.GetAbsoluteRectangle(relative); if (absoluteRectangle.Width > 0f && absoluteRectangle.Height > 0f) { graphicsPath.AddArc(absoluteRectangle, startAngle2, 0f - num2); } graphicsPath.CloseAllFigures(); return(graphicsPath); }
public GraphicsPath GetCompoundPath(GaugeGraphics g) { GraphicsPath graphicsPath = new GraphicsPath(); PointF location = new PointF(this.GetPivotPoint().X - this.GetRadius(), this.GetPivotPoint().Y - this.GetRadius()); RectangleF relative = new RectangleF(location, new SizeF((float)(this.GetRadius() * 2.0), (float)(this.GetRadius() * 2.0))); float num = 0f; if (this.MajorTickMark.Visible) { num = (float)Math.Atan(this.MajorTickMark.Width / 2.0 / this.GetRadius()); } if (this.MinorTickMark.Visible) { num = (float)Math.Max((double)num, Math.Atan(this.MinorTickMark.Width / 2.0 / this.GetRadius())); } num = Utils.Rad2Deg(num); float startAngle = Utils.ToGDIAngle(base.StartPosition - num); float startAngle2 = Utils.ToGDIAngle(base.EndPosition + num); float num2 = (float)(base.EndPosition - base.StartPosition + num * 2.0); graphicsPath.StartFigure(); graphicsPath.AddArc(g.GetAbsoluteRectangle(relative), startAngle, num2); relative.Inflate((float)((0.0 - relative.Width) / 2.0), (float)((0.0 - relative.Height) / 2.0)); RectangleF absoluteRectangle = g.GetAbsoluteRectangle(relative); absoluteRectangle.Inflate(15f, 15f); graphicsPath.AddArc(absoluteRectangle, startAngle2, (float)(360.0 - num2)); graphicsPath.CloseAllFigures(); return(graphicsPath); }
public void RenderTopImage(GaugeGraphics g) { if (base.TopImage != "") { ImageAttributes imageAttributes = new ImageAttributes(); if (base.TopImageTransColor != Color.Empty) { imageAttributes.SetColorKey(base.TopImageTransColor, base.TopImageTransColor, ColorAdjustType.Default); } Image image = this.Common.ImageLoader.LoadImage(base.TopImage); Rectangle destRect = Rectangle.Round(g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f))); if (!base.TopImageHueColor.IsEmpty) { Color color = g.TransformHueColor(base.TopImageHueColor); ColorMatrix colorMatrix = new ColorMatrix(); colorMatrix.Matrix00 = (float)((float)(int)color.R / 255.0); colorMatrix.Matrix11 = (float)((float)(int)color.G / 255.0); colorMatrix.Matrix22 = (float)((float)(int)color.B / 255.0); 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(); } }
public GraphicsPath GetTextPath(GaugeGraphics g) { if (!this.Visible) { return(null); } RectangleF absoluteRectangle = g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f)); GraphicsPath graphicsPath = new GraphicsPath(); string noImageString = SR.NoImageString; Font font = new Font("Microsoft Sans Serif", 8.25f); SizeF sizeF = g.MeasureString(noImageString, font); SizeF absoluteSize = g.GetAbsoluteSize(new SizeF(100f, 100f)); float num = absoluteSize.Width / sizeF.Width; float num2 = absoluteSize.Height / sizeF.Height; float emSize = (float)((!(num < num2)) ? (font.SizeInPoints * num2 * 1.2999999523162842) : (font.SizeInPoints * num * 1.2999999523162842)); StringFormat stringFormat = new StringFormat(); stringFormat.Alignment = StringAlignment.Center; stringFormat.LineAlignment = StringAlignment.Center; graphicsPath.AddString(noImageString, font.FontFamily, (int)font.Style, emSize, absoluteRectangle, stringFormat); if (this.Angle != 0.0) { PointF point = new PointF((float)(absoluteRectangle.X + absoluteRectangle.Width / 2.0), (float)(absoluteRectangle.Y + absoluteRectangle.Height / 2.0)); using (Matrix matrix = new Matrix()) { matrix.RotateAt(this.Angle, point); graphicsPath.Transform(matrix); return(graphicsPath); } } return(graphicsPath); }
private GraphicsPath GetBarPath(float barOffsetInside, float barOffsetOutside) { GaugeGraphics graph = Common.Graph; GraphicsPath graphicsPath = new GraphicsPath(); float num = 0f; if (MajorTickMark.Visible) { num = MajorTickMark.Width / 2f; } if (MinorTickMark.Visible) { num = Math.Max(num, MinorTickMark.Width / 2f); } RectangleF relative = new RectangleF(0f, 0f, 0f, 0f); if (ParentGauge.GetOrientation() == GaugeOrientation.Horizontal) { relative.X = base.StartPosition; relative.Width = base.EndPosition - base.StartPosition; relative.Y = Position - barOffsetInside; relative.Height = barOffsetInside + barOffsetOutside; relative = graph.GetAbsoluteRectangle(relative); relative.Inflate(graph.GetAbsoluteDimension(num), 0f); } else { relative.Y = base.StartPosition; relative.Height = base.EndPosition - base.StartPosition; relative.X = Position - barOffsetInside; relative.Width = barOffsetInside + barOffsetOutside; relative = graph.GetAbsoluteRectangle(relative); relative.Inflate(0f, graph.GetAbsoluteDimension(num)); } if (relative.Width <= 0f) { relative.Width = 1E-06f; } if (relative.Height <= 0f) { relative.Height = 1E-06f; } graphicsPath.AddRectangle(relative); return(graphicsPath); }
internal void BuildMatrices(GaugeGraphics g) { absMatrix.Reset(); RectangleF rectangleF = new RectangleF(0f, 0f, 1f, 1f); RectangleF absoluteRectangle = g.GetAbsoluteRectangle(rectangleF); absMatrix.Translate(g.Transform.OffsetX, g.Transform.OffsetY); absMatrix.Scale(absoluteRectangle.Size.Width, absoluteRectangle.Size.Height); absoluteRectangle = g.GetRelativeRectangle(rectangleF); relMatrix.Reset(); relMatrix.Scale(absoluteRectangle.Size.Width, absoluteRectangle.Size.Height); relMatrix.Translate(0f - g.Transform.OffsetX, 0f - g.Transform.OffsetY); }
public void BuildMatrices(GaugeGraphics g) { this.absMatrix.Reset(); RectangleF rectangleF = new RectangleF(0f, 0f, 1f, 1f); RectangleF rectangleF2 = g.GetAbsoluteRectangle(rectangleF); this.absMatrix.Translate(g.Transform.OffsetX, g.Transform.OffsetY); this.absMatrix.Scale(rectangleF2.Size.Width, rectangleF2.Size.Height); rectangleF2 = g.GetRelativeRectangle(rectangleF); this.relMatrix.Reset(); this.relMatrix.Scale(rectangleF2.Size.Width, rectangleF2.Size.Height); this.relMatrix.Translate((float)(0.0 - g.Transform.OffsetX), (float)(0.0 - g.Transform.OffsetY)); }
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); } } }
public override RectangleF GetBoundRect(GaugeGraphics g) { if (this.Common != null && !float.IsNaN(base.AspectRatio)) { RectangleF absoluteRectangle = g.GetAbsoluteRectangle(base.Position.Rectangle); if (absoluteRectangle.Width > absoluteRectangle.Height * base.AspectRatio) { float width = absoluteRectangle.Width; absoluteRectangle.Width = absoluteRectangle.Height * base.AspectRatio; absoluteRectangle.X += (float)((width - absoluteRectangle.Width) / 2.0); return(g.GetRelativeRectangle(absoluteRectangle)); } float height = absoluteRectangle.Height; absoluteRectangle.Height = absoluteRectangle.Width / base.AspectRatio; absoluteRectangle.Y += (float)((height - absoluteRectangle.Height) / 2.0); return(g.GetRelativeRectangle(absoluteRectangle)); } return(base.Position.Rectangle); }
void ISelectable.DrawSelection(GaugeGraphics g, bool designTimeSelection) { Stack stack = new Stack(); for (NamedElement namedElement = this.ParentObject; namedElement != null; namedElement = (NamedElement)((IRenderable)namedElement).GetParentRenderable()) { stack.Push(namedElement); } foreach (IRenderable item in stack) { g.CreateDrawRegion(item.GetBoundRect(g)); } g.CreateDrawRegion(((IRenderable)this).GetBoundRect(g)); g.DrawSelection(g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f)), designTimeSelection, this.Common.GaugeCore.SelectionBorderColor, this.Common.GaugeCore.SelectionMarkerColor); g.RestoreDrawRegion(); foreach (IRenderable item2 in stack) { IRenderable renderable = item2; g.RestoreDrawRegion(); } }
internal GraphicsPath GetBackPath(GaugeGraphics g) { if (!Visible) { return(null); } GraphicsPath graphicsPath = new GraphicsPath(); RectangleF absoluteRectangle = g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f)); graphicsPath.AddRectangle(absoluteRectangle); if (Angle != 0f) { PointF point = new PointF(absoluteRectangle.X + absoluteRectangle.Width / 2f, absoluteRectangle.Y + absoluteRectangle.Height / 2f); using (Matrix matrix = new Matrix()) { matrix.RotateAt(Angle, point); graphicsPath.Transform(matrix); return(graphicsPath); } } return(graphicsPath); }
public Brush GetBackBrush(GaugeGraphics g) { RectangleF absoluteRectangle = g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f)); Brush brush = null; Color color = this.BackColor; Color color2 = this.BackGradientEndColor; GradientType gradientType = this.BackGradientType; GaugeHatchStyle gaugeHatchStyle = this.BackHatchStyle; if (gaugeHatchStyle != 0) { brush = GaugeGraphics.GetHatchBrush(gaugeHatchStyle, color, color2); } else if (gradientType != 0) { brush = g.GetGradientBrush(absoluteRectangle, color, color2, gradientType); if (this.Angle != 0.0) { PointF pointF = new PointF((float)(absoluteRectangle.X + absoluteRectangle.Width / 2.0), (float)(absoluteRectangle.Y + absoluteRectangle.Height / 2.0)); if (brush is LinearGradientBrush) { ((LinearGradientBrush)brush).TranslateTransform((float)(0.0 - pointF.X), (float)(0.0 - pointF.Y), MatrixOrder.Append); ((LinearGradientBrush)brush).RotateTransform(this.Angle, MatrixOrder.Append); ((LinearGradientBrush)brush).TranslateTransform(pointF.X, pointF.Y, MatrixOrder.Append); } else if (brush is PathGradientBrush) { ((PathGradientBrush)brush).TranslateTransform((float)(0.0 - pointF.X), (float)(0.0 - pointF.Y), MatrixOrder.Append); ((PathGradientBrush)brush).RotateTransform(this.Angle, MatrixOrder.Append); ((PathGradientBrush)brush).TranslateTransform(pointF.X, pointF.Y, MatrixOrder.Append); } } } else { brush = new SolidBrush(color); } return(brush); }
public GraphicsPath GetBackPath(GaugeGraphics g) { if (!this.Visible) { return(null); } GraphicsPath graphicsPath = new GraphicsPath(); RectangleF absoluteRectangle = g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f)); graphicsPath.AddRectangle(absoluteRectangle); if (this.Angle != 0.0) { PointF point = new PointF((float)(absoluteRectangle.X + absoluteRectangle.Width / 2.0), (float)(absoluteRectangle.Y + absoluteRectangle.Height / 2.0)); using (Matrix matrix = new Matrix()) { matrix.RotateAt(this.Angle, point); graphicsPath.Transform(matrix); return(graphicsPath); } } return(graphicsPath); }
public override RectangleF GetBoundRect(GaugeGraphics g) { if (this.Common != null) { RectangleF absolute = this.absoluteRect = g.GetAbsoluteRectangle(base.Position.Rectangle); if (!float.IsNaN(base.AspectRatio)) { if (base.AspectRatio >= 1.0) { float width = absolute.Width; absolute.Width /= base.AspectRatio; absolute.X += (float)((width - absolute.Width) / 2.0); } else { float height = absolute.Height; absolute.Height *= base.AspectRatio; absolute.Y += (float)((height - absolute.Height) / 2.0); } } if (absolute.Width != absolute.Height) { if (absolute.Width > absolute.Height) { absolute.Offset((float)((absolute.Width - absolute.Height) / 2.0), 0f); absolute.Width = absolute.Height; } else if (absolute.Width < absolute.Height) { absolute.Offset(0f, (float)((absolute.Height - absolute.Width) / 2.0)); absolute.Height = absolute.Width; } } return(g.GetRelativeRectangle(absolute)); } return(base.Position.Rectangle); }
public RectangleF GetFrameRectangle(GaugeGraphics g) { RectangleF result; if (this.Parent is GaugeCore) { result = new RectangleF(0f, 0f, (float)(((GaugeCore)this.Parent).GetWidth() - 1), (float)(((GaugeCore)this.Parent).GetHeight() - 1)); } else { if ((this.FrameShape == BackFrameShape.Rectangular || this.FrameShape == BackFrameShape.RoundedRectangular) && this.Parent is CircularGauge) { CircularGauge circularGauge = (CircularGauge)this.Parent; if (circularGauge.ParentObject != null) { result = g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f)); if (circularGauge.Position.Rectangle.Width > 0.0 && circularGauge.Position.Rectangle.Height > 0.0) { if (!double.IsNaN((double)circularGauge.AspectRatio)) { if (circularGauge.AspectRatio >= 1.0) { float width = result.Width; result.Width = result.Height * circularGauge.AspectRatio; result.X += (float)((width - result.Width) / 2.0); } else { float height = result.Height; result.Height = result.Width / circularGauge.AspectRatio; result.Y += (float)((height - result.Height) / 2.0); } } else { float num = circularGauge.Position.Rectangle.Width / circularGauge.Position.Rectangle.Height; if (circularGauge.Position.Rectangle.Width > circularGauge.Position.Rectangle.Height) { float num2 = result.Height * num; result.X += (float)((result.Width - num2) / 2.0); result.Width = num2; } else { float num3 = result.Width / num; result.Y += (float)((result.Height - num3) / 2.0); result.Height = num3; } } } } else { result = circularGauge.absoluteRect; if (!double.IsNaN((double)circularGauge.AspectRatio)) { if (result.Width > result.Height * circularGauge.AspectRatio) { float width2 = result.Width; result.Width = result.Height * circularGauge.AspectRatio; result.X += (float)((width2 - result.Width) / 2.0); } else { float height2 = result.Height; result.Height = result.Width / circularGauge.AspectRatio; result.Y += (float)((height2 - result.Height) / 2.0); } } PointF empty = PointF.Empty; empty.X = (float)(0.0 - g.Graphics.Transform.OffsetX + g.InitialOffset.X); empty.Y = (float)(0.0 - g.Graphics.Transform.OffsetY + g.InitialOffset.Y); result.Offset(empty.X, empty.Y); } goto IL_0371; } result = g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f)); } goto IL_0371; IL_0371: if (this.FrameShape == BackFrameShape.Circular || this.IsCustomXamlFrame()) { if (result.Width > result.Height) { result.X += (float)((result.Width - result.Height) / 2.0); result.Width = result.Height; } else if (result.Height > result.Width) { result.Y += (float)((result.Height - result.Width) / 2.0); result.Height = result.Width; } } float xamlFrameAspectRatio = BackFrame.GetXamlFrameAspectRatio(this.Shape); if (xamlFrameAspectRatio > 1.0) { float num4 = result.Height * xamlFrameAspectRatio; result.X += (float)((result.Width - num4) / 2.0); result.Width = num4; } else if (xamlFrameAspectRatio < 1.0) { float num5 = result.Width / xamlFrameAspectRatio; result.Y += (float)((result.Height - num5) / 2.0); result.Height = num5; } if (this.Parent is GaugeCore) { if (this.ShadowOffset < 0.0) { result.X -= this.ShadowOffset; result.Y -= this.ShadowOffset; result.Width += this.ShadowOffset; result.Height += this.ShadowOffset; } else if (this.ShadowOffset > 0.0) { result.Width -= this.ShadowOffset; result.Height -= this.ShadowOffset; } } return(result); }
public GraphicsPath GetTextPath(GaugeGraphics g) { if (!this.Visible) { return(null); } if (this.Text.Length == 0) { return(null); } RectangleF absoluteRectangle = g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f)); GraphicsPath graphicsPath = new GraphicsPath(); string text = this.Text; Font font = this.Font; text = text.Replace("\\n", "\n"); float emSize; if (this.ResizeMode == ResizeMode.AutoFit) { SizeF sizeF = g.MeasureString(text, font); SizeF absoluteSize = g.GetAbsoluteSize(new SizeF(100f, 100f)); float num = absoluteSize.Width / sizeF.Width; float num2 = absoluteSize.Height / sizeF.Height; emSize = (float)((!(num < num2)) ? (font.SizeInPoints * num2 * 1.2999999523162842 * g.Graphics.DpiY / 96.0) : (font.SizeInPoints * num * 1.2999999523162842 * g.Graphics.DpiY / 96.0)); } else { if (this.FontUnit == FontUnit.Percent) { g.RestoreDrawRegion(); emSize = g.GetAbsoluteDimension(font.Size); RectangleF boundRect = ((IRenderable)this).GetBoundRect(g); g.CreateDrawRegion(boundRect); } else { emSize = (float)(font.SizeInPoints * g.Graphics.DpiY / 96.0); } emSize = (float)(emSize * 1.2999999523162842); } StringFormat stringFormat = new StringFormat(); if (this.TextAlignment == ContentAlignment.TopLeft) { stringFormat.Alignment = StringAlignment.Near; stringFormat.LineAlignment = StringAlignment.Near; } else if (this.TextAlignment == ContentAlignment.TopCenter) { stringFormat.Alignment = StringAlignment.Center; stringFormat.LineAlignment = StringAlignment.Near; } else if (this.TextAlignment == ContentAlignment.TopRight) { stringFormat.Alignment = StringAlignment.Far; stringFormat.LineAlignment = StringAlignment.Near; } else if (this.TextAlignment == ContentAlignment.MiddleLeft) { stringFormat.Alignment = StringAlignment.Near; stringFormat.LineAlignment = StringAlignment.Center; } else if (this.TextAlignment == ContentAlignment.MiddleCenter) { stringFormat.Alignment = StringAlignment.Center; stringFormat.LineAlignment = StringAlignment.Center; } else if (this.TextAlignment == ContentAlignment.MiddleRight) { stringFormat.Alignment = StringAlignment.Far; stringFormat.LineAlignment = StringAlignment.Center; } else if (this.TextAlignment == ContentAlignment.BottomLeft) { stringFormat.Alignment = StringAlignment.Near; stringFormat.LineAlignment = StringAlignment.Far; } else if (this.TextAlignment == ContentAlignment.BottomCenter) { stringFormat.Alignment = StringAlignment.Center; stringFormat.LineAlignment = StringAlignment.Far; } else { stringFormat.Alignment = StringAlignment.Far; stringFormat.LineAlignment = StringAlignment.Far; } graphicsPath.AddString(text, font.FontFamily, (int)font.Style, emSize, absoluteRectangle, stringFormat); if (this.Angle != 0.0) { PointF point = new PointF((float)(absoluteRectangle.X + absoluteRectangle.Width / 2.0), (float)(absoluteRectangle.Y + absoluteRectangle.Height / 2.0)); using (Matrix matrix = new Matrix()) { matrix.RotateAt(this.Angle, point); graphicsPath.Transform(matrix); return(graphicsPath); } } return(graphicsPath); }
public PointF[] GetSelectionMarkers(GaugeGraphics g, float barOffsetInside, float barOffsetOutside, float angularMargin) { PointF location = new PointF(this.GetPivotPoint().X - this.GetRadius(), this.GetPivotPoint().Y - this.GetRadius()); RectangleF relative = new RectangleF(location, new SizeF((float)(this.GetRadius() * 2.0), (float)(this.GetRadius() * 2.0))); float num = 0f; if (this.MajorTickMark.Visible) { num = (float)Math.Atan(this.MajorTickMark.Width / 2.0 / this.GetRadius()); } if (this.MinorTickMark.Visible) { num = (float)Math.Max((double)num, Math.Atan(this.MinorTickMark.Width / 2.0 / this.GetRadius())); } num = Utils.Rad2Deg(num); num += angularMargin; float startAngle = Utils.ToGDIAngle(base.StartPosition - num); Utils.ToGDIAngle(base.EndPosition + num); float sweepAngle = (float)(base.EndPosition - base.StartPosition + num * 2.0); ArrayList arrayList = new ArrayList(); relative.Inflate(barOffsetOutside, barOffsetOutside); float flatness = 0.1f; using (GraphicsPath graphicsPath = new GraphicsPath()) { graphicsPath.AddArc(g.GetAbsoluteRectangle(relative), startAngle, sweepAngle); graphicsPath.Flatten(null, flatness); PointF[] pathPoints = graphicsPath.PathPoints; PointF pointF = default(PointF); PointF pointF2 = default(PointF); this.GetBoundsFromPoints(pathPoints, out pointF, out pointF2); if (this.SweepAngle + num * 2.0 < 360.0) { arrayList.Add(pathPoints[0]); arrayList.Add(pathPoints[pathPoints.Length - 1]); } bool flag = false; bool flag2 = false; bool flag3 = false; bool flag4 = false; for (int i = 1; i < pathPoints.Length - 1; i++) { if (!flag && pathPoints[i].X == pointF.X) { flag = true; arrayList.Add(pathPoints[i]); } if (!flag2 && pathPoints[i].Y == pointF.Y) { flag2 = true; arrayList.Add(pathPoints[i]); } if (!flag3 && pathPoints[i].X == pointF2.X) { flag3 = true; arrayList.Add(pathPoints[i]); } if (!flag4 && pathPoints[i].Y == pointF2.Y) { flag3 = true; arrayList.Add(pathPoints[i]); } } } relative.Inflate((float)(0.0 - (barOffsetInside + barOffsetOutside)), (float)(0.0 - (barOffsetInside + barOffsetOutside))); RectangleF absoluteRectangle = g.GetAbsoluteRectangle(relative); if (absoluteRectangle.Width > 0.0 && absoluteRectangle.Height > 0.0) { using (GraphicsPath graphicsPath2 = new GraphicsPath()) { graphicsPath2.AddArc(absoluteRectangle, startAngle, sweepAngle); graphicsPath2.Flatten(null, flatness); PointF[] pathPoints2 = graphicsPath2.PathPoints; PointF pointF3 = default(PointF); PointF pointF4 = default(PointF); this.GetBoundsFromPoints(pathPoints2, out pointF3, out pointF4); if (this.SweepAngle + num * 2.0 < 360.0) { arrayList.Add(pathPoints2[0]); arrayList.Add(pathPoints2[pathPoints2.Length - 1]); } bool flag5 = false; bool flag6 = false; bool flag7 = false; bool flag8 = false; for (int j = 1; j < pathPoints2.Length - 1; j++) { if (!flag5 && pathPoints2[j].X == pointF3.X) { flag5 = true; arrayList.Add(pathPoints2[j]); } if (!flag6 && pathPoints2[j].Y == pointF3.Y) { flag6 = true; arrayList.Add(pathPoints2[j]); } if (!flag7 && pathPoints2[j].X == pointF4.X) { flag7 = true; arrayList.Add(pathPoints2[j]); } if (!flag8 && pathPoints2[j].Y == pointF4.Y) { flag7 = true; arrayList.Add(pathPoints2[j]); } } } } return((PointF[])arrayList.ToArray(typeof(PointF))); }
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); } } }
internal PointF[] GetSelectionMarkers(GaugeGraphics g, float barOffsetInside, float barOffsetOutside, float angularMargin) { PointF location = new PointF(GetPivotPoint().X - GetRadius(), GetPivotPoint().Y - GetRadius()); RectangleF relative = new RectangleF(location, new SizeF(GetRadius() * 2f, GetRadius() * 2f)); float num = 0f; if (MajorTickMark.Visible) { num = (float)Math.Atan(MajorTickMark.Width / 2f / GetRadius()); } if (MinorTickMark.Visible) { num = (float)Math.Max(num, Math.Atan(MinorTickMark.Width / 2f / GetRadius())); } num = Utils.Rad2Deg(num); num += angularMargin; float startAngle = Utils.ToGDIAngle(base.StartPosition - num); Utils.ToGDIAngle(base.EndPosition + num); float sweepAngle = base.EndPosition - base.StartPosition + num * 2f; ArrayList arrayList = new ArrayList(); relative.Inflate(barOffsetOutside, barOffsetOutside); float flatness = 0.1f; using (GraphicsPath graphicsPath = new GraphicsPath()) { graphicsPath.AddArc(g.GetAbsoluteRectangle(relative), startAngle, sweepAngle); graphicsPath.Flatten(null, flatness); PointF[] pathPoints = graphicsPath.PathPoints; GetBoundsFromPoints(pathPoints, out PointF minPoint, out PointF maxPoint); if (SweepAngle + num * 2f < 360f) { arrayList.Add(pathPoints[0]); arrayList.Add(pathPoints[pathPoints.Length - 1]); } bool flag = false; bool flag2 = false; bool flag3 = false; bool flag4 = false; for (int i = 1; i < pathPoints.Length - 1; i++) { if (!flag && pathPoints[i].X == minPoint.X) { flag = true; arrayList.Add(pathPoints[i]); } if (!flag2 && pathPoints[i].Y == minPoint.Y) { flag2 = true; arrayList.Add(pathPoints[i]); } if (!flag3 && pathPoints[i].X == maxPoint.X) { flag3 = true; arrayList.Add(pathPoints[i]); } if (!flag4 && pathPoints[i].Y == maxPoint.Y) { flag3 = true; arrayList.Add(pathPoints[i]); } } } relative.Inflate(0f - (barOffsetInside + barOffsetOutside), 0f - (barOffsetInside + barOffsetOutside)); RectangleF absoluteRectangle = g.GetAbsoluteRectangle(relative); if (absoluteRectangle.Width > 0f && absoluteRectangle.Height > 0f) { using (GraphicsPath graphicsPath2 = new GraphicsPath()) { graphicsPath2.AddArc(absoluteRectangle, startAngle, sweepAngle); graphicsPath2.Flatten(null, flatness); PointF[] pathPoints2 = graphicsPath2.PathPoints; GetBoundsFromPoints(pathPoints2, out PointF minPoint2, out PointF maxPoint2); if (SweepAngle + num * 2f < 360f) { arrayList.Add(pathPoints2[0]); arrayList.Add(pathPoints2[pathPoints2.Length - 1]); } bool flag5 = false; bool flag6 = false; bool flag7 = false; bool flag8 = false; for (int j = 1; j < pathPoints2.Length - 1; j++) { if (!flag5 && pathPoints2[j].X == minPoint2.X) { flag5 = true; arrayList.Add(pathPoints2[j]); } if (!flag6 && pathPoints2[j].Y == minPoint2.Y) { flag6 = true; arrayList.Add(pathPoints2[j]); } if (!flag7 && pathPoints2[j].X == maxPoint2.X) { flag7 = true; arrayList.Add(pathPoints2[j]); } if (!flag8 && pathPoints2[j].Y == maxPoint2.Y) { flag7 = true; arrayList.Add(pathPoints2[j]); } } } } return((PointF[])arrayList.ToArray(typeof(PointF))); }
internal RectangleF GetFrameRectangle(GaugeGraphics g) { RectangleF result; if (Parent is GaugeCore) { result = new RectangleF(0f, 0f, ((GaugeCore)Parent).GetWidth() - 1, ((GaugeCore)Parent).GetHeight() - 1); } else if ((FrameShape == BackFrameShape.Rectangular || FrameShape == BackFrameShape.RoundedRectangular) && Parent is CircularGauge) { CircularGauge circularGauge = (CircularGauge)Parent; if (circularGauge.ParentObject != null) { result = g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f)); if (circularGauge.Position.Rectangle.Width > 0f && circularGauge.Position.Rectangle.Height > 0f) { if (!double.IsNaN(circularGauge.AspectRatio)) { if (circularGauge.AspectRatio >= 1f) { float width = result.Width; result.Width = result.Height * circularGauge.AspectRatio; result.X += (width - result.Width) / 2f; } else { float height = result.Height; result.Height = result.Width / circularGauge.AspectRatio; result.Y += (height - result.Height) / 2f; } } else { float num = circularGauge.Position.Rectangle.Width / circularGauge.Position.Rectangle.Height; if (circularGauge.Position.Rectangle.Width > circularGauge.Position.Rectangle.Height) { float num2 = result.Height * num; result.X += (result.Width - num2) / 2f; result.Width = num2; } else { float num3 = result.Width / num; result.Y += (result.Height - num3) / 2f; result.Height = num3; } } } } else { result = circularGauge.absoluteRect; if (!double.IsNaN(circularGauge.AspectRatio)) { if (result.Width > result.Height * circularGauge.AspectRatio) { float width2 = result.Width; result.Width = result.Height * circularGauge.AspectRatio; result.X += (width2 - result.Width) / 2f; } else { float height2 = result.Height; result.Height = result.Width / circularGauge.AspectRatio; result.Y += (height2 - result.Height) / 2f; } } PointF empty = PointF.Empty; empty.X = 0f - g.Graphics.Transform.OffsetX + g.InitialOffset.X; empty.Y = 0f - g.Graphics.Transform.OffsetY + g.InitialOffset.Y; result.Offset(empty.X, empty.Y); } } else { result = g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f)); } if (FrameShape == BackFrameShape.Circular || IsCustomXamlFrame()) { if (result.Width > result.Height) { result.X += (result.Width - result.Height) / 2f; result.Width = result.Height; } else if (result.Height > result.Width) { result.Y += (result.Height - result.Width) / 2f; result.Height = result.Width; } } float xamlFrameAspectRatio = GetXamlFrameAspectRatio(Shape); if (xamlFrameAspectRatio > 1f) { float num4 = result.Height * xamlFrameAspectRatio; result.X += (result.Width - num4) / 2f; result.Width = num4; } else if (xamlFrameAspectRatio < 1f) { float num5 = result.Width / xamlFrameAspectRatio; result.Y += (result.Height - num5) / 2f; result.Height = num5; } if (Parent is GaugeCore) { if (ShadowOffset < 0f) { result.X -= ShadowOffset; result.Y -= ShadowOffset; result.Width += ShadowOffset; result.Height += ShadowOffset; } else if (ShadowOffset > 0f) { result.Width -= ShadowOffset; result.Height -= ShadowOffset; } } return(result); }