Example #1
0
        virtual protected void DisplayColumnsAsLinear(System.Windows.Forms.PaintEventArgs e, int columnWidth, int columnWidthNoMargin, int columnStartOffset, int verticalAxisMaxValueInPixels, int lowerLeftX, int lowerLeftY)
        {
            Point Base0, Base1, Base2, Base3;

            IEnumerator Iterator            = this.ChartDescription.Columns.GetEnumerator();
            ChartColumn previousColumn      = null;
            Point       prevBase0           = new Point(0, 0);
            Point       prevBase1           = new Point(0, 0);
            Point       prevBase2           = new Point(0, 0);
            Point       prevBase3           = new Point(0, 0);
            int         columnCurrentOffset = columnStartOffset;
            int         offsetFor0          = (-this.ChartDescription.VerticalAxisMinValue) * verticalAxisMaxValueInPixels / (this.ChartDescription.VerticalAxisMaxValue - this.ChartDescription.VerticalAxisMinValue);

            while (Iterator.MoveNext())
            {
                ChartColumn currentColumn = (ChartColumn)Iterator.Current;
                Debug.Assert(currentColumn.PositiveValuesSum <= this.ChartDescription.VerticalAxisMaxValue, "Chart.DisplayColumns_BarWith3d", "Vertical axis overflow, verify why current column value is higher than axis vertical value");
                Debug.Assert(this.ChartDescription.VerticalAxisMaxValue > 0, "Chart.DisplayColumns_BarWith3d", "Integer divided by 0");

                Base0 = new Point(columnCurrentOffset, lowerLeftY - offsetFor0);
                Base1 = new Point(columnCurrentOffset + columnWidthNoMargin, lowerLeftY - offsetFor0);
                Base2 = new Point(columnCurrentOffset + columnWidthNoMargin + this.ChartDescription.DeltaDepth, lowerLeftY - offsetFor0 - this.ChartDescription.DeltaDepth);
                Base3 = new Point(columnCurrentOffset + this.ChartDescription.DeltaDepth, lowerLeftY - offsetFor0 - this.ChartDescription.DeltaDepth);

                currentColumn.DisplayAsLinear(e, this, previousColumn, columnWidthNoMargin, verticalAxisMaxValueInPixels, Base0, Base1, Base2, Base3, prevBase0, prevBase1, prevBase2, prevBase3);

                // Next
                prevBase0            = Base0;
                prevBase1            = Base1;
                prevBase2            = Base2;
                prevBase3            = Base3;
                columnCurrentOffset += columnWidth;
                previousColumn       = currentColumn;
            }
        }
Example #2
0
        /// <summary>
        /// Display all text on chart for all columns
        /// </summary>
        /// <param name="e"></param>
        /// <param name="columnWidth"></param>
        /// <param name="columnWidthNoMargin"></param>
        /// <param name="columnStartOffset"></param>
        /// <param name="verticalAxisMaxValueInPixels"></param>
        /// <param name="lowerLeftX"></param>
        /// <param name="lowerLeftY"></param>
        virtual protected void DisplayColumnsText(System.Windows.Forms.PaintEventArgs e, int columnWidth, int columnWidthNoMargin, int columnStartOffset, int verticalAxisMaxValueInPixels, int lowerLeftX, int lowerLeftY)
        {
            int         offset;
            int         offsetFor0;
            IEnumerator Iterator            = this.ChartDescription.Columns.GetEnumerator();
            int         columnCurrentOffset = columnStartOffset;

            System.Diagnostics.Debug.Assert(this.ChartDescription.VerticalAxisMaxValue - this.ChartDescription.VerticalAxisMinValue != 0);

            offsetFor0 = (-this.ChartDescription.VerticalAxisMinValue) * verticalAxisMaxValueInPixels / (this.ChartDescription.VerticalAxisMaxValue - this.ChartDescription.VerticalAxisMinValue);
            while (Iterator.MoveNext())
            {
                ChartColumn currentColumn = (ChartColumn)Iterator.Current;

                if (this.ChartDescription.CumulativeMode == ChartCumulativeMode.StartFromLastValue)
                {
                    Debug.Assert(currentColumn.PositiveValuesSum <= this.ChartDescription.VerticalAxisMaxValue, "Chart.OnPaintBackground", "Vertical axis overflow, verify why current column value is higher than axis vertical value");
                }

                if (this.ChartDescription.CumulativeMode == ChartCumulativeMode.StartFrom0)
                {
                    if (currentColumn.HighestValue >= 0)
                    {
                        offset = offsetFor0 + (verticalAxisMaxValueInPixels * currentColumn.HighestValue / (this.ChartDescription.VerticalAxisMaxValue - this.ChartDescription.VerticalAxisMinValue));
                    }
                    else
                    {
                        // In this case, align text on the '0' line offset
                        offset = offsetFor0;
                    }
                }
                else if (this.ChartDescription.CumulativeMode == ChartCumulativeMode.StartFromLastValue)
                {
                    offset = offsetFor0 + (verticalAxisMaxValueInPixels * currentColumn.PositiveValuesSum / (this.ChartDescription.VerticalAxisMaxValue - this.ChartDescription.VerticalAxisMinValue));
                }
                else
                {
                    Debug.Assert(this.ChartDescription.CumulativeMode == ChartCumulativeMode.Max, "Chart.OnPaintBackground", "Cumulative mode not managed");
                    offset = 0;
                }

                int AbsoluteSum = currentColumn.PositiveValuesSum - currentColumn.NegativeValuesSum;

                // Compute sie of bouding rectangle
                System.Drawing.SizeF Size      = e.Graphics.MeasureString(AbsoluteSum.ToString(CultureInfo.InvariantCulture), this.ChartDescription.ColumnFont);
                PointF     Base0               = new PointF((float)columnCurrentOffset, (float)(lowerLeftY - offset) - Size.Height);
                RectangleF backgroundRectangle = new RectangleF(Base0, Size);

                // Align rectangle on column width
                backgroundRectangle.X = columnCurrentOffset + this.ChartDescription.MarginBetweenColumn / 2 + ((columnWidthNoMargin - backgroundRectangle.Width) / 2);
                currentColumn.DisplayText(e, this, backgroundRectangle);

                // Jump to next offset
                columnCurrentOffset += columnWidth;
            }
        }
Example #3
0
		public ChartColumn(ChartColumn sourceColumn)
		{
			if( sourceColumn == null ) throw new NolmeWinFormsArgumentNullException ();

			this.m_Values				= new int [sourceColumn.m_Values.Length];
			sourceColumn.m_Values.CopyTo (this.m_Values, 0);
			this.m_PositiveValuesSum	= sourceColumn.m_PositiveValuesSum;
			this.m_NegativeValuesSum	= sourceColumn.m_NegativeValuesSum;
			this.m_HighestValue			= sourceColumn.m_HighestValue;
			this.m_LowestValue			= sourceColumn.m_LowestValue;
			this.m_Title				= sourceColumn.m_Title;
		}
Example #4
0
        public ChartColumn(ChartColumn sourceColumn)
        {
            if (sourceColumn == null)
            {
                throw new NolmeWinFormsArgumentNullException();
            }

            this.m_Values = new int [sourceColumn.m_Values.Length];
            sourceColumn.m_Values.CopyTo(this.m_Values, 0);
            this.m_PositiveValuesSum = sourceColumn.m_PositiveValuesSum;
            this.m_NegativeValuesSum = sourceColumn.m_NegativeValuesSum;
            this.m_HighestValue      = sourceColumn.m_HighestValue;
            this.m_LowestValue       = sourceColumn.m_LowestValue;
            this.m_Title             = sourceColumn.m_Title;
        }
Example #5
0
        virtual protected void DisplayColumnsTitle(System.Windows.Forms.PaintEventArgs e, int columnWidth, int columnWidthNoMargin, int columnStartOffset, int verticalAxisMaxValueInPixels, int lowerLeftX, int lowerLeftY)
        {
            IEnumerator Iterator            = this.ChartDescription.Columns.GetEnumerator();
            int         columnCurrentOffset = columnStartOffset;

            while (Iterator.MoveNext())
            {
                ChartColumn currentColumn = (ChartColumn)Iterator.Current;

                Point Base0 = new Point(columnCurrentOffset, lowerLeftY);
                Point Base1 = new Point(columnCurrentOffset + columnWidthNoMargin, lowerLeftY);

                currentColumn.DisplayTitle(e, this, Base0, Base1);

                // Jump to next offset
                columnCurrentOffset += columnWidth;
            }
        }
Example #6
0
        /// <summary>
        /// Shift all values to the left
        /// </summary>
        public void ShiftLeft()
        {
            int numberOfColumns = this.ChartDescription.Columns.Count;

            if (numberOfColumns > 1)
            {
                for (int i = 1; i < numberOfColumns; i++)
                {
                    this.ChartDescription.Columns[i - 1] = this.ChartDescription.Columns[i];
                }

                // Create new column (keep in mind that at this stage, Columns[numberOfColumns-1] & Columns[numberOfColumns-2]
                // are 2 pointers on the SAME OBJECT.
                ChartColumn LastColumn = new ChartColumn((ChartColumn)this.ChartDescription.Columns[numberOfColumns - 2]);
                LastColumn.ResetValues();
                this.ChartDescription.Columns[numberOfColumns - 1] = LastColumn;
            }
        }
Example #7
0
        public ChartColumn      AddColumn(int [] values, string title)
        {
            // Create new column
            ChartColumn newColumn = this.AllocateColumn(values, title);

            // Resize vertical axis
            if (newColumn.PositiveValuesSum > this.ChartDescription.VerticalAxisMaxValue)
            {
                this.ChartDescription.VerticalAxisMaxValue = newColumn.PositiveValuesSum;
            }
            if (newColumn.NegativeValuesSum < this.ChartDescription.VerticalAxisMinValue)
            {
                this.ChartDescription.VerticalAxisMinValue = newColumn.NegativeValuesSum;
            }

            // Add column
            this.ChartDescription.Columns.Add(newColumn);
            return(newColumn);
        }
Example #8
0
		/// <summary>
		/// Shift all values to the left
		/// </summary>
		public void ShiftLeft ()
		{
			int numberOfColumns = this.ChartDescription.Columns.Count;
			if (numberOfColumns > 1)
			{
				for (int i = 1; i < numberOfColumns; i++)
				{
					this.ChartDescription.Columns[i-1] = this.ChartDescription.Columns[i];
				}

				// Create new column (keep in mind that at this stage, Columns[numberOfColumns-1] & Columns[numberOfColumns-2] 
				// are 2 pointers on the SAME OBJECT.
				ChartColumn LastColumn = new ChartColumn ((ChartColumn)this.ChartDescription.Columns[numberOfColumns-2]);
				LastColumn.ResetValues ();
				this.ChartDescription.Columns[numberOfColumns-1] = LastColumn;
			}
		}
Example #9
0
		virtual protected ChartColumn	AllocateColumn (int []values, string title)
		{
			ChartColumn	newColumn = new ChartColumn (values, title);
			return newColumn;
		}
Example #10
0
        /// <summary>
        /// Automatic detection and adjustment of vertical axis maximum
        /// </summary>
        public void AdjustVerticalAxis()
        {
            // Reset current max
            this.ChartDescription.VerticalAxisMaxValue = 0;
            this.ChartDescription.VerticalAxisMinValue = 0;
            int savedVerticalAxisMaxValue = int.MinValue;
            int savedVerticalAxisMinValue = int.MaxValue;

            // Iterate to get highest value
            if (this.ChartDescription.CumulativeMode == ChartCumulativeMode.StartFromLastValue)
            {
                IEnumerator Iterator = this.ChartDescription.Columns.GetEnumerator();
                while (Iterator.MoveNext())
                {
                    ChartColumn currentColumn = (ChartColumn)Iterator.Current;
                    if (currentColumn.PositiveValuesSum > savedVerticalAxisMaxValue)
                    {
                        savedVerticalAxisMaxValue = currentColumn.PositiveValuesSum;
                    }
                    if (currentColumn.NegativeValuesSum < savedVerticalAxisMinValue)
                    {
                        savedVerticalAxisMinValue = currentColumn.NegativeValuesSum;
                    }
                }
            }
            else if (this.ChartDescription.CumulativeMode == ChartCumulativeMode.StartFrom0)
            {
                IEnumerator Iterator = this.ChartDescription.Columns.GetEnumerator();
                while (Iterator.MoveNext())
                {
                    ChartColumn currentColumn = (ChartColumn)Iterator.Current;
                    if (currentColumn.HighestValue > savedVerticalAxisMaxValue)
                    {
                        savedVerticalAxisMaxValue = currentColumn.HighestValue;
                    }
                    if (currentColumn.LowestValue < savedVerticalAxisMinValue)
                    {
                        savedVerticalAxisMinValue = currentColumn.LowestValue;
                    }
                }
            }
            else
            {
                Debug.Assert(this.ChartDescription.CumulativeMode == ChartCumulativeMode.Max, "Chart.AdjustVerticalAxis", "Cumulative mode not managed");
            }

            // Compute digits for min & max and adjust to maximum digits
            // Avoir missing grid text when max = 1000 & min = -20 -> scale on [-1000..+1000]
            string Value1        = savedVerticalAxisMaxValue.ToString(CultureInfo.InvariantCulture);
            int    NbMaxDigits   = Value1.Length;
            string Value2        = (-savedVerticalAxisMinValue).ToString(CultureInfo.InvariantCulture);
            int    NbMinDigits   = Value2.Length;
            int    NbDigitsToUse = Math.Max(NbMaxDigits, NbMinDigits);

            // Round max value
            if (savedVerticalAxisMaxValue != 0)
            {
                if (savedVerticalAxisMaxValue == 0)
                {
                    this.ChartDescription.VerticalAxisMaxValue = 0;
                }
                else
                {
                    int Round = (int)Math.Pow(10.0F, (double)(NbDigitsToUse - 1));
                    // N.B.: Round must be an even number in order to make the following calculation works
                    // As Round is a base-10 number, this condition is true.
                    Debug.Assert(Round % 2 == 0, "Chart.AdjustVerticalAxis ()", "Can't proceed when Round is odd");
                    this.ChartDescription.VerticalAxisMaxValue = ((savedVerticalAxisMaxValue + Round) / Round) * Round;
                }

                Debug.Assert(this.ChartDescription.VerticalAxisMaxValue >= savedVerticalAxisMaxValue, "Chart.AdjustVerticalAxis", string.Format(CultureInfo.InvariantCulture, "Overflow during resize from to {0} (max {1})", this.ChartDescription.VerticalAxisMaxValue, savedVerticalAxisMaxValue));
            }

            // Round min value
            if (savedVerticalAxisMinValue != 0)
            {
                int Round = (int)Math.Pow(10.0F, (double)(NbDigitsToUse - 1));
                // N.B.: Round must be an even number in order to make the following calculation works
                // As Round is a base-10 number, this condition is true.
                Debug.Assert(Round % 2 == 0, "Chart.AdjustVerticalAxis ()", "Can't proceed when Round is odd");
                this.ChartDescription.VerticalAxisMinValue = -(((-savedVerticalAxisMinValue + Round) / Round) * Round);

                Debug.Assert(this.ChartDescription.VerticalAxisMinValue <= savedVerticalAxisMinValue, "Chart.AdjustVerticalAxis", string.Format(CultureInfo.InvariantCulture, "Overflow during resize from to {0} (max {1})", this.ChartDescription.VerticalAxisMinValue, savedVerticalAxisMinValue));
            }

            // To avoid later integer divided by 0, make sure min != max
            if (this.ChartDescription.VerticalAxisMaxValue == this.ChartDescription.VerticalAxisMinValue)
            {
                this.ChartDescription.VerticalAxisMaxValue = Math.Abs(this.ChartDescription.VerticalAxisMinValue) * 10000;
            }

            // Change VerticalAxisStep if > VerticalAxisMaxValue
            if (this.ChartDescription.VerticalAxisStep > this.ChartDescription.VerticalAxisMaxValue)
            {
                this.ChartDescription.VerticalAxisStep = this.ChartDescription.VerticalAxisMaxValue / 10;
            }
        }
Example #11
0
        virtual protected ChartColumn   AllocateColumn(int [] values, string title)
        {
            ChartColumn newColumn = new ChartColumn(values, title);

            return(newColumn);
        }
Example #12
0
        virtual internal void DisplayAsBarWith3d(System.Windows.Forms.PaintEventArgs pevent, Chart parent, ChartColumn previousColumn,
                                                 int columnWidthNoMargin, int verticalAxisMaxValueInPixels,
                                                 Point base0, Point base1, Point base2, Point base3,
                                                 Point prevBase0, Point prevBase1, Point prevBase2, Point prevBase3, bool gradientMode)
        {
            bool FirstNegativeBarToDraw = true;

            // Draw all values
            Point CurrentBase0 = base0;
            Point CurrentBase1 = base1;
            Point CurrentBase2 = base2;
            Point CurrentBase3 = base3;

            Point CurrentBasePositive0 = base0;
            Point CurrentBasePositive1 = base1;
            Point CurrentBasePositive2 = base2;
            Point CurrentBasePositive3 = base3;

            Point CurrentBaseNegative0 = base0;
            Point CurrentBaseNegative1 = base1;
            Point CurrentBaseNegative2 = base2;
            Point CurrentBaseNegative3 = base3;

            for (int i = 0; i < this.m_Values.Length; i++)
            {
                // Check if current value is the top level (all next values are 0)
                // This boolean is used to known when we must draw the top of bar
                bool AllNextValuesAreZero = true;
                for (int j = i + 1; j < this.m_Values.Length; j++)
                {
                    if (this.m_Values[j] != 0)
                    {
                        AllNextValuesAreZero = false;
                        break;
                    }
                }

                //
                int offset = this.m_Values[i] * (verticalAxisMaxValueInPixels) / (parent.ChartDescription.VerticalAxisMaxValue - parent.ChartDescription.VerticalAxisMinValue);

                if (this.m_Values[i] != 0)
                {
                    if (this.m_Values[i] >= 0)
                    {
                        CurrentBase0 = CurrentBasePositive0;
                        CurrentBase1 = CurrentBasePositive1;
                        CurrentBase2 = CurrentBasePositive2;
                        CurrentBase3 = CurrentBasePositive3;
                    }
                    else
                    {
                        CurrentBase0 = CurrentBaseNegative0;
                        CurrentBase1 = CurrentBaseNegative1;
                        CurrentBase2 = CurrentBaseNegative2;
                        CurrentBase3 = CurrentBaseNegative3;
                    }

                    Point CurrentTop0  = new Point(CurrentBase0.X, CurrentBase0.Y - offset);
                    Point CurrentTop1  = new Point(CurrentBase1.X, CurrentBase1.Y - offset);
                    Point CurrentTop2  = new Point(CurrentBase2.X, CurrentBase2.Y - offset);
                    Point CurrentTop3  = new Point(CurrentBase3.X, CurrentBase3.Y - offset);
                    Color CurrentColor = parent.ChartDescription.GetPredefinedColor(i);

                    //
                    // 3D Gradient & 3D Flat
                    //
                    if ((parent.ChartDescription.RenderingMode == ChartRenderingMode.BarWith3dGradient) || (parent.ChartDescription.RenderingMode == ChartRenderingMode.BarWith3d))
                    {
                        // Solid brush or gradient brush
                        Color CurrentColor2;
                        if (parent.ChartDescription.RenderingMode == ChartRenderingMode.BarWith3dGradient)
                        {
                            CurrentColor2 = Color.FromArgb(CurrentColor.A, CurrentColor.R / 2, CurrentColor.G / 2, CurrentColor.B / 2);
                        }
                        else
                        {
                            CurrentColor2 = CurrentColor;
                        }

                        // Compute boundaries to fill
                        GraphicsPath        pathSubValues = new GraphicsPath();
                        LinearGradientBrush CurrentBrush;
                        if (this.m_Values[i] >= 0)
                        {
                            Point TopLeft     = new Point(CurrentBase2.X, CurrentBase1.Y);
                            Point BottomRight = new Point(CurrentTop0.X, CurrentTop3.Y);
                            CurrentBrush = new LinearGradientBrush(TopLeft, BottomRight, CurrentColor, CurrentColor2);

                            pathSubValues.AddLine(CurrentBase0, CurrentBase1);
                            pathSubValues.AddLine(CurrentBase1, CurrentBase2);
                            pathSubValues.AddLine(CurrentBase2, CurrentTop2);

                            if (AllNextValuesAreZero)
                            {
                                // Add the 'Top' part'
                                pathSubValues.AddLine(CurrentTop2, CurrentTop3);
                                pathSubValues.AddLine(CurrentTop3, CurrentTop0);
                                pathSubValues.AddLine(CurrentTop0, CurrentBase0);
                            }
                            else
                            {
                                // Skip the 'Top' part
                                pathSubValues.AddLine(CurrentTop2, CurrentTop1);
                                pathSubValues.AddLine(CurrentTop1, CurrentTop0);
                                pathSubValues.AddLine(CurrentTop0, CurrentBase0);
                            }
                        }
                        else
                        {
                            Point TopLeft     = new Point(CurrentBase0.X, CurrentBase3.Y);
                            Point BottomRight = new Point(CurrentTop2.X, CurrentTop1.Y);
                            CurrentBrush = new LinearGradientBrush(TopLeft, BottomRight, CurrentColor, CurrentColor2);

                            pathSubValues.AddLine(CurrentTop0, CurrentTop1);
                            pathSubValues.AddLine(CurrentTop1, CurrentTop2);
                            pathSubValues.AddLine(CurrentTop2, CurrentBase2);
                            if ((FirstNegativeBarToDraw) && (this.PositiveValuesSum == 0))
                            {
                                // Add the 'Top' part'
                                pathSubValues.AddLine(CurrentBase2, CurrentBase3);
                                pathSubValues.AddLine(CurrentBase3, CurrentBase0);
                                pathSubValues.AddLine(CurrentBase0, CurrentTop0);
                                FirstNegativeBarToDraw = false;
                            }
                            else
                            {
                                // Skip the 'Top' part
                                pathSubValues.AddLine(CurrentBase2, CurrentBase1);
                                pathSubValues.AddLine(CurrentBase1, CurrentBase0);
                                pathSubValues.AddLine(CurrentBase0, CurrentTop0);
                            }
                        }

                        // Fill path
                        pevent.Graphics.FillPath(CurrentBrush, pathSubValues);

                        // Draw borders on path
                        this.DisplayBorders(pevent, parent, this.m_Values[i], CurrentBase0, CurrentBase1, CurrentBase2, CurrentBase3, CurrentTop0, CurrentTop1, CurrentTop2, CurrentTop3);
                    }
                    else
                    {
                        Debug.Assert(parent.ChartDescription.RenderingMode == ChartRenderingMode.Linear3d, "ChartColumn.DisplayBars", "Rendering mode not yet managed");
                    }

                    // Next
                    if (parent.ChartDescription.CumulativeMode == ChartCumulativeMode.StartFromLastValue)
                    {
                        if (this.m_Values[i] >= 0)
                        {
                            CurrentBasePositive0 = CurrentTop0;
                            CurrentBasePositive1 = CurrentTop1;
                            CurrentBasePositive2 = CurrentTop2;
                            CurrentBasePositive3 = CurrentTop3;
                        }
                        else
                        {
                            CurrentBaseNegative0 = CurrentTop0;
                            CurrentBaseNegative1 = CurrentTop1;
                            CurrentBaseNegative2 = CurrentTop2;
                            CurrentBaseNegative3 = CurrentTop3;
                        }
                    }
                }
            }

            // Redraw top to override hidden pen color
            GraphicsPath pathTop = new GraphicsPath();

            pathTop.AddLine(CurrentBasePositive0, CurrentBasePositive1);
            pathTop.AddLine(CurrentBasePositive1, CurrentBasePositive2);
            pathTop.AddLine(CurrentBasePositive2, CurrentBasePositive3);
            pathTop.AddLine(CurrentBasePositive3, CurrentBasePositive0);
            pevent.Graphics.DrawPath(parent.ChartDescription.ColumnPen, pathTop);
        }
Example #13
0
        virtual internal void DisplayAsLinear(System.Windows.Forms.PaintEventArgs pevent, Chart parent, ChartColumn previousColumn,
                                              int columnWidthNoMargin, int verticalAxisMaxValueInPixels,
                                              Point base0, Point base1, Point base2, Point base3,
                                              Point prevBase0, Point prevBase1, Point prevBase2, Point prevBase3)
        {
            Debug.Assert(parent.ChartDescription.RenderingMode == ChartRenderingMode.Linear3d, "ChartColumn.DisplayBars", "Rendering mode not yet managed");

            // First column, nothing to draw
            if (previousColumn == null)
            {
                return;
            }

            // Draw all values
            for (int i = 0; i < this.m_Values.Length; i++)
            {
                Color currentColor       = parent.ChartDescription.GetPredefinedColor(i);
                Brush CurrentBrush       = new SolidBrush(currentColor);
                Brush CurrentBrushDarken = new SolidBrush(Color.FromArgb(currentColor.A, currentColor.R / 2, currentColor.G / 2, currentColor.B / 2));

                // Compute points
                int   prevY         = prevBase0.Y - (previousColumn.m_Values[i] * verticalAxisMaxValueInPixels / (parent.ChartDescription.VerticalAxisMaxValue - parent.ChartDescription.VerticalAxisMinValue));
                int   y             = base0.Y - (this.m_Values[i] * verticalAxisMaxValueInPixels / (parent.ChartDescription.VerticalAxisMaxValue - parent.ChartDescription.VerticalAxisMinValue));
                Point currentPoint0 = new Point(prevBase0.X + columnWidthNoMargin / 2, prevY);
                Point currentPoint1 = new Point(base0.X + columnWidthNoMargin / 2, y);
                Point currentPoint2 = new Point(base3.X + columnWidthNoMargin / 2, y - parent.ChartDescription.DeltaDepth);
                Point currentPoint3 = new Point(prevBase3.X + columnWidthNoMargin / 2, prevY - parent.ChartDescription.DeltaDepth);

                // Local top value path
                GraphicsPath pathSubValues = new GraphicsPath();

                pathSubValues.AddLine(currentPoint0, currentPoint1);
                pathSubValues.AddLine(currentPoint1, currentPoint2);
                pathSubValues.AddLine(currentPoint2, currentPoint3);
                pathSubValues.AddLine(currentPoint3, currentPoint0);
                if (prevY > y)
                {
                    pevent.Graphics.FillPath(CurrentBrushDarken, pathSubValues);
                }
                else
                {
                    pevent.Graphics.FillPath(CurrentBrush, pathSubValues);
                }
            }
        }
Example #14
0
		virtual internal void DisplayAsBarWith3d (System.Windows.Forms.PaintEventArgs pevent, Chart parent, ChartColumn	previousColumn, 
													int columnWidthNoMargin, int verticalAxisMaxValueInPixels, 
													Point base0, Point base1, Point base2, Point base3,
													Point prevBase0, Point prevBase1, Point prevBase2, Point prevBase3, bool gradientMode)
		{
			bool  FirstNegativeBarToDraw = true;

			// Draw all values
			Point CurrentBase0 = base0;
			Point CurrentBase1 = base1;
			Point CurrentBase2 = base2;
			Point CurrentBase3 = base3;

			Point CurrentBasePositive0 = base0;
			Point CurrentBasePositive1 = base1;
			Point CurrentBasePositive2 = base2;
			Point CurrentBasePositive3 = base3;

			Point CurrentBaseNegative0 = base0;
			Point CurrentBaseNegative1 = base1;
			Point CurrentBaseNegative2 = base2;
			Point CurrentBaseNegative3 = base3;

			for (int i = 0; i < this.m_Values.Length; i++)
			{
				// Check if current value is the top level (all next values are 0)
				// This boolean is used to known when we must draw the top of bar
				bool AllNextValuesAreZero = true;
				for (int j = i+1; j < this.m_Values.Length; j++)
				{
					if (this.m_Values[j] != 0)
					{
						AllNextValuesAreZero = false;
						break;
					}
				}

				//
				int   offset      = this.m_Values[i] * (verticalAxisMaxValueInPixels) / (parent.ChartDescription.VerticalAxisMaxValue - parent.ChartDescription.VerticalAxisMinValue);

				if (this.m_Values[i] != 0)
				{
					if (this.m_Values[i] >= 0)
					{
						CurrentBase0 = CurrentBasePositive0;
						CurrentBase1 = CurrentBasePositive1;
						CurrentBase2 = CurrentBasePositive2;
						CurrentBase3 = CurrentBasePositive3;
					}
					else
					{
						CurrentBase0 = CurrentBaseNegative0;
						CurrentBase1 = CurrentBaseNegative1;
						CurrentBase2 = CurrentBaseNegative2;
						CurrentBase3 = CurrentBaseNegative3;
					}

					Point	CurrentTop0			= new Point (CurrentBase0.X, CurrentBase0.Y - offset);
					Point	CurrentTop1			= new Point (CurrentBase1.X, CurrentBase1.Y - offset);
					Point	CurrentTop2			= new Point (CurrentBase2.X, CurrentBase2.Y - offset);
					Point	CurrentTop3			= new Point (CurrentBase3.X, CurrentBase3.Y - offset);
					Color	CurrentColor		= parent.ChartDescription.GetPredefinedColor (i);

					//
					// 3D Gradient & 3D Flat
					//
					if ((parent.ChartDescription.RenderingMode == ChartRenderingMode.BarWith3dGradient) ||(parent.ChartDescription.RenderingMode == ChartRenderingMode.BarWith3d))
					{
						// Solid brush or gradient brush
						Color CurrentColor2;
						if (parent.ChartDescription.RenderingMode == ChartRenderingMode.BarWith3dGradient)
							CurrentColor2	= Color.FromArgb (CurrentColor.A, CurrentColor.R  /2, CurrentColor.G  /2, CurrentColor.B  /2);
						else
							CurrentColor2	= CurrentColor;

						// Compute boundaries to fill
						GraphicsPath		pathSubValues = new GraphicsPath ();
						LinearGradientBrush	CurrentBrush;
						if (this.m_Values[i] >= 0)
						{
							Point TopLeft		= new Point (CurrentBase2.X, CurrentBase1.Y);
							Point BottomRight	= new Point (CurrentTop0.X, CurrentTop3.Y);
							CurrentBrush		= new LinearGradientBrush (TopLeft, BottomRight, CurrentColor, CurrentColor2);

							pathSubValues.AddLine (CurrentBase0, CurrentBase1);
							pathSubValues.AddLine (CurrentBase1, CurrentBase2);
							pathSubValues.AddLine (CurrentBase2, CurrentTop2);

							if (AllNextValuesAreZero)
							{
								// Add the 'Top' part'	
								pathSubValues.AddLine (CurrentTop2, CurrentTop3);
								pathSubValues.AddLine (CurrentTop3, CurrentTop0);
								pathSubValues.AddLine (CurrentTop0, CurrentBase0);
							}
							else
							{
								// Skip the 'Top' part
								pathSubValues.AddLine (CurrentTop2, CurrentTop1);
								pathSubValues.AddLine (CurrentTop1, CurrentTop0);
								pathSubValues.AddLine (CurrentTop0, CurrentBase0);
							}
						}
						else 
						{
							Point TopLeft		= new Point (CurrentBase0.X, CurrentBase3.Y);
							Point BottomRight	= new Point (CurrentTop2.X, CurrentTop1.Y);
							CurrentBrush		= new LinearGradientBrush (TopLeft, BottomRight, CurrentColor, CurrentColor2);

							pathSubValues.AddLine (CurrentTop0, CurrentTop1);
							pathSubValues.AddLine (CurrentTop1, CurrentTop2);
							pathSubValues.AddLine (CurrentTop2, CurrentBase2);
							if (( FirstNegativeBarToDraw) && (this.PositiveValuesSum == 0))
							{
								// Add the 'Top' part'	
								pathSubValues.AddLine (CurrentBase2, CurrentBase3);
								pathSubValues.AddLine (CurrentBase3, CurrentBase0);
								pathSubValues.AddLine (CurrentBase0, CurrentTop0);
								FirstNegativeBarToDraw = false;
							}
							else
							{
								// Skip the 'Top' part
								pathSubValues.AddLine (CurrentBase2, CurrentBase1);
								pathSubValues.AddLine (CurrentBase1, CurrentBase0);
								pathSubValues.AddLine (CurrentBase0, CurrentTop0);
							}
						}

						// Fill path
						pevent.Graphics.FillPath (CurrentBrush, pathSubValues);

						// Draw borders on path
						this.DisplayBorders (pevent, parent, this.m_Values[i], CurrentBase0, CurrentBase1, CurrentBase2, CurrentBase3, CurrentTop0, CurrentTop1, CurrentTop2, CurrentTop3);
					}
					else
					{
						Debug.Assert (parent.ChartDescription.RenderingMode == ChartRenderingMode.Linear3d, "ChartColumn.DisplayBars", "Rendering mode not yet managed");
					}

					// Next
					if (parent.ChartDescription.CumulativeMode == ChartCumulativeMode.StartFromLastValue)
					{
						if (this.m_Values[i] >= 0)
						{
							CurrentBasePositive0 = CurrentTop0;
							CurrentBasePositive1 = CurrentTop1;
							CurrentBasePositive2 = CurrentTop2;
							CurrentBasePositive3 = CurrentTop3;
						}
						else
						{
							CurrentBaseNegative0 = CurrentTop0;
							CurrentBaseNegative1 = CurrentTop1;
							CurrentBaseNegative2 = CurrentTop2;
							CurrentBaseNegative3 = CurrentTop3;
						}
					}
				}
			}

			// Redraw top to override hidden pen color
			GraphicsPath pathTop = new GraphicsPath ();
			pathTop.AddLine (CurrentBasePositive0, CurrentBasePositive1);
			pathTop.AddLine (CurrentBasePositive1, CurrentBasePositive2);
			pathTop.AddLine (CurrentBasePositive2, CurrentBasePositive3);
			pathTop.AddLine (CurrentBasePositive3, CurrentBasePositive0);
			pevent.Graphics.DrawPath (parent.ChartDescription.ColumnPen, pathTop);
		}
Example #15
0
		virtual internal void DisplayAsLinear (System.Windows.Forms.PaintEventArgs pevent, Chart parent, ChartColumn	previousColumn, 
												int columnWidthNoMargin, int verticalAxisMaxValueInPixels, 
												Point base0, Point base1, Point base2, Point base3,
												Point prevBase0, Point prevBase1, Point prevBase2, Point prevBase3)
		{
			Debug.Assert (parent.ChartDescription.RenderingMode == ChartRenderingMode.Linear3d, "ChartColumn.DisplayBars", "Rendering mode not yet managed");

			// First column, nothing to draw
			if (previousColumn == null)
				return;

			// Draw all values
			for (int i = 0; i < this.m_Values.Length; i++)
			{
				Color		currentColor		= parent.ChartDescription.GetPredefinedColor (i);
				Brush		CurrentBrush		= new SolidBrush (currentColor);
				Brush		CurrentBrushDarken	= new SolidBrush (Color.FromArgb (currentColor.A, currentColor.R  /2, currentColor.G  /2, currentColor.B  /2));

				// Compute points
				int			prevY			= prevBase0.Y - (previousColumn.m_Values[i] * verticalAxisMaxValueInPixels / (parent.ChartDescription.VerticalAxisMaxValue - parent.ChartDescription.VerticalAxisMinValue));
				int			y				= base0.Y - (this.m_Values[i] * verticalAxisMaxValueInPixels / (parent.ChartDescription.VerticalAxisMaxValue - parent.ChartDescription.VerticalAxisMinValue));
				Point		currentPoint0	= new Point (prevBase0.X + columnWidthNoMargin / 2, prevY);
				Point		currentPoint1	= new Point (base0.X + columnWidthNoMargin / 2, y);
				Point		currentPoint2	= new Point (base3.X + columnWidthNoMargin / 2, y - parent.ChartDescription.DeltaDepth);
				Point		currentPoint3	= new Point (prevBase3.X + columnWidthNoMargin / 2, prevY - parent.ChartDescription.DeltaDepth);
			
				// Local top value path
				GraphicsPath pathSubValues = new GraphicsPath ();

				pathSubValues.AddLine (currentPoint0, currentPoint1);
				pathSubValues.AddLine (currentPoint1, currentPoint2);
				pathSubValues.AddLine (currentPoint2, currentPoint3);
				pathSubValues.AddLine (currentPoint3, currentPoint0);
				if (prevY > y)
					pevent.Graphics.FillPath (CurrentBrushDarken, pathSubValues);
				else
					pevent.Graphics.FillPath (CurrentBrush, pathSubValues);
			}
		}