Esempio n. 1
0
        private void toolTipController1_GetActiveObjectInfo(object sender, DevExpress.Utils.ToolTipControllerGetActiveObjectInfoEventArgs e)
        {
            Point        pt       = e.ControlMousePosition;
            GridView     view     = gridView1;
            GridHitInfo  hi       = view.CalcHitInfo(pt);
            GridViewInfo viewInfo = view.GetViewInfo() as GridViewInfo;

            if (viewInfo == null)
            {
                return;
            }
            if (hi.InColumnPanel && hi.Column != null)
            {
                viewInfo.GetColumnLeftCoord(hi.Column);
                int columnLeftCoord = viewInfo.GetColumnLeftCoord(hi.Column);
                DevExpress.XtraGrid.Drawing.GridColumnInfoArgs columnInfo = viewInfo.ColumnsInfo[hi.Column];
                e.Info = new DevExpress.Utils.ToolTipControlInfo(hi.Column, string.Format("'{0}'; left coord:{1}", columnInfo.Caption, columnLeftCoord));
            }
            if (hi.InRowCell)
            {
                GridCellInfo cellInfo = viewInfo.GetGridCellInfo(hi);
                e.Info = new DevExpress.Utils.ToolTipControlInfo(cellInfo, string.Format("{0}: ({1}, {2})", cellInfo.ViewInfo.DisplayText, cellInfo.RowHandle, cellInfo.Column));
            }
            if (hi.InGroupPanel)
            {
                Rectangle clientBounds = viewInfo.GroupPanel.ViewInfo.ClientBounds;
                e.Info = new DevExpress.Utils.ToolTipControlInfo(viewInfo.GroupPanel, string.Format("Group Panel: {0}", clientBounds));
            }
        }
Esempio n. 2
0
 private DrawElementInfo FindSortGlyphElement(DevExpress.XtraGrid.Drawing.GridColumnInfoArgs info)
 {
     foreach (DrawElementInfo innerElement in info.InnerElements)
     {
         if (innerElement.ElementInfo is SortedShapeObjectInfoArgs)
         {
             return(innerElement);
         }
     }
     return(null);
 }
Esempio n. 3
0
        protected override bool GetShowDetailButtonInCell(GridDataRowInfo ri, DevExpress.XtraGrid.Drawing.GridColumnInfoArgs ci)
        {
            bool showDetailButton = false;

            if (ShowDetailButtons && !ri.IsSpecialRow)
            {
                if (ci.Info.CellIndex == 2 && ci.Info.StartRow == 0) // ci.Info.CellIndex denotes the first visible column
                {
                    showDetailButton = true;
                }
            }
            return(showDetailButton);
        }
Esempio n. 4
0
        protected override void CalcRowsDrawInfo()
        {
            if (AllowUpdateDetails)
            {
                EditFormBounds = Rectangle.Empty;
            }
            CalcDataRight();
            ViewRects.EmptyRows = Rectangle.Empty;
            int     bottom                = ViewRects.Rows.Bottom;
            GridRow row                   = null;
            int     visibleCount          = RowsLoadInfo.ResultRows.Count;
            bool    bottomPositionUpdated = false;

            ViewRects.RowsTotalHeight = 0;
            DevExpress.XtraGrid.Drawing.GridColumnInfoArgs lastColumnInfo = ColumnsInfo.LastColumnInfo;
            GridRowInfo lastRow = null;

            RowsCache.UpdateCache(RowsLoadInfo.ResultRows);
            for (int n = 0; n < visibleCount; n++)
            {
                row = RowsLoadInfo.ResultRows[n];
                if (!bottomPositionUpdated && IView.IsPixelScrollingCore)
                {
                    bottomPositionUpdated = CheckUpdateTopPositionCore(row, ref bottom);
                    if (bottomPositionUpdated && lastRow != null && lastRow.ForcedRow)
                    {
                        if (lastRow.TotalBounds.Top < bottom)
                        {
                            lastRow.DrawMoreIcons = true;
                        }
                    }
                }
                GridRowInfo cached = CheckRowCache(row.RowHandle, row.VisibleIndex, bottom);
                GridRowInfo ri;
                GridRow     nextRow       = (n + 1 < visibleCount ? RowsLoadInfo.ResultRows[n + 1] : null);
                int         rowLineHeight = -1;
                if (cached == null)
                {
                    rowLineHeight = CalcRowHeight(GInfo.Graphics, row.RowHandle, row.VisibleIndex, row.Level);
                    cached        = CheckRowCacheReusable(row, bottom - rowLineHeight, rowLineHeight);
                }
                if (cached != null && row.RowHandle == View.FocusedRowHandle && View.IsEditFormVisible)
                {
                    cached = null;
                }
                if (cached != null)
                {
                    RowsCache.RemoveRow(cached);
                    GridDataRowInfo cachedDataRow  = cached as GridDataRowInfo;
                    bool            allowCachedRow = cachedDataRow == null || cachedDataRow.DetailBounds.IsEmpty;
                    if (cachedDataRow != null && cachedDataRow.EditFormRow)
                    {
                        allowCachedRow = false;
                    }
                    if (allowCachedRow)
                    {
                        lastRow           = ri = cached;
                        bottom            = ri.TotalBounds.Top;
                        ri.ForcedRow      = row.ForcedRow;
                        ri.ForcedRowLight = row.ForcedRowLight;
                        ri.DrawMoreIcons  = !row.NextRowPrimaryChild && (row.ForcedRow || (ri.IsGroupRow && ri.IsGroupRowExpanded));
                        RowsInfo.AddRow(ri);
                        if (bottom < ViewRects.Rows.Top)
                        {
                            break;
                        }
                        continue;
                    }
                }
                lastRow = ri = CreateRowInfo(row);
                Rectangle rowBounds = ViewRects.Rows;
                rowBounds        = ViewRects.Rows;
                rowBounds.Y      = bottom;
                ri.RowLineHeight = rowLineHeight > 0 ? rowLineHeight : CalcRowHeight(GInfo.Graphics, ri.RowHandle, ri.VisibleIndex, ri.Level);
                rowBounds.Height = ri.RowLineHeight * GetRowLineCount(ri.RowHandle, ri.IsGroupRow);
                rowBounds.Y     -= rowBounds.Height;
                ri.Bounds        = rowBounds;
                rowBounds.Height = CalcTotalRowHeight(GInfo.Graphics, ri.RowLineHeight, ri.RowHandle, ri.VisibleIndex, ri.Level, ri.IsGroupRow ? (bool?)null : (bool?)true);
                ri.TotalBounds   = rowBounds;
                if (IsExternalRowCore(ri.RowHandle))
                {
                    ri.Bounds = ri.TotalBounds;
                }
                CalcRowIndents(ri);

                ri.RowFooters.RowFooterCount   = GetRowFooterCountEx(ri.RowHandle, ri.VisibleIndex, (ri.IsGroupRow ? (bool?)null : (bool?)true));
                ri.RowFooters.RowFootersHeight = ri.RowFooters.RowFooterCount * GroupFooterHeight;

                CalcDataRow(ri as GridDataRowInfo, row, nextRow);
                CalcGroupRow(ri as GridGroupRowInfo, row, nextRow);
                CalcExternalRow(ri as GridExternalRowInfo, row, nextRow);
                //add rowSeparator
                bottom = ri.TotalBounds.Top;

                RowsInfo.AddRow(ri);
                if (bottom < ViewRects.Rows.Top)
                {
                    break;
                }
            }
            //RemoveAnimatedItems(RowsCache.Rows);
            ViewRects.RowsTotalHeight = ViewRects.Rows.Bottom - bottom;
            if (bottom > ViewRects.Rows.Top)
            {
                Rectangle r = ViewRects.Rows;
                r.Y                 = ViewRects.Rows.Top;
                r.Height            = bottom - ViewRects.Rows.Top;
                ViewRects.EmptyRows = r;
            }
            //CalcRowsMergeInfo();
            //if(AllowUpdateDetails) {
            //    CheckEditFormVisibility();
            //}
            IView.ResetAllowUpdateRowIndexesCore();
        }
        public override void PrintHeader(IBrickGraphics graph)
        {
            if (!View.OptionsPrint.PrintHeader)
            {
                return;
            }

            Point     indent         = new Point(Indent, HeaderY);
            Rectangle r              = Rectangle.Empty;
            bool      usePrintStyles = View.OptionsPrint.UsePrintStyles;

            SetDefaultBrickStyle(graph, Bricks["HeaderPanel"]);

            foreach (PrintColumnInfo col in Columns)
            {
                if (!usePrintStyles)
                {
                    AppearanceObject temp = new AppearanceObject();
                    AppearanceHelper.Combine(temp, new AppearanceObject[] { col.Column.AppearanceHeader, View.Appearance.HeaderPanel, AppearancePrint.HeaderPanel });
                    SetDefaultBrickStyle(graph, Bricks.Create(temp, BorderSide.All, temp.BorderColor, 1));
                }
                r = col.Bounds;
                r.Offset(indent);
                string caption = col.Column.GetTextCaption();
                if (!ColumnsInfo[Columns.IndexOf(col)].Column.OptionsColumn.ShowCaption)
                {
                    caption = string.Empty;
                }

                DevExpress.XtraGrid.Drawing.GridColumnInfoArgs columnsInfo = ColumnsInfo[Columns.IndexOf(col)];
                DrawElementInfoCollection innerElements   = columnsInfo.InnerElements;
                DrawElementInfo           columnImageInfo = null;
                GlyphElementInfoArgs      elementInfo     = null;
                this.ViewViewInfo.Painter.ElementsPainter.Column.CalcObjectBounds(columnsInfo);
                for (int i = 0; i < innerElements.Count; i++)
                {
                    if (innerElements[i].ElementInfo is DevExpress.Utils.Drawing.GlyphElementInfoArgs)
                    {
                        columnImageInfo = innerElements[i];
                        elementInfo     = columnImageInfo.ElementInfo as GlyphElementInfoArgs;
                        break;
                    }
                }

                ITextBrick tBrick = null;
                if (elementInfo.Glyph == null && elementInfo.ImageIndex < 0)
                {
                    tBrick = DrawTextBrick(graph, caption, r);
                }
                else
                {
                    IPanelBrick panelBrick      = new XETextPanelBrick(graph.DefaultBrickStyle);
                    float       offsetForBorder = panelBrick.BorderWidth;

                    if (columnImageInfo.Alignment != StringAlignment.Center)
                    {
                        tBrick       = new TextBrick();
                        tBrick.Rect  = new RectangleF(offsetForBorder, offsetForBorder, r.Width, r.Height);
                        tBrick.Text  = caption;
                        tBrick.Style = graph.DefaultBrickStyle;
                        tBrick.Sides = BorderSide.None;
                        panelBrick.Bricks.Add(tBrick);
                    }

                    panelBrick.Value = caption;
                    Rectangle columnRect = r;
                    Rectangle imageRect  = new Rectangle(new Point((int)offsetForBorder, (int)offsetForBorder), elementInfo.GlyphSize);
                    imageRect.Y = r.Y + columnImageInfo.ElementInterval;

                    switch (columnImageInfo.Alignment)
                    {
                    case StringAlignment.Near:
                        tBrick.Rect = new RectangleF(new PointF(imageRect.Location.X + imageRect.Size.Width, tBrick.Rect.Y), tBrick.Rect.Size);
                        MakeInflate(ref tBrick, 2 * offsetForBorder, 2 * offsetForBorder);
                        break;

                    case StringAlignment.Center:
                    {
                        imageRect.X += (r.Width - imageRect.Width) / 2;
                    }
                    break;

                    case StringAlignment.Far:
                        tBrick.Rect = new RectangleF(tBrick.Rect.Location, new SizeF(tBrick.Rect.Width - imageRect.Width, tBrick.Rect.Height));
                        MakeInflate(ref tBrick, 2 * offsetForBorder, 2 * offsetForBorder);
                        imageRect.X = (int)tBrick.Rect.Right;
                        break;
                    }


                    ImageBrick iBrick = GetImageBrick(imageRect, columnImageInfo);
                    if (iBrick != null)
                    {
                        panelBrick.Bricks.Add(iBrick);
                    }

                    graph.DrawBrick(panelBrick, columnRect);
                }


                if (tBrick == null)
                {
                    continue;
                }

                if (AppearancePrint.HeaderPanel.TextOptions.WordWrap == WordWrap.NoWrap && View.OptionsPrint.UsePrintStyles)
                {
                    using (Graphics g = this.View.GridControl.CreateGraphics())
                    {
                        SizeF s = g.MeasureString(tBrick.Text, tBrick.Font, 1000, tBrick.StringFormat.Value);
                        if (s.Width + 5 >= r.Width)
                        {
                            tBrick.Text      = "";
                            tBrick.TextValue = "";
                        }
                    }
                }
            }
        }