FastReport
1278 строк · 43.8 Кб
1using System;2using System.Drawing;3using System.Collections.Generic;4using System.ComponentModel;5using FastReport.Utils;6using System.Drawing.Design;7using System.Drawing.Printing;8
9namespace FastReport10{
11/// <summary>12/// Represents a report page.13/// </summary>14/// <remarks>15/// To get/set a paper size and orientation, use the <see cref="PaperWidth"/>, <see cref="PaperHeight"/>16/// and <see cref="Landscape"/> properties. Note that paper size is measured in millimeters.17/// <para/>Report page can contain one or several bands with report objects. Use the <see cref="ReportTitle"/>,18/// <see cref="ReportSummary"/>, <see cref="PageHeader"/>, <see cref="PageFooter"/>,19/// <see cref="ColumnHeader"/>, <see cref="ColumnFooter"/>, <see cref="Overlay"/> properties20/// to get/set the page bands. The <see cref="Bands"/> property holds the list of data bands or groups.21/// Thus you may add several databands to this property to create master-master reports, for example.22/// <note type="caution">23/// Report page can contain bands only. You cannot place report objects such as <b>TextObject</b> on a page.24/// </note>25/// </remarks>26/// <example>27/// This example shows how to create a page with one <b>ReportTitleBand</b> and <b>DataBand</b> bands and add28/// it to the report.29/// <code>30/// ReportPage page = new ReportPage();31/// // set the paper in millimeters32/// page.PaperWidth = 210;33/// page.PaperHeight = 297;34/// // create report title35/// page.ReportTitle = new ReportTitleBand();36/// page.ReportTitle.Name = "ReportTitle1";37/// page.ReportTitle.Height = Units.Millimeters * 10;38/// // create data band39/// DataBand data = new DataBand();40/// data.Name = "Data1";41/// data.Height = Units.Millimeters * 10;42/// // add data band to the page43/// page.Bands.Add(data);44/// // add page to the report45/// report.Pages.Add(page);46/// </code>47/// </example>48public partial class ReportPage : PageBase, IParent49{50#region Constants51
52private const float MAX_PAPER_SIZE_MM = 2000000000;53
54#endregion // Constants55
56#region Fields57private string exportAlias;58private float paperWidth;59private float paperHeight;60private int rawPaperSize;61private bool landscape;62private float leftMargin;63private float topMargin;64private float rightMargin;65private float bottomMargin;66private bool mirrorMargins;67private PageColumns columns;68private FloatCollection guides;69private Border border;70private FillBase fill;71private Watermark watermark;72private bool titleBeforeHeader;73private string outlineExpression;74private bool printOnPreviousPage;75private bool resetPageNumber;76private bool extraDesignWidth;77private bool startOnOddPage;78private bool backPage;79private SubreportObject subreport;80private PageHeaderBand pageHeader;81private ReportTitleBand reportTitle;82private ColumnHeaderBand columnHeader;83private BandCollection bands;84private ReportSummaryBand reportSummary;85private ColumnFooterBand columnFooter;86private PageFooterBand pageFooter;87private OverlayBand overlay;88private string createPageEvent;89private string startPageEvent;90private string finishPageEvent;91private string manualBuildEvent;92private int firstPageSource;93private int otherPagesSource;94private int lastPageSource;95private Duplex duplex;96
97private bool unlimitedHeight;98private bool printOnRollPaper;99private bool unlimitedWidth;100private float unlimitedHeightValue;101private float unlimitedWidthValue;102
103#endregion104
105#region Properties106
107/// <summary>108/// This event occurs when the report engine create new page. On this stage can be modified page properties.109/// </summary>110public event EventHandler CreatePage;111/// <summary>112/// This event occurs when the report engine starts this page.113/// </summary>114public event EventHandler StartPage;115
116/// <summary>117/// This event occurs when the report engine finished this page.118/// </summary>119public event EventHandler FinishPage;120
121/// <summary>122/// This event occurs when the report engine is about to print databands in this page.123/// </summary>124public event EventHandler ManualBuild;125
126/// <summary>127/// Gets or sets a width of the paper, in millimeters.128/// </summary>129[Category("Paper")]130[TypeConverter("FastReport.TypeConverters.PaperConverter, FastReport")]131public float PaperWidth132{133get { return paperWidth; }134set { paperWidth = value; }135}136
137/// <summary>138/// Gets or sets the page name on export139/// </summary>140[Category("Paper")]141public string ExportAlias142{143get { return exportAlias; }144set { exportAlias = value; }145}146
147/// <summary>148/// Gets or sets a height of the paper, in millimeters.149/// </summary>150[Category("Paper")]151[TypeConverter("FastReport.TypeConverters.PaperConverter, FastReport")]152public float PaperHeight153{154get { return paperHeight; }155set { paperHeight = value; }156}157
158/// <summary>159/// Gets or sets the raw index of a paper size.160/// </summary>161/// <remarks>162/// This property stores the RawKind value of a selected papersize. It is used to distinguish163/// between several papers with the same size (for ex. "A3" and "A3 with no margins") used in some164/// printer drivers.165/// <para/>It is not obligatory to set this property. FastReport will select the166/// necessary paper using the <b>PaperWidth</b> and <b>PaperHeight</b> values.167/// </remarks>168[Category("Paper")]169[DefaultValue(0)]170public int RawPaperSize171{172get { return rawPaperSize; }173set { rawPaperSize = value; }174}175
176/// <summary>177/// Gets or sets a value indicating whether the page has unlimited height.178/// </summary>179[DefaultValue(false)]180[Category("Paper")]181public bool UnlimitedHeight182{183get { return unlimitedHeight; }184set185{186unlimitedHeight = value;187if (!unlimitedHeight)188printOnRollPaper = false;189}190}191
192/// <summary>193/// Gets or sets the value indicating whether the unlimited page should be printed on roll paper.194/// </summary>195[DefaultValue(false)]196[Category("Paper")]197public bool PrintOnRollPaper198{199get { return printOnRollPaper; }200set201{202if (unlimitedHeight)203printOnRollPaper = value;204}205}206
207/// <summary>208/// Gets or sets a value indicating whether the page has unlimited width.209/// </summary>210[DefaultValue(false)]211[Category("Paper")]212public bool UnlimitedWidth213{214get { return unlimitedWidth; }215set { unlimitedWidth = value; }216}217
218/// <summary>219/// Get or set the current height of unlimited page.220/// </summary>221[Browsable(false)]222public float UnlimitedHeightValue223{224get { return unlimitedHeightValue; }225set226{227unlimitedHeightValue = value;228if (printOnRollPaper)229PaperHeight = unlimitedHeightValue / Units.Millimeters;230}231}232
233/// <summary>234/// Get or set the current width of unlimited page.235/// </summary>236[Browsable(false)]237public float UnlimitedWidthValue238{239get { return unlimitedWidthValue; }240set { unlimitedWidthValue = value; }241}242
243/// <summary>244/// Gets the current page height in pixels.245/// </summary>246[Browsable(false)]247public float HeightInPixels248{249get250{251return UnlimitedHeight ? UnlimitedHeightValue : PaperHeight * Units.Millimeters;252}253}254
255/// <summary>256/// Gets the current page width in pixels.257/// </summary>258[Browsable(false)]259public float WidthInPixels260{261get262{263if (UnlimitedWidth)264{265if (!IsDesigning)266{267return UnlimitedWidthValue;268}269}270return PaperWidth * Units.Millimeters;271
272}273}274
275/// <summary>276/// Gets or sets a value indicating that page should be in landscape orientation.277/// </summary>278/// <remarks>279/// When you change this property, it will automatically swap paper width and height, as well as paper margins.280/// </remarks>281[DefaultValue(false)]282[Category("Paper")]283public bool Landscape284{285get { return landscape; }286set287{288if (landscape != value)289{290landscape = value;291if (IsDeserializing)292{293return;294}295
296float e = paperWidth;297paperWidth = paperHeight;298paperHeight = e;299
300float m1 = leftMargin; // m3301float m2 = rightMargin; // m1 m2302float m3 = topMargin; // m4303float m4 = bottomMargin; //304
305if (value)306{307leftMargin = m3; // rotate counter-clockwise308rightMargin = m4;309topMargin = m2;310bottomMargin = m1;311}312else313{314leftMargin = m4; // rotate clockwise315rightMargin = m3;316topMargin = m1;317bottomMargin = m2;318}319}320}321}322
323/// <summary>324/// Gets or sets the left page margin, in millimeters.325/// </summary>326[Category("Paper")]327[TypeConverter("FastReport.TypeConverters.PaperConverter, FastReport")]328public float LeftMargin329{330get { return leftMargin; }331set { leftMargin = value; }332}333
334/// <summary>335/// Gets or sets the top page margin, in millimeters.336/// </summary>337[Category("Paper")]338[TypeConverter("FastReport.TypeConverters.PaperConverter, FastReport")]339public float TopMargin340{341get { return topMargin; }342set { topMargin = value; }343}344
345/// <summary>346/// Gets or sets the right page margin, in millimeters.347/// </summary>348[Category("Paper")]349[TypeConverter("FastReport.TypeConverters.PaperConverter, FastReport")]350public float RightMargin351{352get { return rightMargin; }353set { rightMargin = value; }354}355
356/// <summary>357/// Gets or sets the bottom page margin, in millimeters.358/// </summary>359[Category("Paper")]360[TypeConverter("FastReport.TypeConverters.PaperConverter, FastReport")]361public float BottomMargin362{363get { return bottomMargin; }364set { bottomMargin = value; }365}366
367/// <summary>368/// Gets or sets a value indicating that even pages should swap its left and right margins when369/// previewed or printed.370/// </summary>371[DefaultValue(false)]372[Category("Behavior")]373public bool MirrorMargins374{375get { return mirrorMargins; }376set { mirrorMargins = value; }377}378
379/// <summary>380/// Gets the page columns settings.381/// </summary>382[Category("Appearance")]383public PageColumns Columns384{385get { return columns; }386}387
388/// <summary>389/// Gets or sets the page border that will be printed inside the page printing area.390/// </summary>391[Category("Appearance")]392public Border Border393{394get { return border; }395set { border = value; }396}397
398
399/// <summary>400/// Gets or sets the page background fill.401/// </summary>402[Category("Appearance")]403[Editor("FastReport.TypeEditors.FillEditor, FastReport", typeof(UITypeEditor))]404public FillBase Fill405{406get { return fill; }407set408{409if (value == null)410throw new ArgumentNullException("Fill");411fill = value;412}413}414
415/// <summary>416/// Gets or sets the page watermark.417/// </summary>418/// <remarks>419/// To enabled watermark, set its <b>Enabled</b> property to <b>true</b>.420/// </remarks>421[Category("Appearance")]422public Watermark Watermark423{424get { return watermark; }425set426{427if (watermark != value)428if (watermark != null)429watermark.Dispose();430watermark = value;431}432}433
434/// <summary>435/// Gets or sets a value indicating that <b>ReportTitle</b> band should be printed before the436/// <b>PageHeader</b> band.437/// </summary>438[DefaultValue(true)]439[Category("Behavior")]440public bool TitleBeforeHeader441{442get { return titleBeforeHeader; }443set { titleBeforeHeader = value; }444}445
446/// <summary>447/// Gets or sets an outline expression.448/// </summary>449/// <remarks>450/// For more information, see <see cref="BandBase.OutlineExpression"/> property.451/// </remarks>452[Category("Data")]453[Editor("FastReport.TypeEditors.ExpressionEditor, FastReport", typeof(UITypeEditor))]454public string OutlineExpression455{456get { return outlineExpression; }457set { outlineExpression = value; }458}459
460/// <summary>461/// Gets or sets a value indicating whether to start to print this page on a free space of the previous page.462/// </summary>463/// <remarks>464/// This property can be used if you have two or more pages in the report template.465/// </remarks>466[DefaultValue(false)]467[Category("Behavior")]468public bool PrintOnPreviousPage469{470get { return printOnPreviousPage; }471set { printOnPreviousPage = value; }472}473
474/// <summary>475/// Gets or sets a value indicating that FastReport engine must reset page numbers before printing this page.476/// </summary>477/// <remarks>478/// This property can be used if you have two or more pages in the report template.479/// </remarks>480[DefaultValue(false)]481[Category("Behavior")]482public bool ResetPageNumber483{484get { return resetPageNumber; }485set { resetPageNumber = value; }486}487
488/// <summary>489/// Gets or sets a value indicating whether the page has extra width in the report designer.490/// </summary>491/// <remarks>492/// This property may be useful if you work with such objects as Matrix and Table.493/// </remarks>494[DefaultValue(false)]495[Category("Design")]496public bool ExtraDesignWidth497{498get { return extraDesignWidth; }499set { extraDesignWidth = value; }500}501
502/// <summary>503/// Gets or sets a value indicating whether this page will start on an odd page only.504/// </summary>505/// <remarks>506/// This property is useful to print booklet-type reports. Setting this property to <b>true</b>507/// means that this page will start to print on an odd page only. If necessary, an empty page508/// will be added to the prepared report before this page will be printed.509/// </remarks>510[DefaultValue(false)]511[Category("Behavior")]512public bool StartOnOddPage513{514get { return startOnOddPage; }515set { startOnOddPage = value; }516}517
518/// <summary>519/// Uses this page as a back page for previously printed pages.520/// </summary>521[DefaultValue(false)]522[Category("Behavior")]523public bool BackPage524{525get { return backPage; }526set { backPage = value; }527}528
529/// <summary>530/// Gets or sets a report title band.531/// </summary>532[Browsable(false)]533public ReportTitleBand ReportTitle534{535get { return reportTitle; }536set537{538SetProp(reportTitle, value);539reportTitle = value;540}541}542
543/// <summary>544/// Gets or sets a report summary band.545/// </summary>546[Browsable(false)]547public ReportSummaryBand ReportSummary548{549get { return reportSummary; }550set551{552SetProp(reportSummary, value);553reportSummary = value;554}555}556
557/// <summary>558/// Gets or sets a page header band.559/// </summary>560[Browsable(false)]561public PageHeaderBand PageHeader562{563get { return pageHeader; }564set565{566SetProp(pageHeader, value);567pageHeader = value;568}569}570
571/// <summary>572/// Gets or sets a page footer band.573/// </summary>574[Browsable(false)]575public PageFooterBand PageFooter576{577get { return pageFooter; }578set579{580SetProp(pageFooter, value);581pageFooter = value;582}583}584
585/// <summary>586/// Gets or sets a column header band.587/// </summary>588[Browsable(false)]589public ColumnHeaderBand ColumnHeader590{591get { return columnHeader; }592set593{594SetProp(columnHeader, value);595columnHeader = value;596}597}598
599/// <summary>600/// Gets or sets a column footer band.601/// </summary>602[Browsable(false)]603public ColumnFooterBand ColumnFooter604{605get { return columnFooter; }606set607{608SetProp(columnFooter, value);609columnFooter = value;610}611}612
613/// <summary>614/// Gets or sets an overlay band.615/// </summary>616[Browsable(false)]617public OverlayBand Overlay618{619get { return overlay; }620set621{622SetProp(overlay, value);623overlay = value;624}625}626
627/// <summary>628/// Gets the collection of data bands or group header bands.629/// </summary>630/// <remarks>631/// The <b>Bands</b> property holds the list of data bands or group headers.632/// Thus you may add several databands to this property to create master-master reports, for example.633/// </remarks>634[Browsable(false)]635public BandCollection Bands636{637get { return bands; }638}639
640/// <summary>641/// Gets or sets the page guidelines.642/// </summary>643/// <remarks>644/// This property hold all vertical guidelines. The horizontal guidelines are owned by the bands (see645/// <see cref="BandBase.Guides"/> property).646/// </remarks>647[Browsable(false)]648public FloatCollection Guides649{650get { return guides; }651set { guides = value; }652}653
654/// <summary>655/// Gets or sets the reference to a parent <b>SubreportObject</b> that owns this page.656/// </summary>657/// <remarks>658/// This property is <b>null</b> for regular report pages. See the <see cref="SubreportObject"/> for details.659/// </remarks>660[Browsable(false)]661public SubreportObject Subreport662{663get { return subreport; }664set { subreport = value; }665}666
667/// <summary>668/// Gets or sets a script event name that will be fired when the report engine create new page.669/// On this stage can be modified page properties.670/// </summary>671[Category("Build")]672public string CreatePageEvent673{674get { return createPageEvent; }675set { createPageEvent = value; }676}677
678/// <summary>679/// Gets or sets a script event name that will be fired when the report engine starts this page.680/// </summary>681[Category("Build")]682public string StartPageEvent683{684get { return startPageEvent; }685set { startPageEvent = value; }686}687
688/// <summary>689/// Gets or sets a script event name that will be fired when the report engine finished this page.690/// </summary>691[Category("Build")]692public string FinishPageEvent693{694get { return finishPageEvent; }695set { finishPageEvent = value; }696}697
698/// <summary>699/// Gets or sets a script event name that will be fired when the report engine is about700/// to print databands in this page.701/// </summary>702[Category("Build")]703public string ManualBuildEvent704{705get { return manualBuildEvent; }706set { manualBuildEvent = value; }707}708
709/// <summary>710/// Gets or sets the paper source for the first printed page.711/// </summary>712/// <remarks>713/// <para>714/// This property represents the paper source (printer tray) that will be used when printing715/// the first page. To set the source for other pages, use716/// <see cref="LastPageSource"/> and <see cref="OtherPagesSource"/> properties.717/// </para>718/// <para>719/// Note: This property uses the <b>raw</b> number of the paper source.720/// </para>721/// </remarks>722[DefaultValue(7)]723[Category("Print")]724public int FirstPageSource725{726get { return firstPageSource; }727set { firstPageSource = value; }728}729
730/// <summary>731/// Gets or sets the paper source for all printed pages except the first one.732/// </summary>733/// <remarks>734/// <para>735/// This property represents the paper source (printer tray) that will be used when printing736/// all pages except the first one and the last one. To set source for first and last pages, use737/// <see cref="FirstPageSource"/> and <see cref="LastPageSource"/> properties.738/// </para>739/// <para>740/// Note: This property uses the <b>raw</b> number of the paper source.741/// </para>742/// </remarks>743[DefaultValue(7)]744[Category("Print")]745public int OtherPagesSource746{747get { return otherPagesSource; }748set { otherPagesSource = value; }749}750
751/// <summary>752/// Gets or sets the paper source for the last printed page.753/// </summary>754/// <remarks>755/// <para>756/// This property represents the paper source (printer tray) that will be used when printing757/// the last page. To set the source for other pages, use758/// <see cref="FirstPageSource"/> and <see cref="OtherPagesSource"/> properties.759/// </para>760/// <para>761/// Note: This property uses the <b>raw</b> number of the paper source.762/// </para>763/// </remarks>764[DefaultValue(7)]765[Category("Print")]766public int LastPageSource767{768get { return lastPageSource; }769set { lastPageSource = value; }770}771
772/// <summary>773/// Gets or sets the printer duplex mode that will be used when printing this page.774/// </summary>775[DefaultValue(Duplex.Default)]776[Category("Print")]777public Duplex Duplex778{779get { return duplex; }780set { duplex = value; }781}782
783internal bool IsManualBuild784{785get { return !String.IsNullOrEmpty(manualBuildEvent) || ManualBuild != null; }786}787#endregion788
789#region Private Methods790private void DrawBackground(FRPaintEventArgs e, RectangleF rect)791{792rect.Width *= e.ScaleX;793rect.Height *= e.ScaleY;794Brush brush = null;795if (Fill is SolidFill)796brush = e.Cache.GetBrush((Fill as SolidFill).Color);797else798brush = Fill.CreateBrush(rect, e.ScaleX, e.ScaleY);799
800e.Graphics.FillRectangle(brush, rect.Left, rect.Top, rect.Width, rect.Height);801if (!(Fill is SolidFill))802brush.Dispose();803}804#endregion805
806#region Protected Methods807
808/// <inheritdoc/>809protected override void Dispose(bool disposing)810{811if (disposing)812{813if (Subreport != null)814{815Subreport.ReportPage = null;816}817if (Watermark != null)818{819Watermark.Dispose();820Watermark = null;821}822}823base.Dispose(disposing);824}825
826#endregion827
828#region IParent829/// <inheritdoc/>830public virtual void GetChildObjects(ObjectCollection list)831{832if (TitleBeforeHeader)833{834list.Add(reportTitle);835list.Add(pageHeader);836}837else838{839list.Add(pageHeader);840list.Add(reportTitle);841}842list.Add(columnHeader);843foreach (BandBase band in bands)844{845list.Add(band);846}847list.Add(reportSummary);848list.Add(columnFooter);849list.Add(pageFooter);850list.Add(overlay);851}852
853/// <inheritdoc/>854public virtual bool CanContain(Base child)855{856if (IsRunning)857return child is BandBase;858return (child is PageHeaderBand || child is ReportTitleBand || child is ColumnHeaderBand ||859child is DataBand || child is GroupHeaderBand || child is ColumnFooterBand ||860child is ReportSummaryBand || child is PageFooterBand || child is OverlayBand);861}862
863/// <inheritdoc/>864public virtual void AddChild(Base child)865{866if (IsRunning)867{868bands.Add(child as BandBase);869return;870}871if (child is PageHeaderBand)872PageHeader = child as PageHeaderBand;873if (child is ReportTitleBand)874ReportTitle = child as ReportTitleBand;875if (child is ColumnHeaderBand)876ColumnHeader = child as ColumnHeaderBand;877if (child is DataBand || child is GroupHeaderBand)878bands.Add(child as BandBase);879if (child is ReportSummaryBand)880ReportSummary = child as ReportSummaryBand;881if (child is ColumnFooterBand)882ColumnFooter = child as ColumnFooterBand;883if (child is PageFooterBand)884PageFooter = child as PageFooterBand;885if (child is OverlayBand)886Overlay = child as OverlayBand;887}888
889/// <inheritdoc/>890public virtual void RemoveChild(Base child)891{892if (IsRunning)893{894bands.Remove(child as BandBase);895return;896}897if (child is PageHeaderBand && pageHeader == child as PageHeaderBand)898PageHeader = null;899if (child is ReportTitleBand && reportTitle == child as ReportTitleBand)900ReportTitle = null;901if (child is ColumnHeaderBand && columnHeader == child as ColumnHeaderBand)902ColumnHeader = null;903if (child is DataBand || child is GroupHeaderBand)904bands.Remove(child as BandBase);905if (child is ReportSummaryBand && reportSummary == child as ReportSummaryBand)906ReportSummary = null;907if (child is ColumnFooterBand && columnFooter == child as ColumnFooterBand)908ColumnFooter = null;909if (child is PageFooterBand && pageFooter == child as PageFooterBand)910PageFooter = null;911if (child is OverlayBand && overlay == child as OverlayBand)912Overlay = null;913}914
915/// <inheritdoc/>916public virtual int GetChildOrder(Base child)917{918return bands.IndexOf(child as BandBase);919}920
921/// <inheritdoc/>922public virtual void SetChildOrder(Base child, int order)923{924if (order > bands.Count)925order = bands.Count;926int oldOrder = child.ZOrder;927if (oldOrder != -1 && order != -1 && oldOrder != order)928{929if (oldOrder <= order)930order--;931bands.Remove(child as BandBase);932bands.Insert(order, child as BandBase);933}934}935
936/// <inheritdoc/>937public virtual void UpdateLayout(float dx, float dy)938{939// do nothing940}941#endregion942
943#region Public Methods944/// <inheritdoc/>945public override void Assign(Base source)946{947base.Assign(source);948
949ReportPage src = source as ReportPage;950ExportAlias = src.ExportAlias;951Landscape = src.Landscape;952PaperWidth = src.PaperWidth;953PaperHeight = src.PaperHeight;954RawPaperSize = src.RawPaperSize;955LeftMargin = src.LeftMargin;956TopMargin = src.TopMargin;957RightMargin = src.RightMargin;958BottomMargin = src.BottomMargin;959MirrorMargins = src.MirrorMargins;960FirstPageSource = src.FirstPageSource;961OtherPagesSource = src.OtherPagesSource;962LastPageSource = src.LastPageSource;963Duplex = src.Duplex;964Columns.Assign(src.Columns);965Guides.Assign(src.Guides);966Border = src.Border.Clone();967Fill = src.Fill.Clone();968Watermark.Assign(src.Watermark);969TitleBeforeHeader = src.TitleBeforeHeader;970OutlineExpression = src.OutlineExpression;971PrintOnPreviousPage = src.PrintOnPreviousPage;972ResetPageNumber = src.ResetPageNumber;973ExtraDesignWidth = src.ExtraDesignWidth;974BackPage = src.BackPage;975CreatePageEvent = src.CreatePageEvent;976StartOnOddPage = src.StartOnOddPage;977StartPageEvent = src.StartPageEvent;978FinishPageEvent = src.FinishPageEvent;979ManualBuildEvent = src.ManualBuildEvent;980UnlimitedHeight = src.UnlimitedHeight;981PrintOnRollPaper = src.PrintOnRollPaper;982UnlimitedWidth = src.UnlimitedWidth;983UnlimitedHeightValue = src.UnlimitedHeightValue;984UnlimitedWidthValue = src.UnlimitedWidthValue;985}986
987/// <inheritdoc/>988public override void Serialize(FRWriter writer)989{990ReportPage c = writer.DiffObject as ReportPage;991base.Serialize(writer);992if (ExportAlias != c.ExportAlias)993writer.WriteStr("ExportAlias", ExportAlias);994if (Landscape != c.Landscape)995writer.WriteBool("Landscape", Landscape);996if (FloatDiff(PaperWidth, c.PaperWidth) || Landscape != c.Landscape)997writer.WriteFloat("PaperWidth", PaperWidth);998if (FloatDiff(PaperHeight, c.PaperHeight) || Landscape != c.Landscape)999writer.WriteFloat("PaperHeight", PaperHeight);1000if (RawPaperSize != c.RawPaperSize)1001writer.WriteInt("RawPaperSize", RawPaperSize);1002if (FloatDiff(LeftMargin, c.LeftMargin))1003writer.WriteFloat("LeftMargin", LeftMargin);1004if (FloatDiff(TopMargin, c.TopMargin))1005writer.WriteFloat("TopMargin", TopMargin);1006if (FloatDiff(RightMargin, c.RightMargin))1007writer.WriteFloat("RightMargin", RightMargin);1008if (FloatDiff(BottomMargin, c.BottomMargin))1009writer.WriteFloat("BottomMargin", BottomMargin);1010if (MirrorMargins != c.MirrorMargins)1011writer.WriteBool("MirrorMargins", MirrorMargins);1012Columns.Serialize(writer, c.Columns);1013if (Guides.Count > 0)1014writer.WriteValue("Guides", Guides);1015Border.Serialize(writer, "Border", c.Border);1016Fill.Serialize(writer, "Fill", c.Fill);1017Watermark.Serialize(writer, "Watermark", c.Watermark);1018if (TitleBeforeHeader != c.TitleBeforeHeader)1019writer.WriteBool("TitleBeforeHeader", TitleBeforeHeader);1020if (OutlineExpression != c.OutlineExpression)1021writer.WriteStr("OutlineExpression", OutlineExpression);1022if (PrintOnPreviousPage != c.PrintOnPreviousPage)1023writer.WriteBool("PrintOnPreviousPage", PrintOnPreviousPage);1024if (ResetPageNumber != c.ResetPageNumber)1025writer.WriteBool("ResetPageNumber", ResetPageNumber);1026if (ExtraDesignWidth != c.ExtraDesignWidth)1027writer.WriteBool("ExtraDesignWidth", ExtraDesignWidth);1028if (StartOnOddPage != c.StartOnOddPage)1029writer.WriteBool("StartOnOddPage", StartOnOddPage);1030if (BackPage != c.BackPage)1031writer.WriteBool("BackPage", BackPage);1032if (CreatePageEvent != c.CreatePageEvent)1033writer.WriteStr("CreatePageEvent", CreatePageEvent);1034if (StartPageEvent != c.StartPageEvent)1035writer.WriteStr("StartPageEvent", StartPageEvent);1036if (FinishPageEvent != c.FinishPageEvent)1037writer.WriteStr("FinishPageEvent", FinishPageEvent);1038if (ManualBuildEvent != c.ManualBuildEvent)1039writer.WriteStr("ManualBuildEvent", ManualBuildEvent);1040if (UnlimitedHeight != c.UnlimitedHeight)1041writer.WriteBool("UnlimitedHeight", UnlimitedHeight);1042if (PrintOnRollPaper != c.PrintOnRollPaper)1043writer.WriteBool("PrintOnRollPaper", PrintOnRollPaper);1044if (UnlimitedWidth != c.UnlimitedWidth)1045writer.WriteBool("UnlimitedWidth", UnlimitedWidth);1046if (FloatDiff(UnlimitedHeightValue, c.UnlimitedHeightValue))1047writer.WriteFloat("UnlimitedHeightValue", UnlimitedHeightValue);1048if (FloatDiff(UnlimitedWidthValue, c.UnlimitedWidthValue))1049writer.WriteFloat("UnlimitedWidthValue", UnlimitedWidthValue);1050if (FloatDiff(LastPageSource, c.LastPageSource))1051writer.WriteFloat("LastPageSource", LastPageSource);1052if (FloatDiff(FirstPageSource, c.FirstPageSource))1053writer.WriteFloat("FirstPageSource", FirstPageSource);1054if (FloatDiff(OtherPagesSource, c.OtherPagesSource))1055writer.WriteFloat("OtherPageSource", OtherPagesSource);1056if (Duplex.ToString() != c.Duplex.ToString())1057writer.WriteStr("Duplex", Duplex.ToString());1058}1059
1060/// <inheritdoc/>1061public override void Draw(FRPaintEventArgs e)1062{1063if (IsDesigning)1064return;1065
1066IGraphics g = e.Graphics;1067RectangleF pageRect = new RectangleF(0, 0,1068WidthInPixels - 1 / e.ScaleX, HeightInPixels - 1 / e.ScaleY);1069RectangleF printableRect = new RectangleF(1070LeftMargin * Units.Millimeters,1071TopMargin * Units.Millimeters,1072(PaperWidth - LeftMargin - RightMargin) * Units.Millimeters,1073(PaperHeight - TopMargin - BottomMargin) * Units.Millimeters);1074
1075// Fix System.OverflowException when drawing unlimited page without preparing.1076if ((UnlimitedHeight || UnlimitedWidth) && !(IsRunning || IsPrinting))1077{1078pageRect = printableRect;1079}1080
1081DrawBackground(e, pageRect);1082
1083if (UnlimitedHeight || UnlimitedWidth)1084{1085printableRect = new RectangleF(pageRect.Left + LeftMargin * Units.Millimeters,1086pageRect.Top + TopMargin * Units.Millimeters,1087pageRect.Width - (LeftMargin + RightMargin) * Units.Millimeters,1088pageRect.Height - (TopMargin + BottomMargin) * Units.Millimeters);1089}1090IGraphicsState state = g.Save();1091e.Graphics.SetClip(new RectangleF(pageRect.X * e.ScaleX, pageRect.Y * e.ScaleY, pageRect.Width * e.ScaleX, pageRect.Height * e.ScaleY));1092
1093Border.Draw(e, printableRect);1094if (Watermark.Enabled)1095{1096if (!Watermark.ShowImageOnTop)1097Watermark.DrawImage(e, pageRect, Report, IsPrinting);1098if (!Watermark.ShowTextOnTop)1099Watermark.DrawText(e, pageRect, Report, IsPrinting);1100}1101
1102float leftMargin = (int)Math.Round(LeftMargin * Units.Millimeters * e.ScaleX);1103float topMargin = (int)Math.Round(TopMargin * Units.Millimeters * e.ScaleY);1104g.TranslateTransform(leftMargin, topMargin);1105
1106try1107{1108foreach (Base c in AllObjects)1109{1110if (c is ReportComponentBase && c.HasFlag(Flags.CanDraw))1111{1112ReportComponentBase obj = c as ReportComponentBase;1113if (!IsPrinting)1114{1115#if !MONO || (WPF || AVALONIA)1116if (!obj.IsVisible(e))1117continue;1118#endif1119}1120else1121{1122if (!obj.Printable)1123continue;1124else if (obj.Parent is BandBase && !(obj.Parent as BandBase).Printable)1125continue;1126}1127obj.SetDesigning(false);1128obj.SetPrinting(IsPrinting);1129obj.Draw(e);1130obj.SetPrinting(false);1131}1132}1133}1134finally1135{1136g.TranslateTransform(-leftMargin, -topMargin);1137}1138
1139if (Watermark.Enabled)1140{1141if (Watermark.ShowImageOnTop)1142Watermark.DrawImage(e, pageRect, Report, IsPrinting);1143if (Watermark.ShowTextOnTop)1144Watermark.DrawText(e, pageRect, Report, IsPrinting);1145}1146g.Restore(state);1147}1148
1149internal void InitializeComponents()1150{1151ObjectCollection allObjects = AllObjects;1152foreach (Base obj in allObjects)1153{1154if (obj is ReportComponentBase)1155(obj as ReportComponentBase).InitializeComponent();1156}1157}1158
1159internal void FinalizeComponents()1160{1161ObjectCollection allObjects = AllObjects;1162foreach (Base obj in allObjects)1163{1164if (obj is ReportComponentBase)1165(obj as ReportComponentBase).FinalizeComponent();1166}1167}1168
1169/// <inheritdoc/>1170public override string[] GetExpressions()1171{1172List<string> expressions = new List<string>();1173
1174if (!String.IsNullOrEmpty(OutlineExpression))1175expressions.Add(OutlineExpression);1176
1177return expressions.ToArray();1178}1179
1180/// <inheritdoc/>1181public override void ExtractMacros()1182{1183Watermark.Text = ExtractDefaultMacros(Watermark.Text);1184}1185
1186/// <summary>1187/// This method fires the <b>CreatePage</b> event and the script code connected to the <b>CreatePageEvent</b>.1188/// </summary>1189public void OnCreatePage(EventArgs e)1190{1191if (CreatePage != null)1192CreatePage(this, e);1193InvokeEvent(CreatePageEvent, e);1194}1195
1196/// <summary>1197/// This method fires the <b>StartPage</b> event and the script code connected to the <b>StartPageEvent</b>.1198/// </summary>1199public void OnStartPage(EventArgs e)1200{1201if (StartPage != null)1202StartPage(this, e);1203InvokeEvent(StartPageEvent, e);1204}1205
1206/// <summary>1207/// This method fires the <b>FinishPage</b> event and the script code connected to the <b>FinishPageEvent</b>.1208/// </summary>1209public void OnFinishPage(EventArgs e)1210{1211if (FinishPage != null)1212FinishPage(this, e);1213InvokeEvent(FinishPageEvent, e);1214}1215
1216/// <summary>1217/// This method fires the <b>ManualBuild</b> event and the script code connected to the <b>ManualBuildEvent</b>.1218/// </summary>1219public void OnManualBuild(EventArgs e)1220{1221if (ManualBuild != null)1222ManualBuild(this, e);1223InvokeEvent(ManualBuildEvent, e);1224}1225
1226/// <summary>1227/// Updates width of all bands on this page according to page's paper settings.1228/// </summary>1229public void UpdateBandsWidth()1230{1231float pageWidth = (PaperWidth - LeftMargin - RightMargin) * Units.Millimeters;1232float columnWidth = Columns.Width * Units.Millimeters;1233
1234foreach (Base c in AllObjects)1235{1236BandBase b = c as BandBase;1237if (b != null)1238{1239if (Columns.Count > 1 && b.IsColumnDependentBand)1240b.Width = columnWidth;1241else1242b.Width = pageWidth;1243}1244}1245}1246#endregion1247
1248/// <summary>1249/// Initializes a new instance of the <see cref="ReportPage"/> class with default settings.1250/// </summary>1251public ReportPage()1252{1253paperWidth = 210;1254paperHeight = 297;1255leftMargin = 10;1256topMargin = 10;1257rightMargin = 10;1258bottomMargin = 10;1259InitPreview();1260bands = new BandCollection(this);1261guides = new FloatCollection();1262columns = new PageColumns(this);1263border = new Border();1264fill = new SolidFill(Color.White);1265watermark = new Watermark();1266titleBeforeHeader = true;1267startPageEvent = "";1268finishPageEvent = "";1269manualBuildEvent = "";1270BaseName = "Page";1271unlimitedHeight = false;1272printOnRollPaper = false;1273unlimitedWidth = false;1274unlimitedHeightValue = MAX_PAPER_SIZE_MM * Units.Millimeters;1275unlimitedWidthValue = MAX_PAPER_SIZE_MM * Units.Millimeters;1276}1277}1278}