-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e57e113
commit 80b0929
Showing
334 changed files
with
25,227 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
using System; | ||
using System.Linq.Expressions; | ||
using System.Reflection; | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace FastReport.ReportBuilder | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <typeparam name="T"></typeparam> | ||
public class DataBuilder<T> | ||
{ | ||
private readonly ReportBuilder<T> _report; | ||
private DataDefinition _column { get; set; } | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="report"></param> | ||
public DataBuilder(ReportBuilder<T> report) | ||
{ | ||
_report = report; | ||
} | ||
|
||
/// <summary> | ||
/// Add a column with expression | ||
/// </summary> | ||
/// <typeparam name="TProp"></typeparam> | ||
/// <param name="property"></param> | ||
/// <returns></returns> | ||
public DataBuilder<T> Column<TProp>(Expression<Func<T, TProp>> property) | ||
{ | ||
var member = property.Body as MemberExpression; | ||
_column = new DataDefinition | ||
{ | ||
Name = GenericHelpers<T>.PropertyName(property), | ||
Title = member.Member.GetCustomAttribute<DisplayAttribute>()?.Name ?? GenericHelpers<T>.PropertyName(property), | ||
Format = member.Member.GetCustomAttribute<DisplayFormatAttribute>()?.DataFormatString ?? "" | ||
}; | ||
_report._columns.Add(_column); | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// Column title | ||
/// </summary> | ||
/// <param name="title"></param> | ||
/// <returns></returns> | ||
public DataBuilder<T> Title(string title) | ||
{ | ||
_column.Title = title; | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// Percentage width | ||
/// </summary> | ||
/// <param name="width"></param> | ||
/// <returns></returns> | ||
public DataBuilder<T> Width(uint width) | ||
{ | ||
_column.Width = width; | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// Formats of datetime, currency, number etc. | ||
/// </summary> | ||
/// <param name="format"></param> | ||
/// <returns></returns> | ||
public DataBuilder<T> Format(string format) | ||
{ | ||
_column.Format = format; | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// Rendering column with expression | ||
/// </summary> | ||
/// <param name="expression"></param> | ||
/// <returns></returns> | ||
public DataBuilder<T> Expression(string expression) | ||
{ | ||
_column.Expression = expression; | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// Align column content vertical top, bottom, center | ||
/// </summary> | ||
/// <param name="vertAlign"></param> | ||
/// <returns></returns> | ||
public DataBuilder<T> VertAlign(VertAlign vertAlign) | ||
{ | ||
_column.VertAlign = vertAlign; | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// Align column content horizontal left, right, center, justify | ||
/// </summary> | ||
/// <param name="horzAlign"></param> | ||
/// <returns></returns> | ||
public DataBuilder<T> HorzAlign(HorzAlign horzAlign) | ||
{ | ||
_column.HorzAlign = horzAlign; | ||
return this; | ||
} | ||
} | ||
} |
90 changes: 90 additions & 0 deletions
90
src/FastReport.ReportBuilder/Builders/DataHeaderBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
using System.Drawing; | ||
|
||
namespace FastReport.ReportBuilder | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <typeparam name="T"></typeparam> | ||
public class DataHeaderBuilder<T> | ||
{ | ||
private readonly ReportBuilder<T> _report; | ||
|
||
/// <summary> | ||
/// Data header band | ||
/// </summary> | ||
/// <param name="report"></param> | ||
public DataHeaderBuilder(ReportBuilder<T> report) | ||
{ | ||
_report = report; | ||
} | ||
|
||
/// <summary> | ||
/// Set report daha header font family name, size, style | ||
/// </summary> | ||
/// <param name="familyName"></param> | ||
/// <param name="emSize"></param> | ||
/// <param name="style"></param> | ||
/// <returns></returns> | ||
public DataHeaderBuilder<T> Font(string familyName, float emSize, FontStyle style) | ||
{ | ||
_report._dataHeader.Font = new Font(familyName, emSize, style); | ||
return this; | ||
} | ||
|
||
|
||
/// <summary> | ||
/// Set report daha header font family name, size | ||
/// </summary> | ||
/// <param name="familyName"></param> | ||
/// <param name="emSize"></param> | ||
/// <returns></returns> | ||
public DataHeaderBuilder<T> Font(string familyName, float emSize) | ||
{ | ||
return Font(familyName, emSize, FontStyle.Regular); | ||
} | ||
|
||
/// <summary> | ||
/// Set report daha header font family name | ||
/// </summary> | ||
/// <param name="familyName"></param> | ||
/// <returns></returns> | ||
public DataHeaderBuilder<T> Font(string familyName) | ||
{ | ||
return Font(familyName, 10.0f, FontStyle.Regular); | ||
} | ||
|
||
/// <summary> | ||
/// Set data header visibility | ||
/// </summary> | ||
/// <param name="visible"></param> | ||
/// <returns></returns> | ||
public DataHeaderBuilder<T> Visible(bool visible) | ||
{ | ||
_report._dataHeader.Visible = visible; | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// Set data header text color | ||
/// </summary> | ||
/// <param name="color"></param> | ||
/// <returns></returns> | ||
public DataHeaderBuilder<T> TextColor(Color color) | ||
{ | ||
_report._dataHeader.TextColor = color; | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// Set data header background color | ||
/// </summary> | ||
/// <param name="color"></param> | ||
/// <returns></returns> | ||
public DataHeaderBuilder<T> FillColor(Color color) | ||
{ | ||
_report._dataHeader.FillColor = color; | ||
return this; | ||
} | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
src/FastReport.ReportBuilder/Builders/GroupHeaderBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
using System; | ||
using System.Linq.Expressions; | ||
|
||
namespace FastReport.ReportBuilder | ||
{ | ||
/// <summary> | ||
/// Group header band | ||
/// </summary> | ||
/// <typeparam name="T"></typeparam> | ||
public class GroupHeaderBuilder<T> | ||
{ | ||
private readonly ReportBuilder<T> _report; | ||
|
||
/// <summary> | ||
/// Group header band | ||
/// </summary> | ||
/// <param name="report"></param> | ||
public GroupHeaderBuilder(ReportBuilder<T> report) | ||
{ | ||
_report = report; | ||
} | ||
|
||
/// <summary> | ||
/// Set a property for data group condition | ||
/// </summary> | ||
/// <typeparam name="TProp"></typeparam> | ||
/// <param name="property"></param> | ||
/// <returns></returns> | ||
public GroupHeaderBuilder<T> Condition<TProp>(Expression<Func<T, TProp>> property) | ||
{ | ||
_report._groupHeader.Name = GenericHelpers<T>.PropertyName(property); | ||
_report._groupHeader.Visible = true; | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// Sort order group None, Ascending, Descending | ||
/// </summary> | ||
/// <param name="order"></param> | ||
/// <returns></returns> | ||
public GroupHeaderBuilder<T> SortOrder(SortOrder order) | ||
{ | ||
_report._groupHeader.SortOrder = order; | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// Customize condition with expression | ||
/// </summary> | ||
/// <param name="expression"></param> | ||
/// <returns></returns> | ||
public GroupHeaderBuilder<T> Expression(string expression) | ||
{ | ||
_report._groupHeader.Expression = expression; | ||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// Set group header text visibility | ||
/// </summary> | ||
/// <param name="visible"></param> | ||
/// <returns></returns> | ||
public GroupHeaderBuilder<T> TextVisible(bool visible) | ||
{ | ||
_report._groupHeader.TextVisible = visible; | ||
return this; | ||
} | ||
} | ||
} |
Oops, something went wrong.