예제 #1
0
        private int GetColumnBestHeight(GridBand column, int width, DevExpress.Utils.AppearanceObject app)
        {
            GridBandInfoArgs   ex       = null;
            BandedGridViewInfo viewInfo = GridView.GetViewInfo() as BandedGridViewInfo;

            viewInfo.GInfo.AddGraphics(null);
            ex = new GridBandInfoArgs(null, viewInfo.GInfo.Cache);
            try
            {
                ex.InnerElements.Add(new DrawElementInfo(new GlyphElementPainter(),
                                                         new GlyphElementInfoArgs(viewInfo.View.Images, 0, null),
                                                         StringAlignment.Near));
                ex.SetAppearance(app);
                ex.Caption     = column.Caption;
                ex.CaptionRect = new Rectangle(0, 0, (int)(width - 10 * DpiXRel), 1000);
            }
            finally
            {
                viewInfo.GInfo.ReleaseGraphics();
            }

            GraphicsInfo grInfo = new GraphicsInfo();

            grInfo.AddGraphics(null);
            ex.Cache = grInfo.Cache;
            int Height = CalcCaptionTextSize(grInfo.Cache, ex as HeaderObjectInfoArgs, column.Caption);

            return(Height);
        }
        private void gridControlPublication_Paint(object sender, PaintEventArgs e)
        {
            DevExpress.XtraGrid.GridControl gridC = sender as DevExpress.XtraGrid.GridControl;
            DevExpress.XtraGrid.Views.BandedGrid.AdvBandedGridView gridView = gridC.FocusedView as DevExpress.XtraGrid.Views.BandedGrid.AdvBandedGridView;
            BandedGridViewInfo  viewinfo      = gridView.GetViewInfo() as BandedGridViewInfo;
            BandedGridViewRects gridViewRects = viewinfo.ViewRects;
            Rectangle           r             = gridViewRects.BandPanel;

            DevExpress.XtraGrid.Views.Grid.ViewInfo.GridColumnsInfo gci = viewinfo.ColumnsInfo;
            int   y  = gci[gridColumnADRate].Bounds.Y - r.Height;
            int   x  = gci[gridColumnADRate].Bounds.Right;
            Point p1 = new Point(x, y);
            int   y2 = gridViewRects.Rows.Bottom;
            Point p2 = new Point(x, y2);

            e.Graphics.DrawLine(Pens.LightBlue, p1, p2);

            y  = gci[gridColumnColorPricing].Bounds.Y - r.Height;
            x  = gci[gridColumnColorPricing].Bounds.Right;
            p1 = new Point(x, y);
            y2 = gridViewRects.Rows.Bottom;
            p2 = new Point(x, y2);
            e.Graphics.DrawLine(Pens.LightBlue, p1, p2);

            y  = gci[gridColumnDate].Bounds.Y - r.Height;
            x  = gci[gridColumnDate].Bounds.Right;
            p1 = new Point(x, y);
            y2 = gridViewRects.Rows.Bottom;
            p2 = new Point(x, y2);
            e.Graphics.DrawLine(Pens.LightBlue, p1, p2);

            y  = gci[gridColumnID].Bounds.Y - r.Height;
            x  = gci[gridColumnID].Bounds.Right;
            p1 = new Point(x, y);
            y2 = gridViewRects.Rows.Bottom;
            p2 = new Point(x, y2);
            e.Graphics.DrawLine(Pens.LightBlue, p1, p2);

            y  = gci[gridColumnDiscountRate].Bounds.Y - r.Height;
            x  = gci[gridColumnDiscountRate].Bounds.Right;
            p1 = new Point(x, y);
            y2 = gridViewRects.Rows.Bottom;
            p2 = new Point(x, y2);
            e.Graphics.DrawLine(Pens.LightBlue, p1, p2);

            y  = gci[gridColumnFinalRate].Bounds.Y - r.Height;
            x  = gci[gridColumnFinalRate].Bounds.Right;
            p1 = new Point(x, y);
            y2 = gridViewRects.Rows.Bottom;
            p2 = new Point(x, y2);
            e.Graphics.DrawLine(Pens.LightBlue, p1, p2);

            y  = gci[gridColumnPCIRate].Bounds.Y - r.Height;
            x  = gci[gridColumnPCIRate].Bounds.Right;
            p1 = new Point(x, y);
            y2 = gridViewRects.Rows.Bottom;
            p2 = new Point(x, y2);
            e.Graphics.DrawLine(Pens.LightBlue, p1, p2);
        }
예제 #3
0
        private int GetColumnBestHeight(GridBand column, int width /*, GridBand parent_column*/)
        {
            /*GridBandInfoArgs ex = null;
             *
             * if (parent_column == null)
             *  ex = viewInfo.BandsInfo[column];
             * else
             *  ex = viewInfo.BandsInfo[parent_column].Children[column];
             *
             * GraphicsInfo grInfo = new GraphicsInfo();
             * grInfo.AddGraphics(null);
             * ex.Cache = grInfo.Cache;
             * bool canDrawMore = true;
             * Size captionSize = CalcCaptionTextSize(grInfo.Cache, ex as HeaderObjectInfoArgs, column.Caption);
             * Size res = ex.InnerElements.CalcMinSize(grInfo.Graphics, ref canDrawMore);
             * res.Height = Math.Max(res.Height, captionSize.Height);
             * res.Width += captionSize.Width;
             * //res = viewInfo.Painter.ElementsPainter.Column.CalcBoundsByClientRectangle(ex, new Rectangle(Point.Empty, res)).Size;
             * grInfo.ReleaseGraphics();
             * return res.Height;*/

            GridBandInfoArgs   ex       = null;
            BandedGridViewInfo viewInfo = GridView.GetViewInfo() as BandedGridViewInfo;

            viewInfo.GInfo.AddGraphics(null);
            ex = new GridBandInfoArgs(null, viewInfo.GInfo.Cache);
            try
            {
                ex.InnerElements.Add(new DrawElementInfo(new GlyphElementPainter(),
                                                         new GlyphElementInfoArgs(viewInfo.View.Images, 0, null),
                                                         StringAlignment.Near));
                ex.SetAppearance(GridView.Appearance.BandPanel);
                ex.Caption     = column.Caption;
                ex.CaptionRect = new Rectangle(0, 0, width, 1000);
            }
            finally
            {
                viewInfo.GInfo.ReleaseGraphics();
            }

            GraphicsInfo grInfo = new GraphicsInfo();

            grInfo.AddGraphics(null);
            ex.Cache = grInfo.Cache;
            Size captionSize = CalcCaptionTextSize(grInfo.Cache, ex as HeaderObjectInfoArgs, column.Caption);

            return(captionSize.Height);
        }
 private void ФормаИсторииСборки_Load(object sender, EventArgs e)
 {
     this.ЗагрузкаНастроек();
     this.параметрыОтображенияТаблицы = new BandedGridViewInfo(this.данныеТаблицыИстории);
 }
예제 #5
0
        private void CreateGrid()
        {
            int      iCnt         = 1;
            Graphics formGraphics = this.CreateGraphics();

            for (int i = 0; i < GridView.Columns.Count; i++)
            {
                GridView.Columns[i].Width = (int)(GridView.Columns[i].Width * formGraphics.DpiX / 96);
            }

            for (int i = 0; i < m_list.Count; i++)
            {
                if (m_list[i].m_listSystemItems.Count == 0)
                {
                    continue;
                }

                DevExpress.XtraGrid.Views.BandedGrid.GridBand gb = GridView.Bands.AddBand(m_list[i].m_strFunctionalSystemName);
                gb.OptionsBand.AllowMove = false;
                gb.AppearanceHeader.Options.UseTextOptions = true;
                gb.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
                gb.AppearanceHeader.TextOptions.WordWrap   = DevExpress.Utils.WordWrap.Wrap;
                gb.AutoFillDown = true;
                gb.Name         = "band_" + i.ToString();

                for (int j = 0; j < m_list[i].m_listSystemItems.Count; j++)
                {
                    BandedGridColumn col = new BandedGridColumn();
                    col.Name    = m_list[i].m_listSystemItems[j].m_SystemItemID.ToString();
                    col.Caption = m_list[i].m_listSystemItems[j].m_strSystemItemName;
                    col.OptionsColumn.AllowMove = false;
                    col.OptionsColumn.AllowEdit = false;
                    col.Width   = (int)(150 * formGraphics.DpiX / 96);
                    col.Visible = true;
                    col.OptionsColumn.AllowSort = DevExpress.Utils.DefaultBoolean.True;

                    if (m_list[i].m_listSystemItems[j].m_strSystemItemName != m_list[i].m_strFunctionalSystemName)
                    {
                        DevExpress.XtraGrid.Views.BandedGrid.GridBand gb_ = gb.Children.AddBand(m_list[i].m_listSystemItems[j].m_strSystemItemName);
                        gb_.OptionsBand.AllowMove = false;
                        gb_.Width = (int)(150 * formGraphics.DpiX / 96);

                        gb_.Columns.Add(col);
                        gb_.AppearanceHeader.Options.UseTextOptions = true;
                        gb_.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
                        gb_.AppearanceHeader.TextOptions.WordWrap   = DevExpress.Utils.WordWrap.Wrap;
                        gb_.AutoFillDown = true;
                        gb_.Name         = "band_" + i.ToString() + "_" + j.ToString();
                    }
                    else
                    {
                        gb.Columns.Add(col);
                    }

                    iCnt++;
                }
            }

            /*GridBandInfoArgs ex = null;
             * BandedGridViewInfo viewInfo = GridView.GetViewInfo() as BandedGridViewInfo;
             * viewInfo.GInfo.AddGraphics(null);
             * ex = new GridBandInfoArgs(null, viewInfo.GInfo.Cache);
             * try
             * {
             *  ex.InnerElements.Add(new DrawElementInfo(new GlyphElementPainter(),
             *                                          new GlyphElementInfoArgs(viewInfo.View.Images, 0, null),
             *                                          StringAlignment.Near));
             *  ex.SetAppearance(GridView.Appearance.BandPanel);
             *  ex.Caption = "А";
             *  ex.CaptionRect = new Rectangle(0, 0, 100, 100);
             * }
             * finally
             * {
             *  viewInfo.GInfo.ReleaseGraphics();
             * }
             *
             * GraphicsInfo grInfo = new GraphicsInfo();
             * grInfo.AddGraphics(null);
             * ex.Cache = grInfo.Cache;
             * Size captionSize = CalcCaptionTextSize(grInfo.Cache, ex as HeaderObjectInfoArgs, "А");
             * m_singleLineHeight = captionSize.Height;*/

            BandedGridViewInfo viewInfo = GridView.GetViewInfo() as BandedGridViewInfo;

            m_singleLineHeight = viewInfo.BandRowHeight;

            GridView.BeginUpdate();

            for (int i = 0; i < GridView.Bands.Count; i++)
            {
                int Width = 0;
                for (int j = 0; j < GridView.Bands[i].Children.Count; j++)
                {
                    GridBand b            = GridView.Bands[i].Children[j];
                    int      child_height = GetColumnBestHeight(b, b.Width);
                    b.RowCount = child_height / m_singleLineHeight;
                    dictBandHeigths[b.Name] = child_height / m_singleLineHeight;

                    Width += b.Width;
                }

                if (GridView.Bands[i].Children.Count > 0)
                {
                    int parent_height = GetColumnBestHeight(GridView.Bands[i], Width);
                    GridView.Bands[i].RowCount = parent_height / m_singleLineHeight;
                    dictBandHeigths[GridView.Bands[i].Name] = parent_height / m_singleLineHeight;
                }
            }

            int max_parent_row = -1;
            int max_row        = -1;

            for (int i = 0; i < GridView.Bands.Count; i++)
            {
                if (GridView.Bands[i].Children.Count > 0)
                {
                    if (dictBandHeigths[GridView.Bands[i].Name] > max_parent_row)
                    {
                        max_parent_row = dictBandHeigths[GridView.Bands[i].Name];
                    }
                }

                for (int j = 0; j < GridView.Bands[i].Children.Count; j++)
                {
                    GridBand b = GridView.Bands[i].Children[j];

                    if (dictBandHeigths[b.Name] > max_row)
                    {
                        max_row = dictBandHeigths[b.Name];
                    }
                }
            }

            for (int i = 0; i < GridView.Bands.Count; i++)
            {
                if (GridView.Bands[i].Children.Count > 0)
                {
                    GridView.Bands[i].RowCount = max_parent_row;
                }

                for (int j = 0; j < GridView.Bands[i].Children.Count; j++)
                {
                    GridBand b = GridView.Bands[i].Children[j];

                    b.RowCount = max_row;
                }
            }

            GridView.EndUpdate();
        }