Private Const XZero As Integer = 80 Private Const XInt As Integer = 100 Private Const XMin As Integer = 80 Private Const XMax As Integer = 700 Private Const YZero As Integer = 500 Private Const YInt As Integer = 50 Private Const YMin As Integer = 100 Private Const YMax As Integer = 660 Private Const YMin2 As Integer = 160 Private Const YMax2 As Integer = 610 Private Const XAxisY As Integer = 670 Private FntHeader As Font Private FntYAxis As Font Private FntXAxis As Font Private DataGrps As List(Of Single()) Private Data As List(Of Single) Private XNumPage As Integer Private Idx As Integer Private Pages As Integer Private Sub pd_QueryPageSettings(sender As Object, e As QueryPageSettingsEventArgs) Handles pd.QueryPageSettings e.PageSettings.Landscape = True End Sub Private Sub pd_BeginPrint(sender As Object, e As PrintEventArgs) Handles pd.BeginPrint FntHeader = New Font("MS ゴシック", 20.0!) FntYAxis = New Font("MS ゴシック", 10.0!) FntXAxis = New Font("MS ゴシック", 8.0!) 'ページ毎のポイント数 XNumPage = (XMax - XMin) \ XInt Dim st = 0 DataGrps = New List(Of Single()) For Each itm2 In (From itm In Data.Select(Function(d, idx) New With {.data = d, .index = idx}) Let Page = itm.index \ XNumPage Group itm.data By Page Into Group Order By Page) DataGrps.Add(itm2.Group.ToArray) Next Pages = DataGrps.Count Idx = 0 End Sub Private Sub pd_EndPrint(sender As Object, e As PrintEventArgs) Handles pd.EndPrint FntHeader.Dispose() FntYAxis.Dispose() FntXAxis.Dispose() End Sub Private Sub pd_PrintPage(sender As Object, e As PrintPageEventArgs) Handles pd.PrintPage Dim g = e.Graphics DrawHead(g) DrawAxis(g) DrawPoints(g) Idx += 1 If Idx < Pages Then e.HasMorePages = True Else e.HasMorePages = False End If End Sub Private Sub DrawHead(g As Graphics) g.DrawString($"ヘッダ部({Idx + 1}/{Pages})", FntHeader, Brushes.Black, 10, 10) End Sub Private Sub DrawAxis(g As Graphics) g.DrawLine(Pens.Black, XMin, YMin, XMin, YMax) g.DrawLine(Pens.Black, XMin, YMax, XMax, YMax) For y = YMin2 To YMax2 Step YInt g.DrawLine(Pens.Gray, XMin, y, XMax, y) Next End Sub Private Sub DrawPoints(g As Graphics) Dim Points = DataGrps(Idx) Dim x1 = XMin Dim x2 = x1 + XInt Dim y1 = 0 Dim IsFirst = True For Each pt In Points Dim y2 = YZero - (pt / 5) * YInt If IsFirst Then IsFirst = False Else g.DrawString("12/1", FntXAxis, Brushes.Black, x1 + 5, XAxisY) g.DrawLine(Pens.Black, x1, y1, x2, y2) End If x1 = x2 x2 = x1 + XInt y1 = y2 Next End Sub