Ejemplo n.º 1
0
        /// <summary>
        /// Create a Raised border
        /// </summary>
        /// <param name="p_width"></param>
        /// <param name="p_ShadowColor"></param>
        /// <param name="p_LightColor"></param>
        public static RectangleBorder CreateRaisedBorder(int p_width, Color p_ShadowColor, Color p_LightColor)
        {
            RectangleBorder l_Border = new RectangleBorder(new BorderLine(Color.White));;

            l_Border.Top    = new BorderLine(p_LightColor, p_width);
            l_Border.Left   = new BorderLine(p_LightColor, p_width);
            l_Border.Bottom = new BorderLine(p_ShadowColor, p_width);
            l_Border.Right  = new BorderLine(p_ShadowColor, p_width);

            return(l_Border);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Compare to current border with another border.
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            if (obj.GetType() != GetType())
            {
                return(false);
            }
            RectangleBorder l_Other = (RectangleBorder)obj;

            if (l_Other.Left == Left && l_Other.Bottom == Bottom &&
                l_Other.Top == Top && l_Other.Right == Right)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Create a Raised border
        /// </summary>
        /// <param name="p_width"></param>
        /// <param name="p_ShadowColor"></param>
        /// <param name="p_LightColor"></param>
        public static RectangleBorder CreateRaisedBorder(int p_width, Color p_ShadowColor, Color p_LightColor)
        {
            RectangleBorder l_Border = new RectangleBorder(new BorderLine(Color.White)); ;

            l_Border.Top = new BorderLine(p_LightColor, p_width);
            l_Border.Left = new BorderLine(p_LightColor, p_width);
            l_Border.Bottom = new BorderLine(p_ShadowColor, p_width);
            l_Border.Right = new BorderLine(p_ShadowColor, p_width);

            return l_Border;
        }
Ejemplo n.º 5
0
        //public void Draw(GraphicsCache graphics, RectangleF rectangle)
        //{
        //    RectangleBorder border = this;

        //    //Calculate the padding
        //    rectangle = new RectangleF(rectangle.X + Left.Padding, rectangle.Y + Top.Padding, rectangle.Width - (Left.Padding + Right.Padding), rectangle.Height - (Top.Padding + Bottom.Padding));

        //    if (rectangle.Width <= 0 || rectangle.Height <= 0)
        //        return;

        //    PensCache pens = graphics.PensCache;
        //    if (border.Left.Width > 0)
        //    {
        //        Pen leftPen = pens.GetPen(border.Left.Color, 1, border.Left.DashStyle);
        //        for (int i = 0; i < border.Left.Width; i++)
        //            graphics.Graphics.DrawLine(leftPen, rectangle.X + i, rectangle.Y, rectangle.X + i, rectangle.Bottom - 1);
        //    }

        //    if (border.Bottom.Width > 0)
        //    {
        //        Pen bottomPen = pens.GetPen(border.Bottom.Color, 1, border.Bottom.DashStyle);
        //        for (int i = 1; i <= border.Bottom.Width; i++)
        //            graphics.Graphics.DrawLine(bottomPen, rectangle.X, rectangle.Bottom - i, rectangle.Right - 1, rectangle.Bottom - i);
        //    }

        //    if (border.Right.Width > 0)
        //    {
        //        Pen rightPen = pens.GetPen(border.Right.Color, 1, border.Right.DashStyle);
        //        for (int i = 1; i <= border.Right.Width; i++)
        //            graphics.Graphics.DrawLine(rightPen, rectangle.Right - i, rectangle.Y, rectangle.Right - i, rectangle.Bottom - 1);
        //    }

        //    if (border.Top.Width > 0)
        //    {
        //        Pen topPen = pens.GetPen(border.Top.Color, 1, border.Top.DashStyle);
        //        for (int i = 0; i < border.Top.Width; i++)
        //            graphics.Graphics.DrawLine(topPen, rectangle.X, rectangle.Y + i, rectangle.Right - 1, rectangle.Y + i);
        //    }
        //}

        public void Draw(GraphicsCache graphics, RectangleF rectangle)
        {
            RectangleBorder border = this;

            //Calculate the padding
            rectangle = new RectangleF(rectangle.X + Left.Padding, rectangle.Y + Top.Padding, rectangle.Width - (Left.Padding + Right.Padding), rectangle.Height - (Top.Padding + Bottom.Padding));

            if (rectangle.Width <= 0 || rectangle.Height <= 0)
            {
                return;
            }

            PensCache pens = graphics.PensCache;

            if (border.Left.Width > 0)
            {
                Pen   leftPen = pens.GetPen(border.Left.Color, border.Left.Width, border.Left.DashStyle);
                float x;
                float bottom;
                if (border.Left.Width > 1)
                {
                    x      = rectangle.X + ((float)border.Left.Width) / 2;
                    bottom = rectangle.Bottom;
                }
                else
                {
                    x      = rectangle.X;
                    bottom = rectangle.Bottom - 1;
                }
                graphics.Graphics.DrawLine(leftPen, new PointF(x, rectangle.Y),
                                           new PointF(x, bottom));
            }

            if (border.Right.Width > 0)
            {
                Pen   rightPen = pens.GetPen(border.Right.Color, border.Right.Width, border.Right.DashStyle);
                float x;
                float bottom;
                if (border.Right.Width > 1)
                {
                    x      = rectangle.Right - border.Right.Width / 2;
                    bottom = rectangle.Bottom;
                }
                else
                {
                    x      = rectangle.Right - 1;
                    bottom = rectangle.Bottom - 1;
                }
                graphics.Graphics.DrawLine(rightPen, new PointF(x, rectangle.Y),
                                           new PointF(x, bottom));
            }

            if (border.Top.Width > 0)
            {
                Pen   topPen = pens.GetPen(border.Top.Color, border.Top.Width, border.Top.DashStyle);
                float y;
                float right;
                if (border.Top.Width > 1)
                {
                    y     = rectangle.Y + border.Top.Width / 2;
                    right = rectangle.Right;
                }
                else
                {
                    y     = rectangle.Y;
                    right = rectangle.Right - 1;
                }
                graphics.Graphics.DrawLine(topPen, new PointF(rectangle.X, y),
                                           new PointF(right, y));
            }

            if (border.Bottom.Width > 0)
            {
                Pen   bottomPen = pens.GetPen(border.Bottom.Color, border.Bottom.Width, border.Bottom.DashStyle);
                float y;
                float right;
                if (border.Bottom.Width > 1)
                {
                    y     = rectangle.Bottom - border.Bottom.Width / 2;
                    right = rectangle.Right;
                }
                else
                {
                    y     = rectangle.Bottom - 1;
                    right = rectangle.Right - 1;
                }
                graphics.Graphics.DrawLine(bottomPen, new PointF(rectangle.X, y),
                                           new PointF(right, y));
            }
        }