Exemplo n.º 1
0
        private void PaintX(Graphics g)
        {
            // Fill backround
            g.FillRectangle(new SolidBrush(Color.FromArgb(242, 242, 242)), 0, 0, this.Width, this.Height);
            g.DrawRectangle(new Pen(Color.FromArgb(212, 208, 200)), 0, 0, this.Width - 1, this.Height - 1);

            // Draw scroll pane
            g.FillRectangle(new SolidBrush(m_ViewStyle.GetButtonColor(ScrollPaneRect.Contains(m_MousePos) || m_Dragging, Control.MouseButtons == MouseButtons.Left)), m_pScrollPaneRect.X, m_pScrollPaneRect.Y, m_pScrollPaneRect.Width, m_pScrollPaneRect.Height);
            g.DrawRectangle(new Pen(m_ViewStyle.GetBorderColor(ScrollPaneRect.Contains(m_MousePos) || m_Dragging)), m_pScrollPaneRect.X, m_pScrollPaneRect.Y, m_pScrollPaneRect.Width, m_pScrollPaneRect.Height);

            // Draw decrease button
            g.FillRectangle(new SolidBrush(m_ViewStyle.GetButtonColor(DecreaseButtonRect.Contains(m_MousePos) && !m_Dragging, Control.MouseButtons == MouseButtons.Left)), DecreaseButtonRect);
            if (m_Vertical)
            {
                LumiSoft.UI.Controls.Paint.DrawTriangle(g, Color.Black, GetTriangleRect(DecreaseButtonRect), Direction.Up);
            }
            else
            {
                LumiSoft.UI.Controls.Paint.DrawTriangle(g, Color.Black, GetTriangleRect(DecreaseButtonRect), Direction.Left);
            }
            g.DrawRectangle(new Pen(m_ViewStyle.GetBorderColor(DecreaseButtonRect.Contains(m_MousePos) && !m_Dragging)), DecreaseButtonRect);

            // Draw increase button
            g.FillRectangle(new SolidBrush(m_ViewStyle.GetButtonColor(IncreaseButtonRect.Contains(m_MousePos) && !m_Dragging, Control.MouseButtons == MouseButtons.Left)), IncreaseButtonRect);
            if (m_Vertical)
            {
                LumiSoft.UI.Controls.Paint.DrawTriangle(g, Color.Black, GetTriangleRect(IncreaseButtonRect), Direction.Down);
            }
            else
            {
                LumiSoft.UI.Controls.Paint.DrawTriangle(g, Color.Black, GetTriangleRect(IncreaseButtonRect), Direction.Right);
            }
            g.DrawRectangle(new Pen(m_ViewStyle.GetBorderColor(IncreaseButtonRect.Contains(m_MousePos) && !m_Dragging)), IncreaseButtonRect);
        }
Exemplo n.º 2
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);
                }
            }
        }
Exemplo n.º 3
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);
            }
        }