Example #1
0
 /// <summary>
 /// Calculates height needed for this editor.
 /// </summary>
 /// <param name="g"></param>
 /// <param name="value"></param>
 /// <param name="column"></param>
 /// <returns></returns>
 public int CalculateHeight(Graphics g, Object value, WGridColumn column)
 {
     return(19);
 }
Example #2
0
        /// <summary>
        /// Paints default editor. This is called foreach visible cell what isn't active editor.
        /// </summary>
        /// <param name="view"></param>
        /// <param name="g"></param>
        /// <param name="value"></param>
        /// <param name="cellBounds"></param>
        /// <param name="selected"></param>
        /// <param name="column"></param>
        public virtual void PaintDefault(WGridTableView view, Graphics g, Object value, Rectangle cellBounds, bool selected, WGridColumn column)
        {
            ViewStyle m_ViewStyle = view.Grid.ViewStyle;

            Color textColor = selected ?  Color.White : Color.Black;

            if (value != null && value.GetType() == typeof(Decimal))
            {
                if ((decimal)value < 0)
                {
                    textColor = Color.Red;
                }
            }

            if (column.CellTextFormat.Length == 0 && value != null && value.GetType() == typeof(DateTime))
            {
                if ((DateTime)value == DateTime.MinValue)
                {
                    value = "";
                }
                else
                {
                    value = ((DateTime)value).ToString("dd.MM.yyyy");
                }
            }
            else if (value != null && value.GetType() == typeof(bool))
            {
                Rectangle checkRect = new Rectangle(cellBounds.X + (int)(cellBounds.Width - 12) / 2, cellBounds.Y + (int)(cellBounds.Height - 13) / 2, 12, 12);

                // Fill checkrect
                g.FillRectangle(new SolidBrush(Color.White), checkRect);

                if ((bool)value)
                {
                    // Draw check (Lines from up to down).
                    g.DrawLine(new Pen(Color.Black), checkRect.X + 3, checkRect.Y + 5, checkRect.X + 3, checkRect.Y + 5 + 2);
                    g.DrawLine(new Pen(Color.Black), checkRect.X + 4, checkRect.Y + 6, checkRect.X + 4, checkRect.Y + 6 + 2);
                    g.DrawLine(new Pen(Color.Black), checkRect.X + 5, checkRect.Y + 7, checkRect.X + 5, checkRect.Y + 7 + 2);
                    g.DrawLine(new Pen(Color.Black), checkRect.X + 6, checkRect.Y + 6, checkRect.X + 6, checkRect.Y + 6 + 2);
                    g.DrawLine(new Pen(Color.Black), checkRect.X + 7, checkRect.Y + 5, checkRect.X + 7, checkRect.Y + 5 + 2);
                    g.DrawLine(new Pen(Color.Black), checkRect.X + 8, checkRect.Y + 4, checkRect.X + 8, checkRect.Y + 4 + 2);
                    g.DrawLine(new Pen(Color.Black), checkRect.X + 9, checkRect.Y + 3, checkRect.X + 9, checkRect.Y + 3 + 2);
                }

                // Draw rect around check
                g.DrawRectangle(new Pen(m_ViewStyle.GetBorderColor(false)), checkRect);

                value = null;                 // Force not to draw text
            }
            else if (value != null && column.CellTextFormat.Length > 0)
            {
                if (value is IFormattable)
                {
                    value = ((IFormattable)value).ToString(column.CellTextFormat, null);
                }
            }

            if (value != null)
            {
                LumiSoft.UI.Controls.Paint.DrawText(g, textColor, m_ViewStyle.GridCellsFont, value.ToString(), cellBounds, column.CellsTextAlign);
            }
        }
Example #3
0
        /// <summary>
        /// Paints default editor. This is called foreach visible cell what isn't active editor.
        /// </summary>
        /// <param name="g"></param>
        /// <param name="value"></param>
        /// <param name="cellBounds"></param>
        /// <param name="selected"></param>
        /// <param name="column"></param>
        public void PaintDefault(Graphics g, Object value, Rectangle cellBounds, bool selected, WGridColumn column)
        {
            if (column.CellTextFormat.Length == 0 && value != null && value.GetType() == typeof(DateTime))
            {
                value = ((DateTime)value).ToShortDateString();
            }
            else if (value != null && value.GetType() == typeof(bool))
            {
                Rectangle checkRect = new Rectangle(cellBounds.X + (int)(cellBounds.Width - 12) / 2, cellBounds.Y + (int)(cellBounds.Height - 13) / 2, 12, 12);

                ViewStyle m_ViewStyle = new ViewStyle();

                // Fill checkrect
                g.FillRectangle(new SolidBrush(Color.White), checkRect);

                if ((bool)value)
                {
                    // Draw check (Lines from up to down).
                    g.DrawLine(new Pen(Color.Black), checkRect.X + 3, checkRect.Y + 5, checkRect.X + 3, checkRect.Y + 5 + 2);
                    g.DrawLine(new Pen(Color.Black), checkRect.X + 4, checkRect.Y + 6, checkRect.X + 4, checkRect.Y + 6 + 2);
                    g.DrawLine(new Pen(Color.Black), checkRect.X + 5, checkRect.Y + 7, checkRect.X + 5, checkRect.Y + 7 + 2);
                    g.DrawLine(new Pen(Color.Black), checkRect.X + 6, checkRect.Y + 6, checkRect.X + 6, checkRect.Y + 6 + 2);
                    g.DrawLine(new Pen(Color.Black), checkRect.X + 7, checkRect.Y + 5, checkRect.X + 7, checkRect.Y + 5 + 2);
                    g.DrawLine(new Pen(Color.Black), checkRect.X + 8, checkRect.Y + 4, checkRect.X + 8, checkRect.Y + 4 + 2);
                    g.DrawLine(new Pen(Color.Black), checkRect.X + 9, checkRect.Y + 3, checkRect.X + 9, checkRect.Y + 3 + 2);
                }

                // Draw rect around check
                g.DrawRectangle(new Pen(m_ViewStyle.GetBorderColor(false)), checkRect);

                value = null;                 // Force not to draw text
            }
            else if (value != null && column.CellTextFormat.Length > 0)
            {
                if (value is IFormattable)
                {
                    value = ((IFormattable)value).ToString(column.CellTextFormat, null);
                }
            }

            if (value != null)
            {
                if (selected)
                {
                    LumiSoft.UI.Controls.Paint.DrawText(g, Color.White, this.Font, value.ToString(), cellBounds, column.CellsTextAlign);
                }
                else
                {
                    LumiSoft.UI.Controls.Paint.DrawText(g, Color.Black, this.Font, value.ToString(), cellBounds, column.CellsTextAlign);
                }
            }
        }