Example #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;
                }
            }
        }
Example #2
0
 /// <summary>
 /// The Copy Constructor
 /// </summary>
 /// <param name="ggn">The <see cref="GasGaugeNeedle"/> object from which to copy</param>
 public GasGaugeNeedle(GasGaugeNeedle ggn)
     : base(ggn)
 {
     NeedleValue  = ggn.NeedleValue;
     NeedleColor  = ggn.NeedleColor;
     NeedleWidth  = ggn.NeedleWidth;
     SweepAngle   = ggn.SweepAngle;
     _border      = ggn.Border.Clone();
     _labelDetail = ggn.LabelDetail.Clone();
     _labelDetail.FontSpec.Size = ggn.LabelDetail.FontSpec.Size;
 }
Example #3
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.Inflate(-(float)0.05F * nonExpRect.Height, -(float)0.05 * nonExpRect.Width);

            GasGaugeNeedle.CalculateGasGaugeParameters(pane);

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

            return(nonExpRect);
        }
Example #4
0
 /// <summary>
 /// The Copy Constructor
 /// </summary>
 /// <param name="ggn">The <see cref="GasGaugeNeedle"/> object from which to copy</param>
 public GasGaugeNeedle( GasGaugeNeedle ggn )
     : base(ggn)
 {
     NeedleValue = ggn.NeedleValue;
     NeedleColor = ggn.NeedleColor;
     NeedleWidth = ggn.NeedleWidth;
     SweepAngle = ggn.SweepAngle;
     _border = ggn.Border.Clone();
     _labelDetail = ggn.LabelDetail.Clone();
     _labelDetail.FontSpec.Size = ggn.LabelDetail.FontSpec.Size;
 }