Пример #1
0
        DrawColumnHeader
        (
            DrawingObjects oDrawingObjects,
            String sHeaderText,
            Int32 iLeft,
            Int32 iRight,
            ref Int32 iTop
        )
        {
            Debug.Assert(oDrawingObjects != null);
            Debug.Assert(!String.IsNullOrEmpty(sHeaderText));
            AssertValid();

            iTop += oDrawingObjects.GetFontHeightMultiple(0.2F);

            Int32 iColumnHeaderHeight =
                oDrawingObjects.GetFontHeightMultiple(1.3F);

            oDrawingObjects.Graphics.FillRectangle(SystemBrushes.ControlLight,
                                                   iLeft, iTop, iRight - iLeft - 1, iColumnHeaderHeight);

            oDrawingObjects.Graphics.DrawString(sHeaderText, oDrawingObjects.Font,
                                                SystemBrushes.ControlText,
                                                iLeft + oDrawingObjects.GetFontHeightMultiple(0.1F),
                                                iTop + oDrawingObjects.GetFontHeightMultiple(0.15F)
                                                );

            iTop += oDrawingObjects.GetFontHeightMultiple(1.5F);
        }
        DrawRampResults
        (
            DrawingObjects oDrawingObjects,
            String sSourceColumnName,
            String sCaption,
            Double dSourceCalculationNumber1,
            Double dSourceCalculationNumber2,
            Int32 iDecimalPlaces,
            Rectangle oColumnRectangle,
            Int32 iResultsLeft,
            Int32 iResultsRight,
            ref Int32 iTop
        )
        {
            Debug.Assert(oDrawingObjects != null);
            Debug.Assert(!String.IsNullOrEmpty(sSourceColumnName));
            Debug.Assert(!String.IsNullOrEmpty(sCaption));
            Debug.Assert(iDecimalPlaces >= 0);
            AssertValid();

            iTop += oDrawingObjects.GetFontHeightMultiple(0.2F);

            DrawRangeText(oDrawingObjects,
                          DoubleToString(dSourceCalculationNumber1, iDecimalPlaces),
                          DoubleToString(dSourceCalculationNumber2, iDecimalPlaces),
                          SystemBrushes.WindowText, iResultsLeft, iResultsRight, ref iTop);

            iTop += oDrawingObjects.GetFontHeightMultiple(0.35F);

            Int32 iRampMargin = oDrawingObjects.GetFontHeightMultiple(0.1F);

            Graphics      oGraphics         = oDrawingObjects.Graphics;
            SmoothingMode eOldSmoothingMode = oGraphics.SmoothingMode;

            oGraphics.SmoothingMode = SmoothingMode.HighQuality;

            oGraphics.FillPolygon(SystemBrushes.ControlDarkDark, new Point[] {
                new Point(iResultsLeft, iTop + RampHeight - 2),
                new Point(iResultsLeft, iTop + RampHeight - 1),
                new Point(iResultsRight - iRampMargin, iTop + RampHeight - 1),
                new Point(iResultsRight - iRampMargin, iTop - 1)
            });

            oGraphics.SmoothingMode = eOldSmoothingMode;

            iTop += RampHeight + oDrawingObjects.GetFontHeightMultiple(0.05F);

            DrawExcelColumnNameAndCaption(oDrawingObjects, sSourceColumnName,
                                          sCaption, iResultsLeft, iResultsRight, ref iTop);

            // Draw a line separating these results from the next.

            DrawHorizontalSeparator(oDrawingObjects, oColumnRectangle, ref iTop);
        }
Пример #3
0
        DrawRangeText
        (
            DrawingObjects oDrawingObjects,
            String sLeftText,
            String sRightText,
            Brush oBrush,
            ref Int32 iLeft,
            ref Int32 iRight,
            ref Int32 iTop
        )
        {
            Debug.Assert(oDrawingObjects != null);
            Debug.Assert(!String.IsNullOrEmpty(sLeftText));
            Debug.Assert(!String.IsNullOrEmpty(sRightText));
            Debug.Assert(oBrush != null);
            AssertValid();

            oDrawingObjects.Graphics.DrawString(sLeftText, oDrawingObjects.Font,
                                                oBrush, iLeft, iTop);

            oDrawingObjects.Graphics.DrawString(sRightText, oDrawingObjects.Font,
                                                oBrush, iRight, iTop, oDrawingObjects.RightAlignStringFormat);

            iLeft  += MeasureTextWidth(oDrawingObjects, sLeftText);
            iRight -= MeasureTextWidth(oDrawingObjects, sRightText);
            iTop   += oDrawingObjects.GetFontHeightMultiple(1.0F);
        }
Пример #4
0
        DrawAvailableRangeText
        (
            DrawingObjects oDrawingObjects,
            IDynamicFilterRangeTrackBar oDynamicFilterRangeTrackBar,
            ref Int32 iAvailableRangeTextLeft,
            ref Int32 iAvailableRangeTextRight,
            ref Int32 iTop
        )
        {
            Debug.Assert(oDrawingObjects != null);
            Debug.Assert(oDynamicFilterRangeTrackBar != null);
            AssertValid();

            DrawRangeText(oDrawingObjects,

                          oDynamicFilterRangeTrackBar.ValueToString(
                              oDynamicFilterRangeTrackBar.AvailableMinimum),

                          oDynamicFilterRangeTrackBar.ValueToString(
                              oDynamicFilterRangeTrackBar.AvailableMaximum),

                          SystemBrushes.GrayText, ref iAvailableRangeTextLeft,
                          ref iAvailableRangeTextRight, ref iTop
                          );

            iTop += oDrawingObjects.GetFontHeightMultiple(0.4F);
        }
Пример #5
0
        DrawHorizontalSeparator
        (
            DrawingObjects oDrawingObjects,
            Rectangle oColumnRectangle,
            ref Int32 iTop
        )
        {
            Debug.Assert(oDrawingObjects != null);
            AssertValid();

            iTop += oDrawingObjects.GetFontHeightMultiple(0.6F);

            oDrawingObjects.Graphics.DrawLine(SystemPens.ControlLight,
                                              oColumnRectangle.Left, iTop, oColumnRectangle.Right, iTop);

            iTop += oDrawingObjects.GetFontHeightMultiple(0.3F);
        }
Пример #6
0
        DrawExcelColumnName
        (
            DrawingObjects oDrawingObjects,
            String sColumnName,
            Int32 iLeft,
            Int32 iRight,
            ref Int32 iTop
        )
        {
            Debug.Assert(oDrawingObjects != null);
            Debug.Assert(!String.IsNullOrEmpty(sColumnName));

            iTop += oDrawingObjects.GetFontHeightMultiple(0.2F);

            oDrawingObjects.Graphics.DrawString(sColumnName, oDrawingObjects.Font,
                                                SystemBrushes.ControlText,

                                                Rectangle.FromLTRB(iLeft, iTop, iRight,
                                                                   (Int32)(iTop + oDrawingObjects.FontHeight)),

                                                oDrawingObjects.TrimmingStringFormat);

            iTop += oDrawingObjects.GetFontHeightMultiple(1.05F);
        }
        DrawExcelColumnNameAndCaption
        (
            DrawingObjects oDrawingObjects,
            String sColumnName,
            String sCaption,
            Int32 iLeft,
            Int32 iRight,
            ref Int32 iTop
        )
        {
            Debug.Assert(oDrawingObjects != null);
            Debug.Assert(!String.IsNullOrEmpty(sColumnName));
            Debug.Assert(!String.IsNullOrEmpty(sCaption));

            oDrawingObjects.Graphics.DrawString(sCaption, oDrawingObjects.Font,
                                                SystemBrushes.GrayText, iRight,
                                                iTop + oDrawingObjects.GetFontHeightMultiple(0.2F),
                                                oDrawingObjects.RightAlignStringFormat);

            DrawExcelColumnName(oDrawingObjects, sColumnName, iLeft,
                                iRight - MeasureTextWidth(oDrawingObjects, sCaption), ref iTop);
        }
    DrawExcelColumnName
    (
        DrawingObjects oDrawingObjects,
        String sColumnName,
        Int32 iLeft,
        Int32 iRight,
        ref Int32 iTop
    )
    {
        Debug.Assert(oDrawingObjects != null);
        Debug.Assert( !String.IsNullOrEmpty(sColumnName) );

        iTop += oDrawingObjects.GetFontHeightMultiple(0.2F);

        oDrawingObjects.Graphics.DrawString(sColumnName, oDrawingObjects.Font,
            SystemBrushes.ControlText,

            Rectangle.FromLTRB( iLeft, iTop, iRight,
                (Int32)(iTop + oDrawingObjects.FontHeight) ),

            oDrawingObjects.TrimmingStringFormat);

        iTop += oDrawingObjects.GetFontHeightMultiple(1.05F);
    }
    DrawExcelColumnNameAndCaption
    (
        DrawingObjects oDrawingObjects,
        String sColumnName,
        String sCaption,
        Int32 iLeft,
        Int32 iRight,
        ref Int32 iTop
    )
    {
        Debug.Assert(oDrawingObjects != null);
        Debug.Assert( !String.IsNullOrEmpty(sColumnName) );
        Debug.Assert( !String.IsNullOrEmpty(sCaption) );

        oDrawingObjects.Graphics.DrawString(sCaption, oDrawingObjects.Font,
            SystemBrushes.GrayText, iRight,
            iTop + oDrawingObjects.GetFontHeightMultiple(0.2F),
            oDrawingObjects.RightAlignStringFormat);

        DrawExcelColumnName(oDrawingObjects, sColumnName, iLeft,
            iRight - MeasureTextWidth(oDrawingObjects, sCaption), ref iTop);
    }
        DrawColorCategoryResults
        (
            DrawingObjects oDrawingObjects,
            ICollection <String> oCategoryNames,
            GetShapeAndColorForCategory oShapeAndColorGetter,
            Rectangle oColumnRectangle,
            ref Int32 iTop
        )
        {
            Debug.Assert(oDrawingObjects != null);
            Debug.Assert(oCategoryNames != null);
            AssertValid();

            Graphics oGraphics = oDrawingObjects.Graphics;

            iTop += oDrawingObjects.GetFontHeightMultiple(0.2F);

            // The categories are drawn from left to right.  Each category is drawn
            // as a shape followed by the category name.

            // Calculate the width of one category column.

            Single fShapeWidth     = CategoryShapeFactor * oDrawingObjects.FontHeight;
            Single fShapeHalfWidth = fShapeWidth / 2F;

            Single fColumnWidth = (Single)Math.Ceiling(fShapeWidth +
                                                       (MaximumCategoryNameLength * oDrawingObjects.FontHeight));

            // How many columns will fit?  There must be at least one, even if
            // there isn't enough room for one column.

            Debug.Assert(fColumnWidth > 0);

            Int32 iColumns = Math.Max(1,
                                      (Int32)(oColumnRectangle.Width / fColumnWidth));

            fColumnWidth = (Single)oColumnRectangle.Width / (Single)iColumns;

            Int32  iCategories = oCategoryNames.Count;
            Int32  iColumn     = 0;
            Single fLeft       = oColumnRectangle.Left;

            Pen oPen = new Pen(Color.Black, 1.0F);

            oPen.Alignment = PenAlignment.Inset;

            SolidBrush oBrush = new SolidBrush(Color.Black);

            SmoothingMode eOldSmoothingMode = oGraphics.SmoothingMode;

            oGraphics.SmoothingMode = SmoothingMode.HighQuality;
            Int32 i = 0;

            foreach (String sCategoryName in oCategoryNames)
            {
                // Get the shape and color for this category.

                VertexShape eVertexShape;
                Color       oVertexColor;

                oShapeAndColorGetter(i, out eVertexShape, out oVertexColor);

                DrawVertexCategoryShape(oDrawingObjects, eVertexShape, oPen,
                                        oBrush, oVertexColor,
                                        fLeft + fShapeHalfWidth + 2,
                                        iTop + fShapeHalfWidth + 1,
                                        fShapeHalfWidth);

                // Don't let the category name spill over into the next column.

                Single fTopOffset = fShapeWidth * 0.15F;

                Rectangle oNameRectangle = Rectangle.FromLTRB(
                    (Int32)(fLeft + fShapeWidth * 1.4F),
                    (Int32)(iTop + fTopOffset),
                    (Int32)(fLeft + fColumnWidth),
                    (Int32)(iTop + oDrawingObjects.FontHeight + fTopOffset)
                    );

                oGraphics.DrawString(sCategoryName, oDrawingObjects.Font,
                                     SystemBrushes.WindowText, oNameRectangle,
                                     oDrawingObjects.TrimmingStringFormat);

                if (iCategories > MaximumCategoriesToDraw &&
                    i == MaximumCategoriesToDraw - 1)
                {
                    oGraphics.DrawString(
                        "There are additional categories that are not shown here.",
                        oDrawingObjects.Font, SystemBrushes.WindowText,
                        oColumnRectangle.Left,
                        iTop + 1.5F * oDrawingObjects.FontHeight);

                    iTop += oDrawingObjects.GetFontHeightMultiple(3F);
                    break;
                }

                oGraphics.DrawLine(SystemPens.ControlLight,
                                   oNameRectangle.Right - 1,
                                   iTop,
                                   oNameRectangle.Right - 1,
                                   iTop + oDrawingObjects.GetFontHeightMultiple(1.4F)
                                   );

                iColumn++;
                fLeft += fColumnWidth;
                Boolean bIncrementTop = false;

                if (iColumn == iColumns)
                {
                    iColumn       = 0;
                    fLeft         = oColumnRectangle.Left;
                    bIncrementTop = true;
                }
                else if (i == iCategories - 1)
                {
                    bIncrementTop = true;
                }

                if (bIncrementTop)
                {
                    iTop += oDrawingObjects.GetFontHeightMultiple(1.4F);

                    // Draw a line separating these results from the next.

                    DrawHorizontalSeparator(oDrawingObjects, oColumnRectangle,
                                            ref iTop);

                    iTop += oDrawingObjects.GetFontHeightMultiple(0.2F);
                }

                i++;
            }

            oPen.Dispose();
            oBrush.Dispose();
            oGraphics.SmoothingMode = eOldSmoothingMode;
        }
        DrawColorBarResults
        (
            DrawingObjects oDrawingObjects,
            String sSourceColumnName,
            String sCaption,
            String sSourceCalculationMinimum,
            String sSourceCalculationMaximum,
            Color oColor1,
            Color oColor2,
            Rectangle oColumnRectangle,
            Int32 iResultsLeft,
            Int32 iResultsRight,
            ref Int32 iTop
        )
        {
            Debug.Assert(oDrawingObjects != null);
            Debug.Assert(!String.IsNullOrEmpty(sSourceColumnName));
            Debug.Assert(!String.IsNullOrEmpty(sCaption));
            Debug.Assert(!String.IsNullOrEmpty(sSourceCalculationMinimum));
            Debug.Assert(!String.IsNullOrEmpty(sSourceCalculationMaximum));
            AssertValid();

            iTop += oDrawingObjects.GetFontHeightMultiple(0.2F);

            DrawRangeText(oDrawingObjects, sSourceCalculationMinimum,
                          sSourceCalculationMaximum, SystemBrushes.WindowText, iResultsLeft,
                          iResultsRight, ref iTop);

            iTop += oDrawingObjects.GetFontHeightMultiple(0.35F);

            Int32 iColorBarMargin = oDrawingObjects.GetFontHeightMultiple(0.1F);

            Rectangle oColorBarRectangle = Rectangle.FromLTRB(
                iResultsLeft + iColorBarMargin,
                iTop,
                iResultsRight - iColorBarMargin,
                iTop + ColorBarHeight
                );

            // There is a known bug in the LinearGradientBrush that sometimes
            // causes a single line of the wrong color to be drawn at the start of
            // the gradient.  The workaround is to use a brush rectangle that is
            // one pixel larger than the fill rectangle on all sides.

            Rectangle oBrushRectangle = oColorBarRectangle;

            oBrushRectangle.Inflate(1, 1);

            LinearGradientBrush oBrush = new LinearGradientBrush(
                oBrushRectangle, oColor1, oColor2, 0F);

            oDrawingObjects.Graphics.FillRectangle(oBrush, oColorBarRectangle);
            oBrush.Dispose();

            iTop += ColorBarHeight + oDrawingObjects.GetFontHeightMultiple(0.05F);

            DrawExcelColumnNameAndCaption(oDrawingObjects, sSourceColumnName,
                                          sCaption, iResultsLeft, iResultsRight, ref iTop);

            // Draw a line separating these results from the next.

            DrawHorizontalSeparator(oDrawingObjects, oColumnRectangle, ref iTop);
        }
    DrawColorBarResults
    (
        DrawingObjects oDrawingObjects,
        String sSourceColumnName,
        String sCaption,
        String sSourceCalculationMinimum,
        String sSourceCalculationMaximum,
        Color oColor1,
        Color oColor2,
        Rectangle oColumnRectangle,
        Int32 iResultsLeft,
        Int32 iResultsRight,
        ref Int32 iTop
    )
    {
        Debug.Assert(oDrawingObjects != null);
        Debug.Assert( !String.IsNullOrEmpty(sSourceColumnName) );
        Debug.Assert( !String.IsNullOrEmpty(sCaption) );
        Debug.Assert( !String.IsNullOrEmpty(sSourceCalculationMinimum) );
        Debug.Assert( !String.IsNullOrEmpty(sSourceCalculationMaximum) );
        AssertValid();

        iTop += oDrawingObjects.GetFontHeightMultiple(0.2F);

        DrawRangeText(oDrawingObjects, sSourceCalculationMinimum,
            sSourceCalculationMaximum, SystemBrushes.WindowText, iResultsLeft,
            iResultsRight, ref iTop);

        iTop += oDrawingObjects.GetFontHeightMultiple(0.35F);

        Int32 iColorBarMargin = oDrawingObjects.GetFontHeightMultiple(0.1F);

        Rectangle oColorBarRectangle = Rectangle.FromLTRB(
            iResultsLeft + iColorBarMargin,
            iTop,
            iResultsRight - iColorBarMargin,
            iTop + ColorBarHeight
            );

        // There is a known bug in the LinearGradientBrush that sometimes
        // causes a single line of the wrong color to be drawn at the start of
        // the gradient.  The workaround is to use a brush rectangle that is
        // one pixel larger than the fill rectangle on all sides.

        Rectangle oBrushRectangle = oColorBarRectangle;
        oBrushRectangle.Inflate(1, 1);

        LinearGradientBrush oBrush = new LinearGradientBrush(
            oBrushRectangle, oColor1, oColor2, 0F);

        oDrawingObjects.Graphics.FillRectangle(oBrush, oColorBarRectangle);
        oBrush.Dispose();

        iTop += ColorBarHeight + oDrawingObjects.GetFontHeightMultiple(0.05F);

        DrawExcelColumnNameAndCaption(oDrawingObjects, sSourceColumnName,
            sCaption, iResultsLeft, iResultsRight, ref iTop);

        // Draw a line separating these results from the next.

        DrawHorizontalSeparator(oDrawingObjects, oColumnRectangle, ref iTop);
    }
    DrawRampResults
    (
        DrawingObjects oDrawingObjects,
        String sSourceColumnName,
        String sCaption,
        Double dSourceCalculationNumber1,
        Double dSourceCalculationNumber2,
        Int32 iDecimalPlaces,
        Rectangle oColumnRectangle,
        Int32 iResultsLeft,
        Int32 iResultsRight,
        ref Int32 iTop
    )
    {
        Debug.Assert(oDrawingObjects != null);
        Debug.Assert( !String.IsNullOrEmpty(sSourceColumnName) );
        Debug.Assert( !String.IsNullOrEmpty(sCaption) );
        Debug.Assert(iDecimalPlaces >= 0);
        AssertValid();

        iTop += oDrawingObjects.GetFontHeightMultiple(0.2F);

        DrawRangeText(oDrawingObjects,
            DoubleToString(dSourceCalculationNumber1, iDecimalPlaces),
            DoubleToString(dSourceCalculationNumber2, iDecimalPlaces),
            SystemBrushes.WindowText, iResultsLeft, iResultsRight, ref iTop);

        iTop += oDrawingObjects.GetFontHeightMultiple(0.35F);

        Int32 iRampMargin = oDrawingObjects.GetFontHeightMultiple(0.1F);

        Graphics oGraphics = oDrawingObjects.Graphics;
        SmoothingMode eOldSmoothingMode = oGraphics.SmoothingMode;
        oGraphics.SmoothingMode = SmoothingMode.HighQuality;

        oGraphics.FillPolygon(SystemBrushes.ControlDarkDark, new Point[] {
            new Point(iResultsLeft, iTop + RampHeight - 2),
            new Point(iResultsLeft, iTop + RampHeight - 1),
            new Point(iResultsRight - iRampMargin, iTop + RampHeight - 1),
            new Point(iResultsRight - iRampMargin, iTop - 1)
            } );

        oGraphics.SmoothingMode = eOldSmoothingMode;

        iTop += RampHeight + oDrawingObjects.GetFontHeightMultiple(0.05F);

        DrawExcelColumnNameAndCaption(oDrawingObjects, sSourceColumnName,
            sCaption, iResultsLeft, iResultsRight, ref iTop);

        // Draw a line separating these results from the next.

        DrawHorizontalSeparator(oDrawingObjects, oColumnRectangle, ref iTop);
    }
    DrawDynamicFilterRangeTrackBar
    (
        DrawingObjects oDrawingObjects,
        IDynamicFilterRangeTrackBar oDynamicFilterRangeTrackBar,
        Pen oAvailableRangeLinePen,
        Pen oSelectedRangeLinePen,
        Rectangle oColumnRectangle,
        Int32 iTrackBarLeft,
        Int32 iTrackBarRight,
        ref Int32 iTop
    )
    {
        Debug.Assert(oDrawingObjects != null);
        Debug.Assert(oDynamicFilterRangeTrackBar != null);
        Debug.Assert(oAvailableRangeLinePen != null);
        Debug.Assert(oSelectedRangeLinePen != null);

        iTop += oDrawingObjects.GetFontHeightMultiple(0.2F);

        // Draw the text for the available range.

        Int32 iAvailableRangeTextLeft = iTrackBarLeft;
        Int32 iAvailableRangeTextRight = iTrackBarRight;
        Int32 iAvailableRangeTextTop = iTop;

        DrawAvailableRangeText(oDrawingObjects, oDynamicFilterRangeTrackBar,
            ref iAvailableRangeTextLeft, ref iAvailableRangeTextRight,
            ref iTop);

        // Draw the line representing the available range.

        Int32 iLineMargin = oDrawingObjects.GetFontHeightMultiple(0.1F);
        Int32 iAvailableRangeLineLeft = iTrackBarLeft + iLineMargin;
        Int32 iAvailableRangeLineRight = iTrackBarRight - iLineMargin;

        oDrawingObjects.Graphics.DrawLine(oAvailableRangeLinePen,
            iAvailableRangeLineLeft, iTop, iAvailableRangeLineRight, iTop);

        // Draw the line representing the selected range.

        Int32 iSelectedRangeLineLeft, iSelectedRangeLineRight;

        DrawSelectedRangeLine(oDrawingObjects, oDynamicFilterRangeTrackBar,
            oSelectedRangeLinePen, iAvailableRangeLineLeft,
            iAvailableRangeLineRight, out iSelectedRangeLineLeft,
            out iSelectedRangeLineRight, ref iTop);

        // Draw the text for the selected range.

        DrawSelectedRangeText(oDrawingObjects, oDynamicFilterRangeTrackBar,
            iAvailableRangeTextLeft, iAvailableRangeTextRight,
            iSelectedRangeLineLeft, iSelectedRangeLineRight,
            iAvailableRangeTextTop);

        DrawExcelColumnName(oDrawingObjects,
            oDynamicFilterRangeTrackBar.ColumnName, iTrackBarLeft,
            iTrackBarRight, ref iTop);

        // Draw a line separating this track bar from the next.

        DrawHorizontalSeparator(oDrawingObjects, oColumnRectangle, ref iTop);
    }
    DrawColorCategoryResults
    (
        DrawingObjects oDrawingObjects,
        ICollection<String> oCategoryNames,
        GetShapeAndColorForCategory oShapeAndColorGetter,
        Rectangle oColumnRectangle,
        ref Int32 iTop
    )
    {
        Debug.Assert(oDrawingObjects != null);
        Debug.Assert(oCategoryNames != null);
        AssertValid();

        Graphics oGraphics = oDrawingObjects.Graphics;
        iTop += oDrawingObjects.GetFontHeightMultiple(0.2F);

        // The categories are drawn from left to right.  Each category is drawn
        // as a shape followed by the category name.

        // Calculate the width of one category column.

        Single fShapeWidth = CategoryShapeFactor * oDrawingObjects.FontHeight;
        Single fShapeHalfWidth = fShapeWidth / 2F;

        Single fColumnWidth = (Single)Math.Ceiling( fShapeWidth +
            (MaximumCategoryNameLength * oDrawingObjects.FontHeight) );

        // How many columns will fit?  There must be at least one, even if
        // there isn't enough room for one column.

        Debug.Assert(fColumnWidth > 0);

        Int32 iColumns = Math.Max( 1,
            (Int32)(oColumnRectangle.Width / fColumnWidth) );

        fColumnWidth = (Single)oColumnRectangle.Width / (Single)iColumns;

        Int32 iCategories = oCategoryNames.Count;
        Int32 iColumn = 0;
        Single fLeft = oColumnRectangle.Left;

        Pen oPen = new Pen(Color.Black, 1.0F);
        oPen.Alignment = PenAlignment.Inset;

        SolidBrush oBrush = new SolidBrush(Color.Black);

        SmoothingMode eOldSmoothingMode = oGraphics.SmoothingMode;
        oGraphics.SmoothingMode = SmoothingMode.HighQuality;
        Int32 i = 0;

        foreach (String sCategoryName in oCategoryNames)
        {
            // Get the shape and color for this category.

            VertexShape eVertexShape;
            Color oVertexColor;

            oShapeAndColorGetter(i, out eVertexShape, out oVertexColor);

            DrawVertexCategoryShape(oDrawingObjects, eVertexShape, oPen,
                oBrush, oVertexColor,
                fLeft + fShapeHalfWidth + 2,
                iTop + fShapeHalfWidth + 1,
                fShapeHalfWidth);

            // Don't let the category name spill over into the next column.

            Single fTopOffset = fShapeWidth * 0.15F;

            Rectangle oNameRectangle = Rectangle.FromLTRB(
                (Int32)(fLeft + fShapeWidth * 1.4F),
                (Int32)(iTop + fTopOffset),
                (Int32)(fLeft + fColumnWidth),
                (Int32)(iTop + oDrawingObjects.FontHeight + fTopOffset)
                );

            oGraphics.DrawString(sCategoryName, oDrawingObjects.Font,
                SystemBrushes.WindowText, oNameRectangle,
                oDrawingObjects.TrimmingStringFormat);

            if (iCategories > MaximumCategoriesToDraw &&
                i == MaximumCategoriesToDraw - 1)
            {
                oGraphics.DrawString(
                    "There are additional categories that are not shown here.",
                    oDrawingObjects.Font, SystemBrushes.WindowText,
                    oColumnRectangle.Left,
                    iTop + 1.5F * oDrawingObjects.FontHeight);

                iTop += oDrawingObjects.GetFontHeightMultiple(3F);
                break;
            }

            oGraphics.DrawLine( SystemPens.ControlLight,
                oNameRectangle.Right - 1,
                iTop,
                oNameRectangle.Right - 1,
                iTop + oDrawingObjects.GetFontHeightMultiple(1.4F)
                );

            iColumn++;
            fLeft += fColumnWidth;
            Boolean bIncrementTop = false;

            if (iColumn == iColumns)
            {
                iColumn = 0;
                fLeft = oColumnRectangle.Left;
                bIncrementTop = true;
            }
            else if (i == iCategories - 1)
            {
                bIncrementTop = true;
            }

            if (bIncrementTop)
            {
                iTop += oDrawingObjects.GetFontHeightMultiple(1.4F);

                // Draw a line separating these results from the next.

                DrawHorizontalSeparator(oDrawingObjects, oColumnRectangle,
                    ref iTop);

                iTop += oDrawingObjects.GetFontHeightMultiple(0.2F);
            }

            i++;
        }

        oPen.Dispose();
        oBrush.Dispose();
        oGraphics.SmoothingMode = eOldSmoothingMode;
    }
    DrawColumnHeader
    (
        DrawingObjects oDrawingObjects,
        String sHeaderText,
        Int32 iLeft,
        Int32 iRight,
        ref Int32 iTop
    )
    {
        Debug.Assert(oDrawingObjects != null);
        Debug.Assert( !String.IsNullOrEmpty(sHeaderText) );
        AssertValid();

        iTop += oDrawingObjects.GetFontHeightMultiple(0.2F);

        Int32 iColumnHeaderHeight =
            oDrawingObjects.GetFontHeightMultiple(1.3F);

        oDrawingObjects.Graphics.FillRectangle(SystemBrushes.ControlLight,
            iLeft, iTop, iRight - iLeft - 1, iColumnHeaderHeight);

        oDrawingObjects.Graphics.DrawString(sHeaderText, oDrawingObjects.Font,
            SystemBrushes.ControlText,
            iLeft + oDrawingObjects.GetFontHeightMultiple(0.1F),
            iTop + oDrawingObjects.GetFontHeightMultiple(0.15F)
            );

        iTop += oDrawingObjects.GetFontHeightMultiple(1.5F);
    }
Пример #17
0
        DrawDynamicFilterRangeTrackBar
        (
            DrawingObjects oDrawingObjects,
            IDynamicFilterRangeTrackBar oDynamicFilterRangeTrackBar,
            Pen oAvailableRangeLinePen,
            Pen oSelectedRangeLinePen,
            Rectangle oColumnRectangle,
            Int32 iTrackBarLeft,
            Int32 iTrackBarRight,
            ref Int32 iTop
        )
        {
            Debug.Assert(oDrawingObjects != null);
            Debug.Assert(oDynamicFilterRangeTrackBar != null);
            Debug.Assert(oAvailableRangeLinePen != null);
            Debug.Assert(oSelectedRangeLinePen != null);

            iTop += oDrawingObjects.GetFontHeightMultiple(0.2F);

            // Draw the text for the available range.

            Int32 iAvailableRangeTextLeft  = iTrackBarLeft;
            Int32 iAvailableRangeTextRight = iTrackBarRight;
            Int32 iAvailableRangeTextTop   = iTop;

            DrawAvailableRangeText(oDrawingObjects, oDynamicFilterRangeTrackBar,
                                   ref iAvailableRangeTextLeft, ref iAvailableRangeTextRight,
                                   ref iTop);

            // Draw the line representing the available range.

            Int32 iLineMargin              = oDrawingObjects.GetFontHeightMultiple(0.1F);
            Int32 iAvailableRangeLineLeft  = iTrackBarLeft + iLineMargin;
            Int32 iAvailableRangeLineRight = iTrackBarRight - iLineMargin;

            oDrawingObjects.Graphics.DrawLine(oAvailableRangeLinePen,
                                              iAvailableRangeLineLeft, iTop, iAvailableRangeLineRight, iTop);

            // Draw the line representing the selected range.

            Int32 iSelectedRangeLineLeft, iSelectedRangeLineRight;

            DrawSelectedRangeLine(oDrawingObjects, oDynamicFilterRangeTrackBar,
                                  oSelectedRangeLinePen, iAvailableRangeLineLeft,
                                  iAvailableRangeLineRight, out iSelectedRangeLineLeft,
                                  out iSelectedRangeLineRight, ref iTop);

            // Draw the text for the selected range.

            DrawSelectedRangeText(oDrawingObjects, oDynamicFilterRangeTrackBar,
                                  iAvailableRangeTextLeft, iAvailableRangeTextRight,
                                  iSelectedRangeLineLeft, iSelectedRangeLineRight,
                                  iAvailableRangeTextTop);

            DrawExcelColumnName(oDrawingObjects,
                                oDynamicFilterRangeTrackBar.ColumnName, iTrackBarLeft,
                                iTrackBarRight, ref iTop);

            // Draw a line separating this track bar from the next.

            DrawHorizontalSeparator(oDrawingObjects, oColumnRectangle, ref iTop);
        }
    DrawRangeText
    (
        DrawingObjects oDrawingObjects,
        String sLeftText,
        String sRightText,
        Brush oBrush,
        ref Int32 iLeft,
        ref Int32 iRight,
        ref Int32 iTop
    )
    {
        Debug.Assert(oDrawingObjects != null);
        Debug.Assert( !String.IsNullOrEmpty(sLeftText) );
        Debug.Assert( !String.IsNullOrEmpty(sRightText) );
        Debug.Assert(oBrush != null);
        AssertValid();

        oDrawingObjects.Graphics.DrawString(sLeftText, oDrawingObjects.Font,
            oBrush, iLeft, iTop);

        oDrawingObjects.Graphics.DrawString(sRightText, oDrawingObjects.Font,
            oBrush, iRight, iTop, oDrawingObjects.RightAlignStringFormat);

        iLeft += MeasureTextWidth(oDrawingObjects, sLeftText);
        iRight -= MeasureTextWidth(oDrawingObjects, sRightText);
        iTop += oDrawingObjects.GetFontHeightMultiple(1.0F);
    }
    DrawHorizontalSeparator
    (
        DrawingObjects oDrawingObjects,
        Rectangle oColumnRectangle,
        ref Int32 iTop
    )
    {
        Debug.Assert(oDrawingObjects != null);
        AssertValid();

        iTop += oDrawingObjects.GetFontHeightMultiple(0.6F);

        oDrawingObjects.Graphics.DrawLine(SystemPens.ControlLight,
            oColumnRectangle.Left, iTop, oColumnRectangle.Right, iTop);

        iTop += oDrawingObjects.GetFontHeightMultiple(0.3F);
    }
    DrawAvailableRangeText
    (
        DrawingObjects oDrawingObjects,
        IDynamicFilterRangeTrackBar oDynamicFilterRangeTrackBar,
        ref Int32 iAvailableRangeTextLeft,
        ref Int32 iAvailableRangeTextRight,
        ref Int32 iTop
    )
    {
        Debug.Assert(oDrawingObjects != null);
        Debug.Assert(oDynamicFilterRangeTrackBar != null);
        AssertValid();

        DrawRangeText(oDrawingObjects,

            oDynamicFilterRangeTrackBar.ValueToString(
                oDynamicFilterRangeTrackBar.AvailableMinimum),

            oDynamicFilterRangeTrackBar.ValueToString(
                oDynamicFilterRangeTrackBar.AvailableMaximum),

            SystemBrushes.GrayText, ref iAvailableRangeTextLeft,
            ref iAvailableRangeTextRight, ref iTop
            );

        iTop += oDrawingObjects.GetFontHeightMultiple(0.4F);
    }
        //*************************************************************************
        //  Method: DrawVertexCategorySchemeResults()
        //
        /// <summary>
        /// Draws the results of the autofill with vertex category scheme.
        /// </summary>
        ///
        /// <param name="oDrawingObjects">
        /// Objects to draw with.
        /// </param>
        ///
        /// <returns>
        /// The bottom of the area that was drawn.
        /// </returns>
        //*************************************************************************
        protected Int32 DrawVertexCategorySchemeResults(
            DrawingObjects oDrawingObjects
            )
        {
            Debug.Assert(oDrawingObjects != null);
            AssertValid();

            Graphics oGraphics = oDrawingObjects.Graphics;
            Rectangle oControlRectangle = oDrawingObjects.ControlRectangle;
            Int32 iTop = oControlRectangle.Top;

            DrawColumnHeader(oDrawingObjects, VertexPropertyHeader,
            oControlRectangle.Left, oControlRectangle.Right, ref iTop);

            iTop += oDrawingObjects.GetFontHeightMultiple(0.2F);

            // The categories are drawn from left to right.  Each category is drawn
            // as a shape followed by the category name.
            //
            // Calculate the width of one category column.

            Single fShapeWidth = CategoryShapeFactor * oDrawingObjects.FontHeight;
            Single fShapeHalfWidth = fShapeWidth / 2F;

            Single fColumnWidth = (Int32)( fShapeWidth +
            (MaximumVertexCategoryNameLength * oDrawingObjects.FontHeight) );

            // How many columns will fit?  There must be at least one, even if
            // there isn't enough room for one column.

            Int32 iColumns = Math.Max( 1,
            (Int32)(oControlRectangle.Width / fColumnWidth) );

            String sVertexCategoryColumnName;
            String [] asVertexCategoryNames;

            m_oAutoFillWorkbookWithSchemeResults.GetVertexCategoryResults(
            out sVertexCategoryColumnName, out asVertexCategoryNames);

            Int32 iVertexCategories = asVertexCategoryNames.Length;
            Int32 iColumn = 0;
            Single fLeft = oControlRectangle.Left;

            Pen oPen = new Pen(Color.Black, 1.0F);
            oPen.Alignment = PenAlignment.Inset;

            SolidBrush oBrush = new SolidBrush(Color.Black);

            SmoothingMode eOldSmoothingMode = oGraphics.SmoothingMode;
            oGraphics.SmoothingMode = SmoothingMode.HighQuality;

            for (Int32 i = 0; i < iVertexCategories; i++)
            {
            String sVertexCategoryName = asVertexCategoryNames[i];

            // Get the shape and color for this category.  The radius is
            // ignored -- this method assigns its own sizes.

            VertexShape eVertexShape;
            Color oVertexColor;
            Single fVertexRadius;

            WorkbookSchemeAutoFiller.GetVertexCategoryScheme(i,
                out eVertexShape, out oVertexColor, out fVertexRadius);

            DrawVertexCategoryShape(oDrawingObjects, eVertexShape, oPen,
                oBrush, oVertexColor,
                fLeft + fShapeHalfWidth + 2,
                iTop + fShapeHalfWidth + 1,
                fShapeHalfWidth);

            // Don't let the category name spill over into the next column.

            Single fTopOffset = fShapeWidth * 0.15F;

            Rectangle oNameRectangle = Rectangle.FromLTRB(
                (Int32)(fLeft + fShapeWidth * 1.4F),
                (Int32)(iTop + fTopOffset),
                (Int32)(fLeft + fColumnWidth),
                (Int32)(iTop + oDrawingObjects.FontHeight + fTopOffset)
                );

            oGraphics.DrawString(sVertexCategoryName, oDrawingObjects.Font,
                SystemBrushes.WindowText, oNameRectangle,
                oDrawingObjects.TrimmingStringFormat);

            if (iVertexCategories > MaximumVertexCategories &&
                i == MaximumVertexCategories - 1)
            {
                oGraphics.DrawString(
                    "There are additional categories that are not shown here.",
                    oDrawingObjects.Font, SystemBrushes.WindowText,
                    oControlRectangle.Left,
                    iTop + 1.5F * oDrawingObjects.FontHeight);

                iTop += oDrawingObjects.GetFontHeightMultiple(3F);
                break;
            }

            oGraphics.DrawLine( SystemPens.ControlLight,
                oNameRectangle.Right - 1,
                iTop,
                oNameRectangle.Right - 1,
                iTop + oDrawingObjects.GetFontHeightMultiple(1.4F)
                );

            iColumn++;
            fLeft += fColumnWidth;
            Boolean bIncrementTop = false;

            if (iColumn == iColumns)
            {
                iColumn = 0;
                fLeft = oControlRectangle.Left;
                bIncrementTop = true;
            }
            else if (i == iVertexCategories - 1)
            {
                bIncrementTop = true;
            }

            if (bIncrementTop)
            {
                iTop += oDrawingObjects.GetFontHeightMultiple(1.6F);

                DrawHorizontalSeparator(oDrawingObjects, oControlRectangle,
                    ref iTop);

                iTop += oDrawingObjects.GetFontHeightMultiple(0.2F);
            }
            }

            oPen.Dispose();
            oBrush.Dispose();
            oGraphics.SmoothingMode = eOldSmoothingMode;

            return (iTop);
        }