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());
            Add(circularGauge);
            return(circularGauge);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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();
        }
Ejemplo n.º 4
0
        internal GraphicsPath GetFramePath(GaugeGraphics g, float shrinkBy)
        {
            RectangleF frameRectangle    = GetFrameRectangle(g);
            float      absoluteDimension = g.GetAbsoluteDimension(shrinkBy);

            frameRectangle.Inflate(0f - absoluteDimension, 0f - absoluteDimension);
            if (shrinkBy > 0f)
            {
                frameRectangle.Inflate(1f, 1f);
            }
            if (FrameShape == BackFrameShape.Circular)
            {
                GraphicsPath graphicsPath = new GraphicsPath();
                graphicsPath.AddEllipse(frameRectangle);
                return(graphicsPath);
            }
            if (FrameShape == BackFrameShape.AutoShape)
            {
                GraphicsPath graphicsPath2 = new GraphicsPath();
                if (Parent is CircularGauge)
                {
                    CircularGauge circularGauge = (CircularGauge)Parent;
                    if (circularGauge.Scales.Count == 0)
                    {
                        graphicsPath2.AddEllipse(frameRectangle);
                    }
                    else
                    {
                        BuildCircularGaugeAutoFrame(g, graphicsPath2, circularGauge, shrinkBy);
                    }
                }
                else
                {
                    graphicsPath2.AddRectangle(frameRectangle);
                }
                return(graphicsPath2);
            }
            if (FrameShape != BackFrameShape.RoundedRectangular)
            {
                if (FrameShape == BackFrameShape.Rectangular)
                {
                    GraphicsPath graphicsPath3 = new GraphicsPath();
                    graphicsPath3.AddRectangle(frameRectangle);
                    return(graphicsPath3);
                }
                GraphicsPath graphicsPath4 = new GraphicsPath();
                graphicsPath4.FillMode = FillMode.Winding;
                XamlRenderer cachedXamlRenderer = GetCachedXamlRenderer(g);
                graphicsPath4.AddPath(cachedXamlRenderer.Layers[0].Paths[0], connect: false);
                return(graphicsPath4);
            }
            float num  = (!(frameRectangle.Width > frameRectangle.Height)) ? frameRectangle.Width : frameRectangle.Height;
            float num2 = num / 8f;

            float[] array = new float[10];
            for (int i = 0; i < 10; i++)
            {
                array[i] = num2;
            }
            return(g.CreateRoundedRectPath(frameRectangle, array));
        }
Ejemplo n.º 5
0
        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);
        }
 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));
 }