Exemple #1
0
        /// <summary>
        /// Draw- simple draw of an entire page.  Useful when printing or creating an image.
        /// </summary>
        /// <param name="g"></param>
        /// <param name="page"></param>
        /// <param name="clipRectangle"></param>
        public void Draw(Graphics g, int page, System.DrawingCore.Rectangle clipRectangle, bool drawBackground, PointF pageOffset)
        {
            DpiX = g.DpiX;                       // this can change (e.g. printing graphics context)
            DpiY = g.DpiY;

            //			g.InterpolationMode = InterpolationMode.HighQualityBilinear;	// try to unfuzz charts
            g.PageUnit = GraphicsUnit.Pixel;
            g.ScaleTransform(1, 1);

            if (!pageOffset.IsEmpty)    // used when correcting for non-printable area on paper
            {
                g.TranslateTransform(pageOffset.X, pageOffset.Y);
            }

            _left    = 0;
            _top     = 0;
            _hScroll = 0;
            _vScroll = 0;

            RectangleF r = new RectangleF(clipRectangle.X, clipRectangle.Y,
                                          clipRectangle.Width, clipRectangle.Height);

            if (drawBackground)
            {
                g.FillRectangle(Brushes.White, PixelsX(_left), PixelsY(_top),
                                PixelsX(_pgs.PageWidth), PixelsY(_pgs.PageHeight));
            }

            ProcessPage(g, _pgs[page], r, false);
        }
Exemple #2
0
 internal ChartLayout(int width, int height)
 {
     _Width      = width;
     _Height     = height;
     _LeftMargin = _RightMargin = _TopMargin = _BottomMargin = 0;
     _PlotArea   = System.DrawingCore.Rectangle.Empty;
 }
Exemple #3
0
        void DrawPie(Graphics g, Report rpt, Brush brush, System.DrawingCore.Rectangle rect, int iRow, int iCol, float startAngle, float endAngle)
        {
            if ((ChartSubTypeEnum)Enum.Parse(typeof(ChartSubTypeEnum), _ChartDefn.Subtype.EvaluateString(rpt, _row)) == ChartSubTypeEnum.Exploded)
            {
                // Need to adjust the rectangle
                int side = (int)(rect.Width * .75);                     // side needs to be smaller to account for exploded pies
                int offset = (int)(side * .1);                          //  we add a little to the left and top
                int adjX, adjY;
                adjX = adjY = (int)(side * .1);

                float midAngle = startAngle + (endAngle - startAngle) / 2;

                if (midAngle < 90)
                {
                }
                else if (midAngle < 180)
                {
                    adjX = -adjX;
                }
                else if (midAngle < 270)
                {
                    adjX = adjY = -adjX;
                }
                else
                {
                    adjY = -adjY;
                }
                rect = new System.DrawingCore.Rectangle(rect.Left + adjX + offset, rect.Top + adjY + offset, side, side);
            }

            g.FillPie(brush, rect, startAngle, endAngle - startAngle);
            g.DrawPie(Pens.Black, rect, startAngle, endAngle - startAngle);

            return;
        }
Exemple #4
0
 /// <summary>
 /// A method used to obtain a rectangle from the screen coordinates supplied.
 /// </summary>
 public static System.DrawingCore.Rectangle RectFromPoints(Point p1, Point p2)
 {
     System.DrawingCore.Rectangle r = new System.DrawingCore.Rectangle();
     // set the width and x of rectangle
     if (p1.X < p2.X)
     {
         r.X     = p1.X;
         r.Width = p2.X - p1.X;
     }
     else
     {
         r.X     = p2.X;
         r.Width = p1.X - p2.X;
     }
     // set the height and y of rectangle
     if (p1.Y < p2.Y)
     {
         r.Y      = p1.Y;
         r.Height = p2.Y - p1.Y;
     }
     else
     {
         r.Y      = p2.Y;
         r.Height = p1.Y - p2.Y;
     }
     return(r);
 }
        /// <summary>
        /// Replaces the colors of a particular area:
        /// </summary>
        /// <param name="x">x</param>
        /// <param name="y">y</param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="newColor"></param>
        /// <returns></returns>
        public Rectangle FloodFill(int x, int y, Color newColor, int width = 0, int height = 0)
        {
            Color oldColor = GetPixel(x, y);

            if (ColorsEqual(oldColor, newColor))
            {
                return(Rectangle.Empty);
            }
            Rectangle editRegion = new Rectangle(x, y, width, height);

            Stack <Point> points = new Stack <Point>();

            points.Push(new Point(x, y));
            SetPixel(x, y, newColor);

            while (points.Count > 0)
            {
                Point pt = points.Pop();
                if (pt.X > 0)
                {
                    CheckFloodPoint(points, pt.X - 1, pt.Y, oldColor, newColor);
                }
                if (pt.Y > 0)
                {
                    CheckFloodPoint(points, pt.X, pt.Y - 1, oldColor, newColor);
                }
                if (pt.X < Width - 1)
                {
                    CheckFloodPoint(points, pt.X + 1, pt.Y, oldColor, newColor);
                }
                if (pt.Y < Height - 1)
                {
                    CheckFloodPoint(points, pt.X, pt.Y + 1, oldColor, newColor);
                }

                // grow the edit region:
                if (pt.X < editRegion.X)
                {
                    editRegion.Width += editRegion.X - pt.X;
                    editRegion.X      = pt.X;
                }
                else if (pt.X > editRegion.Right)
                {
                    editRegion.Width = pt.X - editRegion.X;
                }

                if (pt.Y < editRegion.Y)
                {
                    editRegion.Height += editRegion.Y - pt.Y;
                    editRegion.Y       = pt.Y;
                }
                else if (pt.Y > editRegion.Bottom)
                {
                    editRegion.Height = pt.Y - editRegion.Y;
                }
            }

            return(editRegion);
        }
        /// <summary>
        /// Locks the image to get it ready for fast manipluations.
        /// </summary>
        public void LockImage()
        {
            _bounds = new Rectangle(Point.Empty, Image.Size);
            _width  = _bounds.Width * sizeof(PixelData);
            if (_width % 4 != 0)
            {
                _width = ((_width >> 2) + 1) << 2;
            }

            _imageData = Image.LockBits(_bounds, ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
            _pBase     = (byte *)_imageData.Scan0.ToPointer();
        }
Exemple #7
0
        void DrawPlotAreaPercentStacked(Report rpt, Graphics g)
        {
            int barsNeeded = CategoryCount;
            int gapsNeeded = CategoryCount * 2;

            // Draw Plot area data
            double max = 1;

            int heightBar   = (int)((Layout.PlotArea.Height - gapsNeeded * _GapSize) / barsNeeded);
            int maxBarWidth = (int)(Layout.PlotArea.Width);

            // Loop thru calculating all the data points
            for (int iRow = 1; iRow <= CategoryCount; iRow++)
            {
                int barLoc = (int)(Layout.PlotArea.Top + (iRow - 1) * ((double)(Layout.PlotArea.Height) / CategoryCount));
                barLoc += _GapSize;                     // space before series

                double sum = 0;
                for (int iCol = 1; iCol <= SeriesCount; iCol++)
                {
                    sum += GetDataValue(rpt, iRow, iCol);
                }
                double v     = 0;
                int    saveX = 0;
                double t     = 0;
                for (int iCol = 1; iCol <= SeriesCount; iCol++)
                {
                    t  = GetDataValue(rpt, iRow, iCol);
                    v += t;

                    int x = (int)((Math.Min(v / sum, max) / max) * maxBarWidth);

                    System.DrawingCore.Rectangle rect;
                    rect = new System.DrawingCore.Rectangle(Layout.PlotArea.Left + saveX, barLoc, x - saveX, heightBar);

                    DrawColumnBar(rpt, g,
                                  GetSeriesBrush(rpt, iRow, iCol),
                                  rect, iRow, iCol);

                    //Add a metafilecomment to use as a tooltip GJL 26092008
                    if (_showToolTips)
                    {
                        String val = "ToolTip:" + t.ToString(_tooltipYFormat) + "|X:" + (int)rect.X + "|Y:" + (int)rect.Y + "|W:" + rect.Width + "|H:" + rect.Height;
                        g.AddMetafileComment(new System.Text.ASCIIEncoding().GetBytes(val));
                    }

                    saveX = x;
                }
            }

            return;
        }
Exemple #8
0
        override internal void Draw(Report rpt)
        {
            CreateSizedBitmap();
            using (Graphics g1 = Graphics.FromImage(_bm))
            {
                _aStream = new System.IO.MemoryStream();
                IntPtr HDC = g1.GetHdc();
                //_mf = new System.DrawingCore.Imaging.Metafile(_aStream, HDC);
                _mf = new System.DrawingCore.Imaging.Metafile(_aStream, HDC, new RectangleF(0, 0, _bm.Width, _bm.Height), System.DrawingCore.Imaging.MetafileFrameUnit.Pixel);
                g1.ReleaseHdc(HDC);
            }

            using (Graphics g = Graphics.FromImage(_mf))
            {
                // 06122007AJM Used to Force Higher Quality
                g.InterpolationMode  = System.DrawingCore.Drawing2D.InterpolationMode.HighQualityBicubic;
                g.SmoothingMode      = System.DrawingCore.Drawing2D.SmoothingMode.HighQuality;
                g.PixelOffsetMode    = System.DrawingCore.Drawing2D.PixelOffsetMode.None;
                g.CompositingQuality = System.DrawingCore.Drawing2D.CompositingQuality.HighQuality;

                // Adjust the top margin to depend on the title height
                Size titleSize = DrawTitleMeasure(rpt, g, ChartDefn.Title);
                Layout.TopMargin = titleSize.Height;

                double max = 0, min = 0;                // Get the max and min values
                //		GetValueMaxMin(rpt, ref max, ref min,0, 1);

                DrawChartStyle(rpt, g);

                // Draw title; routine determines if necessary
                DrawTitle(rpt, g, ChartDefn.Title, new System.DrawingCore.Rectangle(0, 0, _bm.Width, Layout.TopMargin));

                Layout.LeftMargin  = 0;
                Layout.RightMargin = 0;

                // Draw legend
                System.DrawingCore.Rectangle lRect = DrawLegend(rpt, g, false, true);

                Layout.BottomMargin = 0;

                AdjustMargins(lRect, rpt, g);                           // Adjust margins based on legend.

                // Draw Plot area
                DrawPlotAreaStyle(rpt, g, lRect);

                string subtype = _ChartDefn.Subtype.EvaluateString(rpt, _row);

                DrawMap(rpt, g, subtype, max, min);

                DrawLegend(rpt, g, false, false);
            }
        }
Exemple #9
0
        // DrawCategoryAxis
        void DrawCategoryAxis(Report rpt, Graphics g, System.DrawingCore.Rectangle rect)
        {
            if (this.ChartDefn.CategoryAxis == null)
            {
                return;
            }
            Axis a = this.ChartDefn.CategoryAxis.Axis;

            if (a == null)
            {
                return;
            }
            Style s = a.Style;

            Size tSize = DrawTitleMeasure(rpt, g, a.Title);

            DrawTitle(rpt, g, a.Title,
                      new System.DrawingCore.Rectangle(rect.Left, rect.Top, tSize.Width, rect.Height));

            int      drawHeight = rect.Height / CategoryCount;
            TypeCode tc;

            for (int iRow = 1; iRow <= CategoryCount; iRow++)
            {
                object v = this.GetCategoryValue(rpt, iRow, out tc);

                int drawLoc = (int)(rect.Top + (iRow - 1) * ((double)rect.Height / CategoryCount));

                // Draw the category text
                if (a.Visible)
                {
                    System.DrawingCore.Rectangle drawRect = new System.DrawingCore.Rectangle(rect.Left + tSize.Width, drawLoc, rect.Width - tSize.Width, drawHeight);
                    if (s == null)
                    {
                        Style.DrawStringDefaults(g, v, drawRect);
                    }
                    else
                    {
                        s.DrawString(rpt, g, v, tc, null, drawRect);
                    }
                }
                // Draw the Major Tick Marks (if necessary)
                DrawCategoryAxisTick(g, true, a.MajorTickMarks, new Point(rect.Right, drawLoc));
            }

            // Draw the end on (if necessary)
            DrawCategoryAxisTick(g, true, a.MajorTickMarks, new Point(rect.Right, rect.Bottom));

            return;
        }
Exemple #10
0
        private void PrintPage(object sender, PrintPageEventArgs e)
        {
            System.DrawingCore.Rectangle r = new System.DrawingCore.Rectangle(0, 0, int.MaxValue, int.MaxValue);
            // account for the non-printable area of the paper
            PointF pageOffset;

            if (this.UseTrueMargins && this._Report != null)
            {
                // The page offset is set in pixels as the Draw method changes the graphics object to use pixels
                // (the origin transform does not get changed by the change in units.  PrintableArea returns
                // numbers in the hundredths of an inch.

                float x = ((e.PageSettings.PrintableArea.X * e.Graphics.DpiX) / 100.0F) - e.Graphics.Transform.OffsetX;
                float y = ((e.PageSettings.PrintableArea.Y * e.Graphics.DpiY) / 100.0F) - e.Graphics.Transform.OffsetY;

                // Get the margins in printer pixels (don't use the function!)
                // Points to pixels conversion ((double)x * DpiX / POINTSIZEF)
                float lm = (float)((double)_Report.LeftMarginPoints * e.Graphics.DpiX / POINTSIZEF);
                float tm = (float)((double)_Report.TopMarginPoints * e.Graphics.DpiY / POINTSIZEF);
                // Correct based on the report margin
                if (x > lm)      // left margin is less than the minimum left margin
                {
                    x = 0;
                }
                if (y > tm)      // top margin is less than the minimum top margin
                {
                    y = 0;
                }
                pageOffset = new PointF(-x, -y);
            }
            else
            {
                pageOffset = PointF.Empty;
            }

            _DrawPanel.Draw(e.Graphics, printCurrentPage, r, false, pageOffset);

            printCurrentPage++;
            if (printCurrentPage > printEndPage)
            {
                e.HasMorePages = false;
            }
            else
            {
                e.HasMorePages = true;
            }
        }
Exemple #11
0
        /// <summary>将指定区域分块
        /// </summary>
        /// <param name="nSize_Block_R">分块行高</param>
        /// <param name="nSize_Block_C">分块列宽</param>
        /// <param name="nMax">行最大块数</param>
        /// <param name="bBase_Zero">是否从0,0开始计算</param>
        /// <returns></returns>
        public virtual List <Rectangle> Block(int nSize_Block_R, int nSize_Block_C, int nMax, bool bBase_Zero = false)
        {
            List <Rectangle> rectBlocks = new List <System.DrawingCore.Rectangle>();
            Rectangle        rectBlock;
            Rectangle        rectArea = new System.DrawingCore.Rectangle(0, 0, m_Rect.Width, m_Rect.Height);

            int nRows, nCols, nCols_Block, nLeft, nTop;
            int nBase_X = 0, nBase_Y = 0;

            try
            {
                //计算行列块数
                nCols_Block = nSize_Block_C * nMax;
                nRows       = (int)Math.Ceiling(1.0 * m_Rect.Height / nSize_Block_R);
                nCols       = (int)Math.Ceiling(1.0 * m_Rect.Width / nCols_Block);

                //基点调整
                if (bBase_Zero == false)
                {
                    nBase_X  = this.p_Left;
                    nBase_Y  = this.p_Top;
                    rectArea = m_Rect;
                }

                //分区行分段 (均逐分区行扫描)
                for (int i = 0; i < nRows; i++)
                {
                    for (int j = 0; j < nCols; j++)
                    {
                        //示例分区
                        nLeft     = nBase_X + j * nCols_Block;
                        nTop      = nBase_Y + i * nSize_Block_R;
                        rectBlock = new System.DrawingCore.Rectangle(nLeft, nTop, nCols_Block, nSize_Block_R);

                        //与原区叠加
                        rectBlock.Intersect(rectArea);
                        rectBlocks.Add(rectBlock);
                    }
                }
                return(rectBlocks);
            }
            catch
            {
                throw;
            }
        }
Exemple #12
0
        // DrawCategoryAxis
        protected void DrawCategoryAxis(Report rpt, Graphics g, System.DrawingCore.Rectangle rect)
        {
            if (this.ChartDefn.CategoryAxis == null)
            {
                return;
            }
            Axis a = this.ChartDefn.CategoryAxis.Axis;

            if (a == null)
            {
                return;
            }
            Style s = a.Style;

            Size tSize = DrawTitleMeasure(rpt, g, a.Title);

            DrawTitle(rpt, g, a.Title, new System.DrawingCore.Rectangle(rect.Left, rect.Bottom - tSize.Height, rect.Width, tSize.Height));

            int      drawWidth = rect.Width / CategoryCount;
            TypeCode tc;

            for (int iRow = 1; iRow <= CategoryCount; iRow++)
            {
                object v = this.GetCategoryValue(rpt, iRow, out tc);

                int drawLoc = (int)(rect.Left + (iRow - 1) * ((double)rect.Width / CategoryCount));

                // Draw the category text
                if (a.Visible)
                {
                    System.DrawingCore.Rectangle drawRect = new System.DrawingCore.Rectangle(drawLoc, rect.Top, drawWidth, rect.Height - tSize.Height);
                    if (s == null)
                    {
                        Style.DrawStringDefaults(g, v, drawRect);
                    }
                    else
                    {
                        s.DrawString(rpt, g, v, tc, null, drawRect);
                    }
                }
            }

            return;
        }
Exemple #13
0
        void DrawColumnBar(Report rpt, Graphics g, Brush brush, System.DrawingCore.Rectangle rect, int iRow, int iCol)
        {
            g.FillRectangle(brush, rect);
            g.DrawRectangle(Pens.Black, rect);

            if ((ChartSubTypeEnum)Enum.Parse(typeof(ChartSubTypeEnum), _ChartDefn.Subtype.EvaluateString(rpt, _row)) == ChartSubTypeEnum.Stacked ||
                (ChartSubTypeEnum)Enum.Parse(typeof(ChartSubTypeEnum), _ChartDefn.Subtype.EvaluateString(rpt, _row)) == ChartSubTypeEnum.PercentStacked)
            {
                DrawDataPoint(rpt, g, rect, iRow, iCol);
            }
            else
            {
                Point p;
                p = new Point(rect.Right, rect.Top);
                DrawDataPoint(rpt, g, p, iRow, iCol);
            }


            return;
        }
Exemple #14
0
        override internal void Draw(Report rpt)
        {
            CreateSizedBitmap();

            using (Graphics g1 = Graphics.FromImage(_bm))
            {
                _aStream = new System.IO.MemoryStream();
                IntPtr HDC = g1.GetHdc();
                _mf = new System.DrawingCore.Imaging.Metafile(_aStream, HDC, new RectangleF(0, 0, _bm.Width, _bm.Height), System.DrawingCore.Imaging.MetafileFrameUnit.Pixel);
                g1.ReleaseHdc(HDC);
            }

            using (Graphics g = Graphics.FromImage(_mf))
            {
                // 06122007AJM Used to Force Higher Quality
                g.InterpolationMode  = System.DrawingCore.Drawing2D.InterpolationMode.HighQualityBicubic;
                g.SmoothingMode      = System.DrawingCore.Drawing2D.SmoothingMode.HighQuality;
                g.PixelOffsetMode    = System.DrawingCore.Drawing2D.PixelOffsetMode.None;
                g.CompositingQuality = System.DrawingCore.Drawing2D.CompositingQuality.HighQuality;

                // Adjust the top margin to depend on the title height
                Size titleSize = DrawTitleMeasure(rpt, g, ChartDefn.Title);
                Layout.TopMargin = titleSize.Height;

                DrawChartStyle(rpt, g);

                // Draw title; routine determines if necessary
                DrawTitle(rpt, g, ChartDefn.Title, new System.DrawingCore.Rectangle(0, 0, _bm.Width, Layout.TopMargin));

                // Draw legend
                System.DrawingCore.Rectangle lRect = DrawLegend(rpt, g, false, true);

                // Adjust the bottom margin to depend on the Category Axis
                Size caSize = CategoryAxisSize(rpt, g);
                Layout.BottomMargin = caSize.Height;

                // 20022008 AJM GJL - Added required info
                AdjustMargins(lRect, rpt, g);                           // Adjust margins based on legend.

                // Draw Plot area
                DrawPlotAreaStyle(rpt, g, lRect);

                // Draw Category Axis
                if (caSize.Height > 0)
                {
                    DrawCategoryAxis(rpt, g,
                                     new System.DrawingCore.Rectangle(Layout.LeftMargin, _bm.Height - Layout.BottomMargin, _bm.Width - Layout.LeftMargin - Layout.RightMargin, caSize.Height));
                }

                if (ChartDefn.Type == ChartTypeEnum.Doughnut)
                {
                    DrawPlotAreaDoughnut(rpt, g);
                }
                else
                {
                    DrawPlotAreaPie(rpt, g);
                }

                DrawLegend(rpt, g, false, false);
            }
        }
Exemple #15
0
        void DrawPlotAreaDoughnut(Report rpt, Graphics g)
        {
            // Draw Plot area data
            int widthPie   = Layout.PlotArea.Width;
            int maxHeight  = Layout.PlotArea.Height;
            int maxPieSize = Math.Min(widthPie, maxHeight);
            int doughWidth = maxPieSize / 4 / CategoryCount;

            if (doughWidth < 2)
            {
                doughWidth = 2;                                 // enforce minimum width
            }
            float startAngle;
            float endAngle;
            int   pieLocX;
            int   pieLocY;
            int   pieSize;

            // Go and draw the pies
            int left = Layout.PlotArea.Left + (maxPieSize == widthPie? 0: (widthPie - maxPieSize) / 2);
            int top  = Layout.PlotArea.Top + (maxPieSize == maxHeight? 0: (maxHeight - maxPieSize) / 2);

            for (int iRow = 1; iRow <= CategoryCount; iRow++)
            {
                pieLocX = left + ((iRow - 1) * doughWidth);
                pieLocY = top + ((iRow - 1) * doughWidth);

                double total = 0;                       // sum up for this category
                for (int iCol = 1; iCol <= SeriesCount; iCol++)
                {
                    total += this.GetDataValue(rpt, iRow, iCol);
                }

                // Pie size decreases as we go in
                startAngle = 0.0f;
                pieSize    = maxPieSize - ((iRow - 1) * doughWidth * 2);
                for (int iCol = 1; iCol <= SeriesCount; iCol++)
                {
                    double v = this.GetDataValue(rpt, iRow, iCol);
                    endAngle = (float)(startAngle + v / total * 360);

                    DrawPie(g, rpt, GetSeriesBrush(rpt, iRow, iCol),
                            new System.DrawingCore.Rectangle(pieLocX, pieLocY, pieSize, pieSize), iRow, iCol, startAngle, endAngle);

                    startAngle = endAngle;
                }
            }
            // Now draw the center hole with the plot area style
            if (ChartDefn.PlotArea == null || ChartDefn.PlotArea.Style == null)
            {
                return;
            }
            pieLocX = left + (CategoryCount * doughWidth);
            pieLocY = top + (CategoryCount * doughWidth);
            pieSize = maxPieSize - (CategoryCount * doughWidth * 2);
            System.DrawingCore.Rectangle rect = new System.DrawingCore.Rectangle(pieLocX, pieLocY, pieSize, pieSize);
            Style s = ChartDefn.PlotArea.Style;

            Rows cData = ChartDefn.ChartMatrix.GetMyData(rpt);
            Row  r     = cData.Data[0];

            s.DrawBackgroundCircle(rpt, g, r, rect);
        }
Exemple #16
0
        protected void DrawValueAxis(Report rpt, Graphics g, double min, double max,
                                     System.DrawingCore.Rectangle rect, int plotLeft, int plotRight)
        {
            if (this.ChartDefn.ValueAxis == null)
            {
                return;
            }
            Axis a = this.ChartDefn.ValueAxis.Axis;

            if (a == null)
            {
                return;
            }
            Style s = a.Style;

            int    intervalCount;
            double incr;

            SetIncrementAndInterval(rpt, a, min, max, out incr, out intervalCount);      // Calculate the interval count

            Size tSize = DrawTitleMeasure(rpt, g, a.Title);

            DrawTitle(rpt, g, a.Title, new System.DrawingCore.Rectangle(rect.Left, rect.Top, tSize.Width, rect.Height));

            double v = min;

            for (int i = 0; i < intervalCount + 1; i++)
            {
                int h = (int)(((Math.Min(v, max) - min) / (max - min)) * rect.Height);
                if (h < 0)              // this is really some form of error
                {
                    v += incr;
                    continue;
                }

                if (!a.Visible)
                {
                    // nothing to do
                }
                else if (s != null)
                {
                    Size size = s.MeasureString(rpt, g, v, TypeCode.Double, null, int.MaxValue);
                    System.DrawingCore.Rectangle vRect =
                        new System.DrawingCore.Rectangle(rect.Left + tSize.Width, rect.Top + rect.Height - h - size.Height / 2, rect.Width - tSize.Width, size.Height);
                    s.DrawString(rpt, g, v, TypeCode.Double, null, vRect);
                }
                else
                {
                    Size size = Style.MeasureStringDefaults(rpt, g, v, TypeCode.Double, null, int.MaxValue);
                    System.DrawingCore.Rectangle vRect =
                        new System.DrawingCore.Rectangle(rect.Left + tSize.Width, rect.Top + rect.Height - h - size.Height / 2, rect.Width - tSize.Width, size.Height);
                    Style.DrawStringDefaults(g, v, vRect);
                }

                DrawValueAxisGrid(rpt, g, a.MajorGridLines, new Point(plotLeft, rect.Top + rect.Height - h), new Point(plotRight, rect.Top + rect.Height - h));
                DrawValueAxisTick(rpt, g, true, a.MajorTickMarks, a.MajorGridLines, new Point(plotLeft, rect.Top + rect.Height - h));

                v += incr;
            }

            // Draw the end points of the major grid lines
            DrawValueAxisGrid(rpt, g, a.MajorGridLines, new Point(plotLeft, rect.Top), new Point(plotLeft, rect.Bottom));
            DrawValueAxisTick(rpt, g, true, a.MajorTickMarks, a.MajorGridLines, new Point(plotLeft, rect.Top));
            DrawValueAxisGrid(rpt, g, a.MajorGridLines, new Point(plotRight, rect.Top), new Point(plotRight, rect.Bottom));
            DrawValueAxisTick(rpt, g, true, a.MajorTickMarks, a.MajorGridLines, new Point(plotRight, rect.Bottom));

            return;
        }
Exemple #17
0
        private void DrawImageSized(PageImage pi, System.DrawingCore.Image im, System.DrawingCore.Graphics g, System.DrawingCore.RectangleF r)
        {
            float     height, width;  // some work variables
            StyleInfo si = pi.SI;

            // adjust drawing rectangle based on padding
            System.DrawingCore.RectangleF r2 = new System.DrawingCore.RectangleF(r.Left + PixelsX(si.PaddingLeft),
                                                                                 r.Top + PixelsY(si.PaddingTop),
                                                                                 r.Width - PixelsX(si.PaddingLeft + si.PaddingRight),
                                                                                 r.Height - PixelsY(si.PaddingTop + si.PaddingBottom));

            System.DrawingCore.Rectangle ir;   // int work rectangle
            switch (pi.Sizing)
            {
            case ImageSizingEnum.AutoSize:
                // Note: GDI+ will stretch an image when you only provide
                //  the left/top coordinates.  This seems pretty stupid since
                //  it results in the image being out of focus even though
                //  you don't want the image resized.
                if (g.DpiX == im.HorizontalResolution &&
                    g.DpiY == im.VerticalResolution)
                {
                    ir = new System.DrawingCore.Rectangle(Convert.ToInt32(r2.Left), Convert.ToInt32(r2.Top),
                                                          im.Width, im.Height);
                }
                else
                {
                    ir = new System.DrawingCore.Rectangle(Convert.ToInt32(r2.Left), Convert.ToInt32(r2.Top),
                                                          Convert.ToInt32(r2.Width), Convert.ToInt32(r2.Height));
                }
                g.DrawImage(im, ir);

                break;

            case ImageSizingEnum.Clip:
                Region saveRegion = g.Clip;
                Region clipRegion = new Region(g.Clip.GetRegionData());
                clipRegion.Intersect(r2);
                g.Clip = clipRegion;
                if (g.DpiX == im.HorizontalResolution &&
                    g.DpiY == im.VerticalResolution)
                {
                    ir = new System.DrawingCore.Rectangle(Convert.ToInt32(r2.Left), Convert.ToInt32(r2.Top),
                                                          im.Width, im.Height);
                }
                else
                {
                    ir = new System.DrawingCore.Rectangle(Convert.ToInt32(r2.Left), Convert.ToInt32(r2.Top),
                                                          Convert.ToInt32(r2.Width), Convert.ToInt32(r2.Height));
                }
                g.DrawImage(im, ir);
                g.Clip = saveRegion;
                break;

            case ImageSizingEnum.FitProportional:
                float ratioIm = (float)im.Height / (float)im.Width;
                float ratioR  = r2.Height / r2.Width;
                height = r2.Height;
                width  = r2.Width;
                if (ratioIm > ratioR)
                {       // this means the rectangle width must be corrected
                    width = height * (1 / ratioIm);
                }
                else if (ratioIm < ratioR)
                {       // this means the ractangle height must be corrected
                    height = width * ratioIm;
                }
                r2 = new RectangleF(r2.X, r2.Y, width, height);
                g.DrawImage(im, r2);
                break;

            case ImageSizingEnum.Fit:
            default:
                g.DrawImage(im, r2);
                break;
            }
            return;
        }
Exemple #18
0
        override internal void Draw(Report rpt)
        {
            CreateSizedBitmap();


            using (Graphics g1 = Graphics.FromImage(_bm))
            {
                _aStream = new System.IO.MemoryStream();
                IntPtr HDC = g1.GetHdc();
                _mf = new System.DrawingCore.Imaging.Metafile(_aStream, HDC, new RectangleF(0, 0, _bm.Width, _bm.Height), System.DrawingCore.Imaging.MetafileFrameUnit.Pixel);
                g1.ReleaseHdc(HDC);
            }

            using (Graphics g = Graphics.FromImage(_mf))
            {
                // 06122007AJM Used to Force Higher Quality
                g.InterpolationMode  = System.DrawingCore.Drawing2D.InterpolationMode.HighQualityBicubic;
                g.SmoothingMode      = System.DrawingCore.Drawing2D.SmoothingMode.HighQuality;
                g.PixelOffsetMode    = System.DrawingCore.Drawing2D.PixelOffsetMode.None;
                g.CompositingQuality = System.DrawingCore.Drawing2D.CompositingQuality.HighQuality;
                g.PageUnit           = GraphicsUnit.Pixel;

                // Adjust the top margin to depend on the title height
                Size titleSize = DrawTitleMeasure(rpt, g, ChartDefn.Title);
                Layout.TopMargin = titleSize.Height;

                // 20022008 AJM GJL - Added new required info
                double ymax = 0, ymin = 0;              // Get the max and min values for the y axis
                GetValueMaxMin(rpt, ref ymax, ref ymin, 1, 1);

                double xmax = 0, xmin = 0;  // Get the max and min values for the x axis
                GetValueMaxMin(rpt, ref xmax, ref xmin, 0, 1);

                double bmax = 0, bmin = 0;                  // Get the max and min values for the bubble size
                if (ChartDefn.Type == ChartTypeEnum.Bubble) // only applies to bubble (not scatter)
                {
                    GetValueMaxMin(rpt, ref bmax, ref bmin, 2, 1);
                }

                DrawChartStyle(rpt, g);

                // Draw title; routine determines if necessary
                DrawTitle(rpt, g, ChartDefn.Title, new System.DrawingCore.Rectangle(0, 0, Layout.Width, Layout.TopMargin));

                // Adjust the left margin to depend on the Value Axis
                Size vaSize = ValueAxisSize(rpt, g, ymin, ymax);
                Layout.LeftMargin = vaSize.Width;

                // Draw legend
                System.DrawingCore.Rectangle lRect = DrawLegend(rpt, g, false, true);

                // Adjust the bottom margin to depend on the Category Axis
                Size caSize = CategoryAxisSize(rpt, g, xmin, xmax);
                Layout.BottomMargin = caSize.Height;

                AdjustMargins(lRect, rpt, g);                           // Adjust margins based on legend.

                // Draw Plot area
                DrawPlotAreaStyle(rpt, g, lRect);

                // Draw Value Axis
                if (vaSize.Width > 0)                   // If we made room for the axis - we need to draw it
                {
                    DrawValueAxis(rpt, g, ymin, ymax,
                                  new System.DrawingCore.Rectangle(Layout.LeftMargin - vaSize.Width, Layout.TopMargin, vaSize.Width, Layout.PlotArea.Height), Layout.LeftMargin, _bm.Width - Layout.RightMargin);
                }

                // Draw Category Axis
                if (caSize.Height > 0)
                {
                    DrawCategoryAxis(rpt, g, xmin, xmax,
                                     new System.DrawingCore.Rectangle(Layout.LeftMargin, _bm.Height - Layout.BottomMargin, _bm.Width - Layout.LeftMargin - Layout.RightMargin, vaSize.Height),
                                     Layout.TopMargin, _bm.Height - Layout.BottomMargin);
                }

                // Draw Plot area data
                DrawPlot(rpt, g, xmin, xmax, ymin, ymax, bmin, bmax);
                DrawLegend(rpt, g, false, false);
            }
        }
Exemple #19
0
        private void DrawImageSized(PageImage pi, System.DrawingCore.Image im, Graphics g, RectangleF r)
        {
            float     height, width;            // some work variables
            StyleInfo si = pi.SI;

            // adjust drawing rectangle based on padding

            // http://www.fyireporting.com/forum/viewtopic.php?t=892
            //A.S.> convert pt to px if needed(when printing we need px, when draw preview - pt)

            RectangleF r2;

            if (g.PageUnit == GraphicsUnit.Pixel)
            {
                r2 = new RectangleF(r.Left + (si.PaddingLeft * g.DpiX) / 72,
                                    r.Top + (si.PaddingTop * g.DpiX) / 72,
                                    r.Width - ((si.PaddingLeft + si.PaddingRight) * g.DpiX) / 72,
                                    r.Height - ((si.PaddingTop + si.PaddingBottom) * g.DpiX) / 72);
            }
            else
            {
                // adjust drawing rectangle based on padding
                r2 = new RectangleF(r.Left + si.PaddingLeft,
                                    r.Top + si.PaddingTop,
                                    r.Width - si.PaddingLeft - si.PaddingRight,
                                    r.Height - si.PaddingTop - si.PaddingBottom);
            }

            System.DrawingCore.Rectangle ir;    // int work rectangle
            ir = new System.DrawingCore.Rectangle(Convert.ToInt32(r2.Left), Convert.ToInt32(r2.Top),
                                                  Convert.ToInt32(r2.Width), Convert.ToInt32(r2.Height));
            switch (pi.Sizing)
            {
            case ImageSizingEnum.AutoSize:
                // Note: GDI+ will stretch an image when you only provide
                //  the left/top coordinates.  This seems pretty stupid since
                //  it results in the image being out of focus even though
                //  you don't want the image resized.
                if (g.DpiX == im.HorizontalResolution &&
                    g.DpiY == im.VerticalResolution)
                {
                    ir = new System.DrawingCore.Rectangle(Convert.ToInt32(r2.Left), Convert.ToInt32(r2.Top),
                                                          im.Width, im.Height);
                }
                g.DrawImage(im, ir);

                break;

            case ImageSizingEnum.Clip:
                Region saveRegion = g.Clip;
                Region clipRegion = new Region(g.Clip.GetRegionData());
                clipRegion.Intersect(r2);
                g.Clip = clipRegion;
                if (g.DpiX == im.HorizontalResolution &&
                    g.DpiY == im.VerticalResolution)
                {
                    ir = new System.DrawingCore.Rectangle(Convert.ToInt32(r2.Left), Convert.ToInt32(r2.Top),
                                                          im.Width, im.Height);
                }
                g.DrawImage(im, ir);
                g.Clip = saveRegion;
                break;

            case ImageSizingEnum.FitProportional:
                float ratioIm = (float)im.Height / (float)im.Width;
                float ratioR  = r2.Height / r2.Width;
                height = r2.Height;
                width  = r2.Width;
                if (ratioIm > ratioR)
                {       // this means the rectangle width must be corrected
                    width = height * (1 / ratioIm);
                }
                else if (ratioIm < ratioR)
                {       // this means the ractangle height must be corrected
                    height = width * ratioIm;
                }
                r2 = new RectangleF(r2.X, r2.Y, width, height);
                g.DrawImage(im, r2);
                break;

            case ImageSizingEnum.Fit:
            default:
                g.DrawImage(im, r2);
                break;
            }

            //if (SelectTool && pi.AllowSelect && _SelectList.Contains(pi))
            //{
            //    g.FillRectangle(new SolidBrush(Color.FromArgb(50, _SelectItemColor)), ir);
            //}

            return;
        }
Exemple #20
0
        override internal void Draw(Report rpt)
        {
            CreateSizedBitmap();

            using (Graphics g1 = Graphics.FromImage(_bm))
            {
                _aStream = new System.IO.MemoryStream();
                IntPtr HDC = g1.GetHdc();
                _mf = new System.DrawingCore.Imaging.Metafile(_aStream, HDC, new RectangleF(0, 0, _bm.Width, _bm.Height), System.DrawingCore.Imaging.MetafileFrameUnit.Pixel);
                g1.ReleaseHdc(HDC);
            }

            using (Graphics g = Graphics.FromImage(_mf))
            {
                // 06122007AJM Used to Force Higher Quality
                g.InterpolationMode  = System.DrawingCore.Drawing2D.InterpolationMode.HighQualityBicubic;
                g.SmoothingMode      = System.DrawingCore.Drawing2D.SmoothingMode.HighQuality;
                g.PixelOffsetMode    = System.DrawingCore.Drawing2D.PixelOffsetMode.None;
                g.CompositingQuality = System.DrawingCore.Drawing2D.CompositingQuality.HighQuality;

                // Adjust the top margin to depend on the title height
                Size titleSize = DrawTitleMeasure(rpt, g, ChartDefn.Title);
                Layout.TopMargin = titleSize.Height;

                // 20022008 AJM GJL - Added new required info
                double max = 0, min = 0;                // Get the max and min values
                GetValueMaxMin(rpt, ref max, ref min, 0, 1);

                DrawChartStyle(rpt, g);

                // Draw title; routine determines if necessary
                DrawTitle(rpt, g, ChartDefn.Title, new System.DrawingCore.Rectangle(0, 0, Layout.Width, Layout.TopMargin));

                // Adjust the left margin to depend on the Value Axis
                Size vaSize = ValueAxisSize(rpt, g, min, max);
                Layout.LeftMargin = vaSize.Width;

                // Draw legend
                System.DrawingCore.Rectangle lRect = DrawLegend(rpt, g, ChartDefn.Type == ChartTypeEnum.Area? false: true, true);

                // Adjust the bottom margin to depend on the Category Axis
                Size caSize = CategoryAxisSize(rpt, g);
                Layout.BottomMargin = caSize.Height;

                AdjustMargins(lRect, rpt, g);                           // Adjust margins based on legend.

                // Draw Plot area
                DrawPlotAreaStyle(rpt, g, lRect);
                int    intervalCount = 0;
                double incr          = 0;
                // Draw Value Axis
                if (vaSize.Width > 0)                   // If we made room for the axis - we need to draw it
                {
                    DrawValueAxis(rpt, g, min, max,
                                  new System.DrawingCore.Rectangle(Layout.LeftMargin - vaSize.Width, Layout.TopMargin, vaSize.Width, Layout.PlotArea.Height), Layout.LeftMargin, _bm.Width - Layout.RightMargin, out incr, out intervalCount);
                }

                // Draw Category Axis
                if (caSize.Height > 0)
                {
                    //09052008ajm passing chart bounds int
                    DrawCategoryAxis(rpt, g,
                                     new System.DrawingCore.Rectangle(Layout.LeftMargin, _bm.Height - Layout.BottomMargin, Layout.PlotArea.Width, caSize.Height), Layout.TopMargin,
                                     caSize.Width);
                }

                // Draw Plot area data
                if (ChartDefn.Type == ChartTypeEnum.Area)
                {
                    if ((ChartSubTypeEnum)Enum.Parse(typeof(ChartSubTypeEnum), _ChartDefn.Subtype.EvaluateString(rpt, _row)) == ChartSubTypeEnum.Stacked)
                    {
                        DrawPlotAreaAreaStacked(rpt, g, min, max);
                    }
                    else if ((ChartSubTypeEnum)Enum.Parse(typeof(ChartSubTypeEnum), _ChartDefn.Subtype.EvaluateString(rpt, _row)) == ChartSubTypeEnum.PercentStacked)
                    {
                        DrawPlotAreaAreaPercentStacked(rpt, g);
                    }
                    else
                    {
                        DrawPlotAreaArea(rpt, g, min, max);
                    }
                }
                else
                {
                    DrawPlotAreaLine(rpt, g, min, max);
                }
                DrawLegend(rpt, g, ChartDefn.Type == ChartTypeEnum.Area? false: true, false);
            }
        }
Exemple #21
0
/////////////////////////
        protected void DrawCategoryAxis(Report rpt, Graphics g, double min, double max, System.DrawingCore.Rectangle rect, int plotTop, int plotBottom)
        {
            if (this.ChartDefn.CategoryAxis == null)
            {
                return;
            }
            Axis a = this.ChartDefn.CategoryAxis.Axis;

            if (a == null)
            {
                return;
            }
            Style s = a.Style;

            // Account for tick marks
            int tickSize = 0;

            if (a.MajorTickMarks == AxisTickMarksEnum.Cross ||
                a.MajorTickMarks == AxisTickMarksEnum.Outside)
            {
                tickSize = this.AxisTickMarkMajorLen;
            }
            else if (a.MinorTickMarks == AxisTickMarksEnum.Cross ||
                     a.MinorTickMarks == AxisTickMarksEnum.Outside)
            {
                tickSize += this.AxisTickMarkMinorLen;
            }

            int    intervalCount;
            double incr;

            SetIncrementAndInterval(rpt, a, min, max, out incr, out intervalCount);      // Calculate the interval count

            int    maxValueHeight = 0;
            double v    = min;
            Size   size = Size.Empty;

            for (int i = 0; i < intervalCount + 1; i++)
            {
                int x = (int)(((Math.Min(v, max) - min) / (max - min)) * rect.Width);

                if (!a.Visible)
                {
                    // nothing to do
                }
                else if (s != null)
                {
                    size = s.MeasureString(rpt, g, v, TypeCode.Double, null, int.MaxValue);
                    System.DrawingCore.Rectangle vRect =
                        new System.DrawingCore.Rectangle(rect.Left + x - size.Width / 2, rect.Top + tickSize, size.Width, size.Height);
                    s.DrawString(rpt, g, v, TypeCode.Double, null, vRect);
                }
                else
                {
                    size = Style.MeasureStringDefaults(rpt, g, v, TypeCode.Double, null, int.MaxValue);
                    System.DrawingCore.Rectangle vRect =
                        new System.DrawingCore.Rectangle(rect.Left + x - size.Width / 2, rect.Top + tickSize, size.Width, size.Height);
                    Style.DrawStringDefaults(g, v, vRect);
                }
                if (size.Height > maxValueHeight)               // Need to keep track of the maximum height
                {
                    maxValueHeight = size.Height;               //   this is probably overkill since it should always be the same??
                }
                DrawCategoryAxisGrid(rpt, g, a.MajorGridLines, new Point(rect.Left + x, plotTop), new Point(rect.Left + x, plotBottom));
                DrawCategoryAxisTick(rpt, g, true, a.MajorTickMarks, a.MajorGridLines, new Point(rect.Left + x, plotBottom));

                v += incr;
            }

            // Draw the end points of the major grid lines
            DrawCategoryAxisGrid(rpt, g, a.MajorGridLines, new Point(rect.Left, plotTop), new Point(rect.Left, plotBottom));
            DrawCategoryAxisTick(rpt, g, true, a.MajorTickMarks, a.MajorGridLines, new Point(rect.Left, plotBottom));
            DrawCategoryAxisGrid(rpt, g, a.MajorGridLines, new Point(rect.Right, plotTop), new Point(rect.Right, plotBottom));
            DrawCategoryAxisTick(rpt, g, true, a.MajorTickMarks, a.MajorGridLines, new Point(rect.Right, plotBottom));

            Size tSize = DrawTitleMeasure(rpt, g, a.Title);

            DrawTitle(rpt, g, a.Title,
                      new System.DrawingCore.Rectangle(rect.Left, rect.Top + maxValueHeight + tickSize, rect.Width, tSize.Height));

            return;
        }
 /// <summary>
 /// Grabs a sub-section clone of the wrapped image.
 /// </summary>
 /// <param name="rect">The rectangle to cut from.</param>
 /// <param name="format">The PixelFomat to use.</param>
 /// <returns>A sub-bitmap object.</returns>
 public Bitmap Clone(Rectangle rect, PixelFormat format)
 {
     return(Image.Clone(rect, format));
 }