Example #1
0
        protected override GridCellInfo CalcRowCellDrawInfoCore(GridDataRowInfo ri, GridColumnInfoArgs ci, GridCellInfo cell, GridColumnInfoArgs nextColumn, bool calcEditInfo, GridRow nextRow, bool allowCache, Rectangle cellBounds)
        {
            GridCellInfo result;

            result = base.CalcRowCellDrawInfoCore(ri, ci, cell, nextColumn, calcEditInfo, nextRow, allowCache, cellBounds);
            if (result.CellButtonRect == Rectangle.Empty)
            {
                return(result);
            }

            MyGridView view = View as MyGridView;

            if (view == null)
            {
                return(result);
            }


            if (view.OptionsView.DetailButtonsVAlignment == VertAlignment.Top)
            {
                result.CellButtonRect.Y = result.CellValueRect.Y + CellVertIndent + CellValueVIndent;
                return(result);
            }

            if (view.OptionsView.DetailButtonsVAlignment == VertAlignment.Bottom)
            {
                result.CellButtonRect.Y = result.CellValueRect.Bottom - result.CellButtonRect.Height - CellVertIndent - CellValueVIndent;
                return(result);
            }
            return(result);
        }
Example #2
0
        void OnMouseMove(object sender, MouseEventArgs e)
        {
            GridHitInfo hitInfo = view.CalcHitInfo(e.Location);

            if (hitInfo.HitTest == GridHitTest.Row && view.IsGroupRow(hitInfo.RowHandle))
            {
                GridViewInfo       viewInfo = view.GetViewInfo() as GridViewInfo;
                GridGroupRowInfo   rowInfo  = viewInfo.GetGridRowInfo(hitInfo.RowHandle) as GridGroupRowInfo;
                GridColumn         col      = viewInfo.GetNearestColumn(e.Location);
                GridColumnInfoArgs args     = viewInfo.ColumnsInfo[col];
                if (col.VisibleIndex == 0)
                {
                    HotTrackRectangle = new Rectangle(rowInfo.ButtonBounds.Right + 2, rowInfo.Bounds.Y,
                                                      args.Bounds.Width + args.Bounds.X - rowInfo.ButtonBounds.Right - 2, rowInfo.Bounds.Height);
                }
                else
                {
                    HotTrackRectangle = new Rectangle(args.Bounds.X + 2, rowInfo.Bounds.Y,
                                                      args.Bounds.Width - 2, rowInfo.Bounds.Height);
                }
            }
            else
            {
                HotTrackRectangle = Rectangle.Empty;
            }
        }
Example #3
0
        private void DrawQuickCustomisationIconCore(GridViewDrawArgs e, QuickCustomizationIcon icon, Rectangle bounds,
                                                    QuickCustomisationIconStatusEnum status)
        {
            if (icon == null)
            {
                return;
            }
            var patchedRec = new Rectangle(bounds.X + 1, bounds.Y, bounds.Width - 1, bounds.Height);
            var args       = new GridColumnInfoArgs(e.Cache, e.ViewInfo.ColumnsInfo[0].Column)
            {
                Cache          = e.Cache,
                Bounds         = patchedRec,
                HeaderPosition = HeaderPositionKind.Center
            };

            if (status == QuickCustomisationIconStatusEnum.Hot)
            {
                args.State = ObjectState.Hot;
            }
            ElementsPainter.Column.DrawObject(args);
            if (icon.Image == null)
            {
                icon.Image = Resources.Customization;
            }
            var rec = new Rectangle
            {
                Location = new Point(bounds.Left + (bounds.Width - icon.Image.Width) / 2, bounds.Top + (bounds.Height - icon.Image.Height) / 2),
                Size     = new Size(icon.Image.Width, icon.Image.Height)
            };

            e.Graphics.PageUnit = GraphicsUnit.Pixel;
            e.Graphics.DrawImageUnscaled(icon.Image, rec);
        }
Example #4
0
 private void DrawQuickCustomisationIconCore(GridViewDrawArgs e, QuickCustomizationIcon icon, Rectangle bounds,
     QuickCustomisationIconStatusEnum status)
 {
     if (icon == null)
     {
         return;
     }
     var patchedRec = new Rectangle(bounds.X + 1, bounds.Y, bounds.Width - 1, bounds.Height);
     var args = new GridColumnInfoArgs(e.Cache, e.ViewInfo.ColumnsInfo[0].Column)
     {
         Cache = e.Cache,
         Bounds = patchedRec,
         HeaderPosition = HeaderPositionKind.Center
     };
     if (status == QuickCustomisationIconStatusEnum.Hot)
     {
         args.State = ObjectState.Hot;
     }
     ElementsPainter.Column.DrawObject(args);
     if (icon.Image == null)
     {
         icon.Image = Resources.Customization;
     }
     var rec = new Rectangle
     {
         Location = new Point(bounds.Left + (bounds.Width - icon.Image.Width) / 2, bounds.Top + (bounds.Height - icon.Image.Height) / 2),
         Size = new Size(icon.Image.Width, icon.Image.Height)
     };
     e.Graphics.PageUnit = GraphicsUnit.Pixel;
     e.Graphics.DrawImageUnscaled(icon.Image, rec);
 }
Example #5
0
        /// <summary>
        /// Draws the column header.
        /// </summary>
        /// <param name="cache">The cache.</param>
        /// <param name="column">The column.</param>
        public void DrawColumnHeader(GraphicsCache cache, GridColumn column)
        {
            var viewInfo = _gridView.GetViewInfo() as BandedGridViewInfo;

            if (viewInfo != null)
            {
                GridColumnInfoArgs colInfo = viewInfo.ColumnsInfo[column];
                var bandedGridColumn       = column as BandedGridColumn;
                if (bandedGridColumn != null)
                {
                    GridBandInfoArgs bandInfo = getBandInfo(viewInfo.BandsInfo, bandedGridColumn.OwnerBand);
                    if (colInfo == null || bandInfo == null)
                    {
                        return;
                    }
                    colInfo.Cache = cache;

                    int       top   = bandInfo.Bounds.Top;
                    Rectangle rect  = colInfo.Bounds;
                    int       delta = rect.Top - top;
                    rect.Y         = top;
                    rect.Height   += delta;
                    colInfo.Bounds = rect;
                }
                colInfo.Appearance.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Center;
                ElementsPainter.Column.CalcObjectBounds(colInfo);
                ElementsPainter.Column.DrawObject(colInfo);
            }
        }
 private Rectangle CalcButtonRect(GridColumnInfoArgs columnArgs, Graphics gr)
 {
     Rectangle columnRect = columnArgs.Bounds;
     int innerElementsWidth = CalcInnerElementsMinWidth(columnArgs, gr);
     Rectangle buttonRect = new Rectangle(columnRect.Right - innerElementsWidth - buttonSize.Width - 2,
         columnRect.Y + columnRect.Height / 2 - buttonSize.Height / 2, buttonSize.Width, buttonSize.Height);
     return buttonRect;
 }
Example #7
0
        private Rectangle CalcButtonRect(GridColumnInfoArgs columnArgs, Graphics gr)
        {
            Rectangle columnRect         = columnArgs.Bounds;
            int       innerElementsWidth = CalcInnerElementsMinWidth(columnArgs, gr);
            Rectangle buttonRect         = new Rectangle(columnRect.Right - innerElementsWidth - buttonSize.Width - 2,
                                                         columnRect.Y + columnRect.Height / 2 - buttonSize.Height / 2, buttonSize.Width, buttonSize.Height);

            return(buttonRect);
        }
Example #8
0
        private void AddNewColumnsInfo(List <DictionaryEntry> group, int i, GridColumnInfoArgs initCellInfo)
        {
            var cellInfo = new GridColumnInfoArgs(initCellInfo.Column);

            cellInfo.Assign(initCellInfo);
            cellInfo.Tag           = group[i].Key as GridGroupSummaryItem;
            cellInfo.Info.StartRow = i;
            ColumnsInfo.Add(cellInfo);
        }
        private Rectangle GetCheckBoxRectangle(GridColumnInfoArgs columnArgs, Graphics gr)
        {
            Rectangle columnRect         = columnArgs.Bounds;
            int       innerElementsWidth = CalcInnerElementsMinWidth(columnArgs, gr);
            Rectangle Rect = new Rectangle(columnRect.Right - innerElementsWidth - checkBoxSize.Width - 5,
                                           columnRect.Y + columnRect.Height / 2 - checkBoxSize.Height / 2, checkBoxSize.Width, checkBoxSize.Height);

            return(Rect);
        }
        GridHitInfo CalcColumnPanelHitInfo(Point pt, GridHitInfo hi)
        {
            GridColumnInfoArgs ci = CalcColumnHitInfo(pt);
            bool bottomEdge;

            bottomEdge = IntInRangeBottom(pt.Y, ci.Bounds.Bottom, ci.Bounds.Bottom - ControlUtils.ColumnResizeEdgeSize);
            if (bottomEdge)
            {
                hi.HitTest = GridHitTest.RowEdge;
            }
            return(hi);
        }
Example #11
0
        private bool IsButtonRect(Point point, GridColumn column)
        {
            GraphicsInfo info = new GraphicsInfo();

            info.AddGraphics(null);
            GridViewInfo       viewInfo   = view.GetViewInfo() as GridViewInfo;
            GridColumnInfoArgs columnArgs = viewInfo.ColumnsInfo[column];
            Rectangle          buttonRect = CalcButtonRect(columnArgs, info.Graphics);

            info.ReleaseGraphics();
            return(buttonRect.Contains(point));
        }
Example #12
0
 protected int GetColumnHeaderWidth(GridColumnInfoArgs args, GridPainter painter)
 {
     if (args != null)
     {
         int width = painter.CurrentSizerPos - args.Bounds.Left;
         if (width < 0)
         {
             width = args.Bounds.Right - painter.CurrentSizerPos;
         }
         return(width);
     }
     return(0);
 }
Example #13
0
        private bool ClickInEditor(MouseEventArgs e, out Rectangle editorBounds)
        {
            editorBounds = Rectangle.Empty;
            GridViewInfo       vi         = view.GetViewInfo() as GridViewInfo;
            GridColumnInfoArgs columnInfo = CalcColumnHitInfo(e.Location, vi.ColumnsInfo);

            if (columnInfo != null && columnInfo.Column == _Column)
            {
                editorBounds = DrawEditorHelper.GetEditorBounds(columnInfo.Bounds, GetRightIndent());
                return(editorBounds.Contains(e.Location));
            }
            return(false);
        }
Example #14
0
        GridColumnInfoArgs GetFirstNonFixedColumnInfo()
        {
            GridColumnInfoArgs cArgs = null;

            foreach (GridColumnInfoArgs args in ViewInfo.ColumnsInfo)
            {
                if (args.Column != null && args.Column.Fixed == DevExpress.XtraGrid.Columns.FixedStyle.None &&
                    args.Bounds.Left <= Indent)
                {
                    cArgs = args;
                }
            }
            return(cArgs);
        }
Example #15
0
        private Rectangle GetColumnBounds(GridColumn column)
        {
            gridInfo = (GridViewInfo)column.View.GetViewInfo();
            GridColumnInfoArgs colInfo = gridInfo.ColumnsInfo[column];

            if (colInfo != null)
            {
                return(colInfo.Bounds);
            }
            else
            {
                return(Rectangle.Empty);
            }
        }
Example #16
0
 void OnLeftCoordChanged(object sender, EventArgs e)
 {
     if (leftCoordChanged != 0)
     {
         return;
     }
     BeginScroll();
     try {
         GridColumnInfoArgs firstColumnInfo = GetFirstNonFixedColumnInfo();
         if (firstColumnInfo == null)
         {
             return;
         }
         int index = ViewInfo.ColumnsInfo.IndexOf(firstColumnInfo);
         if (IsRight)
         {
             if (ScrollToNextColumn)
             {
                 if (index < ViewInfo.ColumnsInfo.Count - 1)
                 {
                     GridColumnInfoArgs nextColumnInfo = ViewInfo.ColumnsInfo[++index];
                     SetLeftCoord(nextColumnInfo.Bounds.Right - Indent - 2, true);
                 }
             }
             else
             {
                 SetLeftCoord(firstColumnInfo.Bounds.Right - Indent - 2, true);
             }
         }
         else
         {
             if (firstColumnInfo.Column.VisibleIndex != 0)
             {
                 SetLeftCoord(firstColumnInfo.Bounds.Width - firstColumnInfo.Bounds.Right + Indent, false);
             }
             else
             {
                 SetLeftCoord(view.LeftCoord, false);
             }
         }
         oldLeftCoord = view.LeftCoord;
     }
     finally {
         EndScroll();
     }
 }
        void GridControl_Paint(object sender, PaintEventArgs e)
        {
            //paint empty vertical column(s)
            GridViewInfo vi = gridView1.GetViewInfo() as GridViewInfo;

            using (SolidBrush brush = new SolidBrush(vi.PaintAppearance.Empty.BackColor))
            {
                foreach (GridColumn col in emptyColumns)
                {
                    GridColumnInfoArgs info = vi.ColumnsInfo[col];
                    Rectangle          rect = info.Bounds;
                    rect.Height = vi.ClientBounds.Height - 2;
                    rect.Width -= 1;
                    e.Graphics.FillRectangle(brush, rect);
                }
            }
        }
    private int GetColumnBestHeight(GridViewInfo viewInfo, GridColumn column)
    {
        GridColumnInfoArgs ex     = viewInfo.ColumnsInfo[column];
        GraphicsInfo       grInfo = new GraphicsInfo();

        grInfo.AddGraphics(null);
        ex.Cache = grInfo.Cache;
        bool canDrawMore = true;
        Size captionSize = CalcCaptionTextSize(grInfo.Cache, ex as HeaderObjectInfoArgs, column.GetCaption());
        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);
    }
Example #19
0
        private int GetColumnBestHeight(DevExpress.XtraGrid.Columns.GridColumn column)
        {
            try
            {
                DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo viewInfo = GridView.GetViewInfo() as GridViewInfo;

                GridColumnInfoArgs ex = null;
                viewInfo.GInfo.AddGraphics(null);
                ex = new GridColumnInfoArgs(viewInfo.GInfo.Cache, null);
                try
                {
                    ex.InnerElements.Add(new DrawElementInfo(new GlyphElementPainter(),
                                                             new GlyphElementInfoArgs(viewInfo.View.Images, 0, null),
                                                             StringAlignment.Near));
                    ex.SetAppearance(GridView.Appearance.HeaderPanel);
                    ex.Caption     = column.Caption;
                    ex.CaptionRect = new Rectangle(0, 0, (int)(column.VisibleWidth - 10 * DpiXRel), 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);
                bool canDrawMore = true;
                Size res         = ex.InnerElements.CalcMinSize(grInfo.Graphics, ref canDrawMore);

                res.Height = Math.Max(res.Height, captionSize.Height);
                res.Width += captionSize.Width;
                if (viewInfo.Painter != null)
                {
                    res = viewInfo.Painter.ElementsPainter.Column.CalcBoundsByClientRectangle(ex, new Rectangle(Point.Empty, res)).Size;
                    m_dictColumnHeight[column.Name] = res.Height;
                    return(res.Height);
                }
            }
            catch (Exception ex)
            {
                MyLocalizer.XtraMessageBoxShow("В программе произошла ошибка. Описание: " + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(-1);
        }
        private Rectangle CalcCheckBoxRectangle(GridColumn col)
        {
            GraphicsInfo.Default.AddGraphics(null);
            GridViewInfo       viewInfo   = view.GetViewInfo() as GridViewInfo;
            GridColumnInfoArgs columnArgs = viewInfo.ColumnsInfo[col];
            Rectangle          rect;

            try
            {
                rect = GetCheckBoxRectangle(columnArgs, GraphicsInfo.Default.Graphics);
            }
            finally
            {
                GraphicsInfo.Default.ReleaseGraphics();
            }

            return(rect);
        }
Example #21
0
        private int GetColumnBestHeight(GridViewInfo viewInfo, GridColumn column, int height)
        {
            GridColumnInfoArgs ex = viewInfo.ColumnsInfo[column];

            if (ex == null)
            {
                viewInfo.GInfo.AddGraphics(null);
                ex = new GridColumnInfoArgs(viewInfo.GInfo.Cache, null);
                try
                {
                    ex.InnerElements.Add(new DrawElementInfo(new GlyphElementPainter(),
                                                             new GlyphElementInfoArgs(viewInfo.View.Images, 0, null),
                                                             StringAlignment.Near));
                    if (viewInfo.View.CanShowFilterButton(null))
                    {
                        ex.InnerElements.Add(viewInfo.Painter.ElementsPainter.FilterButton, new GridFilterButtonInfoArgs());
                    }
                    ex.SetAppearance(viewInfo.PaintAppearance.HeaderPanel);
                    ex.Caption     = column.Caption;
                    ex.CaptionRect = new Rectangle(0, 0, column.Width - 20, 17);
                }
                finally
                {
                    viewInfo.GInfo.ReleaseGraphics();
                }
            }
            GraphicsInfo grInfo = new GraphicsInfo();

            grInfo.AddGraphics(null);
            ex.Cache = grInfo.Cache;
            bool canDrawMore = true;
            Size captionSize = CalcCaptionTextSize(grInfo.Cache, ex as HeaderObjectInfoArgs, column.GetCaption());
            Size res         = ex.InnerElements.CalcMinSize(grInfo.Graphics, ref canDrawMore);

            //res.Height = Math.Max(res.Height, captionSize.Height);
            res.Height = height;
            res.Width += captionSize.Width;
            //res = viewInfo.Painter.ElementsPainter.Column.CalcBoundsByClientRectangle(ex, new Rectangle(Point.Empty, res)).Size;
            //res =new Size(180, 33);
            grInfo.ReleaseGraphics();
            return(res.Height);
        }
Example #22
0
        protected virtual void DrawQuickCustomisationIconCore(GridViewDrawArgs e, IndicatorObjectInfoArgs info, QuickCustomizationIcon icon, Rectangle bounds, QuickCustomisationIconStatus status)
        {
            Rectangle patchedRec = new Rectangle(bounds.X + 1, bounds.Y, bounds.Width - 1, bounds.Height);
            GridColumnInfoArgs args = new GridColumnInfoArgs(e.Cache, e.ViewInfo.ColumnsInfo[0].Column);
            args.Cache = e.Cache;
            args.Bounds = patchedRec;
            ((HeaderObjectInfoArgs)args).HeaderPosition = HeaderPositionKind.Center;
            if (status == QuickCustomisationIconStatus.Hot)
                ((HeaderObjectInfoArgs)args).State = ObjectState.Hot;
            ElementsPainter.Column.DrawObject(args);

            if (icon.Image != null)
            {
                Rectangle rec = new Rectangle();
                rec.Location = new Point(bounds.Left + 1, bounds.Top + 1);
                rec.Size = new Size(bounds.Width - 2, bounds.Height - 2);
                ImageAttributes attr = new ImageAttributes();
                attr.SetColorKey(icon.TransperentColor, icon.TransperentColor);
                e.Graphics.DrawImage(icon.Image, rec, 0, 0, icon.Image.Width, icon.Image.Height, GraphicsUnit.Pixel, attr);
            }
        }
Example #23
0
 private int GetColumnBestHeight(GridViewInfo viewInfo, GridColumn column)
 {
     var ex = viewInfo.ColumnsInfo[column];
     if (ex == null)
     {
         viewInfo.GInfo.AddGraphics(null);
         ex = new GridColumnInfoArgs(viewInfo.GInfo.Cache, null);
         try
         {
             ex.InnerElements.Add(new DrawElementInfo(new GlyphElementPainter(),
                 new GlyphElementInfoArgs(viewInfo.View.Images, 0, null),
                 StringAlignment.Near));
             if (viewInfo.View.CanShowFilterButton(null))
             {
                 ex.InnerElements.Add(viewInfo.Painter.ElementsPainter.FilterButton,
                     new GridFilterButtonInfoArgs());
             }
             ex.SetAppearance(viewInfo.PaintAppearance.HeaderPanel);
             ex.Caption = column.Caption;
             ex.CaptionRect = new Rectangle(0, 0, column.Width - 20, 17);
         }
         finally
         {
             viewInfo.GInfo.ReleaseGraphics();
         }
     }
     var grInfo = new GraphicsInfo();
     grInfo.AddGraphics(null);
     ex.Cache = grInfo.Cache;
     var canDrawMore = true;
     var captionSize = CalcCaptionTextSize(grInfo.Cache, ex, column.GetCaption());
     var 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;
 }
        void OnCustomDrawColumnHeader(object sender, ColumnHeaderCustomDrawEventArgs e)
        {
            if (!ShowSortIndexInColumnHeader || e.Column == null || e.Column.SortIndex == -1)
            {
                return;
            }
            GridColumnInfoArgs args = e.Info as GridColumnInfoArgs;

            e.Painter.DrawObject(args);
            SortedShapeObjectInfoArgs sortArgs = (SortedShapeObjectInfoArgs)args.InnerElements.Find(typeof(SortedShapeObjectInfoArgs)).ElementInfo;
            Rectangle sortRectangle            = sortArgs.Bounds;
            Rectangle sortIndexRectangle       = new Rectangle(sortRectangle.X - 8, args.CaptionRect.Y,
                                                               10, args.CaptionRect.Height);
            SolidBrush brush = e.Appearance.GetBackBrush(e.Cache) as SolidBrush;

            brush.Color = Color.FromArgb(150, brush.Color);
            Rectangle sortIndexShapeRectangle = new Rectangle(sortIndexRectangle.X - 2, sortIndexRectangle.Y,
                                                              sortIndexRectangle.Width + sortRectangle.Width, sortIndexRectangle.Height);

            e.Cache.FillRectangle(brush, sortIndexShapeRectangle);
            e.Appearance.DrawString(e.Cache, e.Column.SortIndex.ToString(), sortIndexRectangle);
            e.Handled = true;
        }
Example #25
0
        /// <summary>
        /// Computes a suitable height for the column header based upon the number of column header lines required.
        /// </summary>
        /// <param name="view"></param>
        /// <param name="minHeaderHeight"></param>
        /// <param name="lineCount"></param>
        /// <returns></returns>
        internal static int CalcMinColumnRowHeight(GridView view, int minHeaderHeight, int lineCount)
        {
            int maxY = 0;

            minHeaderHeight = Math.Max(minHeaderHeight, 12);

            if (view != null && lineCount > 1)
            {
                GridViewInfo viewInfo = view.GetViewInfo() as GridViewInfo;
                Graphics     graphic  = viewInfo.GInfo.AddGraphics(null);

                try
                {
                    GridColumnInfoArgs e = new GridColumnInfoArgs(viewInfo.GInfo.Cache, null);
                    e.InnerElements.Add(new DrawElementInfo(new GlyphElementPainter(), new GlyphElementInfoArgs(view.Images, 0, null), StringAlignment.Near));
                    if (view.CanShowFilterButton(null))
                    {
                        e.InnerElements.Add(viewInfo.Painter.ElementsPainter.FilterButton, new GridFilterButtonInfoArgs());
                    }
                    e.SetAppearance(viewInfo.PaintAppearance.HeaderPanel);
                    maxY = viewInfo.Painter.ElementsPainter.Column.CalcObjectMinBounds(e).Height;
                    if (view.OptionsView.AllowHtmlDrawHeaders)
                    {
                        string dummyCaption = new StringBuilder("Ûj").Insert(0, "Ûj\n", lineCount - 1).ToString();
                        e.UseHtmlTextDraw = true;
                        e.Caption         = dummyCaption;
                        maxY = Math.Max(maxY, viewInfo.Painter.ElementsPainter.Column.CalcObjectMinBounds(e).Height);
                    }
                }
                finally
                {
                    viewInfo.GInfo.ReleaseGraphics();
                }
            }
            return(Math.Max(maxY, minHeaderHeight));
        }
        private int CalcInnerElementsMinWidth(GridColumnInfoArgs columnArgs, Graphics gr)
        {
            bool canDrawMode = true;

            return(columnArgs.InnerElements.CalcMinSize(gr, ref canDrawMode).Width + 5);
        }
Example #27
0
        private int GetRowBestHeight(GridView _view, int row)
        {
            GridViewInfo viewInfo = _view.GetViewInfo() as GridViewInfo;
            int          height   = 0;

            for (int i = 0; i < _view.VisibleColumns.Count; i++)
            {
                GridColumnInfoArgs ex = viewInfo.ColumnsInfo[_view.Columns[i]];
                if (ex == null)
                {
                    viewInfo.GInfo.AddGraphics(null);
                    ex = new GridColumnInfoArgs(viewInfo.GInfo.Cache, null);
                    try
                    {
                        ex.InnerElements.Add(new DrawElementInfo(new GlyphElementPainter(),
                                                                 new GlyphElementInfoArgs(viewInfo.View.Images, 0, null),
                                                                 StringAlignment.Near));
                        viewInfo.PaintAppearance.Row.TextOptions.WordWrap = WordWrap.Wrap;

                        if (viewInfo.PaintAppearance.Row.Font.Size < _view.Columns[i].AppearanceCell.Font.Size)
                        {
                            ex.SetAppearance(_view.Columns[i].AppearanceCell);
                        }
                        else
                        {
                            ex.SetAppearance(viewInfo.PaintAppearance.Row);
                        }

                        ex.Caption     = Convert.ToString(_view.GetRowCellValue(row, _view.Columns[i]));
                        ex.CaptionRect = new Rectangle(0, 0, _view.Columns[i].Width - 20, 17);
                    }
                    finally
                    {
                        viewInfo.GInfo.ReleaseGraphics();
                    }
                }

                GraphicsInfo grInfo = new GraphicsInfo();
                ex.Appearance.TextOptions.WordWrap = WordWrap.Wrap;
                grInfo.AddGraphics(null);
                ex.Cache = grInfo.Cache;
                bool canDrawMore = true;

                string s;
                if (_view.Columns[i].ColumnEdit is RepositoryItemGridLookUpEdit)
                {
                    RepositoryItemGridLookUpEdit Rep = _view.Columns[i].ColumnEdit as RepositoryItemGridLookUpEdit;
                    s = Rep.GetDisplayTextByKeyValue(_view.GetRowCellValue(row, _view.Columns[i]));
                }
                else
                {
                    String sf;
                    s = Convert.ToString(_view.GetRowCellValue(row, _view.Columns[i]));
                    if (_view.GetRowCellValue(row, _view.Columns[i]) is DateTime)
                    {
                        s = s.Substring(0, s.Length / 2);
                    }
                }
                Size captionSize = CalcCaptionTextSize(grInfo.Cache, ex as HeaderObjectInfoArgs, s);

                Size res = ex.InnerElements.CalcMinSize(grInfo.Graphics, ref canDrawMore);
                res.Height = Math.Max(res.Height, captionSize.Height);
                res.Width  = Math.Max(res.Width, captionSize.Width);
                res        = viewInfo.Painter.ElementsPainter.Column.CalcBoundsByClientRectangle(ex, new Rectangle(Point.Empty, res)).Size;
                grInfo.ReleaseGraphics();
                height = Math.Max(height, res.Height);
            }
            return(height);
        }
 private int CalcInnerElementsMinWidth(GridColumnInfoArgs columnArgs, Graphics gr)
 {
     bool canDrawMode = true;
     return columnArgs.InnerElements.CalcMinSize(gr, ref canDrawMode).Width;
 }