I'm writing a small app that draws Japanese multiplications, based on values in two NumericUpDown controls...
![Name: 10-10-2020_03.42.28.jpg
Views: 76
Size: 20.7 KB]()
The problem i'm trying to solve is how to get the location of the red dots in the image. The location of these points varies depending on the NumericUpDown control values.
The drawing is all done in the Form_Paint event...
The problem i'm trying to solve is how to get the location of the red dots in the image. The location of these points varies depending on the NumericUpDown control values.
The drawing is all done in the Form_Paint event...
Code:
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Dim d1 As Integer = CInt(NumericUpDown1.Value) \ 10
Dim d2 As Integer = CInt(NumericUpDown1.Value) Mod 10
Dim d3 As Integer = CInt(NumericUpDown2.Value) \ 10
Dim d4 As Integer = CInt(NumericUpDown2.Value) Mod 10
Dim w As Integer = 50 + ((d3 - 1) * 12) + 150 + ((d4 - 1) * 12) + 50
Dim h As Integer = 50 + ((d1 - 1) * 12) + 150 + ((d2 - 1) * 12) + 50
Dim x As Integer = -(w \ 2)
Dim y As Integer = -(h \ 2)
e.Graphics.TranslateTransform(300, 300)
e.Graphics.RotateTransform(-45)
Dim current_Y As Integer
For i As Integer = 0 To d1 - 1
current_Y = y + 50 + i * 12
e.Graphics.DrawLine(Pens.SteelBlue, x, current_Y, x + w, current_Y)
Next
For i As Integer = 0 To d2 - 1
current_Y = y + 50 + ((d1 - 1) * 12) + 150 + (i * 12)
e.Graphics.DrawLine(Pens.SteelBlue, x, current_Y, x + w, current_Y)
Next
Dim current_X As Integer
For i As Integer = 0 To d3 - 1
current_X = x + 50 + (i * 12)
e.Graphics.DrawLine(Pens.LightSeaGreen, current_X, y, current_X, y + h)
Next
For i As Integer = 0 To d4 - 1
current_X = x + 50 + ((d3 - 1) * 12) + 150 + (i * 12)
e.Graphics.DrawLine(Pens.LightSeaGreen, current_X, y, current_X, y + h)
Next
e.Graphics.ResetTransform()
End Sub