Inheritance: System.EventArgs
Exemple #1
0
        private void SetBadgeTypeByRules(BadgeRowEventArgs e)
        {
            if (!(e.FieldValue is int))
            {
                return;
            }

            int count = (int)e.FieldValue;

            // Remove ImportantMin and ImportanMax once after deprecation period.
            if (DangerMin <= count && count <= DangerMax)
            {
                e.BadgeType = "Danger";
            }
            else if (WarningMin <= count && count <= WarningMax)
            {
                e.BadgeType = "Warning";
            }
            else if (SuccessMin <= count && count <= SuccessMax)
            {
                e.BadgeType = "Success";
            }
            else if (InfoMin <= count && count <= InfoMax)
            {
                e.BadgeType = "Info";
            }
            else if (HideMin <= count && count <= HideMax)
            {
                e.BadgeType = "Hide";
            }
        }
Exemple #2
0
        /// <summary>
        /// Formats the specified field value for a cell in the <see cref="T:System.Web.UI.WebControls.BoundField" /> object.
        /// </summary>
        /// <param name="dataValue">The field value to format.</param>
        /// <param name="encode">true to encode the value; otherwise, false.</param>
        /// <returns>
        /// The field value converted to the format specified by <see cref="P:System.Web.UI.WebControls.BoundField.DataFormatString" />.
        /// </returns>
        protected override string FormatDataValue(object dataValue, bool encode)
        {
            BadgeRowEventArgs eventArg = new BadgeRowEventArgs(dataValue);

            SetBadgeTypeByRules(eventArg);

            if (SetBadgeType != null)
            {
                SetBadgeType(this, eventArg);
            }

            if (eventArg.BadgeType == "Hide")
            {
                return(string.Empty);
            }

            string css = "badge";

            if (!string.IsNullOrWhiteSpace(eventArg.BadgeType))
            {
                css += " badge-" + eventArg.BadgeType.ToLower();
            }

            string fieldValue = base.FormatDataValue(eventArg.FieldValue, encode);

            return(string.Format("<span class='{0}'>{1}</span>", css, fieldValue));
        }
Exemple #3
0
        private void SetBadgeTypeByRules(BadgeRowEventArgs e)
        {
            if (!(e.FieldValue is int))
            {
                return;
            }

            int count = (int)e.FieldValue;

            if (ImportantMin <= count && count <= ImportantMax)
            {
                e.BadgeType = "Important";
            }
            else if (WarningMin <= count && count <= WarningMax)
            {
                e.BadgeType = "Warning";
            }
            else if (SuccessMin <= count && count <= SuccessMax)
            {
                e.BadgeType = "Success";
            }
            else if (InfoMin <= count && count <= InfoMax)
            {
                e.BadgeType = "Info";
            }
        }
Exemple #4
0
        private void SetBadgeTypeByRules( BadgeRowEventArgs e )
        {
            if ( !( e.FieldValue is int ) )
                return;

            int count = (int)e.FieldValue;

            if ( ImportantMin <= count && count <= ImportantMax )
            {
                e.BadgeType = "Important";
            }
            else if ( WarningMin <= count && count <= WarningMax )
            {
                e.BadgeType = "Warning";
            }
            else if ( SuccessMin <= count && count <= SuccessMax )
            {
                e.BadgeType = "Success";
            }
            else if ( InfoMin <= count && count <= InfoMax )
            {
                e.BadgeType = "Info";
            }
        }
Exemple #5
0
        /// <summary>
        /// Formats the specified field value for a cell in the <see cref="T:System.Web.UI.WebControls.BoundField" /> object.
        /// </summary>
        /// <param name="dataValue">The field value to format.</param>
        /// <param name="encode">true to encode the value; otherwise, false.</param>
        /// <returns>
        /// The field value converted to the format specified by <see cref="P:System.Web.UI.WebControls.BoundField.DataFormatString" />.
        /// </returns>
        protected override string FormatDataValue( object dataValue, bool encode )
        {
            BadgeRowEventArgs eventArg = new BadgeRowEventArgs( dataValue );

            SetBadgeTypeByRules( eventArg );

            if ( SetBadgeType != null )
            {
                SetBadgeType( this, eventArg );
            }

            string css = "badge";
            if( !string.IsNullOrWhiteSpace( eventArg.BadgeType ) )
            {
                css += " badge-" + eventArg.BadgeType.ToLower();
            }

            string fieldValue = base.FormatDataValue( eventArg.FieldValue, encode );

            return string.Format( "<span class='{0}'>{1}</span>", css, fieldValue );
        }
Exemple #6
0
        private void SetBadgeTypeByRules( BadgeRowEventArgs e )
        {
            if ( !( e.FieldValue is int ) )
                return;

            int count = (int)e.FieldValue;

            // Remove ImportantMin and ImportanMax once after deprecation period.
            if ( DangerMin <= count && count <= DangerMax )
            {
                e.BadgeType = "Danger";
            }
            else if ( WarningMin <= count && count <= WarningMax )
            {
                e.BadgeType = "Warning";
            }
            else if ( SuccessMin <= count && count <= SuccessMax )
            {
                e.BadgeType = "Success";
            }
            else if ( InfoMin <= count && count <= InfoMax )
            {
                e.BadgeType = "Info";
            }
            else if ( HideMin <= count && count <= HideMax )
            {
                e.BadgeType = "Hide";
            }
        }