Exemple #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GasGaugeRegion"/> class. 
 /// Create a new <see cref="GasGaugeRegion"/>
 /// </summary>
 /// <param name="label">
 /// The value associated with this <see cref="GasGaugeRegion"/> instance.
 /// </param>
 /// <param name="minVal">
 /// The minimum value of this <see cref="GasGaugeNeedle"/>.
 /// </param>
 /// <param name="maxVal">
 /// The maximum value of this <see cref="GasGaugeNeedle"/>.
 /// </param>
 /// <param name="color">
 /// The display color for this <see cref="GasGaugeRegion"/> instance.
 /// </param>
 public GasGaugeRegion(string label, double minVal, double maxVal, Color color)
     : base(label)
 {
     this.MinValue = minVal;
     this.MaxValue = maxVal;
     this.RegionColor = color;
     this.StartAngle = 0f;
     this.SweepAngle = 0f;
     this._border = new Border(Default.BorderColor, Default.BorderWidth);
     this._labelDetail = new TextObj();
     this._labelDetail.FontSpec.Size = Default.FontSize;
     this._slicePath = null;
 }
Exemple #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GasGaugeRegion"/> class. 
 /// The Copy Constructor
 /// </summary>
 /// <param name="ggr">
 /// The <see cref="GasGaugeRegion"/> object from which to copy
 /// </param>
 public GasGaugeRegion(GasGaugeRegion ggr)
     : base(ggr)
 {
     this._minValue = ggr._minValue;
     this._maxValue = ggr._maxValue;
     this._color = ggr._color;
     this._startAngle = ggr._startAngle;
     this._sweepAngle = ggr._sweepAngle;
     this._border = ggr._border.Clone();
     this._labelDetail = ggr._labelDetail.Clone();
 }
Exemple #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GasGaugeRegion"/> class. 
        /// Constructor for deserializing objects
        /// </summary>
        /// <param name="info">
        /// A <see cref="SerializationInfo"/> instance that defines the serialized data
        /// </param>
        /// <param name="context">
        /// A <see cref="StreamingContext"/> instance that contains the serialized data
        /// </param>
        protected GasGaugeRegion(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
            // The schema value is just a file version parameter. You can use it to make future versions
            // backwards compatible as new member variables are added to classes
            int sch = info.GetInt32("schema2");

            this._labelDetail = (TextObj)info.GetValue("labelDetail", typeof(TextObj));
            this._fill = (Fill)info.GetValue("fill", typeof(Fill));
            this._border = (Border)info.GetValue("border", typeof(Border));
            this._color = (Color)info.GetValue("color", typeof(Color));
            this._minValue = info.GetDouble("minValue");
            this._maxValue = info.GetDouble("maxValue");
            this._startAngle = (float)info.GetDouble("startAngle");
            this._sweepAngle = (float)info.GetDouble("sweepAngle");
            this._boundingRectangle = (RectangleF)info.GetValue("boundingRectangle", typeof(RectangleF));
            this._slicePath = (GraphicsPath)info.GetValue("slicePath", typeof(GraphicsPath));
        }
Exemple #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PieItem"/> class. 
        /// Constructor for deserializing objects
        /// </summary>
        /// <param name="info">
        /// A <see cref="SerializationInfo"/> instance that defines the serialized data
        /// </param>
        /// <param name="context">
        /// A <see cref="StreamingContext"/> instance that contains the serialized data
        /// </param>
        protected PieItem(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
            // The schema value is just a file version parameter.  You can use it to make future versions
            // backwards compatible as new member variables are added to classes
            int sch = info.GetInt32("schema2");

            this._displacement = info.GetDouble("displacement");
            this._labelDetail = (TextObj)info.GetValue("labelDetail", typeof(TextObj));
            this._fill = (Fill)info.GetValue("fill", typeof(Fill));
            this._border = (Border)info.GetValue("border", typeof(Border));
            this._pieValue = info.GetDouble("pieValue");
            this._labelType = (PieLabelType)info.GetValue("labelType", typeof(PieLabelType));
            this._intersectionPoint = (PointF)info.GetValue("intersectionPoint", typeof(PointF));
            this._boundingRectangle = (RectangleF)info.GetValue("boundingRectangle", typeof(RectangleF));
            this._pivotPoint = (PointF)info.GetValue("pivotPoint", typeof(PointF));
            this._endPoint = (PointF)info.GetValue("endPoint", typeof(PointF));

            // _slicePath = (GraphicsPath)info.GetValue( "slicePath", typeof( GraphicsPath ) );
            this._startAngle = (float)info.GetDouble("startAngle");
            this._sweepAngle = (float)info.GetDouble("sweepAngle");
            this._midAngle = (float)info.GetDouble("midAngle");
            this._labelStr = info.GetString("labelStr");
            this._valueDecimalDigits = info.GetInt32("valueDecimalDigits");
            this._percentDecimalDigits = info.GetInt32("percentDecimalDigits");
        }
Exemple #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextObj"/> class. 
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">
 /// The <see cref="TextObj"/> object from which to copy
 /// </param>
 public TextObj(TextObj rhs)
     : base(rhs)
 {
     this._text = rhs.Text;
     this._fontSpec = new FontSpec(rhs.FontSpec);
 }
Exemple #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PieItem"/> class. 
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">
 /// The <see cref="PieItem"/> object from which to copy
 /// </param>
 public PieItem(PieItem rhs)
     : base(rhs)
 {
     this._pieValue = rhs._pieValue;
     this._fill = rhs._fill.Clone();
     this.Border = rhs._border.Clone();
     this._displacement = rhs._displacement;
     this._labelDetail = rhs._labelDetail.Clone();
     this._labelType = rhs._labelType;
     this._valueDecimalDigits = rhs._valueDecimalDigits;
     this._percentDecimalDigits = rhs._percentDecimalDigits;
 }
Exemple #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PieItem"/> class. 
 /// Create a new <see cref="PieItem"/>.
 /// </summary>
 /// <param name="pieValue">
 /// The value associated with this <see cref="PieItem"/> instance.
 /// </param>
 /// <param name="color">
 /// The display color for this <see cref="PieItem"/> instance.
 /// </param>
 /// <param name="displacement">
 /// The amount this <see cref="PieItem"/>  instance will be displaced from the center point.
 /// </param>
 /// <param name="label">
 /// Text label for this <see cref="PieItem"/> instance.
 /// </param>
 public PieItem(double pieValue, Color color, double displacement, string label)
     : base(label)
 {
     this._pieValue = pieValue;
     this._fill = new Fill(color.IsEmpty ? _rotator.NextColor : color);
     this._displacement = displacement;
     this._border = new Border(Default.BorderColor, Default.BorderWidth);
     this._labelDetail = new TextObj();
     this._labelDetail.FontSpec.Size = Default.FontSize;
     this._labelType = Default.LabelType;
     this._valueDecimalDigits = Default.ValueDecimalDigits;
     this._percentDecimalDigits = Default.PercentDecimalDigits;
     this._slicePath = null;
 }
Exemple #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GasGaugeNeedle"/> class. 
 /// Create a new <see cref="GasGaugeNeedle"/>
 /// </summary>
 /// <param name="label">
 /// The value associated with this <see cref="GasGaugeNeedle"/>
 /// instance.
 /// </param>
 /// <param name="val">
 /// The value of this <see cref="GasGaugeNeedle"/>.
 /// </param>
 /// <param name="color">
 /// The display color for this <see cref="GasGaugeNeedle"/>
 /// instance.
 /// </param>
 public GasGaugeNeedle(string label, double val, Color color)
     : base(label)
 {
     this.NeedleValue = val;
     this.NeedleColor = color;
     this.NeedleWidth = Default.NeedleWidth;
     this.SweepAngle = 0f;
     this._border = new Border(Default.BorderColor, Default.BorderWidth);
     this._labelDetail = new TextObj();
     this._labelDetail.FontSpec.Size = Default.FontSize;
     this._slicePath = null;
 }
Exemple #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GasGaugeNeedle"/> class. 
 /// The Copy Constructor
 /// </summary>
 /// <param name="ggn">
 /// The <see cref="GasGaugeNeedle"/> object from which to copy
 /// </param>
 public GasGaugeNeedle(GasGaugeNeedle ggn)
     : base(ggn)
 {
     this.NeedleValue = ggn.NeedleValue;
     this.NeedleColor = ggn.NeedleColor;
     this.NeedleWidth = ggn.NeedleWidth;
     this.SweepAngle = ggn.SweepAngle;
     this._border = ggn.Border.Clone();
     this._labelDetail = ggn.LabelDetail.Clone();
     this._labelDetail.FontSpec.Size = ggn.LabelDetail.FontSpec.Size;
 }
Exemple #10
0
        /// <summary>
        /// Create a <see cref="TextObj"/> for each bar in the <see cref="GraphPane"/>.
        /// </summary>
        /// <remarks>
        /// This method will go through the bars, create a label that corresponds to the bar value, and place it on the graph depending on user preferences.
        /// This works for horizontal or vertical bars in clusters or stacks, but only for <see cref="BarItem"/> types.  This method does not apply to
        /// <see cref="ErrorBarItem"/> or <see cref="HiLowBarItem"/> objects. Call this method only after calling <see cref="GraphPane.AxisChange()"/>.
        /// </remarks>
        /// <param name="pane">
        /// The GraphPane in which to place the text labels.
        /// </param>
        /// <param name="isBarCenter">
        /// true to center the labels inside the bars, false to place the labels just above the top of the bar.
        /// </param>
        /// <param name="valueFormat">
        /// The double.ToString string format to use for creating the labels.
        /// </param>
        /// <param name="fontFamily">
        /// The string name of the font family to use for the labels
        /// </param>
        /// <param name="fontSize">
        /// The floating point size of the font, in scaled points
        /// </param>
        /// <param name="fontColor">
        /// The color in which to draw the labels
        /// </param>
        /// <param name="isBold">
        /// true for a bold font type, false otherwise
        /// </param>
        /// <param name="isItalic">
        /// true for an italic font type, false otherwise
        /// </param>
        /// <param name="isUnderline">
        /// true for an underline font type, false otherwise
        /// </param>
        public static void CreateBarLabels(
            GraphPane pane, 
            bool isBarCenter, 
            string valueFormat, 
            string fontFamily, 
            float fontSize, 
            Color fontColor, 
            bool isBold, 
            bool isItalic, 
            bool isUnderline)
        {
            bool isVertical = pane.BarSettings.Base == BarBase.X;

            // keep a count of the number of BarItems
            int curveIndex = 0;

            // Get a valuehandler to do some calculations for us
            ValueHandler valueHandler = new ValueHandler(pane, true);

            // Loop through each curve in the list
            foreach (CurveItem curve in pane.CurveList)
            {
                // work with BarItems only
                BarItem bar = curve as BarItem;
                if (bar != null)
                {
                    IPointList points = curve.Points;

                    // ADD JKB 9/21/07
                    // The labelOffset should depend on whether the curve is YAxis or Y2Axis.
                    // JHC - Generalize to any value axis
                    // Make the gap between the bars and the labels = 1.5% of the axis range
                    float labelOffset;

                    Scale scale = curve.ValueAxis(pane).Scale;
                    labelOffset = (float)(scale._max - scale._min) * 0.015f;

                    // Loop through each point in the BarItem
                    for (int i = 0; i < points.Count; i++)
                    {
                        // Get the high, low and base values for the current bar
                        // note that this method will automatically calculate the "effective"
                        // values if the bar is stacked
                        double baseVal, lowVal, hiVal;
                        valueHandler.GetValues(curve, i, out baseVal, out lowVal, out hiVal);

                        // Get the value that corresponds to the center of the bar base
                        // This method figures out how the bars are positioned within a cluster
                        float centerVal = (float)valueHandler.BarCenterValue(bar, bar.GetBarWidth(pane), i, baseVal, curveIndex);

                        // Create a text label -- note that we have to go back to the original point
                        // data for this, since hiVal and lowVal could be "effective" values from a bar stack
                        string barLabelText = (isVertical ? points[i].Y : points[i].X).ToString(valueFormat);

                        // Calculate the position of the label -- this is either the X or the Y coordinate
                        // depending on whether they are horizontal or vertical bars, respectively
                        float position;
                        if (isBarCenter)
                        {
                            position = (float)(hiVal + lowVal) / 2.0f;
                        }
                        else if (hiVal >= 0)
                        {
                            position = (float)hiVal + labelOffset;
                        }
                        else
                        {
                            position = (float)hiVal - labelOffset;
                        }

                        // Create the new TextObj
                        TextObj label;
                        if (isVertical)
                        {
                            label = new TextObj(barLabelText, centerVal, position);
                        }
                        else
                        {
                            label = new TextObj(barLabelText, position, centerVal);
                        }

                        label.FontSpec.Family = fontFamily;

                        // Configure the TextObj

                        // CHANGE JKB 9/21/07
                        // CoordinateFrame should depend on whether curve is YAxis or Y2Axis.
                        label.Location.CoordinateFrame = (isVertical && curve.IsY2Axis) ? CoordType.AxisXY2Scale : CoordType.AxisXYScale;

                        label.FontSpec.Size = fontSize;
                        label.FontSpec.FontColor = fontColor;
                        label.FontSpec.IsItalic = isItalic;
                        label.FontSpec.IsBold = isBold;
                        label.FontSpec.IsUnderline = isUnderline;

                        label.FontSpec.Angle = isVertical ? 90 : 0;
                        label.Location.AlignH = isBarCenter ? AlignH.Center : (hiVal >= 0 ? AlignH.Left : AlignH.Right);
                        label.Location.AlignV = AlignV.Center;
                        label.FontSpec.Border.IsVisible = false;
                        label.FontSpec.Fill.IsVisible = false;

                        // Add the TextObj to the GraphPane
                        pane.GraphObjList.Add(label);
                    }

                    curveIndex++;
                }
            }
        }