示例#1
0
        /// <summary>
        /// Calculate the values needed to properly display this <see c_ref="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="ggn">The <see c_ref="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;
 }
示例#3
0
        /// <summary>
        /// Calculate the <see c_ref="RectangleF"/> that will be used to define the bounding rectangle of
        /// the GasGaugeNeedle.
        /// </summary>
        /// <remarks>This rectangle always lies inside of the <see c_ref="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 c_ref="ZedGraph.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 c_ref="ZedGraph.GraphPane"/> object using the
        /// <see c_ref="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 c_ref="RectangleF"/> (normally the <see c_ref="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(-0.05F * nonExpRect.Height, -(float)0.05 * nonExpRect.Width);

            CalculateGasGaugeParameters(pane);

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

            return(nonExpRect);
        }
示例#4
0
		/// <summary>
		/// The Copy Constructor
		/// </summary>
		/// <param name="ggn">The <see c_ref="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;
		}