/// <summary> /// Evaluates the specified row. /// </summary> /// <param name="row">The row.</param> /// <param name="table">The table.</param> /// <param name="defaultStyle">The default style.</param> /// <returns></returns> public tableStyleSetterResponse evaluate(DataRow row, DataTable table, dataTableStyleEntry defaultStyle) { tableStyleSetterResponse output = new tableStyleSetterResponse(defaultStyle, null); try { foreach (var unit in units) { output = unit.evaluate(row, table, output); if (output.style != defaultStyle) { return(output); } } foreach (var item in items) { output = item(row, table, output); if (output.style != defaultStyle) { return(output); } } } catch (Exception ex) { output.notes.Add(GetType().Name + "EVALUATE" + ex.Message); output.notes.Add(ex.StackTrace); } return(output); }
public static void SetStyle(this ExcelRow row, dataTableStyleEntry style, Boolean isEven = false) { if (style != null) { if (style?.Cell?.minSize?.height == null) { return; } row.Height = style.Cell.minSize.height; row.StyleName = style.key.ToString(); row.Style.SetStyle(style, isEven); } }
/// <summary> /// Sets the style. /// </summary> /// <param name="ExcelStyle">The excel style.</param> /// <param name="styleEntry">The style entry.</param> public static void SetStyle(this ExcelStyle Style, dataTableStyleEntry styleEntry, Boolean isEven = false) { Style.Font.SetStyle(styleEntry.Text); //Style.TextRotation = styleEntry.Text.ro2 if (isEven) { Style.Fill.SetStyle(styleEntry.Background); } else { Style.Fill.SetStyle(styleEntry.BackgroundAlt); } Style.SetStyle(styleEntry.Cell); }
/// <summary> /// Makes the default response. /// </summary> /// <param name="evaluationValue">if set to <c>true</c> [evaluation value].</param> /// <param name="okStype">The default style.</param> /// <returns></returns> protected tableStyleSetterResponse makeDefaultResponse(Boolean evaluationValue, dataTableStyleEntry okStype, dataTableStyleEntry noStype) { try { if (evaluationValue) { return(makeDefaultResponse(1, okStype, noStype)); } else { return(makeDefaultResponse(0, okStype, noStype)); } } catch (Exception ex) { throw new DataException(ex.LogException("StyleRule[" + GetType().Name + "]:makeDefaultResponse", "STYLE", false)); } }
/// <summary> /// Evaluates the specified row. /// </summary> /// <param name="row">The row.</param> /// <param name="table">The table.</param> /// <param name="defaultStyle">The default style.</param> /// <returns></returns> public abstract tableStyleSetterResponse evaluate(DataRow row, DataTable table, dataTableStyleEntry defaultStyle);
/// <summary> /// Makes the default response. /// </summary> /// <param name="evaluationValue">The evaluation value.</param> /// <param name="okStyle">The default style.</param> /// <returns></returns> protected tableStyleSetterResponse makeDefaultResponse(Double evaluationValue, dataTableStyleEntry okStyle, dataTableStyleEntry noStype) { //if (okStyle == null) okStyle = new dataTableStyleEntry(); tableStyleSetterResponse output = null; if (evaluationValue == 0) { output = new tableStyleSetterResponse(noStype, this); } else if (evaluationValue > 0) { if (colorGradientDictionary != null) { if (output == null) { output = new tableStyleSetterResponse(okStyle, this); } output.style.Background.Color = ColorWorks.GetColor(colorGradientDictionary.GetColor(evaluationValue)); output.style.BackgroundAlt.Color = ColorWorks.GetColor(colorGradientDictionary.GetColor(evaluationValue)); //.ColorFromHex(); } else { output = new tableStyleSetterResponse(customStyleEntry, this); } } return(output); }
/// <summary> /// Initializes a new instance of the <see cref="dataRowIndexDynamicStyle{TEnum}"/> class. /// </summary> /// <param name="_key">The key.</param> /// <param name="indexList">The index list.</param> public dataRowIndexDynamicStyle(dataTableStyleEntry style, IEnumerable <Int32> indexList) { customStyleEntry = style; indexes.AddRange(indexList); }
/// <summary> /// Evaluates the specified row. /// </summary> /// <param name="row">The row.</param> /// <param name="table">The table.</param> /// <param name="defaultStyle">The default style.</param> /// <returns></returns> public override tableStyleSetterResponse evaluate(DataRow row, DataTable table, dataTableStyleEntry defaultStyle) { var tableReal = row.Table; if (tableReal == null) { return(new tableStyleSetterResponse(defaultStyle, this)); } Int32 i = tableReal.Rows.IndexOf(row); if (indexes.Contains(i)) { return(new tableStyleSetterResponse(table.GetStyleSet().GetStyle(styleKey), this)); } return(new tableStyleSetterResponse(defaultStyle, this)); if (indexFromSourceTable) { IDataTableForStatistics statTable = tableReal as IDataTableForStatistics; if (statTable != null) { i = i - statTable.RowStart; } } //return makeDefaultResponse(confirmCritarion(i), , defaultStyle); }
#pragma warning disable CS1574 // XML comment has cref attribute 'criteria' that could not be resolved /// <summary> /// Evaluates the <see cref="columnName"/> column of the <c>row</c> against <see cref="criteria"/>, if test is positive returns the style associated with <see cref="styleKey"/> /// </summary> /// <param name="row">The row.</param> /// <param name="table">The table.</param> /// <param name="defaultStyle">The default style.</param> /// <returns></returns> public override tableStyleSetterResponse evaluate(DataRow row, DataTable table, dataTableStyleEntry defaultStyle) #pragma warning restore CS1574 // XML comment has cref attribute 'criteria' that could not be resolved { var tableReal = row.Table; if (tableReal == null) { return(new tableStyleSetterResponse(defaultStyle, this)); } if (!tableReal.Columns.Contains(columnName)) { return(new tableStyleSetterResponse(defaultStyle, this)); } DataColumn dc = tableReal.Columns[columnName]; Object vo = row[columnName]; TValueType val = vo.imbConvertValueSafeTyped <TValueType>(); Boolean ok = matchlist.Contains(val); if (DoInverseLogic) { ok = !ok; } if (ok) { return(new tableStyleSetterResponse(table.GetStyleSet().GetStyle(styleKey), this)); } return(new tableStyleSetterResponse(defaultStyle, this)); //return makeDefaultResponse(confirmZoneAndCriterion(row, dc), , defaultStyle); }
/// <summary> /// Evaluates the <see cref="columnName"/> column of the <c>row</c> against <see cref="criteria"/>, if test is positive returns the style associated with <see cref="styleKey"/> /// </summary> /// <param name="row">The row.</param> /// <param name="table">The table.</param> /// <param name="defaultStyle">The default style.</param> /// <returns></returns> public override tableStyleSetterResponse evaluate(DataRow row, DataTable table, dataTableStyleEntry defaultStyle) { DataTable rowTable = row.Table; if (rowTable == null) { return(new tableStyleSetterResponse(defaultStyle, this)); } if (!rowTable.Columns.Contains(columnName)) { return(makeDefaultResponse(false, null, defaultStyle)); } DataColumn dc = rowTable.Columns[columnName]; Boolean ok = confirmCritarion(row[dc]); if (!ok) { return(makeDefaultResponse(false, null, defaultStyle)); } if (typeof(TValueType).isNumber()) { TValueType val = row[dc].imbConvertValueSafeTyped <TValueType>(); if (criteria.testCriteria(val)) { return(new tableStyleSetterResponse(table.GetStyleSet().GetStyle(styleKey), this)); } } // if (criteria.testCriteria(row[dc])) return new tableStyleSetterResponse(table.GetStyleSet().GetStyle(styleKey), this); return(new tableStyleSetterResponse(defaultStyle, this)); }