vb.net - Hasmorepages 属性失败
问题描述
我创建了一个例程,旨在根据先前存储的行信息队列打印可变数量的行和/或页面。每页打印良好,但打印多页时,会叠印两页。我看不到我的逻辑错误,但一定有一个。有问题的代码副本如下。Nextline.newpage 是一个布尔值,设置为 true 以强制一个新页面。在我的文本示例中,有六个“Newpage”,“hasmorepages”设置为 true 六次,例程退出了六次。输出仍然是四页,其中一页打印正确,三页在一张纸上打印两页。任何帮助将不胜感激。顺便说一句,这是我的第一个问题,所以请客气。
Private Sub PrintLines(Sender As Object, e As PrintPageEventArgs) Handles PrintDoc.PrintPage
Dim White As String = GetARGBString(PrinterDefaultBackcolor)
Do Until Lines.Count = 0
Dim Nextline As Lineformat = Lines.Dequeue
If Nextline.NewPage Then
e.HasMorePages = True
Exit Sub
End If
With Nextline
Dim LineBackColor As String = Nextline.backColor
If LineBackColor <> White Or .Borders = True Then DrawShape(Nextline, e)
If .Text <> "" Then DrawText(Nextline, e)
End With
Loop
End Sub
Private Sub DrawShape(Line As Lineformat, E As PrintPageEventArgs)
With Line
Dim Top As Integer = .Top * 100
Dim Left As Integer = .Left * 100
Dim Width As Integer = .BackGroundWidth * 100
Dim Height As Integer = .BackGroundHeight * 100
Dim Point As New Point(Left, Top)
Dim Size As New Size(Width, Height)
Dim Rect As New Rectangle(Point, Size)
Dim TransparentFillColor As String = "00" & Strings.Right(.backColor, 6)
Dim FillColor As FullColor = GetColorFromString(.backColor)
Dim BorderPen As New Pen(Color.Black)
Dim FillBrush As New SolidBrush(FillColor.Color)
E.Graphics.FillRectangle(FillBrush, Rect)
If Line.Borders = True Then
E.Graphics.DrawRectangle(BorderPen, Rect)
End If
End With
End Sub
Private Sub DrawText(Line As Lineformat, E As PrintPageEventArgs)
With Line
Dim MyFont = SetFontStyle(.FontFamily, .FontPoints, .FontBold, .FontItalic, .FontUnderline)
Dim TextColor As FullColor = GetColorFromString(.ForeColor)
Dim MyBrush As New SolidBrush(TextColor.Color)
Dim top As Integer = .Top * 100
Dim Left As Integer = .Left * 100
Dim Width As Integer = .LineWidth * 100
Dim Height As Integer = .LineHeight * 100
Dim point As New Point(Left, top)
Dim Size As New Size(Width, Height)
Dim Rect As New RectangleF(point, Size)
Dim SF As New StringFormat()
SF.FormatFlags = TextFormatFlags.WordEllipsis
E.Graphics.DrawString(.Text, MyFont, MyBrush, Rect, SF)
End With
End Sub
结束类
解决方案
推荐阅读
- python - Python - 如何自动编辑类对象值?
- git - 无法将 Intellij 项目导出到本地 Git 目录
- node.js - npm 错误!缺少脚本:构建:通用
- macos - Pfctl 如何为内核扩展设置防火墙规则
- php - Laravel 5 eloquent 不在数据库中存储特殊字符
- r - 在 mutate 函数中乘以选定行的总和
- spring - 从 1.5.16 升级到 Spring Boot 2 时开始出现错误 NoClassDefFoundError: ObjectMapper
- angular - TypeScript 和 chai-as-promsied:最终是无效属性
- python - 未知 URL 类型:图像抓取
- javascript - TypeError - d 未定义