Beispiel #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;
 }
		/// <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;
		}
Beispiel #3
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;
 }
Beispiel #4
0
 /// <summary>
 /// Initializes a new instance of the CellStyle class with default settings
 /// </summary>
 public CellStyle()
 {
     this.isPropertySet = new Dictionary <AllProperties, bool>();
     this.backColor     = Color.Empty;
     this.foreColor     = Color.Empty;
     this.font          = null;
     this.padding       = CellPadding.Empty;
     this.wordWrap      = false;
 }
Beispiel #5
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));
        }
Beispiel #6
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);
        }
Beispiel #7
0
 /// <summary>
 /// Initializes a new instance of the CellStyle class with default settings
 /// </summary>
 public CellStyle()
 {
     this.isPropertySet = new Dictionary<AllProperties, bool>();
     this.backColor = Color.Empty;
     this.foreColor = Color.Empty;
     this.font = null;
     this.padding = CellPadding.Empty;
     this.wordWrap = false;
 }
Beispiel #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;

            this.Padding = e.Cell == null ? CellPadding.Empty : e.Cell.Padding;

            bool tooltipActive = e.Table.ToolTip.Active;

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

            e.Table.ResetMouseEventArgs();

            if (tooltipActive)
            {
                if (e.Cell != null)
                {
                    CellToolTipEventArgs args = new CellToolTipEventArgs(e.Cell, new Point(e.X, e.Y));

                    // The default tooltip is to show the full text for any cell that has been truncated
                    if (e.Cell.IsTextTrimmed)
                        args.ToolTipText = e.Cell.Text;

                    // Allow the outside world to modify the text or cancel this tooltip
                    e.Table.OnCellToolTipPopup(args);

                    // Even if this tooltip has been cancelled we need to get rid of the old tooltip
                    if (args.Cancel)
                        e.Table.ToolTip.SetToolTip(e.Table, string.Empty);
                    else
                        e.Table.ToolTip.SetToolTip(e.Table, args.ToolTipText);
                }
                else
                {
                    e.Table.ToolTip.SetToolTip(e.Table, string.Empty);
                }
                e.Table.ToolTip.Active = true;
            }
        }
		/// <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);
		}
		/// <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);
			}
		}
		/// <summary>
		/// Raises the MouseMove event
		/// </summary>
		/// <param name="e">A CellMouseEventArgs that contains the event data</param>
		public virtual void OnMouseMove(CellMouseEventArgs e)
		{
			this.Bounds = e.CellRect;
			
			if (e.Cell == null)
			{
				this.Padding = CellPadding.Empty;
			}
			else
			{
				this.Padding = e.Cell.Padding;
			}
		}
		/// <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;
			}
		}
		/// <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;
			}
		}
		/// <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.InvalidateRect(e.CellRect);
		}
Beispiel #15
0
 /// <summary>
 /// Returns the height that is required to render this cell. If zero is returned then the default row height is used.
 /// </summary>
 /// <param name="cell"></param>
 /// <param name="graphics">The GDI+ drawing surface provided by the Paint event.</param>
 /// <returns></returns>
 public virtual int GetCellHeight(Graphics graphics, Cell cell)
 {
     this.Padding = cell.Padding;
     this.Font = cell.Font;
     return 0;
 }
Beispiel #16
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;

                // Cell settings supercede Column/Row settings

                bool alignmentSet = false;
                bool lineAlignmentSet = false;
                if (e.Cell.CellStyle != null)
                {
                    CellStyle style = e.Cell.CellStyle;
                    if (style.IsAlignmentSet)
                    {
                        alignmentSet = true;
                        this.Alignment = style.Alignment;
                    }
                    if (style.IsLineAlignmentSet)
                    {
                        lineAlignmentSet = true;
                        this.LineAlignment = style.LineAlignment;
                    }
                }

                if (!alignmentSet)
                    this.Alignment = e.Table.ColumnModel.Columns[e.Column].Alignment;
                if (!lineAlignmentSet)
                    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);
        }
Beispiel #17
0
        /// <summary>
        /// Initializes a new instance of the CellRenderer class with default settings
        /// </summary>
        protected CellRenderer()
            : base()
        {
            this.format = "";

            // this.formatProvider was initialised using System.Globalization.CultureInfo.CurrentUICulture,
            // but this means formatProvider can be set to a Neutral Culture which does not cantain Numberic
            // and DateTime formatting information.  System.Globalization.CultureInfo.CurrentCulture is
            // guaranteed to include this formatting information and thus avoids crashes during formatting.
            this.formatProvider = System.Globalization.CultureInfo.CurrentCulture;

            this.grayTextBrush = new SolidBrush(SystemColors.GrayText);
            this.padding = CellPadding.Empty;
        }