Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class GDICoordinateSystem
public Shared Sub Main
Application.Run(New Form1)
End Sub
End class
public class Form1
Inherits System.Windows.Forms.Form
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
Dim g As Graphics = e.Graphics
g.TranslateTransform(50, 40)
Dim vertFont As New Font("Verdana", 10, FontStyle.Regular)
Dim horzFont As New Font("Verdana", 10, FontStyle.Regular)
Dim blackBrush As New SolidBrush(Color.Black)
Dim blackPen As New Pen(Color.Black, 1)
Dim bluePen As New Pen(Color.Blue, 1)
' Page Coordinate *****
'X axis drawing
g.DrawString("200", horzFont, blackBrush, 200, 5)
g.DrawString("100", horzFont, blackBrush, 100, 5)
g.DrawString("X", horzFont, blackBrush, 250, 0)
' Drawing vertical strings
Dim vertStrFormat As New StringFormat
vertStrFormat.FormatFlags = StringFormatFlags.DirectionVertical
'Y axis drawing
g.DrawString("100", vertFont, blackBrush, 0, 100)
g.DrawString("200", vertFont, blackBrush, 0, 200)
g.DrawString("Y", vertFont, blackBrush, 0, 250)
' Drawing a vertical and a horizontal line
g.DrawLine(blackPen, 0, 0, 0, 250)
g.DrawLine(blackPen, 0, 0, 250, 0)
Dim A As New Point(0, 0)
Dim B As New Point(120, 80)
g.DrawLine(Pens.Black, A, B)
End Sub
Public Sub New()
MyBase.New()
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
End Sub
End Class