当前位置: 首页>>代码示例>>C#>>正文


C# Page.AddMM方法代码示例

本文整理汇总了C#中Page.AddMM方法的典型用法代码示例。如果您正苦于以下问题:C# Page.AddMM方法的具体用法?C# Page.AddMM怎么用?C# Page.AddMM使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Page的用法示例。


在下文中一共展示了Page.AddMM方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InsertDefinitions

        // 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;
        }
开发者ID:rmc00,项目名称:gsf,代码行数:61,代码来源:CorrectnessReportGenerator.cs

示例2: InsertDetailsList


//.........这里部分代码省略.........
                    signalColumnWidthMillimeters = signalColumnWidthMillimeters.Zip(signalDetails[deviceIndex][signalIndex], (currentWidth, text) => Math.Max(currentWidth, signalRowFont.rGetTextWidthMM(text))).ToArray();

                    signalIndex++;
                }

                deviceIndex++;
            }

            // Determine the total width of the list so that it can be centered
            listWidthMillimeters = Math.Max(deviceColumnWidthMillimeters.Sum(width => width + ColumnPaddingMillimeters) - ColumnPaddingMillimeters, SignalIndentMillimeters + signalColumnWidthMillimeters.Sum(width => width + ColumnPaddingMillimeters) - ColumnPaddingMillimeters);

            for (deviceIndex = 0; deviceIndex < deviceDetails.Length; deviceIndex++)
            {
                // If the height of the device header, plus the device row, plus the signal header, plus one signal row reaches beyond the bottom of the page, start a new page
                if (verticalMillimeters + deviceHeaderFont.rSizeMM + deviceRowFont.rSizeMM + signalHeaderFont.rSizeMM + signalRowFont.rSizeMM + 4.0D * RowPaddingMillimeters > PageHeightMillimeters - PageMarginMillimeters - FooterHeightMillimeters - SpacingMillimeters)
                {
                    // Insert footer on the current page first
                    InsertFooter(fontDefinition, page, now, pageNumber);

                    // Increment the page number and create a new page
                    page = CreatePage(report);
                    pageNumber++;

                    // Add the report date to the top of the page
                    verticalMillimeters = PageMarginMillimeters;
                    verticalMillimeters += InsertReportDate(fontDefinition, page, PageMarginMillimeters) + SpacingMillimeters;
                }

                // Add the device header to the page
                horizontalMillimeters = (PageWidthMillimeters - listWidthMillimeters) / 2.0D;

                for (int i = 0; i < deviceHeaders.Length; i++)
                {
                    page.AddMM(horizontalMillimeters, verticalMillimeters + deviceHeaderFont.rSizeMM, new RepString(deviceHeaderFont, deviceHeaders[i]));
                    horizontalMillimeters += deviceColumnWidthMillimeters[i] + ColumnPaddingMillimeters;
                }

                verticalMillimeters += deviceHeaderFont.rSizeMM + RowPaddingMillimeters;

                // Add the device row to the page
                horizontalMillimeters = (PageWidthMillimeters - listWidthMillimeters) / 2.0D;

                for (int i = 0; i < deviceDetails[deviceIndex].Length; i++)
                {
                    page.AddMM(horizontalMillimeters, verticalMillimeters + deviceRowFont.rSizeMM, new RepString(deviceRowFont, deviceDetails[deviceIndex][i]));
                    horizontalMillimeters += deviceColumnWidthMillimeters[i] + ColumnPaddingMillimeters;
                }

                verticalMillimeters += deviceRowFont.rSizeMM + RowPaddingMillimeters * 2.0D;

                // Add the signal header to the page
                horizontalMillimeters = (PageWidthMillimeters - listWidthMillimeters) / 2.0D + SignalIndentMillimeters;

                for (int i = 0; i < signalHeaders.Length; i++)
                {
                    page.AddMM(horizontalMillimeters, verticalMillimeters + signalHeaderFont.rSizeMM, new RepString(signalHeaderFont, signalHeaders[i]));
                    horizontalMillimeters += signalColumnWidthMillimeters[i] + ColumnPaddingMillimeters;
                }

                verticalMillimeters += signalHeaderFont.rSizeMM + RowPaddingMillimeters;

                // Each signal is on its own row in the details list
                foreach (string[] row in signalDetails[deviceIndex])
                {
                    // If the height of the row reaches beyond the bottom of the page, start a new page
                    if (verticalMillimeters + signalRowFont.rSizeMM > PageHeightMillimeters - PageMarginMillimeters - FooterHeightMillimeters - SpacingMillimeters)
开发者ID:rmc00,项目名称:gsf,代码行数:67,代码来源:CorrectnessReportGenerator.cs

示例3: InsertFiveDaySummary


//.........这里部分代码省略.........
                .Select((text, index) =>
                {
                    FontProp font = new FontPropMM(fontDefinition, rowHeightMillimeters * 0.8D);
                    font.bBold = index == 0;
                    return font;
                })
                .ToArray();

            dayThreeWidthMillimeters = dayThreeText
                .Zip(dayThreeFonts, (text, font) => font.rGetTextWidthMM(text))
                .Max();

            // Get the text for the measurement counts in the fifth column of the table
            measurementsExpected = m_deviceStatsList.Sum(deviceStats => deviceStats.MeasurementsExpected[ReportDays - 2]);
            measurementsReceived = m_deviceStatsList.Sum(deviceStats => deviceStats.MeasurementsReceived[ReportDays - 2]);
            measurementsLatched = m_deviceStatsList.Sum(deviceStats => deviceStats.GetMeasurementsLatched(ReportDays - 2));
            measurementsUnreasonable = m_deviceStatsList.Sum(deviceStats => deviceStats.GetMeasurementsUnreasonable(ReportDays - 2));

            dayFourText = new string[]
            {
                (m_reportDate - TimeSpan.FromDays(1.0D)).ToString("MM/dd"),
                ((measurementsReceived - measurementsLatched - measurementsUnreasonable) / measurementsExpected).ToString("0.00%"),
                (measurementsLatched / measurementsExpected).ToString("0.00%"),
                (measurementsUnreasonable / measurementsExpected).ToString("0.00%")
            };

            dayFourFonts = dayFourText
                .Select((text, index) =>
                {
                    FontProp font = new FontPropMM(fontDefinition, rowHeightMillimeters * 0.8D);
                    font.bBold = index == 0;
                    return font;
                })
                .ToArray();

            dayFourWidthMillimeters = dayFourText
                .Zip(dayFourFonts, (text, font) => font.rGetTextWidthMM(text))
                .Max();

            // Get the text for the measurement counts in the sixth column of the table
            measurementsExpected = m_deviceStatsList.Sum(deviceStats => deviceStats.MeasurementsExpected[ReportDays - 1]);
            measurementsReceived = m_deviceStatsList.Sum(deviceStats => deviceStats.MeasurementsReceived[ReportDays - 1]);
            measurementsLatched = m_deviceStatsList.Sum(deviceStats => deviceStats.GetMeasurementsLatched(ReportDays - 1));
            measurementsUnreasonable = m_deviceStatsList.Sum(deviceStats => deviceStats.GetMeasurementsUnreasonable(ReportDays - 1));

            dayFiveText = new string[]
            {
                (m_reportDate).ToString("MM/dd"),
                ((measurementsReceived - measurementsLatched - measurementsUnreasonable) / measurementsExpected).ToString("0.00%"),
                (measurementsLatched / measurementsExpected).ToString("0.00%"),
                (measurementsUnreasonable / measurementsExpected).ToString("0.00%")
            };

            dayFiveFonts = dayFiveText
                .Select((text, index) =>
                {
                    FontProp font = new FontPropMM(fontDefinition, rowHeightMillimeters * 0.8D);
                    font.bBold = index == 0;
                    return font;
                })
                .ToArray();

            dayFiveWidthMillimeters = dayFiveText
                .Zip(dayFiveFonts, (text, font) => font.rGetTextWidthMM(text))
                .Max();

            // Determine the full width of the table
            tableWidthMillimeters = labelsWidthMillimeters + ColumnPadding
                + dayOneWidthMillimeters + ColumnPadding
                + dayTwoWidthMillimeters + ColumnPadding
                + dayThreeWidthMillimeters + ColumnPadding
                + dayFourWidthMillimeters + ColumnPadding
                + dayFiveWidthMillimeters;

            // Add the table to the page
            for (int i = 0; i < labelText.Length; i++)
            {
                horizontalMillimeters = (PageWidthMillimeters - tableWidthMillimeters) / 2;

                page.AddMM(horizontalMillimeters, verticalMillimeters + rowHeightMillimeters * 0.9D, new RepString(labelFonts[i], labelText[i]));
                horizontalMillimeters += labelsWidthMillimeters + ColumnPadding;

                page.AddMM(horizontalMillimeters + dayOneWidthMillimeters - dayOneFonts[i].rGetTextWidthMM(dayOneText[i]), verticalMillimeters + rowHeightMillimeters * 0.9D, new RepString(dayOneFonts[i], dayOneText[i]));
                horizontalMillimeters += dayOneWidthMillimeters + ColumnPadding;

                page.AddMM(horizontalMillimeters + dayTwoWidthMillimeters - dayTwoFonts[i].rGetTextWidthMM(dayTwoText[i]), verticalMillimeters + rowHeightMillimeters * 0.9D, new RepString(dayTwoFonts[i], dayTwoText[i]));
                horizontalMillimeters += dayTwoWidthMillimeters + ColumnPadding;

                page.AddMM(horizontalMillimeters + dayThreeWidthMillimeters - dayThreeFonts[i].rGetTextWidthMM(dayThreeText[i]), verticalMillimeters + rowHeightMillimeters * 0.9D, new RepString(dayThreeFonts[i], dayThreeText[i]));
                horizontalMillimeters += dayThreeWidthMillimeters + ColumnPadding;

                page.AddMM(horizontalMillimeters + dayFourWidthMillimeters - dayFourFonts[i].rGetTextWidthMM(dayFourText[i]), verticalMillimeters + rowHeightMillimeters * 0.9D, new RepString(dayFourFonts[i], dayFourText[i]));
                horizontalMillimeters += dayFourWidthMillimeters + ColumnPadding;

                page.AddMM(horizontalMillimeters + dayFiveWidthMillimeters - dayFiveFonts[i].rGetTextWidthMM(dayFiveText[i]), verticalMillimeters + rowHeightMillimeters * 0.9D, new RepString(dayFiveFonts[i], dayFiveText[i]));
                verticalMillimeters += rowHeightMillimeters + RowPadding;
            }

            return TableHeightMillimeters;
        }
开发者ID:rmc00,项目名称:gsf,代码行数:101,代码来源:CorrectnessReportGenerator.cs

示例4: InsertBarChart

        // Inserts the bar chart onto the given page.
        private double InsertBarChart(Page page, double verticalMillimeters)
        {
            const double ChartWidthMillimeters = (550.0D / 96.0D) * 25.4D;
            const double ChartHeightMillimeters = (275.0D / 96.0D) * 25.4D;

            using (Chart chart = GetBarChart())
                page.AddMM((PageWidthMillimeters - ChartWidthMillimeters) / 2.0D, verticalMillimeters + ChartHeightMillimeters, new RepImageMM(ChartToImage(chart), ChartWidthMillimeters, ChartHeightMillimeters));

            return ChartHeightMillimeters;
        }
开发者ID:rmc00,项目名称:gsf,代码行数:11,代码来源:CorrectnessReportGenerator.cs

示例5: InsertFooter

 // 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;
 }
开发者ID:rmc00,项目名称:gsf,代码行数:9,代码来源:CorrectnessReportGenerator.cs

示例6: InsertDetailsList

        // Add detailed information about each individual device, starting on the current page and adding new pages as necessary.
        private void InsertDetailsList(Report report, FontDef fontDefinition, Page page, double verticalMillimeters, DateTime now, int pageNumber)
        {
            const double ColumnPaddingMillimeters = 10.0D;
            const double RowPaddingMillimeters = 2.0D;

            double[] columnWidthMillimeters;
            double listWidthMillimeters;
            double horizontalMillimeters;

            FontProp levelFont = new FontPropMM(fontDefinition, 0.0D);
            FontProp columnHeaderFont = new FontPropMM(fontDefinition, 0.0D);
            FontProp rowFont = new FontPropMM(fontDefinition, 0.0D);

            List<DeviceStats>[] levels = GetLevels(ReportDays);
            string[][][] levelDetails = new string[levels.Length][][];
            string[][] deviceDetails;
            string[] columnHeaders;

            // Set up fonts to be used in the details list
            levelFont.rSizePoint = 12.0D;
            columnHeaderFont.rSizePoint = 10.0D;
            rowFont.rSizePoint = 10.0D;
            levelFont.bBold = true;
            columnHeaderFont.bBold = true;

            // Set up the column header and the initial values for the column widths
            columnHeaders = new string[] { "Name", "Completeness", "Data Errors", "Time Errors" };
            columnWidthMillimeters = columnHeaders.Select(columnHeaderFont.rGetTextWidthMM).ToArray();

            for (int level = 0; level < levels.Length; level++)
            {
                // Set up the device details array for the current level
                deviceDetails = new string[levels[level].Count][];
                levelDetails[level] = deviceDetails;

                // Sort the devices in this level by name
                levels[level].Sort((device1, device2) => string.Compare(device1.Name, device2.Name, StringComparison.Ordinal));

                for (int device = 0; device < levels[level].Count; device++)
                {
                    // Populate the device details with data for each device
                    deviceDetails[device] = new string[]
                    {
                        levels[level][device].Name,
                        (levels[level][device].MeasurementsReceived[ReportDays - 1] / levels[level][device].MeasurementsExpected[ReportDays - 1]).ToString("0.##%"),
                        levels[level][device].DataQualityErrors[ReportDays - 1].ToString("#,##0"),
                        levels[level][device].TimeQualityErrors[ReportDays - 1].ToString("#,##0")
                    };

                    // Update the column widths if they need to be widened to accomodate the data
                    columnWidthMillimeters = columnWidthMillimeters.Zip(deviceDetails[device], (currentWidth, text) => Math.Max(currentWidth, rowFont.rGetTextWidthMM(text))).ToArray();
                }
            }

            // Determine the total width of the list so that it can be centered
            listWidthMillimeters = columnWidthMillimeters.Sum(width => width + ColumnPaddingMillimeters) - ColumnPaddingMillimeters;

            for (int level = 0; level < levels.Length; level++)
            {
                // Get the device details for the current level
                deviceDetails = levelDetails[level];

                // If the level has no data, don't bother adding it to the details list
                if (deviceDetails.Length > 0)
                {
                    // If the height of the level header, plus the column header, plus one row of data reaches beyond the bottom of the page, start a new page
                    if (verticalMillimeters + levelFont.rSizeMM + columnHeaderFont.rSizeMM + rowFont.rSizeMM > PageHeightMillimeters - PageMarginMillimeters - FooterHeightMillimeters - SpacingMillimeters)
                    {
                        // Insert footer on the current page first
                        InsertFooter(fontDefinition, page, now, pageNumber);

                        // Increment the page number and create a new page
                        page = CreatePage(report);
                        pageNumber++;

                        // Add the report date to the top of the page
                        verticalMillimeters = PageMarginMillimeters;
                        verticalMillimeters += InsertReportDate(fontDefinition, page, PageMarginMillimeters) + SpacingMillimeters;
                    }

                    // Add the level header to the page
                    horizontalMillimeters = (PageWidthMillimeters - listWidthMillimeters) / 2.0D;
                    page.AddMM(horizontalMillimeters, verticalMillimeters + levelFont.rSizeMM, new RepString(levelFont, "Level " + level));
                    verticalMillimeters += levelFont.rSizeMM + RowPaddingMillimeters;

                    // Add the column header to the page
                    for (int i = 0; i < columnHeaders.Length; i++)
                    {
                        page.AddMM(horizontalMillimeters, verticalMillimeters + columnHeaderFont.rSizeMM, new RepString(columnHeaderFont, columnHeaders[i]));
                        horizontalMillimeters += columnWidthMillimeters[i] + ColumnPaddingMillimeters;
                    }

                    verticalMillimeters += columnHeaderFont.rSizeMM + RowPaddingMillimeters;

                    // Each device is on its own row in the details list
                    foreach (string[] row in deviceDetails)
                    {
                        // If the height of the row reaches beyond the bottom of the page, start a new page
                        if (verticalMillimeters + rowFont.rSizeMM > PageHeightMillimeters - PageMarginMillimeters - FooterHeightMillimeters - SpacingMillimeters)
//.........这里部分代码省略.........
开发者ID:rmc00,项目名称:gsf,代码行数:101,代码来源:CompletenessReportGenerator.cs

示例7: InsertPieChart

        // Inserts the pie chart to the given page, which includes the level summary for the report date beside it.
        private double InsertPieChart(FontDef fontDefinition, Page page, double verticalMillimeters)
        {
            const double ChartWidthMillimeters = (300.0D / 96.0D) * 25.4D;
            const double ChartHeightMillimeters = (300.0D / 96.0D) * 25.4D;
            const double ColumnPadding = 10.0D;

            List<DeviceStats>[] levels = GetLevels(ReportDays);
            Color[] colors = GetLevelColors();
            double verticalStart = verticalMillimeters;

            double totalWidthMillimeters;
            double horizontalMillimeters;
            double rowHeightMillimeters;

            string[] labelText;
            FontProp[] labelFonts;
            double labelsWidthMillimeters;

            string[] countText;
            FontProp[] countFonts;
            double countsWidthMillimeters;

            using (Chart chart = GetPieChart())
            {
                // Determine the height of each row of the level summary
                rowHeightMillimeters = (ChartHeightMillimeters * 0.8D) / levels.Length;

                // Add vertical indent of 10% of the chart height
                verticalMillimeters += ChartHeightMillimeters * 0.1D;

                // Get the text for the labels in the first column of the table
                labelText = levels
                    .Select((level, index) => "Level " + index)
                    .Reverse()
                    .ToArray();

                labelFonts = labelText
                    .Select(text =>
                    {
                        FontProp font = new FontPropMM(fontDefinition, rowHeightMillimeters * 0.6D);
                        font.bBold = true;
                        return font;
                    })
                    .Reverse()
                    .ToArray();

                labelsWidthMillimeters = labelText
                    .Zip(labelFonts, (text, font) => font.rGetTextWidthMM(text))
                    .Max();

                // Get the text for the device counts in the second column of the table
                countText = levels
                    .Select(level => level.Count.ToString())
                    .Reverse()
                    .ToArray();

                countFonts = countText
                    .Select((text, level) => (FontProp)new FontPropMM(fontDefinition, rowHeightMillimeters * 0.6D, colors[level]))
                    .Reverse()
                    .ToArray();

                countsWidthMillimeters = countText
                    .Zip(countFonts, (text, font) => font.rGetTextWidthMM(text))
                    .Max();

                // Determine the total width of the pie chart and level summary,
                // then set horizontalMillimeters such that the pie chart and level
                // summary are centered on the page
                totalWidthMillimeters = labelsWidthMillimeters + ColumnPadding + countsWidthMillimeters + ColumnPadding + ChartWidthMillimeters;
                horizontalMillimeters = (PageWidthMillimeters - totalWidthMillimeters) / 2.0D;

                // Add the table to the page
                for (int i = 0; i < levels.Length; i++)
                {
                    page.AddMM(horizontalMillimeters, verticalMillimeters + rowHeightMillimeters * 0.8D, new RepString(labelFonts[i], labelText[i]));
                    page.AddMM(horizontalMillimeters + labelsWidthMillimeters + ColumnPadding + countsWidthMillimeters - countFonts[i].rGetTextWidthMM(countText[i]), verticalMillimeters + rowHeightMillimeters * 0.8D, new RepString(countFonts[i], countText[i]));
                    verticalMillimeters += rowHeightMillimeters;
                }

                // Add the pie chart to the page
                verticalMillimeters = verticalStart;
                page.AddMM(horizontalMillimeters + labelsWidthMillimeters + ColumnPadding + countsWidthMillimeters + ColumnPadding, verticalMillimeters + ChartHeightMillimeters, new RepImageMM(ChartToImage(chart), ChartWidthMillimeters, ChartHeightMillimeters));
            }

            return ChartHeightMillimeters;
        }
开发者ID:rmc00,项目名称:gsf,代码行数:87,代码来源:CompletenessReportGenerator.cs

示例8: InsertDefinitions

        // 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;
        }
开发者ID:rmc00,项目名称:gsf,代码行数:64,代码来源:CompletenessReportGenerator.cs

示例9: InsertFiveDaySummary


//.........这里部分代码省略.........

            // Get the text for the device counts in the fourth column of the table
            levels = GetLevels(ReportDays - 2);

            dayThreeText = new string[] { (m_reportDate - TimeSpan.FromDays(2.0D)).ToString("MM/dd") }
                .Concat(levels.Select(level => level.Count.ToString()).Reverse())
                .Concat(new string[] { levels.Sum(level => level.Count).ToString() })
                .ToArray();

            dayThreeFonts = dayThreeText
                .Select((text, index) =>
                {
                    FontProp font = new FontPropMM(fontDefinition, rowHeightMillimeters * 0.8D);
                    font.bBold = index == 0;
                    return font;
                })
                .ToArray();

            dayThreeWidthMillimeters = dayThreeText
                .Zip(dayThreeFonts, (text, font) => font.rGetTextWidthMM(text))
                .Max();

            // Get the text for the device counts in the fifth column of the table
            levels = GetLevels(ReportDays - 1);

            dayFourText = new string[] { (m_reportDate - TimeSpan.FromDays(1.0D)).ToString("MM/dd") }
                .Concat(levels.Select(level => level.Count.ToString()).Reverse())
                .Concat(new string[] { levels.Sum(level => level.Count).ToString() })
                .ToArray();

            dayFourFonts = dayFourText
                .Select((text, index) =>
                {
                    FontProp font = new FontPropMM(fontDefinition, rowHeightMillimeters * 0.8D);
                    font.bBold = index == 0;
                    return font;
                })
                .ToArray();

            dayFourWidthMillimeters = dayFourText
                .Zip(dayFourFonts, (text, font) => font.rGetTextWidthMM(text))
                .Max();

            // Get the text for the device counts in the sixth column of the table
            levels = GetLevels(ReportDays);

            dayFiveText = new string[] { (m_reportDate).ToString("MM/dd") }
                .Concat(levels.Select(level => level.Count.ToString()).Reverse())
                .Concat(new string[] { levels.Sum(level => level.Count).ToString() })
                .ToArray();

            dayFiveFonts = dayFiveText
                .Select((text, index) =>
                {
                    FontProp font = new FontPropMM(fontDefinition, rowHeightMillimeters * 0.8D);
                    font.bBold = index == 0;
                    return font;
                })
                .ToArray();

            dayFiveWidthMillimeters = dayFiveText
                .Zip(dayFiveFonts, (text, font) => font.rGetTextWidthMM(text))
                .Max();

            // Determine the full width of the table
            tableWidthMillimeters = labelsWidthMillimeters + ColumnPadding
                + dayOneWidthMillimeters + ColumnPadding
                + dayTwoWidthMillimeters + ColumnPadding
                + dayThreeWidthMillimeters + ColumnPadding
                + dayFourWidthMillimeters + ColumnPadding
                + dayFiveWidthMillimeters;

            // Add the table to the page
            for (int i = 0; i < labelText.Length; i++)
            {
                horizontalMillimeters = (PageWidthMillimeters - tableWidthMillimeters) / 2;

                page.AddMM(horizontalMillimeters, verticalMillimeters + rowHeightMillimeters * 0.9D, new RepString(labelFonts[i], labelText[i]));
                horizontalMillimeters += labelsWidthMillimeters + ColumnPadding;

                page.AddMM(horizontalMillimeters + dayOneWidthMillimeters - dayOneFonts[i].rGetTextWidthMM(dayOneText[i]), verticalMillimeters + rowHeightMillimeters * 0.9D, new RepString(dayOneFonts[i], dayOneText[i]));
                horizontalMillimeters += dayOneWidthMillimeters + ColumnPadding;

                page.AddMM(horizontalMillimeters + dayTwoWidthMillimeters - dayTwoFonts[i].rGetTextWidthMM(dayTwoText[i]), verticalMillimeters + rowHeightMillimeters * 0.9D, new RepString(dayTwoFonts[i], dayTwoText[i]));
                horizontalMillimeters += dayTwoWidthMillimeters + ColumnPadding;

                page.AddMM(horizontalMillimeters + dayThreeWidthMillimeters - dayThreeFonts[i].rGetTextWidthMM(dayThreeText[i]), verticalMillimeters + rowHeightMillimeters * 0.9D, new RepString(dayThreeFonts[i], dayThreeText[i]));
                horizontalMillimeters += dayThreeWidthMillimeters + ColumnPadding;

                page.AddMM(horizontalMillimeters + dayFourWidthMillimeters - dayFourFonts[i].rGetTextWidthMM(dayFourText[i]), verticalMillimeters + rowHeightMillimeters * 0.9D, new RepString(dayFourFonts[i], dayFourText[i]));
                horizontalMillimeters += dayFourWidthMillimeters + ColumnPadding;

                page.AddMM(horizontalMillimeters + dayFiveWidthMillimeters - dayFiveFonts[i].rGetTextWidthMM(dayFiveText[i]), verticalMillimeters + rowHeightMillimeters * 0.9D, new RepString(dayFiveFonts[i], dayFiveText[i]));
                verticalMillimeters += rowHeightMillimeters + RowPadding;
            }

            page.AddMM((PageWidthMillimeters - tableWidthMillimeters) / 2, verticalMillimeters - rowHeightMillimeters - (1.5D * RowPadding), new RepRectMM(new BrushProp(report, Color.Black), labelsWidthMillimeters + ColumnPadding + dayOneWidthMillimeters + ColumnPadding + dayTwoWidthMillimeters + ColumnPadding + dayThreeWidthMillimeters + ColumnPadding + dayFourWidthMillimeters + ColumnPadding + dayFiveWidthMillimeters, 0.1D));

            return TableHeightMillimeters;
        }
开发者ID:rmc00,项目名称:gsf,代码行数:101,代码来源:CompletenessReportGenerator.cs


注:本文中的Page.AddMM方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。