Smrf.NodeXL.ExcelTemplate.GraphImageCompositor.CreateLegendImages C# (CSharp) Method

CreateLegendImages() protected method

protected CreateLegendImages ( IEnumerable oLegendControls, Double dImageWidth, IEnumerable &oImages, Double &dTotalImageHeight ) : void
oLegendControls IEnumerable
dImageWidth Double
oImages IEnumerable
dTotalImageHeight Double
return void
    CreateLegendImages
    (
        IEnumerable<LegendControlBase> oLegendControls,
        Double dImageWidth,
        out IEnumerable<Image> oImages,
        out Double dTotalImageHeight
    )
    {
        Debug.Assert(oLegendControls != null);
        Debug.Assert(dImageWidth > 0);
        AssertValid();

        List<Image> oLegendImages = new List<Image>();
        oImages = oLegendImages;
        dTotalImageHeight = 0;

        foreach (LegendControlBase oLegendControl in oLegendControls)
        {
            if (oLegendControl.Visible && oLegendControl.Height > 0)
            {
                System.Windows.Media.Imaging.BitmapSource oBitmapSource;

                using ( System.Drawing.Bitmap oBitmap =
                    oLegendControl.DrawOnBitmap(
                        (Int32)Math.Ceiling(dImageWidth) ) )
                {
                    oBitmapSource = WpfGraphicsUtil.BitmapToBitmapSource(
                        oBitmap);
                }

                Image oLegendImage = new Image();
                oLegendImage.Source = oBitmapSource;
                oLegendImage.Width = dImageWidth;

                oLegendImage.Measure(new Size(
                    dImageWidth, Double.PositiveInfinity) );

                oLegendImages.Add(oLegendImage);
                dTotalImageHeight += oLegendImage.DesiredSize.Height;
            }
        }
    }