Example #1
0
        public LinearScale Add(string name)
        {
            LinearScale linearScale = new LinearScale();

            linearScale.Name = name;
            Add(linearScale);
            return(linearScale);
        }
Example #2
0
        public override object Clone()
        {
            MemoryStream           stream = new MemoryStream();
            BinaryFormatSerializer binaryFormatSerializer = new BinaryFormatSerializer();

            binaryFormatSerializer.Serialize(this, stream);
            LinearScale linearScale = new LinearScale();

            binaryFormatSerializer.Deserialize(linearScale, stream);
            return(linearScale);
        }
        internal GraphicsPath GetPointerPath(GaugeGraphics g)
        {
            if (!Visible)
            {
                return(null);
            }
            GraphicsPath graphicsPath = new GraphicsPath();
            LinearScale  scale        = GetScale();

            scale.GetPositionFromValue(scale.GetValueLimit(base.Position));
            if (Type == LinearPointerType.Marker || Image != string.Empty)
            {
                MarkerStyleAttrib markerStyleAttrib = GetMarkerStyleAttrib(g);
                if (markerStyleAttrib.path != null)
                {
                    graphicsPath.AddPath(markerStyleAttrib.path, connect: false);
                }
            }
            else if (Type == LinearPointerType.Bar)
            {
                BarStyleAttrib barStyleAttrib = GetBarStyleAttrib(g);
                if (barStyleAttrib.primaryPath == null)
                {
                    graphicsPath.Dispose();
                    return(null);
                }
                if (barStyleAttrib.primaryPath != null)
                {
                    graphicsPath.AddPath(barStyleAttrib.primaryPath, connect: false);
                }
            }
            else if (Type == LinearPointerType.Thermometer)
            {
                BarStyleAttrib thermometerStyleAttrib = GetThermometerStyleAttrib(g);
                if (thermometerStyleAttrib.primaryPath == null)
                {
                    graphicsPath.Dispose();
                    return(null);
                }
                if (thermometerStyleAttrib.totalPath != null)
                {
                    graphicsPath.AddPath(thermometerStyleAttrib.primaryPath, connect: false);
                }
            }
            return(graphicsPath);
        }
        public LinearScale GetScale()
        {
            if (GetGauge() == null)
            {
                return(null);
            }
            LinearScale linearScale = null;

            try
            {
                return(GetGauge().Scales[base.ScaleName]);
            }
            catch
            {
                return(null);
            }
        }
        private double GetBarStartValue()
        {
            LinearScale scale = GetScale();

            if (Type == LinearPointerType.Thermometer)
            {
                return(double.NegativeInfinity);
            }
            if (BarStart == BarStart.ScaleStart)
            {
                return(double.NegativeInfinity);
            }
            if (scale.Logarithmic)
            {
                return(1.0);
            }
            return(0.0);
        }
        internal override void Render(GaugeGraphics g)
        {
            if (Common == null || !base.Visible || GetScale() == null || double.IsNaN(StartValue) || double.IsNaN(EndValue))
            {
                return;
            }
            Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceStartRendering(Name));
            g.StartHotRegion(this);
            LinearScale  scale        = GetScale();
            Pen          pen          = null;
            Brush        brush        = null;
            GraphicsPath graphicsPath = null;

            try
            {
                graphicsPath = g.GetLinearRangePath(scale.GetPositionFromValue(StartValue), scale.GetPositionFromValue(EndValue), StartWidth, EndWidth, scale.Position, GetGauge().GetOrientation(), DistanceFromScale, Placement, scale.Width);
                if (graphicsPath == null || !g.Graphics.VisibleClipBounds.IntersectsWith(graphicsPath.GetBounds()))
                {
                    g.EndHotRegion();
                    Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceRenderingComplete(Name));
                    return;
                }
                brush         = g.GetLinearRangeBrush(graphicsPath.GetBounds(), base.FillColor, base.FillHatchStyle, base.FillGradientType, base.FillGradientEndColor, GetGauge().GetOrientation(), GetScale().GetReversed(), StartValue, EndValue);
                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();
                throw;
            }
            Common.GaugeCore.HotRegionList.SetHotRegion(this, PointF.Empty, graphicsPath);
            g.EndHotRegion();
            Common.GaugeCore.TraceWrite("GaugePaint", SR.TraceRenderingComplete(Name));
        }
        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);
            }
        }
        private LinearRange[] GetColorRanges()
        {
            LinearGauge gauge = GetGauge();
            LinearScale scale = GetScale();

            if (gauge == null || scale == null)
            {
                return(null);
            }
            double    barStartValue = GetBarStartValue();
            double    position      = base.Position;
            ArrayList arrayList     = null;

            foreach (LinearRange range in gauge.Ranges)
            {
                if (range.GetScale() != scale || !(range.InRangeBarPointerColor != Color.Empty))
                {
                    continue;
                }
                double valueLimit  = scale.GetValueLimit(range.StartValue);
                double valueLimit2 = scale.GetValueLimit(range.EndValue);
                if ((barStartValue >= valueLimit && barStartValue <= valueLimit2) || (position >= valueLimit && position <= valueLimit2) || (valueLimit >= barStartValue && valueLimit <= position) || (valueLimit2 >= barStartValue && valueLimit2 <= position))
                {
                    if (arrayList == null)
                    {
                        arrayList = new ArrayList();
                    }
                    arrayList.Add(range);
                }
            }
            if (arrayList == null)
            {
                return(null);
            }
            return((LinearRange[])arrayList.ToArray(typeof(LinearRange)));
        }
        internal GraphicsPath GetPath(GaugeGraphics g, bool getShadowPath)
        {
            if (getShadowPath && (!base.Visible || base.ShadowOffset == 0f))
            {
                return(null);
            }
            if (double.IsNaN(StartValue) || double.IsNaN(EndValue))
            {
                return(null);
            }
            LinearScale  scale           = GetScale();
            GraphicsPath linearRangePath = g.GetLinearRangePath(scale.GetPositionFromValue(StartValue), scale.GetPositionFromValue(EndValue), StartWidth, EndWidth, scale.Position, GetGauge().GetOrientation(), DistanceFromScale, Placement, scale.Width);

            if (getShadowPath)
            {
                using (Matrix matrix = new Matrix())
                {
                    matrix.Translate(base.ShadowOffset, base.ShadowOffset);
                    linearRangePath.Transform(matrix);
                    return(linearRangePath);
                }
            }
            return(linearRangePath);
        }
        internal BarStyleAttrib GetThermometerStyleAttrib(GaugeGraphics g)
        {
            BarStyleAttrib barStyleAttrib = new BarStyleAttrib();

            if (Image != "")
            {
                return(barStyleAttrib);
            }
            LinearScale scale = GetScale();
            double      num   = scale.GetValueLimit(GetBarStartValue());

            if ((Type == LinearPointerType.Thermometer || BarStart == BarStart.ScaleStart) && num > scale.MinimumLog)
            {
                num = scale.MinimumLog;
            }
            double valueLimit         = scale.GetValueLimit(base.Position);
            float  positionFromValue  = scale.GetPositionFromValue(num);
            float  positionFromValue2 = scale.GetPositionFromValue(valueLimit);
            float  num2              = positionFromValue2 - positionFromValue;
            float  width             = Width;
            float  bulbSize          = ThermometerBulbSize;
            float  bulbOffset        = thermometerBulbOffset;
            float  distanceFromScale = DistanceFromScale;

            if (Math.Round(num2, 4) == 0.0 && Type != LinearPointerType.Thermometer)
            {
                return(barStyleAttrib);
            }
            double num3 = scale.GetValueLimit(double.PositiveInfinity);

            if (num3 < scale.Maximum)
            {
                num3 = scale.Maximum;
            }
            float positionFromValue3 = scale.GetPositionFromValue(num3);

            barStyleAttrib.primaryPath = g.GetThermometerPath(positionFromValue, positionFromValue2, width, scale.Position, GetGauge().GetOrientation(), distanceFromScale, Placement, scale.GetReversed(), scale.Width, bulbOffset, bulbSize, ThermometerStyle);
            if (barStyleAttrib.primaryPath == null)
            {
                return(barStyleAttrib);
            }
            barStyleAttrib.totalPath    = g.GetThermometerPath(positionFromValue, positionFromValue3, Width, scale.Position, GetGauge().GetOrientation(), DistanceFromScale, Placement, scale.GetReversed(), scale.Width, ThermometerBulbOffset, ThermometerBulbSize, ThermometerStyle);
            barStyleAttrib.totalBrush   = g.GetLinearRangeBrush(barStyleAttrib.totalPath.GetBounds(), ThermometerBackColor, ThermometerBackHatchStyle, (RangeGradientType)Enum.Parse(typeof(RangeGradientType), ThermometerBackGradientType.ToString()), ThermometerBackGradientEndColor, GetGauge().GetOrientation(), GetScale().GetReversed(), 0.0, 0.0);
            barStyleAttrib.primaryBrush = g.GetLinearRangeBrush(barStyleAttrib.primaryPath.GetBounds(), FillColor, FillHatchStyle, (RangeGradientType)Enum.Parse(typeof(RangeGradientType), FillGradientType.ToString()), FillGradientEndColor, GetGauge().GetOrientation(), GetScale().GetReversed(), 0.0, 0.0);
            LinearRange[] colorRanges = GetColorRanges();
            if (colorRanges != null)
            {
                barStyleAttrib.secondaryPaths   = new GraphicsPath[colorRanges.Length];
                barStyleAttrib.secondaryBrushes = new Brush[colorRanges.Length];
                int           num4  = 0;
                LinearRange[] array = colorRanges;
                foreach (LinearRange linearRange in array)
                {
                    double num5 = scale.GetValueLimit(linearRange.StartValue);
                    if (num5 < num)
                    {
                        num5 = num;
                    }
                    if (num5 > valueLimit)
                    {
                        num5 = valueLimit;
                    }
                    double num6 = scale.GetValueLimit(linearRange.EndValue);
                    if (num6 < num)
                    {
                        num6 = num;
                    }
                    if (num6 > valueLimit)
                    {
                        num6 = valueLimit;
                    }
                    float positionFromValue4 = scale.GetPositionFromValue(num5);
                    float positionFromValue5 = scale.GetPositionFromValue(num6);
                    if (Math.Round(positionFromValue5 - positionFromValue4, 4) == 0.0)
                    {
                        barStyleAttrib.secondaryPaths[num4]   = null;
                        barStyleAttrib.secondaryBrushes[num4] = null;
                    }
                    else
                    {
                        barStyleAttrib.secondaryPaths[num4]   = g.GetLinearRangePath(positionFromValue4, positionFromValue5, width, width, scale.Position, GetGauge().GetOrientation(), distanceFromScale, Placement, scale.Width);
                        barStyleAttrib.secondaryBrushes[num4] = g.GetLinearRangeBrush(barStyleAttrib.primaryPath.GetBounds(), linearRange.InRangeBarPointerColor, FillHatchStyle, (RangeGradientType)Enum.Parse(typeof(RangeGradientType), FillGradientType.ToString()), FillGradientEndColor, GetGauge().GetOrientation(), GetScale().GetReversed(), 0.0, 0.0);
                    }
                    num4++;
                }
            }
            return(barStyleAttrib);
        }
        internal BarStyleAttrib GetBarStyleAttrib(GaugeGraphics g)
        {
            BarStyleAttrib barStyleAttrib = new BarStyleAttrib();

            if (Image != "")
            {
                return(barStyleAttrib);
            }
            LinearScale scale = GetScale();
            double      num   = scale.GetValueLimit(GetBarStartValue());

            if ((Type == LinearPointerType.Thermometer || BarStart == BarStart.ScaleStart) && num > scale.Minimum)
            {
                num = scale.Minimum;
            }
            double valueLimit        = scale.GetValueLimit(base.Position);
            float  positionFromValue = scale.GetPositionFromValue(num);

            _ = ThermometerBulbOffset;
            float positionFromValue2 = scale.GetPositionFromValue(valueLimit);

            if (Math.Round(positionFromValue2 - positionFromValue, 4) == 0.0)
            {
                return(barStyleAttrib);
            }
            if (base.BarStyle == BarStyle.Style1)
            {
                barStyleAttrib.primaryPath = g.GetLinearRangePath(positionFromValue, positionFromValue2, Width, Width, scale.Position, GetGauge().GetOrientation(), DistanceFromScale, Placement, scale.Width);
                if (barStyleAttrib.primaryPath == null)
                {
                    return(barStyleAttrib);
                }
                barStyleAttrib.primaryBrush = g.GetLinearRangeBrush(barStyleAttrib.primaryPath.GetBounds(), FillColor, FillHatchStyle, (RangeGradientType)Enum.Parse(typeof(RangeGradientType), FillGradientType.ToString()), FillGradientEndColor, GetGauge().GetOrientation(), GetScale().GetReversed(), 0.0, 0.0);
                LinearRange[] colorRanges = GetColorRanges();
                if (colorRanges != null)
                {
                    barStyleAttrib.secondaryPaths   = new GraphicsPath[colorRanges.Length];
                    barStyleAttrib.secondaryBrushes = new Brush[colorRanges.Length];
                    int           num2  = 0;
                    LinearRange[] array = colorRanges;
                    foreach (LinearRange linearRange in array)
                    {
                        double num3 = scale.GetValueLimit(linearRange.StartValue);
                        if (num3 < num)
                        {
                            num3 = num;
                        }
                        if (num3 > valueLimit)
                        {
                            num3 = valueLimit;
                        }
                        double num4 = scale.GetValueLimit(linearRange.EndValue);
                        if (num4 < num)
                        {
                            num4 = num;
                        }
                        if (num4 > valueLimit)
                        {
                            num4 = valueLimit;
                        }
                        float positionFromValue3 = scale.GetPositionFromValue(num3);
                        float positionFromValue4 = scale.GetPositionFromValue(num4);
                        if (Math.Round(positionFromValue4 - positionFromValue3, 4) == 0.0)
                        {
                            barStyleAttrib.secondaryPaths[num2]   = null;
                            barStyleAttrib.secondaryBrushes[num2] = null;
                        }
                        else
                        {
                            barStyleAttrib.secondaryPaths[num2]   = g.GetLinearRangePath(positionFromValue3, positionFromValue4, Width, Width, scale.Position, GetGauge().GetOrientation(), DistanceFromScale, Placement, scale.Width);
                            barStyleAttrib.secondaryBrushes[num2] = g.GetLinearRangeBrush(barStyleAttrib.primaryPath.GetBounds(), linearRange.InRangeBarPointerColor, FillHatchStyle, (RangeGradientType)Enum.Parse(typeof(RangeGradientType), FillGradientType.ToString()), FillGradientEndColor, GetGauge().GetOrientation(), GetScale().GetReversed(), 0.0, 0.0);
                        }
                        num2++;
                    }
                }
            }
            return(barStyleAttrib);
        }
Example #12
0
 public int IndexOf(LinearScale value)
 {
     return(base.List.IndexOf(value));
 }
Example #13
0
 public void Insert(int index, LinearScale value)
 {
     base.List.Insert(index, value);
 }
Example #14
0
 public bool Contains(LinearScale value)
 {
     return(base.List.Contains(value));
 }
Example #15
0
 public void Remove(LinearScale value)
 {
     base.List.Remove(value);
 }
Example #16
0
 public int Add(LinearScale value)
 {
     return(base.List.Add(value));
 }