123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- using System.Drawing;
- using System.ComponentModel;
- using System.Drawing.Printing;
- using FastReport.Utils;
- namespace FastReport
- {
- partial class ReportPage
- {
- #region Fields
- private int firstPageSource;
- private int otherPagesSource;
- private int lastPageSource;
- private Duplex duplex;
- #endregion
- #region Properties
- /// <summary>
- /// Gets or sets the paper source for the first printed page.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This property represents the paper source (printer tray) that will be used when printing
- /// the first page. To set the source for other pages, use
- /// <see cref="LastPageSource"/> and <see cref="OtherPagesSource"/> properties.
- /// </para>
- /// <para>
- /// Note: This property uses the <b>raw</b> number of the paper source.
- /// </para>
- /// </remarks>
- [DefaultValue(7)]
- [Category("Print")]
- public int FirstPageSource
- {
- get { return firstPageSource; }
- set { firstPageSource = value; }
- }
- /// <summary>
- /// Gets or sets the paper source for all printed pages except the first one.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This property represents the paper source (printer tray) that will be used when printing
- /// all pages except the first one and the last one. To set source for first and last pages, use
- /// <see cref="FirstPageSource"/> and <see cref="LastPageSource"/> properties.
- /// </para>
- /// <para>
- /// Note: This property uses the <b>raw</b> number of the paper source.
- /// </para>
- /// </remarks>
- [DefaultValue(7)]
- [Category("Print")]
- public int OtherPagesSource
- {
- get { return otherPagesSource; }
- set { otherPagesSource = value; }
- }
- /// <summary>
- /// Gets or sets the paper source for the last printed page.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This property represents the paper source (printer tray) that will be used when printing
- /// the last page. To set the source for other pages, use
- /// <see cref="FirstPageSource"/> and <see cref="OtherPagesSource"/> properties.
- /// </para>
- /// <para>
- /// Note: This property uses the <b>raw</b> number of the paper source.
- /// </para>
- /// </remarks>
- [DefaultValue(7)]
- [Category("Print")]
- public int LastPageSource
- {
- get { return lastPageSource; }
- set { lastPageSource = value; }
- }
- /// <summary>
- /// Gets or sets the printer duplex mode that will be used when printing this page.
- /// </summary>
- [DefaultValue(Duplex.Default)]
- [Category("Print")]
- public Duplex Duplex
- {
- get { return duplex; }
- set { duplex = value; }
- }
- #endregion
- #region Public Methods
- internal void DrawSearchHighlight(FRPaintEventArgs e, int objIndex, CharacterRange range)
- {
- IGraphics g = e.Graphics;
- float leftMargin = LeftMargin * Units.Millimeters * e.ScaleX;
- float topMargin = TopMargin * Units.Millimeters * e.ScaleY;
- ObjectCollection allObjects = AllObjects;
- if (objIndex < 0 && objIndex >= allObjects.Count)
- return;
- ISearchable obj = allObjects[objIndex] as ISearchable;
- if (obj != null)
- {
- g.TranslateTransform(leftMargin, topMargin);
- try
- {
- obj.DrawSearchHighlight(e, range);
- }
- finally
- {
- g.TranslateTransform(-leftMargin, -topMargin);
- }
- }
- }
- internal void Print(FRPaintEventArgs e)
- {
- try
- {
- SetPrinting(true);
- SetDesigning(false);
- Draw(e);
- }
- finally
- {
- SetPrinting(false);
- }
- }
-
- internal ReportComponentBase HitTest(PointF mouse)
- {
- mouse.X -= LeftMargin * Units.Millimeters;
- mouse.Y -= TopMargin * Units.Millimeters;
- ObjectCollection allObjects = AllObjects;
- for (int i = allObjects.Count - 1; i >= 0; i--)
- {
- ReportComponentBase c = allObjects[i] as ReportComponentBase;
- if (c != null)
- {
- if (c.PointInObject(mouse))
- return c;
- }
- }
- return null;
- }
- #endregion
- private void AssignPreview(ReportPage src)
- {
- FirstPageSource = src.FirstPageSource;
- OtherPagesSource = src.OtherPagesSource;
- LastPageSource = src.LastPageSource;
- Duplex = src.Duplex;
- }
- private void WritePreview(FRWriter writer, ReportPage c)
- {
- if (FirstPageSource != c.FirstPageSource)
- writer.WriteInt("FirstPageSource", FirstPageSource);
- if (OtherPagesSource != c.OtherPagesSource)
- writer.WriteInt("OtherPagesSource", OtherPagesSource);
- if (LastPageSource != c.LastPageSource)
- writer.WriteInt("LastPageSource", LastPageSource);
- if (Duplex != c.Duplex)
- writer.WriteValue("Duplex", Duplex);
- }
- private void InitPreview()
- {
- firstPageSource = 7;
- otherPagesSource = 7;
- lastPageSource = 7;
- duplex = Duplex.Default;
- }
- }
- }
|