Exemple #1
0
        /// <summary>
        /// get the data cell of a row
        /// </summary>
        /// <param name="AGridRow"></param>
        /// <returns></returns>
        public override SourceGrid.Cells.ICellVirtual GetDataCell(int AGridRow)
        {
            SourceGrid.Cells.ICellVirtual ReturnValue;
            SourceGrid.Cells.ICellVirtual BaseDataCell = base.GetDataCell(AGridRow);
            SourceGrid.Cells.ICellVirtual AlternatingDataCellSelected;
            SourceGrid.Cells.ICellVirtual BoldBorderDataCellSelected;
            TSgrdDataGrid GridWrapper = (TSgrdDataGrid)FGrid;

            int Reminder;

            HeaderCell.View   = ((TSgrdDataGrid)FGrid).ColumnHeaderView;
            FDataCellSelected = BaseDataCell.Copy();

            // Create a ToolTip
            FDataCellSelected.AddController(SourceGrid.Cells.Controllers.ToolTipText.Default);
            FDataCellSelected.Model.AddModel(TToolTipModel.myDefault);

            // Alternating BackColor (banding effect)
            Math.DivRem(AGridRow, 2, out Reminder);

            if (Reminder == 0)
            {
                FDataCellSelected.View.BackColor = ((TSgrdDataGrid)FGrid).CellBackgroundColour;
                FDataCellSelected.View.Border    = new DevAge.Drawing.RectangleBorder(new BorderLine(GridWrapper.GridLinesColour, 0.5f));
                ReturnValue = FDataCellSelected;
            }
            else
            {
                if (((TSgrdDataGrid)FGrid).AlternatingBackgroundColour != Color.Empty)
                {
                    AlternatingDataCellSelected                = FDataCellSelected.Copy();
                    AlternatingDataCellSelected.View           = (SourceGrid.Cells.Views.IView)FDataCellSelected.View.Clone();
                    AlternatingDataCellSelected.View.BackColor = ((TSgrdDataGrid)FGrid).AlternatingBackgroundColour;
                    AlternatingDataCellSelected.View.Border    = new DevAge.Drawing.RectangleBorder(new BorderLine(GridWrapper.GridLinesColour, 0.5f));
                    ReturnValue = AlternatingDataCellSelected;
                }
                else
                {
                    ReturnValue = FDataCellSelected;
                }
            }

            if (FBoldRightBorder)
            {
                BoldBorderDataCellSelected = ReturnValue.Copy();

                BoldBorderDataCellSelected.View.Border = new DevAge.Drawing.RectangleBorder(new BorderLine(GridWrapper.GridLinesColour, 0.5f),
                                                                                            new BorderLine(GridWrapper.GridLinesColour, 0.5f),
                                                                                            new BorderLine(GridWrapper.GridLinesColour, 0.5f),
                                                                                            new BorderLine(GridWrapper.GridLinesColour, 5f));

                ReturnValue = BoldBorderDataCellSelected;
            }

            return(ReturnValue);
        }
Exemple #2
0
        /// <summary>
        /// get the data cell of a row
        /// </summary>
        /// <param name="AGridRow"></param>
        /// <returns></returns>
        public override SourceGrid.Cells.ICellVirtual GetDataCell(int AGridRow)
        {
            SourceGrid.Cells.ICellVirtual ReturnValue;
            SourceGrid.Cells.ICellVirtual BaseDataCell = base.GetDataCell(AGridRow);
            SourceGrid.Cells.ICellVirtual AlternatingDataCellSelected;
            SourceGrid.Cells.ICellVirtual BoldBorderDataCellSelected;
            TSgrdDataGrid GridWrapper = (TSgrdDataGrid)FGrid;

            // Standard border
            RectangleBorder border = new DevAge.Drawing.RectangleBorder(new BorderLine(GridWrapper.GridLinesColour, 0.5f));

            // Test to see if the cell is part of a highlighted row
            bool rowIsHighlighted = false;

            foreach (SourceGrid.Decorators.DecoratorBase dec in FGrid.Decorators)
            {
                if ((dec is SourceGrid.Decorators.DecoratorSelection) && dec.IntersectWith(new Range(AGridRow, 1, AGridRow, 1)))
                {
                    rowIsHighlighted = true;
                }
            }

            int Remainder;

            HeaderCell.View   = ((TSgrdDataGrid)FGrid).ColumnHeaderView;
            FDataCellSelected = BaseDataCell.Copy();
            FDataCellSelected.View.ForeColor = Color.Black;
            // Info: if you want to play with a bold font, re-enable the following line and the one about 15 lines down
            //FDataCellSelected.View.Font = new Font(GridWrapper.Font, FontStyle.Regular);

            // Create a ToolTip
            FDataCellSelected.AddController(SourceGrid.Cells.Controllers.ToolTipText.Default);
            FDataCellSelected.Model.AddModel(TToolTipModel.myDefault);

            // Alternating BackColor (banding effect)
            Math.DivRem(AGridRow, 2, out Remainder);

            if (rowIsHighlighted)
            {
                // Highlighted rows have a solid background of the selection backcolor
                // Then when the highlight decoration is applied it will be a fully transparent version of this overlaid on top
                // Highlighted rows use a bold font and text colour that is a contrast with the background
                Color selectionColour = ((SelectionBase)GridWrapper.Selection).BackColor;
                FDataCellSelected.View.BackColor = Color.FromArgb(255, selectionColour.R, selectionColour.G, selectionColour.B);    // Fully solid
                FDataCellSelected.View.ForeColor = GetBestContrastColor(FDataCellSelected.View.BackColor);
                // Info: if you want to play with a bold font, re-enable the following line and the one about 15 lines above
                //FDataCellSelected.View.Font = new Font(GridWrapper.Font, FontStyle.Bold);
                FDataCellSelected.View.Border = border;
                ReturnValue = FDataCellSelected;
            }
            else if (Remainder == 0)
            {
                FDataCellSelected.View.BackColor = ((TSgrdDataGrid)FGrid).CellBackgroundColour;
                FDataCellSelected.View.Border    = border;
                ReturnValue = FDataCellSelected;
            }
            else
            {
                if (((TSgrdDataGrid)FGrid).AlternatingBackgroundColour != Color.Empty)
                {
                    AlternatingDataCellSelected                = FDataCellSelected.Copy();
                    AlternatingDataCellSelected.View           = (SourceGrid.Cells.Views.IView)FDataCellSelected.View.Clone();
                    AlternatingDataCellSelected.View.BackColor = ((TSgrdDataGrid)FGrid).AlternatingBackgroundColour;
                    AlternatingDataCellSelected.View.Border    = border;
                    ReturnValue = AlternatingDataCellSelected;
                }
                else
                {
                    ReturnValue = FDataCellSelected;
                }
            }

            if (FBoldRightBorder)
            {
                BoldBorderDataCellSelected = ReturnValue.Copy();

                BoldBorderDataCellSelected.View.Border = new DevAge.Drawing.RectangleBorder(new BorderLine(GridWrapper.GridLinesColour, 0.5f),
                                                                                            new BorderLine(GridWrapper.GridLinesColour, 0.5f),
                                                                                            new BorderLine(GridWrapper.GridLinesColour, 0.5f),
                                                                                            new BorderLine(GridWrapper.GridLinesColour, 5f));

                ReturnValue = BoldBorderDataCellSelected;
            }

            return(ReturnValue);
        }