Exemplo n.º 1
0
        private void DrawItems(Graphics g)
        {
            List <BandStructureNode> list = new List <BandStructureNode>();

            EnumNodes(list, FRoot);

            foreach (BandStructureNode node in list)
            {
                int offs = 24 + Offset - 2;

                RectangleF fillRect = new RectangleF(node.Left, node.Top + offs, Width - node.Left - 1, node.Height);
                BandBase   bandFill = null;

                foreach (BandBase band in node.Bands)
                {
                    bandFill = band;
                    if (band is GroupHeaderBand || band is DataBand)
                    {
                        break;
                    }
                }

                // highlight active band group
                //foreach (BandBase band in node.Bands)
                //{
                //  if (Designer.SelectedObjects.IndexOf(band) != -1)
                //  {
                //    fillBrush = new LinearGradientBrush(fillRect, Color.FromArgb(220, 235, 255),
                //      Color.FromArgb(130, 170, 230), LinearGradientMode.Vertical);
                //    break;
                //  }
                //}

                // fill node area
                bandFill.DrawBandHeader(g, fillRect, false);
                g.DrawRectangle(SystemPens.ControlDark, node.Left, node.Top + offs, Width - node.Left - 1, node.Height);

                // draw band title
                float scale = ReportWorkspace.Scale;
                using (StringFormat sf = new StringFormat())
                {
                    foreach (BandBase band in node.Bands)
                    {
                        g.DrawLine(SystemPens.ControlDark, node.Left + 8, band.Top * scale + offs, Width, band.Top * scale + offs);

                        RectangleF textRect = new RectangleF(node.Left + 4, band.Top * scale + offs + 4,
                                                             Width - (node.Left + 4) - 4, band.Height * scale - 4);
                        ObjectInfo info = RegisteredObjects.FindObject(band);
                        string     text = Res.Get(info.Text);
                        if (band.GetInfoText() != "")
                        {
                            text += ": " + band.GetInfoText();
                        }

                        float           textHeight = DrawUtils.MeasureString(g, text, DrawUtils.Default96Font, textRect, sf).Height;
                        TextFormatFlags flags      = textHeight > textRect.Height ?
                                                     TextFormatFlags.WordBreak : TextFormatFlags.VerticalCenter | TextFormatFlags.WordBreak;
                        TextRenderer.DrawText(g, text, DrawUtils.Default96Font,
                                              new Rectangle((int)textRect.Left, (int)textRect.Top, (int)textRect.Width, (int)textRect.Height),
                                              SystemColors.WindowText, flags);

                        if (band.IsAncestor)
                        {
                            g.DrawImage(Res.GetImage(99), (int)(node.Left + Width - 10), (int)(band.Top * scale + offs + 3));
                        }
                    }
                }
            }
        }