Example #1
0
        private void DrawRowPreviewEditor(GridViewDrawArgs e, GridDataRowInfo ri, RepositoryItem item)
        {
            GridCellInfo info = new GridCellInfo(null, ri, ri.PreviewBounds);

            info.Editor = item;
            DrawCellEdit(e, ((CustomGridViewInfo)e.ViewInfo).GetRowPreviewViewInfo(e, ri), info, ri.AppearancePreview, false);
        }
        public virtual Rectangle GetRowPreviewEditBounds(GridDataRowInfo ri)
        {
            Rectangle r = new Rectangle(new Point(0, 0), ri.PreviewBounds.Size);

            r.Inflate(-this.Painter.ElementsPainter.RowPreview.GetPreviewTextHorizontalPadding(this) / 2, -this.Painter.ElementsPainter.RowPreview.GetPreviewTextVerticalPadding(this) / 2);
            return(r);
        }
Example #3
0
        void PrepareListOfMergedRows()
        {
            int          iMergeCellCount = 0;
            GridViewInfo vInfo           = gridView1.GetViewInfo() as GridViewInfo;

            int       UnCalculatedHeightScale = vInfo.RowsLoadInfo.VisibleRowCount / vInfo.RowsInfo.Count;
            Rectangle allBounds     = new Rectangle(vInfo.Bounds.X, vInfo.Bounds.Y, vInfo.Bounds.Width, vInfo.Bounds.Height * UnCalculatedHeightScale);
            Rectangle initialBounds = vInfo.Bounds;

            vInfo.Calc(gridControl1.CreateGraphics(), allBounds);
            for (int i = 0; i < vInfo.RowsInfo.Count; i++)
            {
                GridDataRowInfo rowInfo = vInfo.RowsInfo[i] as GridDataRowInfo;
                if (rowInfo != null)
                {
                    GridCellInfo cInfo = rowInfo.Cells[gridView1.Columns["ID"]];
                    if (!cInfo.IsMerged || cInfo.MergedCell.FirstCell == cInfo)
                    {
                        mergedRows.Add(i, iMergeCellCount - 1);
                    }
                    else
                    {
                        mergedRows.Add(i, iMergeCellCount);
                        iMergeCellCount++;
                    }
                    mergedRows[i]++;
                }
            }
            vInfo.Calc(gridControl1.CreateGraphics(), initialBounds);
        }
        public static Bitmap GetRowImage(GridView view, int rowHandle)
        {
            GridViewInfo    gvi    = view.GetViewInfo() as GridViewInfo;
            GridDataRowInfo ri     = gvi.RowsInfo.OfType <GridDataRowInfo>().Where(r => r.RowHandle == rowHandle).FirstOrDefault();
            Bitmap          rowBmp = null;

            if (ri != null)
            {
                Bitmap gridBmp = new Bitmap(view.GridControl.Width, view.GridControl.Height);
                view.GridControl.DrawToBitmap(gridBmp, new Rectangle(0, 0, view.GridControl.Width, view.GridControl.Height));
                float[][] matrixItems = new float[][]
                {
                    new float[] { 1, 0, 0, 0, 0 },
                    new float[] { 0, 1, 0, 0, 0 },
                    new float[] { 0, 0, 1, 0, 0 },
                    new float[] { 0, 0, 0, 0.7F, 0 },
                    new float[] { 0, 0, 0, 0, 1 }
                };
                ColorMatrix     colorMatrix = new ColorMatrix(matrixItems);
                ImageAttributes attr        = new System.Drawing.Imaging.ImageAttributes();
                attr.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
                rowBmp = new Bitmap(ri.DataBounds.Width, ri.DataBounds.Height);
                Graphics  gr          = Graphics.FromImage(rowBmp);
                Rectangle imageBounds = new Rectangle(Point.Empty, ri.DataBounds.Size);
                gr.DrawImage(gridBmp, imageBounds, ri.DataBounds.X, ri.DataBounds.Y,
                             ri.DataBounds.Width, ri.DataBounds.Height, GraphicsUnit.Pixel, attr);
            }
            return(rowBmp);
        }
Example #5
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 #6
0
        /// <summary>
        /// 根据行,列索引来获取RepositoryItem
        /// </summary>
        /// <param name="view">GridView</param>
        /// <param name="rowIndex">行索引</param>
        /// <param name="columnIndex">列索引</param>
        /// <returns>RepositoryItem</returns>
        public static RepositoryItem GetRepositoryItem(this GridView view, int rowIndex, int columnIndex)
        {
            GridViewInfo    _viewInfo    = view.GetViewInfo() as GridViewInfo;
            GridDataRowInfo _viewRowInfo = _viewInfo.RowsInfo.FindRow(rowIndex) as GridDataRowInfo;

            return(_viewRowInfo.Cells[columnIndex].Editor);
        }
Example #7
0
 public virtual BaseEditViewInfo GetRowPreviewViewInfo(GridViewDrawArgs e, GridDataRowInfo ri)
 {
     fRowPreviewViewInfo.Bounds    = GetRowPreviewEditBounds(ri);
     fRowPreviewViewInfo.EditValue = View.GetRowPreviewValue(ri.RowHandle);
     fRowPreviewViewInfo.Focused   = true;
     fRowPreviewViewInfo.CalcViewInfo(e.Graphics);
     return(fRowPreviewViewInfo);
 }
Example #8
0
        protected override void DrawEmbeddedBorder(ViewDrawArgs e)
        {
            base.DrawEmbeddedBorder(e);
            GridView detailView = e.ViewInfo.View as GridView;

            if (detailView == null)
            {
                return;
            }
            int             sourceRowHandle = detailView.SourceRowHandle;
            GridView        parentView      = detailView.ParentView as GridView;
            GridViewInfo    parentViewInfo  = parentView.GetViewInfo() as GridViewInfo;
            GridViewInfo    detailViewInfo  = (GridViewInfo)detailView.GetViewInfo();
            GridDataRowInfo ri = parentViewInfo.RowsInfo.Where(rinfo => rinfo.RowHandle == sourceRowHandle).First() as GridDataRowInfo;

            if (ri == null)
            {
                return;
            }

            GridCellInfo cell = ri.Cells[parentView.VisibleColumns[0]];
            int          center;
            int          level = 0;
            Point        p1;
            Point        p2;
            int          lineIndent = 4;

            if (cell != null)
            {
                center = cell.CellButtonRect.Left + cell.CellButtonRect.Width / 2 - lineIndent;
            }
            else
            {
                center = ri.DetailIndentBounds.Left + ri.DetailIndentBounds.Width / 2;
            }

            foreach (GridRowInfo rowInfo in detailViewInfo.RowsInfo)
            {
                if (detailView.IsRowVisible(rowInfo.RowHandle) != RowVisibleState.Visible)
                {
                    continue;
                }
                level = rowInfo.Bounds.Top + rowInfo.Bounds.Height / 2;
                if (level != 0)
                {
                    p1 = new Point(center, level);
                    p2 = new Point(ri.IndentRect.Right + parentViewInfo.DetailIndent, level);
                    e.Cache.DrawLine(Pens.Black, p1, p2);
                }
            }
            if (level != 0)
            {
                p1 = new Point(center, ri.Bounds.Bottom);
                p2 = new Point(center, level);
                e.Cache.DrawLine(Pens.Black, p1, p2);
            }
        }
Example #9
0
        public virtual Rectangle GetRowPreviewEditBounds(GridDataRowInfo ri)
        {
            Rectangle r = new Rectangle(new Point(0, 0), ri.PreviewBounds.Size);

            r.Inflate(-GridRowPreviewPainter.PreviewTextIndent, -GridRowPreviewPainter.PreviewTextVIndent);
            r.X     += ri.PreviewIndent;
            r.Width -= ri.PreviewIndent;
            return(r);
        }
        public virtual Rectangle GetRowPreviewEditBounds(GridDataRowInfo ri)
        {
            Rectangle r = new Rectangle(new Point(0, 0), ri.PreviewBounds.Size);

            r.Inflate(-GetPreviewTextIndent(), -GetPreviewTextVIndent());
            int previewIndent = Painter.ElementsPainter.RowPreview.GetPreviewIndent(this);

            r.X     += previewIndent;
            r.Width -= previewIndent;
            return(r);
        }
Example #11
0
        public virtual Rectangle GetRowPreviewEditBounds(GridDataRowInfo ri)
        {
            Rectangle r = new Rectangle(new Point(0, 0), ri.PreviewBounds.Size);
            //r.Inflate(-GridRowPreviewPainter.PreviewTextIndent, -GridRowPreviewPainter.PreviewTextVIndent);
            GridRowPreviewPainter x = new GridRowPreviewPainter(this.Painter.ElementsPainter);

            r.Inflate(-x.GetPreviewTextIndent(ri), -x.GetPreviewTextVIndent(ri));
            r.X     += x.GetPreviewIndent(this); // ri.PreviewIndent;
            r.Width -= x.GetPreviewIndent(this); // ri.PreviewIndent;
            return(r);
        }
Example #12
0
        protected override void DrawRowPreview(GridViewDrawArgs e, GridDataRowInfo ri)
        {
            RepositoryItem item = ((CustomGridView)e.ViewInfo.View).PreviewRowEdit;

            if (item == null)
            {
                base.DrawRowPreview(e, ri);
            }
            else
            {
                DrawRowPreviewEditor(e, ri, item);
            }
        }
Example #13
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);
        }
Example #14
0
        /// <summary>
        /// 向下查找输入的信息
        /// </summary>
        private void btnNext_Click(object sender, EventArgs e)
        {
            try
            {
                if (textContent.Text.Trim() == "")
                {
                    return;
                }
                int locationRowNo    = browseXtraGridView.FocusedRowHandle;
                int locationColumnNo = browseXtraGridView.FocusedColumn.AbsoluteIndex;

                textContent.Focus();
                browseXtraGridView.Focus();
                for (int i = locationRowNo; i < browseXtraGridView.DataRowCount; i++)
                {
                    for (int j = locationColumnNo + 1; j < browseXtraGridView.Columns.Count; j++)
                    {
                        if (!browseXtraGridView.Columns[j].Visible)
                        {
                            continue;
                        }
                        string cellValue = DataTypeConvert.GetString(browseXtraGridView.GetRowCellDisplayText(i, browseXtraGridView.Columns[j]));
                        if (cellValue.Contains(textContent.Text.Trim()))
                        {
                            browseXtraGridView.FocusedRowHandle = i;
                            browseXtraGridView.FocusedColumn    = browseXtraGridView.Columns[j];

                            GridViewInfo    vi       = browseXtraGridView.GetViewInfo() as GridViewInfo;
                            GridDataRowInfo rowInfo  = vi.RowsInfo.GetInfoByHandle(i) as GridDataRowInfo;
                            GridCellInfo    cellInfo = rowInfo.Cells[0];
                            if (cellInfo != null)
                            {
                                cellInfo.State = GridRowCellState.FocusedCell;
                            }
                            return;
                        }
                        else
                        {
                            continue;
                        }
                    }
                    locationColumnNo = -1;
                }
            }
            catch (Exception ex)
            {
                //ExceptionHandler.HandleException(this.Text + "--向下查找输入的信息错误。", ex);
                ExceptionHandler.HandleException(this.Text + "--" + f.tsmiXxczsrdxxcw.Text, ex);
            }
        }
Example #15
0
        private GridCellInfoCollection GetMergeCells(int rowHandle, GridColumn column)
        {
            GridViewInfo    viewInfo = gridView1.GetViewInfo() as GridViewInfo;
            GridDataRowInfo rowInfo  = viewInfo.GetGridRowInfo(rowHandle) as GridDataRowInfo;

            if (rowInfo != null)
            {
                GridCellInfo cellInfo = rowInfo.Cells[column];
                if (cellInfo != null && cellInfo.IsMerged)
                {
                    return(cellInfo.MergedCell.MergedCells);
                }
            }
            return(null);
        }
Example #16
0
        protected internal virtual void ActivatePreviewEditor()
        {
            if (PreviewRowEdit == null)
            {
                return;
            }
            GridDataRowInfo ri = ViewInfo.GetGridRowInfo(FocusedRowHandle) as GridDataRowInfo;

            if (ri == null)
            {
                return;
            }
            Rectangle bounds = ((CustomGridViewInfo)ViewInfo).GetRowPreviewEditBounds(ri);

            bounds.Offset(ri.PreviewBounds.Location);
            UpdateEditor(PreviewRowEdit, new UpdateEditorInfoArgs(
                             false, bounds, ri.AppearancePreview, GetRowPreviewValue(FocusedRowHandle), ElementsLookAndFeel, string.Empty, null));
        }
Example #17
0
        protected override void DrawRegularRow(GridViewDrawArgs e, GridDataRowInfo ri)
        {
            base.DrawRegularRow(e, ri);
            if (ri.IsMasterRow && ri.MasterRowExpanded)
            {
                GridView detailView = View.GetDetailView(ri.RowHandle, 0) as GridView;
                if (detailView == null)
                {
                    return;
                }

                int   level = 0;
                Point p1;
                Point p2;

                GridCellInfo cell = ri.Cells[View.VisibleColumns[0]];
                int          center;
                if (cell != null)
                {
                    center = cell.CellButtonRect.Left + cell.CellButtonRect.Width / 2;
                }
                else
                {
                    center = ri.DetailIndentBounds.Left + ri.DetailIndentBounds.Width / 2;
                }

                GridViewInfo detailViewInfo = (GridViewInfo)detailView.GetViewInfo();
                foreach (GridRowInfo rowInfo in detailViewInfo.RowsInfo)
                {
                    if (detailView.IsRowVisible(rowInfo.RowHandle) != RowVisibleState.Visible)
                    {
                        continue;
                    }
                    level = rowInfo.Bounds.Top + rowInfo.Bounds.Height / 2;
                    p1    = new Point(center, level);
                    p2    = new Point(ri.DetailIndentBounds.Right, level);
                    e.Cache.DrawLine(Pens.Black, p1, p2);
                }
                p1 = new Point(center, ri.DetailIndentBounds.Top);
                p2 = new Point(center, level);
                e.Cache.DrawLine(Pens.Black, p1, p2);
            }
        }
 void RefreshAppearance(GridViewInfo viewInfo, GridRowInfo rowInfo, GridColumn column)
 {
     if (column != null)
     {
         GridDataRowInfo dataRow = rowInfo as GridDataRowInfo;
         if (dataRow != null)
         {
             var cell = dataRow.Cells[column];
             if (cell != null)
             {
                 cell.State = DevExpress.XtraGrid.Views.Base.GridRowCellState.Dirty;
             }
         }
     }
     else
     {
         rowInfo.SetDataDirty();
     }
 }
        public Rectangle GetAutoFilterRowBounds()
        {
            GridViewInfo    viewInfo = _View.GetViewInfo() as GridViewInfo;
            GridDataRowInfo rowInfo  = viewInfo.GetGridRowInfo(GridControl.AutoFilterRowHandle) as GridDataRowInfo;

            if (rowInfo == null || (rowInfo.RowState & GridRowCellState.Focused) != 0)
            {
                return(Rectangle.Empty);
            }
            Rectangle r = rowInfo.DataBounds;

            if (r.X < viewInfo.ViewRects.ColumnPanelLeft)
            {
                r.X = viewInfo.ViewRects.ColumnPanelLeft;
            }
            if (r.Right > viewInfo.ViewRects.Rows.Right)
            {
                r.Width = viewInfo.ViewRects.Rows.Right - r.X;
            }
            return(r);
        }
Example #20
0
        /// <summary>
        /// 向上查找输入的信息
        /// </summary>
        private void btnExpand_Click(object sender, EventArgs e)
        {
            try
            {
                if (textContent.Text.Trim() == "")
                {
                    return;
                }

                if (browseXtraGridView.DataRowCount == 0 || browseXtraGridView.Columns.Count == 0)
                {
                    MessageHandler.ShowMessageBox("请查询信息后再进行查找定位操作。");
                    return;
                }

                int locationRowNo    = browseXtraGridView.FocusedRowHandle;
                int locationColumnNo = browseXtraGridView.FocusedColumn.AbsoluteIndex;

                textContent.Focus();
                browseXtraGridView.Focus();
                for (int i = locationRowNo; i >= 0; i--)
                {
                    for (int j = locationColumnNo - 1; j >= 0; j--)
                    {
                        if (!browseXtraGridView.Columns[j].Visible)
                        {
                            continue;
                        }
                        string cellValue = DataTypeConvert.GetString(browseXtraGridView.GetRowCellDisplayText(i, browseXtraGridView.Columns[j]));
                        if (cellValue.Contains(textContent.Text.Trim()))
                        {
                            browseXtraGridView.FocusedRowHandle = i;
                            browseXtraGridView.FocusedColumn    = browseXtraGridView.Columns[j];

                            GridViewInfo    vi      = browseXtraGridView.GetViewInfo() as GridViewInfo;
                            GridDataRowInfo rowInfo = vi.RowsInfo.GetInfoByHandle(i) as GridDataRowInfo;
                            if (rowInfo == null || rowInfo.Cells.Count == 0)
                            {
                                continue;
                            }
                            GridCellInfo cellInfo = rowInfo.Cells[0];
                            if (cellInfo != null)
                            {
                                cellInfo.State = GridRowCellState.FocusedCell;
                            }
                            return;
                        }
                        else
                        {
                            continue;
                        }
                    }
                    locationColumnNo = browseXtraGridView.Columns.Count;
                }

                MessageHandler.ShowMessageBox(string.Format("向上未查询到包含【{0}】的记录。", textContent.Text.Trim()));
            }
            catch (Exception ex)
            {
                //ExceptionHandler.HandleException(this.Text + "--向上查找输入的信息错误。", ex);
                ExceptionHandler.HandleException(this.Text + "--" + f.tsmiXsczsrdxxcw.Text, ex);
            }
        }
Example #21
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();
        }