Пример #1
0
        /// <summary>
        /// Calculate the values needed to properly display this <see cref="GasGaugeNeedle"/>.
        /// </summary>
        /// <param name="pane">
        /// A graphic device object to be drawn into. This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        public static void CalculateGasGaugeParameters(GraphPane pane)
        {
            //loop thru slices and get total value and maxDisplacement
            double minVal = double.MaxValue;
            double maxVal = double.MinValue;

            foreach (CurveItem curve in pane.CurveList)
            {
                if (curve is GasGaugeRegion)
                {
                    GasGaugeRegion ggr = (GasGaugeRegion)curve;
                    if (maxVal < ggr.MaxValue)
                    {
                        maxVal = ggr.MaxValue;
                    }

                    if (minVal > ggr.MinValue)
                    {
                        minVal = ggr.MinValue;
                    }
                }
            }

            //Set Needle Sweep angle values here based on the min and max values of the GasGuage
            foreach (CurveItem curve in pane.CurveList)
            {
                if (curve is GasGaugeNeedle)
                {
                    GasGaugeNeedle ggn   = (GasGaugeNeedle)curve;
                    float          sweep = ((float)ggn.NeedleValue - (float)minVal) /
                                           ((float)maxVal - (float)minVal) * 180.0f;
                    ggn.SweepAngle = sweep;
                }
            }
        }
Пример #2
0
 /// <summary>
 /// The Copy Constructor
 /// </summary>
 /// <param name="ggr">The <see cref="GasGaugeRegion"/> object from which to copy</param>
 public GasGaugeRegion(GasGaugeRegion ggr)
     : base(ggr)
 {
     _minValue    = ggr._minValue;
     _maxValue    = ggr._maxValue;
     _color       = ggr._color;
     _startAngle  = ggr._startAngle;
     _sweepAngle  = ggr._sweepAngle;
     _border      = ggr._border.Clone();
     _labelDetail = ggr._labelDetail.Clone();
 }
Пример #3
0
        /// <summary>
        /// Calculate the values needed to properly display this <see cref="GasGaugeRegion"/>.
        /// </summary>
        /// <param name="pane">
        /// A graphic device object to be drawn into. This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        public static void CalculateGasGuageParameters(GraphPane pane)
        {
            //loop thru slices and get total value and maxDisplacement
            double minVal = double.MaxValue;
            double maxVal = double.MinValue;

            foreach (CurveItem curve in pane.CurveList)
            {
                if (curve is GasGaugeRegion)
                {
                    GasGaugeRegion ggr = (GasGaugeRegion)curve;
                    if (maxVal < ggr.MaxValue)
                    {
                        maxVal = ggr.MaxValue;
                    }

                    if (minVal > ggr.MinValue)
                    {
                        minVal = ggr.MinValue;
                    }
                }
            }

            //Calculate start and sweep angles for each of the GasGaugeRegion based on teh min and max value
            foreach (CurveItem curve in pane.CurveList)
            {
                if (curve is GasGaugeRegion)
                {
                    GasGaugeRegion ggr   = (GasGaugeRegion)curve;
                    float          start = ((float)ggr.MinValue - (float)minVal) / ((float)maxVal - (float)minVal) * 180.0f;
                    float          sweep = ((float)ggr.MaxValue - (float)minVal) / ((float)maxVal - (float)minVal) * 180.0f;
                    sweep = sweep - start;

                    Fill f = new Fill(Color.White, ggr.RegionColor, -(sweep / 2f));
                    ggr.Fill = f;

                    ggr.StartAngle = start;
                    ggr.SweepAngle = sweep;
                }
            }
        }
Пример #4
0
        /// <summary>
        /// Calculate the <see cref="RectangleF"/> that will be used to define the bounding rectangle of
        /// the GasGaugeNeedle.
        /// </summary>
        /// <remarks>This rectangle always lies inside of the <see cref="Chart.Rect"/>, and it is
        /// normally a square so that the pie itself is not oval-shaped.</remarks>
        /// <param name="g">
        /// A graphic device object to be drawn into. This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="GraphPane"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects. This is calculated and
        /// passed down by the parent <see cref="GraphPane"/> object using the
        /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        /// <param name="chartRect">The <see cref="RectangleF"/> (normally the <see cref="Chart.Rect"/>)
        /// that bounds this pie.</param>
        /// <returns></returns>
        public static RectangleF CalcRectangle(Graphics g, GraphPane pane, float scaleFactor, RectangleF chartRect)
        {
            RectangleF nonExpRect = chartRect;

            if ((2 * nonExpRect.Height) > nonExpRect.Width)
            {
                //Scale based on width
                float percentS = ((nonExpRect.Height * 2) - nonExpRect.Width) / (nonExpRect.Height * 2);
                nonExpRect.Height = ((nonExpRect.Height * 2) - ((nonExpRect.Height * 2) * percentS));
            }
            else
            {
                nonExpRect.Height = nonExpRect.Height * 2;
            }

            nonExpRect.Width = nonExpRect.Height;

            float xDelta = (chartRect.Width / 2) - (nonExpRect.Width / 2);

            //Align Horizontally
            nonExpRect.X += xDelta;
            //nonExpRect.Y += -(float)0.025F * nonExpRect.Height;
            //nonExpRect.Y += ((chartRect.Height) - (nonExpRect.Height / 2)) - 10.0f;

            nonExpRect.Inflate(-(float)0.05F * nonExpRect.Height, -(float)0.05 * nonExpRect.Width);

            GasGaugeRegion.CalculateGasGuageParameters(pane);

            foreach (CurveItem curve in pane.CurveList)
            {
                if (curve is GasGaugeRegion)
                {
                    GasGaugeRegion gg = (GasGaugeRegion)curve;
                    gg._boundingRectangle = nonExpRect;
                }
            }

            return(nonExpRect);
        }