Ejemplo n.º 1
0
 /********************************************************
  * Static fields representing some preset styles
  * Updating these styles will affect the entire application.
  */
 /// <summary>
 /// Static constructor
 /// </summary>
 static TextStyle()
 {
     Normal = new TextStyle(null);
     Heading1 = new TextStyle(Normal);
     Heading2 = new TextStyle(Normal);
     Heading3 = new TextStyle(Normal);
     PageHeader = new TextStyle(Normal);
     PageFooter = new TextStyle(Normal);
     TableHeader = new TextStyle(Normal);
     TableRow = new TextStyle(Normal);
     BoldStyle = new TextStyle(Normal);
     UnderlineStyle = new TextStyle(Normal);
     ItalicStyle = new TextStyle(Normal);
     ResetStyles();
 }
Ejemplo n.º 2
0
 /********************************************
  * Instance specific information
  */
 /// <summary>
 /// Public constructor that is used to create a new TextStyle.
 /// A new TextStyle is always based on a pre-existing style.
 /// TextStyle.Normal is the top-most style that everything is
 /// based from.
 /// </summary>
 /// <param name="defaultStyle">A default <see cref="ReportPrinting.TextStyle"/>
 /// for the new style to be based on.</param>
 public TextStyle(TextStyle defaultStyle)
 {
     this.defaultStyle = defaultStyle;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Paints or measures the object passed in according 
        /// to the formatting rules of this column.
        /// </summary>
        /// <param name="g">the graphics to paint the value onto</param>
        /// <param name="text">the text to paint</param>
        /// <param name="textStyle">the textStyle to use to paint the text</param>
        /// <param name="x">the x coordinate to start the paint</param>
        /// <param name="y">the y coordinate to start the paint</param>
        /// <param name="width">the width of the cell</param>
        /// <param name="height">The max height of this cell (when in sizeOnly mode)</param>
        /// <param name="sizeOnly">only calculate the sizes</param>
        /// <returns>A sizeF representing the measured size of the string + margins</returns>
        public virtual SizeF SizePaintCell( 
			Graphics g, string text, TextStyle textStyle,
			float x, float y, float width,
			float height, bool sizeOnly)
        {
            SizeF stringSize = new SizeF(width, height);
            Font font = textStyle.GetFont();
            StringFormat stringFormat = textStyle.GetStringFormat();

            float sideMargins = textStyle.MarginNear + textStyle.MarginFar + RightPenWidth;
            float topBottomMargins = textStyle.MarginTop + textStyle.MarginBottom;
            Bounds bounds = new Bounds (x, y, x + width, y + height);
            Bounds innerBounds = bounds.GetBounds (textStyle.MarginTop,
                textStyle.MarginFar + RightPenWidth, textStyle.MarginBottom, textStyle.MarginNear);
            SizeF maxSize = innerBounds.GetSizeF();

            if (sizeOnly)
            {
                // Find the height of the actual string to be drawn
                stringSize = g.MeasureString(text, font, maxSize, stringFormat);
                stringSize.Width += sideMargins;
                stringSize.Height += topBottomMargins;
                // Don't go bigger than maxHeight
                stringSize.Height = Math.Min (stringSize.Height, height);
            }
            else
            {
                // draw background & text
                if (textStyle.BackgroundBrush != null)
                {
                    g.FillRectangle (textStyle.BackgroundBrush, bounds.GetRectangleF());
                }
                RectangleF textLayout = innerBounds.GetRectangleF (stringSize,
                    SectionText.ConvertAlign (textStyle.StringAlignment),
                    textStyle.VerticalAlignment);
                g.DrawString(text, font, textStyle.Brush, textLayout, stringFormat);
            }
            return stringSize;
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="text">String of text to print</param>
 /// <param name="textStyle">TextStyle used to print the text</param>
 public SectionText(string text, TextStyle textStyle)
 {
     this.Text = text;
     this.TextStyle = textStyle;
 }
 /// <summary>
 /// Constructor requires text and style
 /// </summary>
 /// <param name="text">Text to be displayed </param>
 /// <param name="textStyle">TextStyle to use for printing the text</param>
 public RepeatableTextSection(string text, TextStyle textStyle)
     : base(text, textStyle)
 {
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="dataSource">A DataView to use as the source of data</param>
 public SectionTable(DataView dataSource)
 {
     this.DataSource = dataSource;
     this.borderPens = new BorderPens();
     this.headerTextStyle = new TextStyle (TextStyle.TableHeader);
     this.detailRowTextStyle = new TextStyle (TextStyle.TableRow);
     this.alternatingRowTextStyle = new TextStyle (this.detailRowTextStyle);
     this.rowHeights = new ArrayList (dataSource.Count);
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Gets a RepeatableTextSection with the given parameters.
        /// </summary>
        /// <param name="firstPageText">A string to use for the first page</param>
        /// <param name="evenPageText">A string to use for even pages</param>
        /// <param name="oddPageText">A string to use for odd pages</param>
        /// <param name="textStyle">The <see cref="ReportPrinting.TextStyle"/> for the text.</param>
        /// <param name="hAlign">The <see cref="ReportPrinting.HorizontalAlignment"/>
        /// for the text.</param>
        /// <returns>A RepeatableTextSection</returns>
        /// <remarks>
        /// <para>
        /// Specifing null for the firstPageText will result in oddPageText
        /// being used instead.  The blank string "" will suppress printing
        /// of a header.
        /// </para>
        /// This method is often used with the PageHeader and PageFooter
        /// properties as follows:
        /// <code>
        ///    builder.PageHeader.AddSection(builder.GetRepeatable(
        ///        "Text for first page",
        ///        "Text for odd pages",
        ///        "Text for even pages",
        ///        TextStyle.PageHeader,
        ///        StringAlignment.Center));
        /// </code>
        /// But it can be used anywhere you need to get a RepeateableTextSection.
        /// </remarks>
        public RepeatableTextSection GetRepeatable(string firstPageText, 
            string evenPageText, string oddPageText, 
            TextStyle textStyle, HorizontalAlignment hAlign)
        {
            RepeatableTextSection section = new RepeatableTextSection (
                oddPageText, textStyle);

            section.TextFirstPage = firstPageText;
            section.TextEvenPage = evenPageText;
            section.TextOddPage = oddPageText;
            section.UseFullWidth = true;
            section.HorizontalAlignment = hAlign;
            return section;
        }
Ejemplo n.º 8
0
        public void MakeDocument(ReportDocument reportDocument, string strFontSize, string strStartDate, string strEndDate)
        {
            TextStyle.ResetStyles();

            float fFontSize = 10;
            float.TryParse(strFontSize, out fFontSize);

            TextStyle.Normal.Size = 10;
            TextStyle.Heading1.Size = 16;
            TextStyle.Heading1.Bold = true;
            TextStyle.TableHeader.StringAlignment = StringAlignment.Center;
            TextStyle.TableHeader.Size = fFontSize;
            TextStyle.TableHeader.Bold = true;
            TextStyle.TableRow.Size = fFontSize;
            TextStyle.TableRow.Bold = false;

            var builder = new ReportBuilder(reportDocument);
            builder.StartLinearLayout(Direction.Vertical);

            var margins = new Margins(40, 30, 60, 0);
            builder.CurrentDocument.DefaultPageSettings.Margins = margins;

            var dv = GetDataView(strStartDate, strEndDate);
            //builder.AddPageHeader(String.Empty, "This is test 11 - Tables with lines", "page %p");
            builder.AddPageHeader(String.Empty, "Scheduled Lens Replenishment Compliance Report", "Date: " + DateTime.Now.ToShortDateString());
            //builder.AddPageFooter("Page %p of %tp" , HorizontalAlignment.Right);
            //builder.AddText("Patients to be notified for scheduled lens replenishments during the month of: " + DateTime.Now.AddMonths(1).ToString("MMMM") + " " + DateTime.Now.AddMonths(1).Year + ".");
            builder.AddHorizontalLine();
            builder.DefaultTablePen = reportDocument.ThinPen;
            builder.AddTable(dv, true, 100);
            builder.CurrentSection.UseFullWidth = true;
            var headerRow = new TextStyle(TextStyle.TableHeader) { StringAlignment = StringAlignment.Center };

            //builder.AddColumn("PatientName", "Name", 1.4f, false, false);
            //builder.CurrentColumn.HeaderTextStyle = headerRow;
            //builder.AddColumn("PatientAddress", "Address", 1.1f, false, false);
            //builder.CurrentColumn.HeaderTextStyle = headerRow;
            //builder.AddColumn("RpS", "RpS", .6f, false, false);
            //builder.CurrentColumn.HeaderTextStyle = headerRow;
            //builder.AddColumn("NextSchdReplacement", "Next Schd Repl", .9f, false, false);
            //builder.CurrentColumn.HeaderTextStyle = headerRow;
            //builder.AddColumn("Eye", "Eye", .3f, false, false);
            //builder.CurrentColumn.HeaderTextStyle = headerRow;
            //builder.AddColumn("Manf", "Manufacturer", 1f, false, false);
            //builder.CurrentColumn.HeaderTextStyle = headerRow;
            //builder.AddColumn("Series", "Series", .7f, false, false);
            //builder.CurrentColumn.HeaderTextStyle = headerRow;
            //builder.AddColumn("BC", "BC", .3f, false, false);
            //builder.CurrentColumn.HeaderTextStyle = headerRow;
            //builder.AddColumn("DIA", "DIA", .3f, false, false);
            //builder.CurrentColumn.HeaderTextStyle = headerRow;
            //builder.AddColumn("Sphere", "Sphere", .5f, false, false);
            //builder.CurrentColumn.HeaderTextStyle = headerRow;
            //builder.AddColumn("CYL", "CYL", .3f, false, false);
            //builder.CurrentColumn.HeaderTextStyle = headerRow;
            //builder.AddColumn("Axis", "Axis", .3f, false, false);
            //builder.CurrentColumn.HeaderTextStyle = headerRow;
            //builder.AddColumn("Add", "Add", .3f, false, false);
            //builder.CurrentColumn.HeaderTextStyle = headerRow;
            //builder.AddColumn("Tint", "Tint", 1f, false, false);
            //builder.CurrentColumn.HeaderTextStyle = headerRow;
            //builder.AddColumn("Automail", "AM", .2f, false, false);
            //builder.CurrentColumn.HeaderTextStyle = headerRow;
            //builder.AddColumn("DoNotSend", "DS", .2f, false, false);
            //builder.CurrentColumn.HeaderTextStyle = headerRow;

            builder.AddColumn("PatientName", "Patient", 1.1f, false, false);
            builder.CurrentColumn.HeaderTextStyle = headerRow;
            builder.AddColumn("RpS", "RpS", .7f, false, false);
            builder.CurrentColumn.HeaderTextStyle = headerRow;
            builder.AddColumn("NextSchdReplacement", "Next Schd Repl", 1.1f, false, false);
            builder.CurrentColumn.HeaderTextStyle = headerRow;
            builder.AddColumn("Eye", "Eye", .2f, false, false);
            builder.CurrentColumn.HeaderTextStyle = headerRow;
            builder.AddColumn("Manf", "Manufacturer", 1f, false, false);
            builder.CurrentColumn.HeaderTextStyle = headerRow;
            builder.AddColumn("Series", "Series", .7f, false, false);
            builder.CurrentColumn.HeaderTextStyle = headerRow;
            builder.AddColumn("BC", "BC", .6f, false, false);
            builder.CurrentColumn.HeaderTextStyle = headerRow;
            builder.AddColumn("DIA", "DIA", .5f, false, false);
            builder.CurrentColumn.HeaderTextStyle = headerRow;
            builder.AddColumn("Sphere", "Sphere", .6f, false, false);
            builder.CurrentColumn.HeaderTextStyle = headerRow;
            builder.AddColumn("CYL", "CYL", .7f, false, false);
            builder.CurrentColumn.HeaderTextStyle = headerRow;
            builder.AddColumn("Axis", "Axis", .5f, false, false);
            builder.CurrentColumn.HeaderTextStyle = headerRow;
            builder.AddColumn("Add", "Add", .6f, false, false);
            builder.CurrentColumn.HeaderTextStyle = headerRow;
            builder.AddColumn("Tint", "Tint", 1.2f, false, false);
            builder.CurrentColumn.HeaderTextStyle = headerRow;
            builder.AddColumn("Automail", "AM", .2f, false, false);
            builder.CurrentColumn.HeaderTextStyle = headerRow;
            builder.AddColumn("DoNotSend", "DS", .2f, false, false);
            builder.CurrentColumn.HeaderTextStyle = headerRow;

            builder.FinishLinearLayout();
        }
Ejemplo n.º 9
0
 public SectionText AddTextSection(string text, TextStyle textStyle)
 {
     return AddText (text, textStyle);
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Adds a section to the ReportDocument
        /// consisting of a text field with a given TextStyle
        /// </summary>
        /// <param name="text">Text for this section</param>
        /// <param name="textStyle">Text style to use for this section</param>
        /// <returns>ReportSection just created</returns>
        public SectionText AddText(string text, TextStyle textStyle)
        {
            SectionText section = new SectionText(text, textStyle);
            if (this.documentMode)
            {
                section.SingleLineMode = true;
            }

            AddSection(section);
            return section;
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Gets a rectangle for the image
        /// </summary>
        RectangleF GetImageRect(Bounds bounds, Image image, TextStyle textStyle)
        {
            SizeF maxSize = bounds.GetSizeF();
            SizeF imgSize = new SizeF (ImageWidth, ImageHeight);

            return bounds.GetRectangleF (imgSize,
                SectionText.ConvertAlign (textStyle.StringAlignment),
                textStyle.VerticalAlignment);
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Constructor requires text and style
 /// </summary>
 /// <param name="text">Text to be displayed </param>
 /// <param name="textStyle">TextStyle to use for printing the text</param>
 public RepeatableTextSection(string text, TextStyle textStyle)
     : base(text, textStyle)
 {
 }
Ejemplo n.º 13
0
        /********************************************
         * Instance specific information
         */

        /// <summary>
        /// Public constructor that is used to create a new TextStyle.
        /// A new TextStyle is always based on a pre-existing style.
        /// TextStyle.Normal is the top-most style that everything is
        /// based from.
        /// </summary>
        /// <param name="defaultStyle">A default <see cref="ReportPrinting.TextStyle"/>
        /// for the new style to be based on.</param>
        public TextStyle(TextStyle defaultStyle)
        {
            this.defaultStyle = defaultStyle;
        }