Ejemplo n.º 1
0
        /// <summary>
        /// Create a fill brush using current properties.  This method will construct a brush based on the
        /// settings of <see cref="Fill.Type"/>, <see cref="Fill.Color"/>
        /// and <see cref="Fill.Brush"/>.  If
        /// <see cref="Fill.Type"/> is set to <see cref="FillType.Brush"/> and
        /// <see cref="Fill.Brush"/>
        /// is null, then a <see cref="LinearGradientBrush"/> will be created between the colors of
        /// <see cref="System.Drawing.Color.White"/> and <see cref="Fill.Color"/>.
        /// </summary>
        /// <param name="rect">A rectangle that bounds the object to be filled.  This determines
        /// the start and end of the gradient fill.</param>
        /// <param name="dataValue">The data value to be used for a value-based
        /// color gradient.  This is only applicable for <see cref="FillType.GradientByX"/>,
        /// <see cref="FillType.GradientByY"/> or <see cref="FillType.GradientByZ"/>.</param>
        /// <returns>A <see cref="System.Drawing.Brush"/> class representing the fill brush</returns>
        public Brush MakeBrush( RectangleF rect, PointPair dataValue )
        {
            // get a brush
            if ( this.IsVisible && ( !_color.IsEmpty || _brush != null ) )
            {
                if ( rect.Height < 1.0F )
                    rect.Height = 1.0F;
                if ( rect.Width < 1.0F )
                    rect.Width = 1.0F;

                //Brush	brush;
                if ( _type == FillType.Brush )
                {
                    return ScaleBrush( rect, _brush, _isScaled );
                }
                else if ( IsGradientValueType )
                {
                    if ( dataValue != null )
                    {
                        if ( !_secondaryValueGradientColor.IsEmpty )
                        {
                            // Go ahead and create a new Fill so we can do all the scaling, etc.,
                            // that is associated with a gradient
                            Fill tmpFill = new Fill( _secondaryValueGradientColor,
                                    GetGradientColor( dataValue ), _angle );
                            return tmpFill.MakeBrush( rect );
                        }
                        else
                            return new SolidBrush( GetGradientColor( dataValue ) );
                    }
                    else if ( _rangeDefault != double.MaxValue )
                    {
                        if ( !_secondaryValueGradientColor.IsEmpty )
                        {
                            // Go ahead and create a new Fill so we can do all the scaling, etc.,
                            // that is associated with a gradient
                            Fill tmpFill = new Fill( _secondaryValueGradientColor,
                                    GetGradientColor( _rangeDefault ), _angle );
                            return tmpFill.MakeBrush( rect );
                        }
                        else
                            return new SolidBrush( GetGradientColor( _rangeDefault ) );
                    }
                    else
                        return ScaleBrush( rect, _brush, true );
                }
                else
                    return new SolidBrush( _color );
            }

            // Always return a suitable default
            return new SolidBrush( Color.White );
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Constructor that sets the color property to the specified value, and sets
 /// the remaining <see cref="LineBase"/> properties to default
 /// values as defined in the <see cref="Default"/> class.
 /// </summary>
 /// <param name="color">The color to assign to this new Line object</param>
 public LineBase( Color color )
 {
     _width = Default.Width;
     _style = Default.Style;
     _dashOn = Default.DashOn;
     _dashOff = Default.DashOff;
     _isVisible = Default.IsVisible;
     _color = color.IsEmpty ? Default.Color : color;
     _isAntiAlias = Default.IsAntiAlias;
     _gradientFill = new Fill( Color.Red, Color.White );
     _gradientFill.Type = FillType.None;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 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 BoxObj( 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" );

            _fill = (Fill) info.GetValue( "fill", typeof(Fill) );
            _border = (Border) info.GetValue( "border", typeof(Border) );
        }
Ejemplo n.º 4
0
        /// <summary>
        /// The Copy Constructor
        /// </summary>
        /// <param name="rhs">The Fill object from which to copy</param>
        public Fill( Fill rhs )
        {
            _color = rhs._color;
            _secondaryValueGradientColor = rhs._color;

            if ( rhs._brush != null )
                _brush = (Brush) rhs._brush.Clone();
            else
                _brush = null;
            _type = rhs._type;
            _alignH = rhs.AlignH;
            _alignV = rhs.AlignV;
            _isScaled = rhs.IsScaled;
            _rangeMin = rhs._rangeMin;
            _rangeMax = rhs._rangeMax;
            _rangeDefault = rhs._rangeDefault;
            _gradientBM = null;

            if ( rhs._colorList != null )
                _colorList = (Color[]) rhs._colorList.Clone();
            else
                _colorList = null;

            if ( rhs._positionList != null )
            {
                _positionList = (float[]) rhs._positionList.Clone();
            }
            else
                _positionList = null;

            if ( rhs._image != null )
                _image = (Image) rhs._image.Clone();
            else
                _image = null;

            _angle = rhs._angle;
            _wrapMode = rhs._wrapMode;
        }
Ejemplo n.º 5
0
 /// <summary>
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">The <see cref="PieItem"/> object from which to copy</param>
 public PieItem( PieItem rhs )
     : base(rhs)
 {
     _pieValue = rhs._pieValue;
     _fill = rhs._fill.Clone();
     this.Border = rhs._border.Clone();
     _displacement = rhs._displacement;
     _labelDetail = rhs._labelDetail.Clone();
     _labelType = rhs._labelType;
     _valueDecimalDigits = rhs._valueDecimalDigits;
     _percentDecimalDigits = rhs._percentDecimalDigits;
 }
Ejemplo n.º 6
0
        /// <summary>
        /// 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 GasGaugeNeedle( 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" );

            _labelDetail = (TextObj)info.GetValue( "labelDetail", typeof( TextObj ) );
            _fill = (Fill)info.GetValue( "fill", typeof( Fill ) );
            _border = (Border)info.GetValue( "border", typeof( Border ) );
            _needleValue = info.GetDouble( "needleValue" );
            _boundingRectangle = (RectangleF)info.GetValue( "boundingRectangle", typeof( RectangleF ) );
            _slicePath = (GraphicsPath)info.GetValue( "slicePath", typeof( GraphicsPath ) );
            _sweepAngle = (float)info.GetDouble( "sweepAngle" );
            _color = (Color)info.GetValue( "color", typeof( Color ) );
        }
Ejemplo n.º 7
0
        /// <summary>
        /// The Copy Constructor
        /// </summary>
        /// <param name="rhs">The Symbol object from which to copy</param>
        public Symbol( Symbol rhs )
        {
            _size = rhs.Size;
            _type = rhs.Type;
            _isAntiAlias = rhs._isAntiAlias;
            _isVisible = rhs.IsVisible;
            _fill = rhs.Fill.Clone();
            _border = rhs.Border.Clone();

            if ( rhs.UserSymbol != null )
                _userSymbol = rhs.UserSymbol.Clone() as GraphicsPath;
            else
                _userSymbol = null;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Create a new <see cref="PieItem"/>, providing a gradient fill for the pie color.
        /// </summary>
        /// <param name="pieValue">The value associated with this <see cref="PieItem"/> instance.</param>
        /// <param name="color1">The starting display color for the gradient <see cref="Fill"/> for this
        /// <see cref="PieItem"/> instance.</param>
        /// <param name="color2">The ending display color for the gradient <see cref="Fill"/> for this
        /// <see cref="PieItem"/> instance.</param>
        /// <param name="fillAngle">The angle for the gradient <see cref="Fill"/>.</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 color1, Color color2, float fillAngle,
						double displacement, string label )
            : this(pieValue, color1, displacement, label)
        {
            if ( !color1.IsEmpty && !color2.IsEmpty )
                _fill = new Fill( color1, color2, fillAngle );
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Default constructor that sets all <see cref="JapaneseCandleStick"/> properties to
        /// default values as defined in the <see cref="Default"/> class.
        /// </summary>
        public JapaneseCandleStick()
            : base()
        {
            _risingFill = new Fill( Default.RisingColor );
            _fallingFill = new Fill( Default.FallingColor );

            _risingBorder = new Border( Default.RisingBorder, LineBase.Default.Width );
            _fallingBorder = new Border( Default.FallingBorder, LineBase.Default.Width );

            _fallingColor = Default.FallingColor;
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Default constructor that sets the <see cref="SymbolType"/> and
 /// <see cref="Color"/> as specified, and the remaining
 /// <see cref="Symbol"/> properties to default
 /// values as defined in the <see cref="Default"/> class.
 /// </summary>
 /// <param name="type">A <see cref="SymbolType"/> enum value
 /// indicating the shape of the symbol</param>
 /// <param name="color">A <see cref="Color"/> value indicating
 /// the color of the symbol
 /// </param>
 public Symbol( SymbolType type, Color color )
 {
     _size = Default.Size;
     _type = type;
     _isAntiAlias = Default.IsAntiAlias;
     _isVisible = Default.IsVisible;
     _border = new Border( Default.IsBorderVisible, color, Default.PenWidth );
     _fill = new Fill( color, Default.FillBrush, Default.FillType );
     _userSymbol = null;
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Draw the <see cref="JapaneseCandleStick"/> to the specified <see cref="Graphics"/>
        /// device at the specified location.
        /// </summary>
        /// <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="isXBase">boolean value that indicates if the "base" axis for this
        /// <see cref="JapaneseCandleStick"/> is the X axis.  True for an <see cref="XAxis"/> base,
        /// false for a <see cref="YAxis"/> or <see cref="Y2Axis"/> base.</param>
        /// <param name="pixBase">The independent axis position of the center of the candlestick in
        /// pixel units</param>
        /// <param name="pixHigh">The high value position of the candlestick in
        /// pixel units</param>
        /// <param name="pixLow">The low value position of the candlestick in
        /// pixel units</param>
        /// <param name="pixOpen">The opening value position of the candlestick in
        /// pixel units</param>
        /// <param name="pixClose">The closing value position of the candlestick in
        /// pixel units</param>
        /// <param name="halfSize">The scaled width of one-half of a bar, in pixels</param>
        /// <param name="scaleFactor">
        /// The scaling factor for the features of the graph based on the <see cref="PaneBase.BaseDimension"/>.  This
        /// scaling factor is calculated by the <see cref="PaneBase.CalcScaleFactor"/> method.  The scale factor
        /// represents a linear multiple to be applied to font sizes, symbol sizes, etc.</param>
        /// <param name="pen">A pen with the <see cref="Color"/> attribute for this
        /// <see cref="JapaneseCandleStick"/></param>
        /// <param name="fill">
        /// The <see cref="Fill" /> instance to be used for filling this
        /// <see cref="JapaneseCandleStick" />
        /// </param>
        /// <param name="border">The <see cref="Border" /> instance to be used for drawing the
        /// border around the <see cref="JapaneseCandleStick" /> filled box</param>
        /// <param name="pt">The <see cref="PointPair" /> to be used for determining the
        /// <see cref="Fill" />, just in case it's a <see cref="FillType.GradientByX" />,
        /// <see cref="FillType.GradientByY" />, or
        /// <see cref="FillType.GradientByZ" /> <see cref="FillType" /></param>
        public void Draw( Graphics g, GraphPane pane, bool isXBase,
								float pixBase, float pixHigh, float pixLow,
								float pixOpen, float pixClose, float halfSize,
								float scaleFactor, Pen pen, Fill fill, Border border, PointPair pt )
        {
            //float halfSize = (int) ( _size * scaleFactor / 2.0f + 0.5f );

            if ( pixBase != PointPair.Missing && Math.Abs( pixLow ) < 1000000 &&
                        Math.Abs( pixHigh ) < 1000000)
            {
                RectangleF rect;
                if ( isXBase )
                {
                    rect = new RectangleF( pixBase - halfSize, Math.Min( pixOpen, pixClose ),
                                halfSize * 2.0f, Math.Abs( pixOpen - pixClose ) );

                    g.DrawLine( pen, pixBase, pixHigh, pixBase, pixLow );
                }
                else
                {
                    rect = new RectangleF( Math.Min( pixOpen, pixClose ), pixBase - halfSize,
                                Math.Abs( pixOpen - pixClose ), halfSize * 2.0f );

                    g.DrawLine( pen, pixHigh, pixBase, pixLow, pixBase );
                }

                if ( _isOpenCloseVisible && Math.Abs( pixOpen ) < 1000000 &&
                            Math.Abs( pixClose ) < 1000000 )
                {
                    if ( rect.Width == 0 )
                        rect.Width = 1;
                    if ( rect.Height == 0 )
                        rect.Height = 1;

                    fill.Draw( g, rect, pt );
                    border.Draw( g, pane, scaleFactor, rect );
                }
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 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 JapaneseCandleStick( 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" );

            _risingFill = (Fill)info.GetValue( "risingFill", typeof( Fill ) );
            _fallingFill = (Fill)info.GetValue( "fallingFill", typeof( Fill ) );
            _risingBorder = (Border)info.GetValue( "risingBorder", typeof( Border ) );
            _fallingBorder = (Border)info.GetValue( "fallingBorder", typeof( Border ) );

            if ( schema2 >= 11 )
                _fallingColor = (Color) info.GetValue( "fallingColor", typeof( Color ) );
        }
Ejemplo n.º 13
0
        /// <summary>
        /// The Copy Constructor
        /// </summary>
        /// <param name="rhs">The <see cref="JapaneseCandleStick"/> object from which to copy</param>
        public JapaneseCandleStick( JapaneseCandleStick rhs )
            : base(rhs)
        {
            _risingFill = rhs._risingFill.Clone();
            _fallingFill = rhs._fallingFill.Clone();

            _risingBorder = rhs._risingBorder.Clone();
            _fallingBorder = rhs._fallingBorder.Clone();

            _fallingColor = rhs._fallingColor;
        }
Ejemplo n.º 14
0
        /// <summary>
        /// The Copy Constructor
        /// </summary>
        /// <param name="rhs">The LineBase object from which to copy</param>
        public LineBase( LineBase rhs )
        {
            _width = rhs._width;
            _style = rhs._style;
            _dashOn = rhs._dashOn;
            _dashOff = rhs._dashOff;

            _isVisible = rhs._isVisible;
            _color = rhs._color;

            _isAntiAlias = rhs._isAntiAlias;
            _gradientFill = new Fill( rhs._gradientFill );
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 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 Symbol( SerializationInfo info, StreamingContext 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( "schema" );

            _size = info.GetSingle( "size" );
            _type = (SymbolType) info.GetValue( "type", typeof(SymbolType) );
            _isAntiAlias = info.GetBoolean( "isAntiAlias" );
            _isVisible = info.GetBoolean( "isVisible" );
            _fill = (Fill) info.GetValue( "fill", typeof(Fill) );
            _border = (Border) info.GetValue( "border", typeof(Border) );

            if ( sch >= 11 )
                _userSymbol = (GraphicsPath)info.GetValue( "userSymbol", typeof( GraphicsPath ) );
            else
                _userSymbol = null;
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 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 LineBase( SerializationInfo info, StreamingContext 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( "schema0" );

            _width = info.GetSingle( "width" );
            _style = (DashStyle)info.GetValue( "style", typeof( DashStyle ) );
            _dashOn = info.GetSingle( "dashOn" );
            _dashOff = info.GetSingle( "dashOff" );
            _isVisible = info.GetBoolean( "isVisible" );
            _isAntiAlias = info.GetBoolean( "isAntiAlias" );
            _color = (Color)info.GetValue( "color", typeof( Color ) );
            _gradientFill = (Fill)info.GetValue( "gradientFill", typeof( Fill ) );
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Default constructor that sets all <see cref="Legend"/> properties to default
        /// values as defined in the <see cref="Default"/> class.
        /// </summary>
        public Legend()
        {
            _position = Default.Position;
            _isHStack = Default.IsHStack;
            _isVisible = Default.IsVisible;
            this.Location = new Location( 0, 0, CoordType.PaneFraction );

            _fontSpec = new FontSpec( Default.FontFamily, Default.FontSize,
                Default.FontColor, Default.FontBold,
                Default.FontItalic, Default.FontUnderline,
                Default.FontFillColor, Default.FontFillBrush,
                Default.FontFillType );
            _fontSpec.Border.IsVisible = false;

            _border = new Border( Default.IsBorderVisible, Default.BorderColor, Default.BorderWidth );
            _fill = new Fill( Default.FillColor, Default.FillBrush, Default.FillType );

            _gap = Default.Gap;

            _isReverse = Default.IsReverse;

            _isShowLegendSymbols = Default.IsShowLegendSymbols;
        }
Ejemplo n.º 18
0
 /// <summary>
 /// 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)
 {
     _pieValue = pieValue;
     _fill = new Fill( color.IsEmpty ? _rotator.NextColor : color );
     _displacement = displacement;
     _border = new Border( Default.BorderColor, Default.BorderWidth );
     _labelDetail = new TextObj();
     _labelDetail.FontSpec.Size = Default.FontSize;
     _labelType = Default.LabelType;
     _valueDecimalDigits = Default.ValueDecimalDigits;
     _percentDecimalDigits = Default.PercentDecimalDigits;
     _slicePath = null;
 }
Ejemplo n.º 19
0
        /// <summary>
        /// The Copy Constructor
        /// </summary>
        /// <param name="rhs">The XAxis object from which to copy</param>
        public Legend( Legend rhs )
        {
            _rect = rhs.Rect;
            _position = rhs.Position;
            _isHStack = rhs.IsHStack;
            _isVisible = rhs.IsVisible;

            _location = rhs.Location;
            _border = rhs.Border.Clone();
            _fill = rhs.Fill.Clone();

            _fontSpec = rhs.FontSpec.Clone();

            _gap = rhs._gap;

            _isReverse = rhs._isReverse;

            _isShowLegendSymbols = rhs._isShowLegendSymbols;
        }
Ejemplo n.º 20
0
        /// <summary>
        /// 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" );

            _displacement = info.GetDouble( "displacement" );
            _labelDetail = (TextObj)info.GetValue( "labelDetail", typeof( TextObj ) );
            _fill = (Fill)info.GetValue( "fill", typeof( Fill ) );
            _border = (Border)info.GetValue( "border", typeof( Border ) );
            _pieValue = info.GetDouble( "pieValue" );
            _labelType = (PieLabelType)info.GetValue( "labelType", typeof( PieLabelType ) );
            _intersectionPoint = (PointF)info.GetValue( "intersectionPoint", typeof( PointF ) );
            _boundingRectangle = (RectangleF)info.GetValue( "boundingRectangle", typeof( RectangleF ) );
            _pivotPoint = (PointF)info.GetValue( "pivotPoint", typeof( PointF ) );
            _endPoint = (PointF)info.GetValue( "endPoint", typeof( PointF ) );
            // _slicePath = (GraphicsPath)info.GetValue( "slicePath", typeof( GraphicsPath ) );
            _startAngle = (float)info.GetDouble( "startAngle" );
            _sweepAngle = (float)info.GetDouble( "sweepAngle" );
            _midAngle = (float)info.GetDouble( "midAngle" );
            _labelStr = info.GetString( "labelStr" );
            _valueDecimalDigits = info.GetInt32( "valueDecimalDigits" );
            _percentDecimalDigits = info.GetInt32( "percentDecimalDigits" );
        }
Ejemplo n.º 21
0
        /// <summary>
        /// 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 Legend( SerializationInfo info, StreamingContext 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( "schema" );

            _position = (LegendPos)info.GetValue( "position", typeof( LegendPos ) );
            _isHStack = info.GetBoolean( "isHStack" );
            _isVisible = info.GetBoolean( "isVisible" );
            _fill = (Fill)info.GetValue( "fill", typeof( Fill ) );
            _border = (Border)info.GetValue( "border", typeof( Border ) );
            _fontSpec = (FontSpec)info.GetValue( "fontSpec", typeof( FontSpec ) );
            _location = (Location)info.GetValue( "location", typeof( Location ) );

            _gap = info.GetSingle( "gap" );

            if ( schema >= 11 )
                _isReverse = info.GetBoolean( "isReverse" );

            if ( schema >= 12 )
                _isShowLegendSymbols = info.GetBoolean( "isShowLegendSymbols" );
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Do all rendering associated with this <see cref="GasGaugeNeedle"/> item to the specified
        /// <see cref="Graphics"/> device. This method is normally only
        /// called by the Draw method of the parent <see cref="CurveList"/>
        /// collection object.
        /// </summary>
        /// <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="pos">Not used for rendering GasGaugeNeedle</param>
        /// <param name="scaleFactor">Not used for rendering GasGaugeNeedle</param>
        public override void Draw( Graphics g, GraphPane pane, int pos, float scaleFactor )
        {
            if ( pane.Chart._rect.Width <= 0 && pane.Chart._rect.Height <= 0 )
            {
                _slicePath = null;
            }
            else
            {
                CalcRectangle( g, pane, scaleFactor, pane.Chart._rect );

                _slicePath = new GraphicsPath();

                if ( !_isVisible )
                    return;

                RectangleF tRect = _boundingRectangle;

                if ( tRect.Width >= 1 && tRect.Height >= 1 )
                {
                    SmoothingMode sMode = g.SmoothingMode;
                    g.SmoothingMode = SmoothingMode.AntiAlias;

                    Matrix matrix = new Matrix();

                    matrix.Translate( tRect.X + ( tRect.Width / 2 ), tRect.Y + ( tRect.Height / 2 ), MatrixOrder.Prepend );

                    PointF[] pts = new PointF[2];
                    pts[0] = new PointF( ( ( tRect.Height * .10f ) / 2.0f ) * (float)Math.Cos( -SweepAngle * Math.PI / 180.0f ),
                    ( ( tRect.Height * .10f ) / 2.0f ) * (float)Math.Sin( -SweepAngle * Math.PI / 180.0f ) );
                    pts[1] = new PointF( ( tRect.Width / 2.0f ) * (float)Math.Cos( -SweepAngle * Math.PI / 180.0f ),
                    ( tRect.Width / 2.0f ) * (float)Math.Sin( -SweepAngle * Math.PI / 180.0f ) );

                    matrix.TransformPoints( pts );

                    Pen p = new Pen( NeedleColor, ( ( tRect.Height * .10f ) / 2.0f ) );
                    p.EndCap = LineCap.ArrowAnchor;
                    g.DrawLine( p, pts[0].X, pts[0].Y, pts[1].X, pts[1].Y );

                    //Fill center 10% with Black dot;
                    Fill f = new Fill( Color.Black );
                    RectangleF r = new RectangleF( ( tRect.X + ( tRect.Width / 2 ) ) - 1.0f, ( tRect.Y + ( tRect.Height / 2 ) ) - 1.0f, 1.0f, 1.0f );
                    r.Inflate( ( tRect.Height * .10f ), ( tRect.Height * .10f ) );
                    Brush b = f.MakeBrush( r );
                    g.FillPie( b, r.X, r.Y, r.Width, r.Height, 0.0f, -180.0f );

                    Pen borderPen = new Pen( Color.White, 2.0f );
                    g.DrawPie( borderPen, r.X, r.Y, r.Width, r.Height, 0.0f, -180.0f );

                    g.SmoothingMode = sMode;
                }
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Create a fill brush using current properties.  This method will construct a brush based on the
        /// settings of <see cref="Fill.Type"/>, <see cref="Fill.Color"/>
        /// and <see cref="Fill.Brush"/>.  If
        /// <see cref="Fill.Type"/> is set to <see cref="FillType.Brush"/> and
        /// <see cref="Fill.Brush"/>
        /// is null, then a <see cref="LinearGradientBrush"/> will be created between the colors of
        /// <see cref="System.Drawing.Color.White"/> and <see cref="Fill.Color"/>.
        /// </summary>
        /// <param name="rect">A rectangle that bounds the object to be filled.  This determines
        /// the start and end of the gradient fill.</param>
        /// <param name="dataValue">The data value to be used for a value-based
        /// color gradient.  This is only applicable for <see cref="FillType.GradientByX"/>,
        /// <see cref="FillType.GradientByY"/> or <see cref="FillType.GradientByZ"/>.</param>
        /// <returns>A <see cref="System.Drawing.Brush"/> class representing the fill brush</returns>
        public Brush MakeBrush(RectangleF rect, PointPair dataValue)
        {
            // get a brush
            if (this.IsVisible && (!_color.IsEmpty || _brush != null))
            {
                if (rect.Height < 1.0F)
                {
                    rect.Height = 1.0F;
                }
                if (rect.Width < 1.0F)
                {
                    rect.Width = 1.0F;
                }

                //Brush	brush;
                if (_type == FillType.Brush)
                {
                    return(ScaleBrush(rect, _brush, _isScaled));
                }
                else if (IsGradientValueType)
                {
                    if (dataValue != null)
                    {
                        if (!_secondaryValueGradientColor.IsEmpty)
                        {
                            // Go ahead and create a new Fill so we can do all the scaling, etc.,
                            // that is associated with a gradient
                            Fill tmpFill = new Fill(_secondaryValueGradientColor,
                                                    GetGradientColor(dataValue), _angle);
                            return(tmpFill.MakeBrush(rect));
                        }
                        else
                        {
                            return(new SolidBrush(GetGradientColor(dataValue)));
                        }
                    }
                    else if (_rangeDefault != double.MaxValue)
                    {
                        if (!_secondaryValueGradientColor.IsEmpty)
                        {
                            // Go ahead and create a new Fill so we can do all the scaling, etc.,
                            // that is associated with a gradient
                            Fill tmpFill = new Fill(_secondaryValueGradientColor,
                                                    GetGradientColor(_rangeDefault), _angle);
                            return(tmpFill.MakeBrush(rect));
                        }
                        else
                        {
                            return(new SolidBrush(GetGradientColor(_rangeDefault)));
                        }
                    }
                    else
                    {
                        return(ScaleBrush(rect, _brush, true));
                    }
                }
                else
                {
                    return(new SolidBrush(_color));
                }
            }

            // Always return a suitable default
            return(new SolidBrush(Color.White));
        }