Example #1
0
        public static bool AlterGridOptions(Report nreport)
        {
            bool nresult = false;

            using (GridOptions ndia = new GridOptions())
            {
                ndia.bcolor.BackColor     = GraphicUtils.ColorFromInteger(nreport.GridColor);
                ndia.checkenabled.Checked = nreport.GridEnabled;
                ndia.textwidth.Text       = Twips.TextFromTwips(nreport.GridWidth);
                ndia.textheight.Text      = Twips.TextFromTwips(nreport.GridHeight);
                if (nreport.GridLines)
                {
                    ndia.combostyle.SelectedIndex = 1;
                }
                else
                {
                    ndia.combostyle.SelectedIndex = 0;
                }
                ndia.checkvisible.Checked = nreport.GridVisible;
                if (ndia.ShowDialog() == DialogResult.OK)
                {
                    nreport.GridLines   = (ndia.combostyle.SelectedIndex == 1);
                    nreport.GridEnabled = ndia.checkenabled.Checked;
                    nreport.GridWidth   = Twips.TwipsFromText(ndia.textwidth.Text);
                    nreport.GridHeight  = Twips.TwipsFromText(ndia.textheight.Text);
                    nreport.GridColor   = GraphicUtils.IntegerFromColor(ndia.bcolor.BackColor);
                    nreport.GridVisible = ndia.checkvisible.Checked;
                    nresult             = true;
                }
            }
            return(nresult);
        }
Example #2
0
        /// <summary>
        /// Encode the content using the encoding scheme given
        /// </summary>
        /// <param name="content"></param>
        /// <param name="encoding"></param>
        /// <returns></returns>
        public virtual void EncodeInMetafile(MetaFile metafile, int posx, int posy, int modul, String content, Encoding encoding)
        {
            bool[][] matrix = calQrcode(encoding.GetBytes(content));

            /*int PrintWidth = matrix.Length * qrCodeScale*modul + 1;
             * int PrintHeight = matrix.Length * qrCodeScale*modul + 1;
             * MetaObjectDraw metaobj = new MetaObjectDraw();
             * metaobj.MetaType = MetaObjectType.Draw;
             * metaobj.Top = posy;
             * metaobj.Left = posx;
             * metaobj.Width = PrintWidth;
             * metaobj.Height = PrintHeight;
             * metaobj.DrawStyle = ShapeType.Rectangle;
             * metaobj.BrushStyle = (int)BrushType.Solid;
             * metaobj.PenStyle = (int)PenType.Clear;
             * metaobj.PenWidth = 0;
             * metaobj.PenColor = GraphicUtils.IntegerFromColor(qrCodeBackgroundColor);
             * metaobj.BrushColor = GraphicUtils.IntegerFromColor(qrCodeBackgroundColor);
             * metafile.Pages[metafile.CurrentPage].Objects.Add(metaobj);*/


            int bwidth = qrCodeScale * modul;

            for (int i = 0; i < matrix.Length; i++)
            {
                for (int j = 0; j < matrix.Length; j++)
                {
                    if (matrix[j][i])
                    {
                        MetaObjectDraw metaobj = new MetaObjectDraw();
                        metaobj.MetaType   = MetaObjectType.Draw;
                        metaobj.Top        = posy + i * bwidth;
                        metaobj.Left       = posx + j * bwidth;
                        metaobj.Width      = bwidth;
                        metaobj.Height     = bwidth;
                        metaobj.DrawStyle  = ShapeType.Rectangle;
                        metaobj.BrushStyle = (int)BrushType.Solid;
                        metaobj.PenStyle   = (int)PenType.Solid;
                        metaobj.PenWidth   = 0;
                        metaobj.PenColor   = GraphicUtils.IntegerFromColor(qrCodeForegroundColor);
                        metaobj.BrushColor = GraphicUtils.IntegerFromColor(qrCodeForegroundColor);
                        metafile.Pages[metafile.CurrentPage].Objects.Add(metaobj);
                    }
                }
            }
        }
        public override object ParseFormattedValue(object formattedValue, DataGridViewCellStyle cellStyle, System.ComponentModel.TypeConverter formattedValueTypeConverter, System.ComponentModel.TypeConverter valueTypeConverter)
        {
            object aresult = null;
            ObjectInspectorCellType celltype = (ObjectInspectorCellType)GetColumnValue("TYPEENUM");

            switch (celltype)
            {
            case ObjectInspectorCellType.DropDownList:
            case ObjectInspectorCellType.DropDown:
                if (formattedValue.ToString().Length == 0)
                {
                    aresult = DBNull.Value;
                }
                else
                {
                    Strings list  = (Strings)GetColumnValue("VALUELIST");
                    int     index = list.IndexOf(formattedValue.ToString());
                    if (index < 0)
                    {
                        index = 0;
                    }
                    aresult = index;
                }
                break;

            case ObjectInspectorCellType.Text:
            case ObjectInspectorCellType.Expression:
                aresult = formattedValue.ToString();
                break;

            case ObjectInspectorCellType.Color:
                if (formattedValue.ToString().Length == 0)
                {
                    aresult = DBNull.Value;
                }
                else
                {
                    aresult = GraphicUtils.IntegerFromColor((Color)formattedValue);
                }
                break;

            case ObjectInspectorCellType.Image:
                if (formattedValue is Variant)
                {
                    Variant imvar = (Variant)formattedValue;
                    if (imvar.VarType == VariantType.Binary)
                    {
                        System.IO.MemoryStream nstream = ((Variant)formattedValue).GetStream();
                        aresult = StringUtil.GetSizeAsString(nstream.Length);
                    }
                    else
                    {
                        aresult = formattedValue;
                    }
                }
                else
                {
                    aresult = "";
                }

                break;

            case ObjectInspectorCellType.FontName:
                aresult = formattedValue.ToString();
                break;

            case ObjectInspectorCellType.FontStyle:
                if (formattedValue.ToString().Length == 0)
                {
                    aresult = DBNull.Value;
                }
                else
                {
                    aresult = GraphicUtils.IntegerFromStringFontStyle(formattedValue.ToString());
                }
                break;

            case ObjectInspectorCellType.Decimal:
                if (formattedValue.ToString().Length == 0)
                {
                    aresult = DBNull.Value;
                }
                else
                {
                    aresult = System.Convert.ToDecimal(formattedValue);
                }
                break;

            case ObjectInspectorCellType.Boolean:
                if (formattedValue.ToString().Length == 0)
                {
                    aresult = DBNull.Value;
                }
                else
                {
                    aresult = System.Convert.ToBoolean(formattedValue);
                }
                break;

            case ObjectInspectorCellType.Integer:
                if (formattedValue.ToString().Length == 0)
                {
                    aresult = DBNull.Value;
                }
                else
                {
                    aresult = (int)Math.Round(System.Convert.ToDecimal(formattedValue));
                }
                break;
            }
            if (aresult == null)
            {
                aresult = base.ParseFormattedValue(formattedValue, cellStyle, formattedValueTypeConverter, valueTypeConverter);
            }
            return(aresult);
        }
Example #4
0
        public static void PrepareReport(Report nreport, DataGridView ngrid, DataGridViewPrintOptions opts)
        {
            const int DefaultScreenDPI = 142;

            int BOOL_WIDTH = 100;
            int BOOL_SEP   = 20;

            if (nreport.SubReports[0].Sections.Count == 1)
            {
                nreport.SubReports[0].AddGroup("TOTAL");
            }
            Section Detail      = nreport.SubReports[0].Sections[nreport.SubReports[0].FirstDetail];
            Section GroupHeader = nreport.SubReports[0].Sections[nreport.SubReports[0].FirstDetail - 1];
            Section GroupFooter = nreport.SubReports[0].Sections[nreport.SubReports[0].LastDetail + 1];
            string  aliasname   = nreport.DataInfo[0].Alias;
            int     totalwidth  = Detail.Width;

            int rowcount = ngrid.Rows.Count;

            if (opts.PrintSelected)
            {
                rowcount = ngrid.SelectedRows.Count;
            }
            SortedList <string, DataGridViewColumn> CampoColumna = new SortedList <string, DataGridViewColumn>();
            List <DataGridViewColumn>            Columnas        = new List <DataGridViewColumn>();
            SortedList <int, DataGridViewColumn> ColumnasString  = new SortedList <int, DataGridViewColumn>();
            SortedList <int, DataGridViewColumn> ColumnasBool    = new SortedList <int, DataGridViewColumn>();
            SortedList <int, DataGridViewColumn> ColumnasImage   = new SortedList <int, DataGridViewColumn>();
            List <string> Campos = new List <string>();
            int           idxcol = 0;

            if (opts.SelectedColumns.Count == 0)
            {
                foreach (DataGridViewColumn ncol in ngrid.Columns)
                {
                    if (ncol.Visible)
                    {
                        Columnas.Add(ncol);
                        idxcol++;
                        CampoColumna.Add("CAMPO" + idxcol.ToString(), ncol);
                        Campos.Add("CAMPO" + idxcol.ToString());
                    }
                }
            }
            else
            {
                foreach (DataGridViewColumn ncol in opts.SelectedColumns)
                {
                    Columnas.Add(ncol);
                    idxcol++;
                    CampoColumna.Add("CAMPO" + idxcol.ToString(), ncol);
                    Campos.Add("CAMPO" + idxcol.ToString());
                }
            }
            int separator           = 40;
            int level_separator     = 200;
            int level_separator_gap = 50;
            // Calculate total width for the selected
            int   maxwidth    = 0;
            float screendpi   = GraphicUtils.ScreenDPI();
            float scalepixels = 1440f / screendpi;

            for (idxcol = 0; idxcol < Columnas.Count; idxcol++)
            {
                DataGridViewColumn ncol = Columnas[idxcol];
                int newwidth            = System.Convert.ToInt32(Math.Round(ncol.Width * scalepixels));
                maxwidth = maxwidth + newwidth;

                if (idxcol < (Columnas.Count - 1))
                {
                    maxwidth = maxwidth + separator;
                }
            }

            List <ShapeItem> HorzShapes = new List <ShapeItem>();
            int pagewidth = opts.PaperWidth();

            pagewidth = pagewidth - nreport.LeftMargin - nreport.RightMargin;
            float fsize     = ngrid.Font.Size;
            float fontscale = 1.0f;
            float scalesep  = 1.0f;
            float newscale  = 1.0f;

            if (opts.AdjustWidth)
            {
                newscale    = (float)pagewidth / maxwidth;
                scalepixels = 1440f / screendpi * newscale;
                scalesep    = newscale;
                if (maxwidth > pagewidth)
                {
                    fontscale = newscale;
                    fsize     = fsize * fontscale;
                    if (fsize <= 0)
                    {
                        fsize = 1;
                    }
                }
            }
            // Calculate font size and width scale
            int rowheight = System.Convert.ToInt32(Math.Round(ngrid.RowTemplate.Height * scalepixels));

            BOOL_WIDTH          = System.Convert.ToInt32(BOOL_WIDTH * fontscale);
            BOOL_SEP            = System.Convert.ToInt32(BOOL_SEP * fontscale);
            separator           = System.Convert.ToInt32(separator * fontscale);
            level_separator     = System.Convert.ToInt32(level_separator * fontscale);
            level_separator_gap = System.Convert.ToInt32(level_separator_gap * fontscale);
            GroupHeader.Height  = rowheight;
            Detail.Height       = rowheight;
            // Prepare datatable
            DataTable ntable = new DataTable();

            idxcol = 0;
            int posx = 0;
            // Grey header
            ShapeItem sitem = new ShapeItem(nreport);

            sitem.Shape      = ShapeType.Rectangle;
            sitem.BrushStyle = BrushType.Solid;
            sitem.PenStyle   = Reportman.Drawing.PenType.Clear;
            sitem.BrushColor = GraphicUtils.IntegerFromColor(Color.FromArgb(200, 200, 200));
            sitem.Height     = rowheight;
            sitem.Align      = PrintItemAlign.TopBottom;
            HorzShapes.Add(sitem);
            nreport.GenerateNewName(sitem);
            GroupHeader.Components.Add(sitem);


            sitem        = new ShapeItem(nreport);
            sitem.Shape  = ShapeType.VertLine;
            sitem.Height = rowheight;
            sitem.Align  = PrintItemAlign.TopBottom;
            nreport.GenerateNewName(sitem);
            GroupHeader.Components.Add(sitem);


            if (opts.DrawBackGroundColors)
            {
                // Background color
                sitem = new ShapeItem(nreport);
                sitem.PrintCondition       = aliasname + ".BACKCOLOR<>NULL";
                sitem.BrushColorExpression = aliasname + ".BACKCOLOR";
                sitem.Shape    = ShapeType.Rectangle;
                sitem.Width    = maxwidth;
                sitem.PenStyle = Reportman.Drawing.PenType.Clear;
                sitem.PosX     = posx;
                sitem.Align    = PrintItemAlign.TopBottom;
                Detail.Components.Add(sitem);
                HorzShapes.Add(sitem);
            }

            sitem       = new ShapeItem(nreport);;
            sitem.Shape = ShapeType.HorzLine;
            sitem.Width = maxwidth;
            HorzShapes.Add(sitem);
            nreport.GenerateNewName(sitem);
            GroupHeader.Components.Add(sitem);


            sitem       = new ShapeItem(nreport);;
            sitem.Shape = ShapeType.HorzLine;
            sitem.Width = maxwidth;
            HorzShapes.Add(sitem);
            nreport.GenerateNewName(sitem);
            GroupFooter.Components.Add(sitem);

            sitem       = new ShapeItem(nreport);;
            sitem.Shape = ShapeType.HorzLine;
            sitem.Width = maxwidth;
            HorzShapes.Add(sitem);
            sitem.Align = PrintItemAlign.Bottom;
            nreport.GenerateNewName(sitem);
            GroupHeader.Components.Add(sitem);

            if (opts.VerticalLines)
            {
                sitem        = new ShapeItem(nreport);
                sitem.Shape  = ShapeType.VertLine;
                sitem.Height = rowheight;
                sitem.Align  = PrintItemAlign.TopBottom;
                nreport.GenerateNewName(sitem);
                Detail.Components.Add(sitem);
            }

            string columnlevel = "";


            for (idxcol = 0; idxcol < Columnas.Count; idxcol++)
            {
                DataGridViewColumn           ncol      = Columnas[idxcol];
                DataGridViewContentAlignment cellalign = DataGridViewContentAlignment.NotSet;
                if (ngrid.DefaultCellStyle != null)
                {
                    cellalign = ngrid.DefaultCellStyle.Alignment;
                }
                if (ncol.DefaultCellStyle != null)
                {
                    cellalign = ncol.DefaultCellStyle.Alignment;
                }
                LabelItem litem = new LabelItem(nreport);
                SetAlignFromCellFormat(cellalign, litem);
                litem.VAlignment = TextAlignVerticalType.Top;
                if (litem.Alignment == TextAlignType.Left)
                {
                    litem.Alignment = TextAlignType.Justify;
                }
                litem.Height   = rowheight;
                litem.FontSize = System.Convert.ToInt16(fsize);
                nreport.GenerateNewName(litem);
                litem.Text = ncol.HeaderText;
                GroupHeader.Components.Add(litem);
                litem.Height   = rowheight;
                litem.PosX     = posx;
                litem.WordWrap = opts.WordWrap;
                litem.CutText  = !opts.WordWrap;
                litem.Width    = System.Convert.ToInt32(Math.Round(ncol.Width * scalepixels));


                bool istextcolumn = false;
                istextcolumn = ncol is DataGridViewTextBoxColumn;
                if (!istextcolumn)
                {
                    if (ncol is DataGridViewColumnAdvanced)
                    {
                        istextcolumn = true;
                    }
                }
                TreeGridAdvanced ngridav;
                if (istextcolumn)
                {
                    ntable.Columns.Add(Campos[idxcol], System.Type.GetType("System.String"));
                    ColumnasString.Add(idxcol, ncol);
                    if ((ncol is TreeGridAdvancedColumn) && (ngrid is TreeGridAdvanced))
                    {
                        if (columnlevel == "")
                        {
                            columnlevel = "LEVEL";
                        }
                        ngridav = (TreeGridAdvanced)ngrid;
                        for (int idxlevel = 1; idxlevel <= ngridav.MaxLevel; idxlevel++)
                        {
                            // Add Image for level
                            ImageItem imaitem = new ImageItem(nreport);
                            imaitem.Expression     = aliasname + ".IMAGE";
                            imaitem.PrintCondition = aliasname + ".LEVEL=" + idxlevel.ToString();
                            imaitem.Height         = rowheight;
                            imaitem.Align          = PrintItemAlign.TopBottom;
                            imaitem.Width          = level_separator;
                            imaitem.PosX           = level_separator_gap + posx + level_separator * (idxlevel) - level_separator + level_separator_gap;
                            imaitem.PosY           = 0;
                            imaitem.DrawStyle      = ImageDrawStyleType.Full;
                            imaitem.dpires         = System.Convert.ToInt32(DefaultScreenDPI);
                            nreport.GenerateNewName(imaitem);


                            Detail.Components.Add(imaitem);

                            // Add expression foreach level
                            ExpressionItem exitem = new ExpressionItem(nreport);
                            exitem.Expression     = aliasname + "." + Campos[idxcol];
                            exitem.PrintCondition = aliasname + ".LEVEL=" + idxlevel.ToString();
                            exitem.WordWrap       = opts.WordWrap;
                            exitem.CutText        = !opts.WordWrap;
                            SetAlignFromCellFormat(cellalign, exitem);
                            if (exitem.Alignment == TextAlignType.Left)
                            {
                                exitem.Alignment = TextAlignType.Justify;
                            }
                            exitem.VAlignment = TextAlignVerticalType.Top;
                            exitem.FontSize   = System.Convert.ToInt16(fsize);
                            exitem.Height     = rowheight;
                            exitem.PosX       = level_separator_gap * 2 + posx + level_separator * idxlevel;
                            exitem.Height     = rowheight;
                            nreport.GenerateNewName(exitem);
                            exitem.Width = litem.Width - level_separator * (idxlevel + 1);
                            Detail.Components.Add(exitem);


                            if (opts.DrawTreeLines)
                            {
                                // Last child line
                                sitem = new ShapeItem(nreport);
                                sitem.PrintCondition = "((" + aliasname + ".LEVEL=" + idxlevel.ToString() + ") AND (" + aliasname + ".LASTCHILD))";
                                sitem.Shape          = ShapeType.VertLine;
                                sitem.PenStyle       = Reportman.Drawing.PenType.Dot;
                                sitem.PosX           = level_separator_gap + posx + level_separator * idxlevel - level_separator;
                                sitem.Height         = rowheight / 3;
                                Detail.Components.Add(sitem);

                                // Not last child horz line
                                sitem = new ShapeItem(nreport);
                                sitem.PrintCondition = "((" + aliasname + ".LEVEL=" + idxlevel.ToString() + ") AND (NOT (" + aliasname + ".LASTCHILD)))";
                                sitem.Shape          = ShapeType.VertLine;
                                sitem.PenStyle       = Reportman.Drawing.PenType.Dot;
                                sitem.PosX           = level_separator_gap + posx + level_separator * idxlevel - level_separator;
                                sitem.Align          = PrintItemAlign.TopBottom;
                                Detail.Components.Add(sitem);

                                // Other parent lines
                                sitem = new ShapeItem(nreport);
                                sitem.PrintCondition = aliasname + ".LEVEL>" + idxlevel.ToString();
                                sitem.Shape          = ShapeType.VertLine;
                                sitem.Align          = PrintItemAlign.TopBottom;
                                sitem.PenStyle       = Reportman.Drawing.PenType.Dot;
                                sitem.PosX           = level_separator_gap + posx + level_separator * idxlevel - level_separator;
                                sitem.Height         = rowheight / 2;
                                Detail.Components.Add(sitem);

                                // Horz arrow
                                sitem = new ShapeItem(nreport);
                                sitem.PrintCondition = aliasname + ".LEVEL=" + idxlevel.ToString();
                                sitem.PenStyle       = Reportman.Drawing.PenType.Dot;
                                sitem.Shape          = ShapeType.HorzLine;
                                sitem.PosX           = level_separator_gap + posx + level_separator * idxlevel - level_separator;
                                sitem.PosY           = rowheight / 3;
                                sitem.Width          = level_separator / 2;
                                Detail.Components.Add(sitem);
                            }
                        }
                    }
                    else
                    {
                        ExpressionItem exitem = new ExpressionItem(nreport);
                        exitem.Expression = aliasname + "." + Campos[idxcol];
                        exitem.WordWrap   = opts.WordWrap;
                        exitem.CutText    = !opts.WordWrap;
                        SetAlignFromCellFormat(cellalign, exitem);
                        if (exitem.Alignment == TextAlignType.Left)
                        {
                            exitem.Alignment = TextAlignType.Justify;
                        }
                        exitem.VAlignment = TextAlignVerticalType.Top;
                        exitem.FontSize   = System.Convert.ToInt16(fsize);
                        exitem.Height     = rowheight;
                        exitem.PosX       = posx;
                        exitem.Height     = rowheight;
                        nreport.GenerateNewName(exitem);
                        exitem.Width = litem.Width;


                        Detail.Components.Add(exitem);
                    }
                }
                else
                {
                    if (ncol is DataGridViewImageColumn)
                    {
                        ColumnasImage.Add(idxcol, ncol);
                        ntable.Columns.Add(Campos[idxcol], System.Type.GetType("System.Object"));

                        ImageItem imaitem = new ImageItem(nreport);
                        imaitem.Expression = aliasname + "." + Campos[idxcol];
                        imaitem.Height     = rowheight;
                        imaitem.Align      = PrintItemAlign.TopBottom;
                        imaitem.Width      = litem.Width;
                        imaitem.PosX       = posx + separator;
                        imaitem.PosY       = 0;
                        imaitem.DrawStyle  = ImageDrawStyleType.Full;
                        imaitem.dpires     = System.Convert.ToInt32(DefaultScreenDPI);
                        nreport.GenerateNewName(imaitem);


                        Detail.Components.Add(imaitem);
                    }
                    else
                    if (ncol is DataGridViewCheckBoxColumn)
                    {
                        ColumnasBool.Add(idxcol, ncol);
                        ntable.Columns.Add(Campos[idxcol], System.Type.GetType("System.Boolean"));

                        ShapeItem cuaditem = new ShapeItem(nreport);
                        cuaditem.Shape          = ShapeType.Rectangle;
                        cuaditem.PrintCondition = aliasname + "." + Campos[idxcol] + "<>NULL";
                        //cuaditem.Align = PrintItemAlign.TopBottom;
                        cuaditem.BrushStyle = BrushType.Clear;
                        cuaditem.Height     = rowheight;
                        int shapepos = posx + (litem.Width / 2) - BOOL_WIDTH / 2;
                        cuaditem.PosX   = shapepos;
                        cuaditem.PosY   = BOOL_SEP;
                        cuaditem.Width  = BOOL_WIDTH;
                        cuaditem.Height = BOOL_WIDTH;
                        nreport.GenerateNewName(cuaditem);
                        Detail.Components.Add(cuaditem);

                        cuaditem                = new ShapeItem(nreport);
                        cuaditem.Shape          = ShapeType.Oblique1;
                        cuaditem.PrintCondition = aliasname + "." + Campos[idxcol];
                        //cuaditem.Align = PrintItemAlign.TopBottom;
                        cuaditem.BrushStyle = BrushType.Clear;
                        cuaditem.Height     = rowheight;
                        cuaditem.PosX       = shapepos;
                        cuaditem.PosY       = BOOL_SEP;
                        cuaditem.Width      = BOOL_WIDTH;
                        cuaditem.Height     = BOOL_WIDTH;
                        nreport.GenerateNewName(cuaditem);
                        Detail.Components.Add(cuaditem);


                        cuaditem                = new ShapeItem(nreport);
                        cuaditem.Shape          = ShapeType.Oblique2;
                        cuaditem.PrintCondition = aliasname + "." + Campos[idxcol];
                        //cuaditem.Align = PrintItemAlign.TopBottom;
                        cuaditem.BrushStyle = BrushType.Clear;
                        cuaditem.Height     = rowheight;
                        cuaditem.PosX       = shapepos;
                        cuaditem.PosY       = BOOL_SEP;
                        cuaditem.Width      = BOOL_WIDTH;
                        cuaditem.Height     = BOOL_WIDTH;
                        nreport.GenerateNewName(cuaditem);
                        Detail.Components.Add(cuaditem);
                    }
                    else
                    {
                        throw new Exception("Tipo de columna no soportada:" + ncol.GetType().ToString());
                    }
                }



                posx = posx + litem.Width;
                posx = posx + System.Convert.ToInt32(separator * scalesep);


                if (opts.VerticalLines)
                {
                    sitem        = new ShapeItem(nreport);
                    sitem.Shape  = ShapeType.VertLine;
                    sitem.PosX   = posx;
                    sitem.Height = rowheight;
                    sitem.Align  = PrintItemAlign.TopBottom;
                    Detail.Components.Add(sitem);
                }

                sitem        = new ShapeItem(nreport);
                sitem.Shape  = ShapeType.VertLine;
                sitem.PosX   = posx;
                sitem.Height = rowheight;
                sitem.Align  = PrintItemAlign.TopBottom;
                GroupHeader.Components.Add(sitem);

                if (opts.HorizontalLines)
                {
                    sitem       = new ShapeItem(nreport);
                    sitem.Shape = ShapeType.HorzLine;
                    sitem.Width = maxwidth;
                    HorzShapes.Add(sitem);
                    //sitem.Align = PrintItemAlign.Top;
                    Detail.Components.Add(sitem);

                    sitem = new ShapeItem(nreport);
                    sitem.PrintCondition = "CURRENTGROUP=0";
                    sitem.Shape          = ShapeType.HorzLine;
                    sitem.Width          = maxwidth;
                    HorzShapes.Add(sitem);
                    sitem.Align = PrintItemAlign.Bottom;
                    Detail.Components.Add(sitem);
                }
            }
            foreach (ShapeItem nshape in HorzShapes)
            {
                nshape.Width = posx;
            }
            int colbackground = 0;

            if (opts.DrawBackGroundColors)
            {
                ntable.Columns.Add("BACKCOLOR", System.Type.GetType("System.Int32"));
                colbackground = ntable.Columns.Count - 1;
            }
            if (columnlevel != "")
            {
                ntable.Columns.Add("IMAGE", System.Type.GetType("System.Object"));
                ntable.Columns.Add("LEVEL", System.Type.GetType("System.Int32"));
                ntable.Columns.Add("LASTCHILD", System.Type.GetType("System.Boolean"));
            }
            object[] nvalues = new object[ntable.Columns.Count];
            int      counter = 0;

            foreach (DataGridViewRow dgrow in ngrid.Rows)
            {
                if ((!opts.PrintSelected) || ((opts.PrintSelected) && (dgrow.Selected)))
                {
                    foreach (int index in ColumnasString.Keys)
                    {
                        nvalues[index] = dgrow.Cells[ColumnasString[index].Index].FormattedValue;
                    }
                    foreach (int index in ColumnasBool.Keys)
                    {
                        nvalues[index] = dgrow.Cells[ColumnasBool[index].Index].Value;
                    }
                    foreach (int index in ColumnasImage.Keys)
                    {
                        MemoryStream mstream = GetImageStreamFromObject(dgrow.Cells[ColumnasImage[index].Index].Value);
                        if (mstream != null)
                        {
                            nvalues[index] = mstream;
                        }
                        else
                        {
                            nvalues[index] = DBNull.Value;
                        }
                    }
                    if (opts.DrawBackGroundColors)
                    {
                        DataGridViewCellStyle nstyle = null;
                        if (!dgrow.DefaultCellStyle.BackColor.IsEmpty)
                        {
                            nstyle = dgrow.DefaultCellStyle;
                        }
                        if (nstyle == null)
                        {
                            if ((!ngrid.AlternatingRowsDefaultCellStyle.BackColor.IsEmpty))
                            {
                                if (counter % 2 == 1)
                                {
                                    nstyle = ngrid.AlternatingRowsDefaultCellStyle;
                                }
                                else
                                if (!ngrid.DefaultCellStyle.BackColor.IsEmpty)
                                {
                                    nstyle = ngrid.DefaultCellStyle;
                                }
                            }
                            else
                            {
                                if (!ngrid.DefaultCellStyle.BackColor.IsEmpty)
                                {
                                    nstyle = ngrid.AlternatingRowsDefaultCellStyle;
                                }
                            }
                        }
                        nvalues[colbackground] = DBNull.Value;
                        if (nstyle != null)
                        {
                            if (nstyle.BackColor != Color.White)
                            {
                                if (nstyle.BackColor != Color.FromArgb(255, 255, 255))
                                {
                                    nvalues[colbackground] = GraphicUtils.IntegerFromColor(nstyle.BackColor);
                                }
                            }
                        }
                    }
                    if (columnlevel.Length > 0)
                    {
                        TreeGridRow  trow    = (TreeGridRow)dgrow;
                        MemoryStream mstream = GetImageStreamFromObject(trow.Image);
                        if (mstream != null)
                        {
                            nvalues[nvalues.Length - 3] = mstream;
                        }
                        nvalues[nvalues.Length - 2] = trow.Level;
                        nvalues[nvalues.Length - 1] = trow.IsLastSibling;

/*
 *                      if (trow.Parent != null)
 *                          nvalues[nvalues.Length - 1] = ((trow.Node.Childs.Count == 0) || (!trow.Node.Expanded)) && (((TreeGridRow)dgrow).ChildIndex + 1) == ((TreeGridRow)dgrow).Parent.Node.Childs.Count;
 *                      else
 *                      {
 *                          nvalues[nvalues.Length - 1] = ((trow.Node.Childs.Count == 0) || (!trow.Node.Expanded)) && (((TreeGridAdvanced)ngrid).MainNode.Childs.Count == trow.ChildIndex + 1);
 *                      }*/
                    }
                    ntable.Rows.Add(nvalues);
                    counter++;
                }
            }
            nreport.DataInfo[aliasname].DataViewOverride = new DataView(ntable);
            //return meta;
        }