public override object Clone() { MemoryStream stream = new MemoryStream(); BinaryFormatSerializer binaryFormatSerializer = new BinaryFormatSerializer(); binaryFormatSerializer.Serialize(this, stream); CircularGauge circularGauge = new CircularGauge(); binaryFormatSerializer.Deserialize(circularGauge, stream); return(circularGauge); }
public CircularGauge Add(string name) { CircularGauge circularGauge = new CircularGauge(); circularGauge.Name = name; circularGauge.Scales.Add(new CircularScale()); circularGauge.Pointers.Add(new CircularPointer()); circularGauge.Ranges.Add(new CircularRange()); this.Add(circularGauge); return(circularGauge); }
public void Insert(int index, CircularGauge value) { base.List.Insert(index, value); }
public bool Contains(CircularGauge value) { return(base.List.Contains(value)); }
public void Remove(CircularGauge value) { base.List.Remove(value); }
public int Add(CircularGauge value) { return(base.List.Add(value)); }
public int IndexOf(CircularGauge value) { return(base.List.IndexOf(value)); }
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 = (float)(pointer.CapWidth / 2.0 * pointer.GetScale().Radius / 100.0); if (pointer.CapVisible && num4 > num3) { num3 = num4; } float num5 = (float)(pointer.GetNeedleTailLength() * pointer.GetScale().Radius / 100.0); if (num5 > num3) { num3 = num5; } } } foreach (Knob knob in gauge.Knobs) { if (knob.Visible) { float num6 = (float)(knob.Width * knob.GetScale().Radius / 100.0); if (num6 > num3) { num3 = num6; } } } num3 = g.GetAbsoluteDimension(num3); float absoluteDimension = g.GetAbsoluteDimension((float)(radius / 5.0)); float absoluteDimension2 = g.GetAbsoluteDimension((float)(this.FrameWidth * radius / 100.0)); float absoluteDimension3 = g.GetAbsoluteDimension((float)(shrinkBy * radius / 100.0)); absoluteDimension += absoluteDimension2; absoluteDimension -= absoluteDimension3; float num7 = num - startAngle; PointF absolutePoint = g.GetAbsolutePoint(gauge.PivotPoint); float absoluteDimension4 = g.GetAbsoluteDimension(num2); float num8 = (float)(startAngle * 3.1415927410125732 / 180.0); float num9 = (float)((360.0 - startAngle - num7) * 3.1415927410125732 / 180.0); PointF pointF = default(PointF); pointF.X = absolutePoint.X - absoluteDimension4 * (float)Math.Sin((double)num8); pointF.Y = absolutePoint.Y + absoluteDimension4 * (float)Math.Cos((double)num8); PointF pointF2 = default(PointF); pointF2.X = absolutePoint.X + absoluteDimension4 * (float)Math.Sin((double)num9); pointF2.Y = absolutePoint.Y + absoluteDimension4 * (float)Math.Cos((double)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 < 270.0) { path.AddArc(rect, (float)(startAngle + 270.0 + 90.0), 90f); path.AddArc(rect4, (float)(startAngle + 90.0), num7); path.AddArc(rect2, (float)(startAngle + num7 + 90.0), 90f); path.AddArc(rect3, (float)(startAngle + num7 + 90.0 + 45.0), (float)(360.0 - num7 - 90.0)); } else if (num7 >= 320.0) { path.AddEllipse(rect4); } else { float num10 = (float)(90.0 - (360.0 - num7) / 2.0); path.AddArc(rect, (float)(startAngle + 270.0 + 90.0 + num10), (float)(90.0 - num10)); path.AddArc(rect4, (float)(startAngle + 90.0), num7); path.AddArc(rect2, (float)(startAngle + num7 + 90.0), (float)(90.0 - num10)); } path.CloseFigure(); }
public GraphicsPath GetFramePath(GaugeGraphics g, float shrinkBy) { RectangleF frameRectangle = this.GetFrameRectangle(g); float absoluteDimension = g.GetAbsoluteDimension(shrinkBy); frameRectangle.Inflate((float)(0.0 - absoluteDimension), (float)(0.0 - absoluteDimension)); if (shrinkBy > 0.0) { frameRectangle.Inflate(1f, 1f); } if (this.FrameShape == BackFrameShape.Circular) { GraphicsPath graphicsPath = new GraphicsPath(); graphicsPath.AddEllipse(frameRectangle); return(graphicsPath); } if (this.FrameShape == BackFrameShape.AutoShape) { GraphicsPath graphicsPath2 = new GraphicsPath(); if (this.Parent is CircularGauge) { CircularGauge circularGauge = (CircularGauge)this.Parent; if (circularGauge.Scales.Count == 0) { graphicsPath2.AddEllipse(frameRectangle); } else { this.BuildCircularGaugeAutoFrame(g, graphicsPath2, circularGauge, shrinkBy); } } else { graphicsPath2.AddRectangle(frameRectangle); } return(graphicsPath2); } if (this.FrameShape == BackFrameShape.RoundedRectangular) { float num = (!(frameRectangle.Width > frameRectangle.Height)) ? frameRectangle.Width : frameRectangle.Height; float num2 = (float)(num / 8.0); float[] array = new float[10]; for (int i = 0; i < 10; i++) { array[i] = num2; } return(g.CreateRoundedRectPath(frameRectangle, array)); } if (this.FrameShape == BackFrameShape.Rectangular) { GraphicsPath graphicsPath3 = new GraphicsPath(); graphicsPath3.AddRectangle(frameRectangle); return(graphicsPath3); } GraphicsPath graphicsPath4 = new GraphicsPath(); graphicsPath4.FillMode = FillMode.Winding; XamlRenderer cachedXamlRenderer = this.GetCachedXamlRenderer(g); graphicsPath4.AddPath(cachedXamlRenderer.Layers[0].Paths[0], false); return(graphicsPath4); }
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); }