private void AddDataColumn(TlmBase tlm, int index, string value, FontProp fontProp, double width)
        {
            double initialWidth    = fontProp.rGetTextWidthMM(value);
            string remainingString = value.Trim();

            while (initialWidth > width)
            {
                string[] tokens     = remainingString.Split(' ');
                string   splitValue = tokens.First();

                foreach (string token in tokens.Skip(1))
                {
                    if (fontProp.rGetTextWidthMM(splitValue + token) < width)
                    {
                        splitValue = splitValue + ' ' + token;
                    }
                    else
                    {
                        break;
                    }
                }

                remainingString = remainingString.Replace(splitValue, "");
                tlm.Add(index, new RepString(fontProp, splitValue));
                tlm.NewLine(index);
                initialWidth = fontProp.rGetTextWidthMM(remainingString);
            }
            tlm.Add(index, new RepString(fontProp, remainingString));
        }
Example #2
0
        //----------------------------------------------------------------------------------------------------
        #region Test RepString
        //----------------------------------------------------------------------------------------------------

        //----------------------------------------------------------------------------------------------------x
        /// <summary>Prints the specified character at the current position.</summary>
        /// <param name="iChar">Character code</param>
        protected void PrintCharacter(Int32 iChar)
        {
            if (rX > 185) // new line
            {
                rY += fp.rLineFeedMM;
                rX  = 22;
            }
            if (rY > 280) // new page
            {
                new Page(this);
                rY = 40;
            }

            Char   ch      = (Char)iChar;
            String s       = ch.ToString();
            Double rWidth  = fp.rGetTextWidthMM(s);
            Double rHeight = fp.rLineFeedMM * 0.65;

            page_Cur.AddRightMM(rX, rY - 2.5, new RepInt32(fp_Small, (Int32)ch));
            page_Cur.AddMM(rX + 0.1, rY - 2, new RepInt32(fp_XSmall, 10));
            if (iChar < 256)
            {
                Int32 iOct = (iChar % 8) + 10 * ((iChar / 8) % 8) + 100 * ((iChar / 64) % 8);
                page_Cur.AddRightMM(rX, rY, new RepInt32(fp_Small, iOct, ""));
                page_Cur.AddMM(rX + 0.1, rY + 0.5, new RepInt32(fp_XSmall, 8));
            }
            page_Cur.AddMM(rX + 2, rY, new RepRectMM(bp, rWidth, rHeight));
            page_Cur.AddMM(rX + 2, rY, new RepString(fp, s));
            rX += 15;
        }
        // Inserts the page footer onto the given page, which includes the time of report generation as well as the page number.
        private double InsertFooter(Page page)
        {
            FontProp font = new FontProp(FontDefinition, 0.0D);

            font.rSizePoint = 12.0D;
            page.AddMM(PageWidthMillimeters - PageMarginMillimeters - font.rGetTextWidthMM(page.iPageNo.ToString()), PageHeightMillimeters - 15, new RepString(font, page.iPageNo.ToString()));
            return(font.rSizeMM);
        }
Example #4
0
        // Inserts the page footer onto the given page, which includes the time of report generation as well as the page number.
        private double InsertFooter(FontDef fontDefinition, Page page, DateTime now, int pageNumber)
        {
            FontProp font = new FontProp(fontDefinition, 0.0D);

            font.rSizePoint = 12.0D;
            page.AddMM(PageMarginMillimeters, PageHeightMillimeters - PageMarginMillimeters, new RepString(font, now.ToShortDateString() + " " + now.ToShortTimeString()));
            page.AddMM(PageWidthMillimeters - PageMarginMillimeters - font.rGetTextWidthMM(pageNumber.ToString()), PageHeightMillimeters - PageMarginMillimeters, new RepString(font, pageNumber.ToString()));
            return(font.rSizeMM);
        }
        // Inserts the page footer onto the given page, which includes the time of report generation as well as the page number.
        private double InsertHeader()
        {
            string ReportIdentifier = "Individual Breaker Report - " + StartTime.ToString("MM/dd/yyyy") + " - " + EndTime.ToString("MM/dd/yyyy") + "";

            FontProp font = new FontProp(FontDefinition, 0.0D);

            font.rSizePoint = 12.0D;

            FontProp meterNameFont = new FontProp(FontDefinition, 0.0D);

            meterNameFont.rSizePoint = 12.0D;

            int height = 6;

            double reportIdentifierHorizontalPosition = PageWidthMillimeters / 2 - font.rGetTextWidthMM(ReportIdentifier) / 2;

            page_Cur.AddMM(reportIdentifierHorizontalPosition, height, new RepString(font, ReportIdentifier));
            page_Cur.AddMM(0, 10, new RepRectMM(new BrushProp(this, Color.Black), PageWidthMillimeters, 0.1D));

            return(20);
        }
Example #6
0
        // Insert the list of definitions on the given page.
        private double InsertDefinitions(FontDef fontDefinition, Page page, double verticalMillimeters)
        {
            const double FontSize = 8.0D;
            const double FooterWidthMillimeters = 6.5D * 25.4D;

            FontProp font = new FontProp(fontDefinition, 0.0D);
            StringBuilder builder;
            int lengthWithoutWord;
            double lineHeightMillimeters;

            string definitionsText = "Good: Measurements received which are neither latched nor unreasonable." + Environment.NewLine +
                                     "Latched: Measurements received which have maintained the same value for an extended period of time." + Environment.NewLine +
                                     "Unreasonable: Measurements received whose values have fallen outside of the range defined by reasonability constraints." + Environment.NewLine +
                                     "Correctness: Percentage of good measurements over total measurements expected, per device.";

            // Break the definitions text into lines
            string[] lines = definitionsText.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

            // Set font size and line spacing
            font.rSizePoint = FontSize;
            lineHeightMillimeters = 1.5D * font.rSizeMM;

            foreach (string line in lines)
            {
                // String builder will be used to determine if the line is too wide to fit
                // on the page, and to break the line into multiple lines if necessary
                builder = new StringBuilder();

                // Break the line into words
                foreach (string word in line.Split())
                {
                    // Store the length of the line without an additional word so we can restore
                    // the original line if the additional word makes the line too long to fit
                    lengthWithoutWord = builder.Length;

                    // Add white space if this is not the first word in the line
                    if (builder.Length > 0)
                        builder.Append(' ');

                    // Add the word to the line
                    builder.Append(word);

                    // If the line is too long, put the original line onto the page and
                    // trim the string builder down to only the word we just added
                    if (font.rGetTextWidthMM(builder.ToString()) > FooterWidthMillimeters)
                    {
                        page.AddMM(PageMarginMillimeters, verticalMillimeters + font.rSizeMM, new RepString(font, builder.ToString(0, lengthWithoutWord)));
                        builder.Remove(0, lengthWithoutWord);
                        builder.Insert(0, "             ");
                        verticalMillimeters += lineHeightMillimeters;
                    }
                }
                
                // Add the remainder of the line to the page.
                page.AddMM(PageMarginMillimeters, verticalMillimeters + font.rSizeMM, new RepString(font, builder.ToString()));
                verticalMillimeters += 1.5D * lineHeightMillimeters;
            }

            return 0.0D;
        }
Example #7
0
 // Inserts the page footer onto the given page, which includes the time of report generation as well as the page number.
 private double InsertFooter(FontDef fontDefinition, Page page, DateTime now, int pageNumber)
 {
     FontProp font = new FontProp(fontDefinition, 0.0D);
     font.rSizePoint = 12.0D;
     page.AddMM(PageMarginMillimeters, PageHeightMillimeters - PageMarginMillimeters, new RepString(font, now.ToShortDateString() + " " + now.ToShortTimeString()));
     page.AddMM(PageWidthMillimeters - PageMarginMillimeters - font.rGetTextWidthMM(pageNumber.ToString()), PageHeightMillimeters - PageMarginMillimeters, new RepString(font, pageNumber.ToString()));
     return font.rSizeMM;
 }
Example #8
0
        // Insert the list of definitions on the given page.
        private double InsertDefinitions(FontDef fontDefinition, Page page, double verticalMillimeters)
        {
            const double FontSize = 8.0D;
            const double FooterWidthMillimeters = 6.5D * 25.4D;

            FontProp font = new FontProp(fontDefinition, 0.0D);
            StringBuilder builder;
            int lengthWithoutWord;
            double lineHeightMillimeters;

            string definitionsText = string.Format("Level 4: {0} - Devices which are reporting as expected, with a completeness of at least {1:0.##}% on the report date.", m_level4Alias, m_level4Threshold) + Environment.NewLine +
                string.Format("Level 3: {0} - Devices with a completeness of at least {1:0.##}% on the report date.", m_level3Alias, m_level3Threshold) + Environment.NewLine +
                string.Format("Level 2: Poor - Devices which reported on the report date, but had an completeness below {0:0.##}%.", m_level3Threshold) + Environment.NewLine +
                "Level 1: Offline - Devices which did not report on the report date, but have reported at some time during the 30 days prior to the report date." + Environment.NewLine +
                "Level 0: Failed - Devices which have not reported during the 30 days prior to the report date." + Environment.NewLine +
                "Completeness: Percentage of measurements received over total measurements expected, per device." + Environment.NewLine +
                "Acceptable Quality: Devices which are in Level 4 or Level 3.";

            // Break the definitions text into lines
            string[] lines = definitionsText.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

            // Set font size and line spacing
            font.rSizePoint = FontSize;
            lineHeightMillimeters = 1.5D * font.rSizeMM;

            foreach (string line in lines)
            {
                // String builder will be used to determine if the line is too wide to fit
                // on the page, and to break the line into multiple lines if necessary
                builder = new StringBuilder();

                // Break the line into words
                foreach (string word in line.Split())
                {
                    // Store the length of the line without an additional word so we can restore
                    // the original line if the additional word makes the line too long to fit
                    lengthWithoutWord = builder.Length;

                    // Add white space if this is not the first word in the line
                    if (builder.Length > 0)
                        builder.Append(' ');

                    // Add the word to the line
                    builder.Append(word);

                    // If the line is too long, put the original line onto the page and
                    // trim the string builder down to only the word we just added
                    if (font.rGetTextWidthMM(builder.ToString()) > FooterWidthMillimeters)
                    {
                        page.AddMM(PageMarginMillimeters, verticalMillimeters + font.rSizeMM, new RepString(font, builder.ToString(0, lengthWithoutWord)));
                        builder.Remove(0, lengthWithoutWord);
                        builder.Insert(0, "             ");
                        verticalMillimeters += lineHeightMillimeters;
                    }
                }

                // Add the remainder of the line to the page.
                page.AddMM(PageMarginMillimeters, verticalMillimeters + font.rSizeMM, new RepString(font, builder.ToString()));
                verticalMillimeters += 1.5D * lineHeightMillimeters;
            }

            return 0.0D;
        }
Example #9
0
        // Insert the list of definitions on the given page.
        private double InsertDefinitions(FontDef fontDefinition, Page page, double verticalMillimeters)
        {
            const double FontSize = 8.0D;
            const double FooterWidthMillimeters = 6.5D * 25.4D;

            FontProp      font = new FontProp(fontDefinition, 0.0D);
            StringBuilder builder;
            int           lengthWithoutWord;
            double        lineHeightMillimeters;

            string definitionsText = "Good: Measurements received which are neither latched nor unreasonable." + Environment.NewLine +
                                     "Latched: Measurements received which have maintained the same value for an extended period of time." + Environment.NewLine +
                                     "Unreasonable: Measurements received whose values have fallen outside of the range defined by reasonability constraints." + Environment.NewLine +
                                     "Correctness: Percentage of good measurements over total measurements expected, per device.";

            // Break the definitions text into lines
            string[] lines = definitionsText.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

            // Set font size and line spacing
            font.rSizePoint       = FontSize;
            lineHeightMillimeters = 1.5D * font.rSizeMM;

            foreach (string line in lines)
            {
                // String builder will be used to determine if the line is too wide to fit
                // on the page, and to break the line into multiple lines if necessary
                builder = new StringBuilder();

                // Break the line into words
                foreach (string word in line.Split())
                {
                    // Store the length of the line without an additional word so we can restore
                    // the original line if the additional word makes the line too long to fit
                    lengthWithoutWord = builder.Length;

                    // Add white space if this is not the first word in the line
                    if (builder.Length > 0)
                    {
                        builder.Append(' ');
                    }

                    // Add the word to the line
                    builder.Append(word);

                    // If the line is too long, put the original line onto the page and
                    // trim the string builder down to only the word we just added
                    if (font.rGetTextWidthMM(builder.ToString()) > FooterWidthMillimeters)
                    {
                        page.AddMM(PageMarginMillimeters, verticalMillimeters + font.rSizeMM, new RepString(font, builder.ToString(0, lengthWithoutWord)));
                        builder.Remove(0, lengthWithoutWord);
                        builder.Insert(0, "             ");
                        verticalMillimeters += lineHeightMillimeters;
                    }
                }

                // Add the remainder of the line to the page.
                page.AddMM(PageMarginMillimeters, verticalMillimeters + font.rSizeMM, new RepString(font, builder.ToString()));
                verticalMillimeters += 1.5D * lineHeightMillimeters;
            }

            return(0.0D);
        }