Exemple #1
0
 /// <summary>
 /// Initializes a new instance of the CellStyle class with default settings
 /// </summary>
 public CellStyle()
 {
     this.backColor = Color.Empty;
     this.foreColor = Color.Empty;
     this.font      = null;
     this.padding   = CellPadding.Empty;
     this.wordWrap  = false;
 }
Exemple #2
0
 /// <summary>
 /// Initializes a new instance of the CellStyle class with default settings
 /// </summary>
 public CellStyle()
 {
     this.backColor = Color.Empty;
     this.foreColor = Color.Empty;
     this.font = null;
     this.padding = CellPadding.Empty;
     this.wordWrap = false;
 }
Exemple #3
0
        /// <summary>
        /// Initializes a new instance of the CellRenderer class with default settings
        /// </summary>
        protected CellRenderer()
            : base()
        {
            this.format = "";

            this.grayTextBrush = new SolidBrush(SystemColors.GrayText);
            this.padding = CellPadding.Empty;
        }
Exemple #4
0
        /// <summary>
        /// Converts the given value object to the specified type, using
        /// the specified context and culture information
        /// </summary>
        /// <param name="context">An ITypeDescriptorContext that provides
        /// a format context</param>
        /// <param name="culture">A CultureInfo object. If a null reference
        /// is passed, the current culture is assumed</param>
        /// <param name="value">The Object to convert</param>
        /// <param name="destinationType">The Type to convert the value
        /// parameter to</param>
        /// <returns>An Object that represents the converted value</returns>
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            if (destinationType == null)
            {
                throw new ArgumentNullException("destinationType");
            }

            if ((destinationType == typeof(string)) && (value is CellPadding))
            {
                CellPadding p = (CellPadding)value;

                if (culture == null)
                {
                    culture = CultureInfo.CurrentCulture;
                }

                string separator = culture.TextInfo.ListSeparator + " ";

                TypeConverter converter = TypeDescriptor.GetConverter(typeof(int));

                string[] s = new string[4];

                s[0] = converter.ConvertToString(context, culture, p.Left);
                s[1] = converter.ConvertToString(context, culture, p.Top);
                s[2] = converter.ConvertToString(context, culture, p.Right);
                s[3] = converter.ConvertToString(context, culture, p.Bottom);

                return(string.Join(separator, s));
            }

            if ((destinationType == typeof(InstanceDescriptor)) && (value is CellPadding))
            {
                CellPadding p = (CellPadding)value;

                Type[] t = new Type[4];
                t[0] = t[1] = t[2] = t[3] = typeof(int);

                ConstructorInfo info = typeof(CellPadding).GetConstructor(t);

                if (info != null)
                {
                    object[] o = new object[4];

                    o[0] = p.Left;
                    o[1] = p.Top;
                    o[2] = p.Right;
                    o[3] = p.Bottom;

                    return(new InstanceDescriptor(info, o));
                }
            }

            return(base.ConvertTo(context, culture, value, destinationType));
        }
Exemple #5
0
        /// <summary>
        /// Tests whether obj is a CellPadding structure with the same values as
        /// this Padding structure
        /// </summary>
        /// <param name="obj">The Object to test</param>
        /// <returns>This method returns true if obj is a CellPadding structure
        /// and its Left, Top, Right, and Bottom properties are equal to
        /// the corresponding properties of this CellPadding structure;
        /// otherwise, false</returns>
        public override bool Equals(object obj)
        {
            if (!(obj is CellPadding))
            {
                return(false);
            }

            CellPadding padding = (CellPadding)obj;

            if (((padding.Left == this.Left) && (padding.Top == this.Top)) && (padding.Right == this.Right))
            {
                return(padding.Bottom == this.Bottom);
            }

            return(false);
        }
Exemple #6
0
        /// <summary>
        /// Raises the PaintCell event
        /// </summary>
        /// <param name="e">A PaintCellEventArgs that contains the event data</param>
        public virtual void OnPaintCell(PaintCellEventArgs e)
        {
            this.Bounds = e.CellRect;

            if (e.Cell != null)
            {
                this.Padding = e.Cell.Padding;

                this.Alignment = e.Table.ColumnModel.Columns[e.Column].Alignment;
                this.LineAlignment = e.Table.TableModel.Rows[e.Row].Alignment;

                this.Format = e.Table.ColumnModel.Columns[e.Column].Format;

                this.Font = e.Cell.Font;
            }
            else
            {
                this.Padding = CellPadding.Empty;

                this.Alignment = ColumnAlignment.Left;
                this.LineAlignment = RowAlignment.Center;

                this.Format = "";

                this.Font = null;
            }

            // if the font is null, use the default font
            if (this.Font == null)
            {
                this.Font = Control.DefaultFont;
            }

            // paint the Cells background
            this.OnPaintBackground(e);

            // paint the Cells foreground
            this.OnPaint(e);
        }
Exemple #7
0
        /// <summary>
        /// Raises the MouseUp event
        /// </summary>
        /// <param name="e">A CellMouseEventArgs that contains the event data</param>
        public virtual void OnMouseUp(CellMouseEventArgs e)
        {
            this.Bounds = e.CellRect;

            if (e.Cell == null)
            {
                this.Padding = CellPadding.Empty;
            }
            else
            {
                this.Padding = e.Cell.Padding;
            }
        }
Exemple #8
0
        /// <summary>
        /// Raises the MouseEnter event
        /// </summary>
        /// <param name="e">A CellMouseEventArgs that contains the event data</param>
        public virtual void OnMouseEnter(CellMouseEventArgs e)
        {
            this.Bounds = e.CellRect;

            if (e.Cell == null)
            {
                this.Padding = CellPadding.Empty;
            }
            else
            {
                this.Padding = e.Cell.Padding;
            }

            bool tooltipActive = e.Table.ToolTip.Active;

            if (tooltipActive)
            {
                e.Table.ToolTip.Active = false;
            }

            e.Table.ResetMouseEventArgs();

            e.Table.ToolTip.SetToolTip(e.Table, e.Cell.ToolTipText);

            if (tooltipActive)
            {
                e.Table.ToolTip.Active = true;
            }
        }
Exemple #9
0
        /// <summary>
        /// Raises the MouseDown event
        /// </summary>
        /// <param name="e">A CellMouseEventArgs that contains the event data</param>
        public virtual void OnMouseDown(CellMouseEventArgs e)
        {
            if (!e.Table.Focused)
            {
                if (!(e.Table.IsEditing && e.Table.EditingCell == e.CellPos && e.Table.EditingCellEditor is IEditorUsesRendererButtons))
                {
                    e.Table.Focus();
                }
            }

            this.Bounds = e.CellRect;

            if (e.Cell == null)
            {
                this.Padding = CellPadding.Empty;
            }
            else
            {
                this.Padding = e.Cell.Padding;
            }
        }
Exemple #10
0
        /// <summary>
        /// Raises the LostFocus event
        /// </summary>
        /// <param name="e">A CellFocusEventArgs that contains the event data</param>
        public virtual void OnLostFocus(CellFocusEventArgs e)
        {
            this.Bounds = e.CellRect;

            if (e.Cell == null)
            {
                this.Padding = CellPadding.Empty;
            }
            else
            {
                this.Padding = e.Cell.Padding;
            }

            e.Table.Invalidate(e.CellRect);
        }
Exemple #11
0
        /// <summary>
        /// Raises the DoubleClick event
        /// </summary>
        /// <param name="e">A CellMouseEventArgs that contains the event data</param>
        public virtual void OnDoubleClick(CellMouseEventArgs e)
        {
            this.Bounds = e.CellRect;

            if (e.Cell == null)
            {
                this.Padding = CellPadding.Empty;
            }
            else
            {
                this.Padding = e.Cell.Padding;
            }

            if (e.Table.EditStartAction == EditStartAction.DoubleClick && e.Table.IsCellEditable(e.CellPos))
            {
                e.Table.EditCell(e.CellPos);
            }
        }