コード例 #1
0
 /// <summary>
 /// Indexer: get the Sample instance at the specified ordinal position in the list
 /// </summary>
 /// <param name="index">The ordinal position in the list of samples</param>
 /// <returns>Returns a <see cref="PointPair" /> instance containing the
 /// data specified by <see cref="XType" /> and <see cref="YType" />
 /// </returns>
 public PointPair this[int index]
 {
     get
     {
         PointPair pt = new PointPair();
         Sample sample = (Sample) list[index];
         pt.X = GetValue( sample, XType );
         pt.Y = GetValue( sample, YType );
         return pt;
     }
 }
コード例 #2
0
ファイル: PointPair.cs プロジェクト: GunioRobot/zeegraph
        /// <summary>
        /// The PointPair copy constructor.
        /// </summary>
        /// <param name="rhs">The basis for the copy.</param>
        public PointPair( PointPair rhs )
            : base(rhs)
        {
            this.Z = rhs.Z;

            if ( rhs.Tag is ICloneable )
                this.Tag = ((ICloneable) rhs.Tag).Clone();
            else
                this.Tag = rhs.Tag;
        }
コード例 #3
0
        /// <summary>
        /// Indexer to access the specified <see cref="PointPair"/> object by
        /// its ordinal position in the list.
        /// </summary>
        /// <param name="index">The ordinal position (zero-based) of the
        /// <see cref="PointPair"/> object to be accessed.</param>
        /// <value>A <see cref="PointPair"/> object reference.</value>
        public PointPair this[int index]
        {
            get
            {
                if ( index < 0 || index >= _bindingSource.Count )
                    throw new System.ArgumentOutOfRangeException( "Error: Index out of range" );

                object row = _bindingSource[index];

                double x = GetDouble( row, _xDataMember, index );
                double y = GetDouble( row, _yDataMember, index );
                double z = GetDouble( row, _zDataMember, index );
                object tag = GetObject( row, _tagDataMember );

                PointPair pt = new PointPair( x, y, z );
                pt.Tag = tag;
                return pt;
            }
        }
コード例 #4
0
ファイル: ErrorBar.cs プロジェクト: GunioRobot/zeegraph
        /// <summary>
        /// Draw the <see cref="ErrorBar"/> 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="ErrorBar"/> 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 error bar in
        /// pixel units</param>
        /// <param name="pixValue">The dependent axis position of the top of the error bar in
        /// pixel units</param>
        /// <param name="pixLowValue">The dependent axis position of the bottom of the error bar in
        /// pixel units</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 attributes of <see cref="Color"/> and
        /// <see cref="PenWidth"/> for this <see cref="ErrorBar"/></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>
        /// <param name="isSelected">Indicates that the <see cref="ErrorBar" /> should be drawn
        /// with attributes from the <see cref="Selection" /> class.
        /// </param>
        public void Draw( Graphics g, GraphPane pane, bool isXBase,
								float pixBase, float pixValue,
								float pixLowValue, float scaleFactor, Pen pen, bool isSelected,
								PointPair dataValue )
        {
            if ( isXBase )
            {
                g.DrawLine( pen, pixBase, pixValue, pixBase, pixLowValue );
                _symbol.DrawSymbol( g, pane, (int)pixBase, (int)pixValue,
                            scaleFactor, isSelected, dataValue );
                _symbol.DrawSymbol( g, pane, (int)pixBase, (int)pixLowValue,
                            scaleFactor, isSelected, dataValue );
            }
            else
            {
                g.DrawLine( pen, pixValue, pixBase, pixLowValue, pixBase );
                _symbol.DrawSymbol( g, pane, (int)pixValue, (int)pixBase,
                            scaleFactor, isSelected, dataValue );
                _symbol.DrawSymbol( g, pane, (int)pixLowValue, (int)pixBase,
                            scaleFactor, isSelected, dataValue );
            }
        }
コード例 #5
0
ファイル: Fill.cs プロジェクト: GunioRobot/zeegraph
        internal Color GetGradientColor( PointPair dataValue )
        {
            double val;

            if ( dataValue == null )
                val = _rangeDefault;
            else if ( _type == FillType.GradientByColorValue )
                val = dataValue.ColorValue;
            else if ( _type == FillType.GradientByZ )
                val = dataValue.Z;
            else if ( _type == FillType.GradientByY )
                val = dataValue.Y;
            else
                val = dataValue.X;

            return GetGradientColor( val );
        }
コード例 #6
0
ファイル: LineBase.cs プロジェクト: GunioRobot/zeegraph
        /// <summary>
        /// Create a <see cref="Pen" /> object based on the properties of this
        /// <see cref="LineBase" />.
        /// </summary>
        /// <param name="pane">The owner <see cref="GraphPane" /> of this
        /// <see cref="LineBase" />.
        /// </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="dataValue">The data value to be used for a value-based
        /// color gradient.  This is only applicable if <see cref="Fill.Type">GradientFill.Type</see>
        /// is one of <see cref="FillType.GradientByX"/>,
        /// <see cref="FillType.GradientByY"/>, <see cref="FillType.GradientByZ"/>,
        /// or <see cref="FillType.GradientByColorValue" />.
        /// </param>
        /// <returns>A <see cref="Pen" /> object with the properties of this <see cref="LineBase" />
        /// </returns>
        public Pen GetPen( PaneBase pane, float scaleFactor, PointPair dataValue )
        {
            Color color = _color;
            if ( _gradientFill.IsGradientValueType )
                color = _gradientFill.GetGradientColor( dataValue );

            Pen pen = new Pen( color,
                        pane.ScaledPenWidth( _width, scaleFactor ) );

            pen.DashStyle = _style;

            if ( _style == DashStyle.Custom )
            {
                if ( _dashOff > 1e-10 && _dashOn > 1e-10 )
                {
                    pen.DashStyle = DashStyle.Custom;
                    float[] pattern = new float[2];
                    pattern[0] = _dashOn;
                    pattern[1] = _dashOff;
                    pen.DashPattern = pattern;
                }
                else
                    pen.DashStyle = DashStyle.Solid;
            }

            return pen;
        }
コード例 #7
0
ファイル: Fill.cs プロジェクト: GunioRobot/zeegraph
 /// <summary>
 /// Fill the background of the <see cref="RectangleF"/> area, using the
 /// fill type from this <see cref="Fill"/>.
 /// </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="rect">The <see cref="RectangleF"/> struct specifying the area
 /// to be filled</param>
 /// <param name="pt">The data value to be used 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, RectangleF rect, PointPair pt )
 {
     if ( this.IsVisible )
     {
         using ( Brush brush = this.MakeBrush( rect, pt ) )
         {
             g.FillRectangle( brush, rect );
         }
     }
 }
コード例 #8
0
ファイル: Fill.cs プロジェクト: GunioRobot/zeegraph
        /// <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 );
        }
コード例 #9
0
ファイル: Symbol.cs プロジェクト: GunioRobot/zeegraph
        /// <summary>
        /// Draw the <see cref="Symbol"/> to the specified <see cref="Graphics"/> device
        /// at the specified location.  This routine draws a single symbol.
        /// </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="x">The x position of the center of the symbol in
        /// pixel units</param>
        /// <param name="y">The y position of the center of the symbol in
        /// pixel units</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="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>
        /// <param name="isSelected">Indicates that the <see cref="Symbol" /> should be drawn
        /// with attributes from the <see cref="Selection" /> class.
        /// </param>
        public void DrawSymbol( Graphics g, GraphPane pane, int x, int y,
							float scaleFactor, bool isSelected, PointPair dataValue )
        {
            Symbol source = this;
            if ( isSelected )
                source = Selection.Symbol;

            // Only draw if the symbol is visible
            if (	_isVisible &&
                    this.Type != SymbolType.None &&
                    x < 100000 && x > -100000 &&
                    y < 100000 && y > -100000 )
            {
                SmoothingMode sModeSave = g.SmoothingMode;
                if ( _isAntiAlias )
                    g.SmoothingMode = SmoothingMode.HighQuality;

                using ( Pen pen = _border.GetPen( pane, scaleFactor, dataValue ) )
                using ( GraphicsPath path = this.MakePath( g, scaleFactor ) )
                using ( Brush brush = this.Fill.MakeBrush( path.GetBounds(), dataValue ) )
                {
                    DrawSymbol( g, x, y, path, pen, brush );
                }

                g.SmoothingMode = sModeSave;
            }
        }
コード例 #10
0
ファイル: ZeeGraphWeb.cs プロジェクト: GunioRobot/zeegraph
        /// <summary>
        /// Provides binding between <see cref="DataSource"/> and the specified pane.  Extracts the
        /// data from <see cref="DataSource"/> and copies it into the appropriate
        /// <see cref="IPointList"/> for each <see cref="CurveItem"/> in the
        /// specified <see cref="GraphPane"/>.
        /// </summary>
        /// <param name="g">The <see cref="Graphics"/> object to be used for rendering the data.</param>
        /// <param name="pane">The <see cref="GraphPane"/> object which will receive the data.</param>
        protected void PopulateByDataSource( Graphics g, GraphPane pane )
        {
            if ( this.CurveList.Count == 0 )
                return;

            //If the Datasource column names are available we can bind them
            // correctly to their corresponding DataMember.
            if ( this.DataMember != null && this.DataMember != String.Empty
                && this.DataSource != null
                && this.DataSource is ITypedList
                && this.DataSource is IListSource
                )
            {
                ITypedList tlist = this.DataSource as ITypedList;
                IListSource listSource = this.DataSource as IListSource;
                IList list = listSource.GetList();
                PropertyDescriptorCollection pdc = tlist.GetItemProperties( null );
                bool bListContainsList = listSource.ContainsListCollection;

                //Get the DataMember and Type of the base axis in the DataSource
                string baseDataMember = this.DataMember;
                PropertyDescriptor basePd = pdc.Find( baseDataMember, true );
                if ( basePd == null )
                    throw new System.Exception( "Can't find DataMember '" + baseDataMember + "' in DataSource for the base axis." );
                baseDataMember = basePd.Name;
                Type baseDataType = basePd.PropertyType;
                int indexBaseColumn = pdc.IndexOf( basePd );

                //Foreach bar/curve
                //  Get its DataMember and Type in the DataSource
                //	Add the curve to the pane
                //  Add all corresponding points(baseAxis,valueAxis,0)
                //Note: Z axis is not supported
                foreach ( ZeeGraphWebCurveItem curveItem in this.CurveList )
                {
                    //Axis valueAxis = curveItem.ValueAxis;
                    PropertyDescriptorCollection pdcValue = pdc;
                    IList valueList = list;
                    bool bValueListContainsList = bListContainsList;

                    //If present, use DataSource of Curve instead of main DataSource
                    if ( curveItem.DataSource != null
                        && curveItem.DataSource is ITypedList
                        && curveItem.DataSource is IListSource )
                    {
                        ITypedList valueTlist = curveItem.DataSource as ITypedList;
                        pdcValue = valueTlist.GetItemProperties( null );
                        IListSource valueListSource = curveItem.DataSource as IListSource;
                        valueList = valueListSource.GetList();
                        bValueListContainsList = valueListSource.ContainsListCollection;
                    }

                    string valueDataMember = curveItem.DataMember;
                    PropertyDescriptor pd = pdcValue.Find( valueDataMember, true );
                    if ( pd == null )
                        throw new System.Exception( "Can't find DataMember '" + valueDataMember + "' in DataSource for the " + curveItem.Label + " axis." );
                    valueDataMember = pd.Name; //Get the exact case-dependent name
                    Type valueDataType = pd.PropertyType;
                    int indexValueColumn = pdcValue.IndexOf( pd );

                    //Add points
                    PointPairList points = new PointPairList();
                    PointPair pair = new PointPair();
                    object oColumnValue;

                    try
                    {
                        int nRow = 0;
                        foreach ( object row in list )
                        {
                            //
                            // Value axis binding (Y axis)
                            //
                            object valueRow = valueList[nRow];

                            //Get item value in 'row'
                            if ( bValueListContainsList )
                            {
                                if ( !( valueRow is IList ) )
                                    throw new System.InvalidCastException( "The DataSource contains a list which declares its items as lists, but these don't support the IList interface." );
                                oColumnValue = ( valueRow as IList )[indexValueColumn];
                            }
                            else
                            {
                                oColumnValue = pd.GetValue( valueRow );
                            }

                            //Convert value to double (always double)
                            double v = 0;
                            switch ( oColumnValue.GetType().ToString() )
                            {
                                case "System.DateTime":
                                    v = new XDate( Convert.ToDateTime( oColumnValue ) ).XLDate;
                                    break;
                                default:
                                    try
                                    {
                                        v = Convert.ToDouble( oColumnValue );
                                    }
                                    catch
                                    {
                                        throw new NotImplementedException( "Conversion from " + oColumnValue.GetType() + " to double not implemented." );
                                    }
                                    break;
                            }

                            //
                            // Base axis binding (X axis)
                            //
                            pair.Tag = oColumnValue; //Original typed value
                            pair.Y = v;
                            if ( this.XAxis.Type == AxisType.DateAsOrdinal
                                || this.XAxis.Type == AxisType.Date )
                            {
                                pair.X = new XDate( Convert.ToDateTime( basePd.GetValue( row ) ) ).XLDate;
                            }
                            else
                                pair.X = Convert.ToDouble( basePd.GetValue( row ) );

                            points.Add( pair );

                            nRow++;
                        }
                    }
                    catch ( System.ArgumentOutOfRangeException )
                    {
                        //A local datasource was set on this curve but it has fewer rows than the axis datasource.
                        //So we stop feeding this curve.
                    }

                    //Create curve in pane with its points
                    curveItem.CreateInPane( pane, points );
                }
            }
            else
            {
                //Add curves and values set in designer
                ZeeGraphWebCurveItem curve;
                for ( int i = 0; i < CurveList.Count; i++ )
                {
                    curve = CurveList[i];

                    PointPairList points = new PointPairList();
                    PointPair pair = new PointPair();
                    for ( int j = 0; j < curve.Points.Count; j++ )
                    {
                        curve.Points[j].CopyTo( pair );
                        points.Add( pair );
                    }

                    curve.CreateInPane( pane, points );
                }
            }

            //NOTE: ZeeGraphWeb.DataMember = base axis
            //NOTE: ZedGraphCurveItem.DataMember = Y
            //NOTE: Z values are only supported via the callback (???)
            //TODO: cache the data-map table before processing rows (???)
        }
コード例 #11
0
        /// <summary>
        /// Add a set of points to the <see cref="RollingPointPairList"/> from
        /// three arrays of type double.
        /// If the X or Y array is null, then a set of ordinal values is automatically
        /// generated in its place (see <see cref="AxisType.Ordinal"/>.
        /// If the <see paramref="z"/> value
        /// is null, then it is set to zero.
        /// If the arrays are of different size, then the larger array prevails and the
        /// smaller array is padded with <see cref="PointPairBase.Missing"/> values.
        /// </summary>
        /// <param name="x">A double[] array of X values</param>
        /// <param name="y">A double[] array of Y values</param>
        /// <param name="z">A double[] array of Z values</param>
        public void Add(double[] x, double[] y, double[] z)
        {
            int len = 0;

            if (x != null)
            {
                len = x.Length;
            }
            if (y != null && y.Length > len)
            {
                len = y.Length;
            }
            if (z != null && z.Length > len)
            {
                len = z.Length;
            }

            for (int i = 0; i < len; i++)
            {
                PointPair point = new PointPair();

                if (x == null)
                {
                    point.X = (double)i + 1.0;
                }
                else if (i < x.Length)
                {
                    point.X = x[i];
                }
                else
                {
                    point.X = PointPair.Missing;
                }

                if (y == null)
                {
                    point.Y = (double)i + 1.0;
                }
                else if (i < y.Length)
                {
                    point.Y = y[i];
                }
                else
                {
                    point.Y = PointPair.Missing;
                }

                if (z == null)
                {
                    point.Z = (double)i + 1.0;
                }
                else if (i < z.Length)
                {
                    point.Z = z[i];
                }
                else
                {
                    point.Z = PointPair.Missing;
                }

                Add(point);
            }
        }
コード例 #12
0
 /// <summary>
 /// Add a <see cref="PointPair"/> onto the head of the queue,
 /// overwriting old values if the buffer is full.
 /// </summary>
 /// <param name="item">The <see cref="PointPair" /> to be added.</param>
 public void Add(PointPair item)
 {
     _mBuffer[GetNextIndex()] = item;
 }
コード例 #13
0
ファイル: CurveItem.cs プロジェクト: GunioRobot/zeegraph
        /// <summary>
        /// Add a <see cref="PointPair"/> object to the end of the points collection for this curve.
        /// </summary>
        /// <remarks>
        /// This method will only work if the <see cref="IPointList" /> instance reference
        /// at <see cref="Points" /> supports the <see cref="IPointListEdit" /> interface.
        /// Otherwise, it does nothing.
        /// </remarks>
        /// <param name="point">A reference to the <see cref="PointPair"/> object to
        /// be added</param>
        public void AddPoint( PointPair point )
        {
            if ( _points == null )
                this.Points = new PointPairList();

            if ( _points is IPointListEdit )
                ( _points as IPointListEdit ).Add( point );
            else
                throw new NotImplementedException();
        }
コード例 #14
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 );
                }
            }
        }
コード例 #15
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));
        }