Change rectangle measures
This commit is contained in:
parent
dd9f8d6617
commit
3c308ded70
|
|
@ -6,6 +6,7 @@ Public Class GUI
|
||||||
Dim GratingW, GratingH As Double
|
Dim GratingW, GratingH As Double
|
||||||
Dim DrawW, DrawH As Integer
|
Dim DrawW, DrawH As Integer
|
||||||
Dim Aspect1, Aspect2 As Double
|
Dim Aspect1, Aspect2 As Double
|
||||||
|
Dim p1X, p1Y, p2X, p2Y, p3X, p3Y, p4X, p4Y As Integer
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -14,6 +15,18 @@ Public Class GUI
|
||||||
|
|
||||||
AddHandler DrawBox.Paint, AddressOf DrawingPanel_Paint
|
AddHandler DrawBox.Paint, AddressOf DrawingPanel_Paint
|
||||||
get_drawboxParameters()
|
get_drawboxParameters()
|
||||||
|
set_startPoints()
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub set_startPoints()
|
||||||
|
p1X = boxMidX - CInt(DrawW / 2)
|
||||||
|
p1Y = boxMidY - CInt(DrawH / 2)
|
||||||
|
p2X = boxMidX + CInt(DrawW / 2)
|
||||||
|
p2Y = boxMidY - CInt(DrawH / 2)
|
||||||
|
p3X = boxMidX + CInt(DrawW / 2)
|
||||||
|
p3Y = boxMidY + CInt(DrawH / 2)
|
||||||
|
p4X = boxMidX - CInt(DrawW / 2)
|
||||||
|
p4Y = boxMidY + CInt(DrawH / 2)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub get_drawboxParameters()
|
Private Sub get_drawboxParameters()
|
||||||
|
|
@ -35,18 +48,7 @@ Public Class GUI
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
Private Sub DrawingPanel_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs)
|
Private Sub DrawingPanel_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs)
|
||||||
Dim p1X As Integer = boxMidX - CInt(DrawW / 2)
|
|
||||||
Dim p1Y As Integer = boxMidY - CInt(DrawH / 2)
|
|
||||||
Dim p2X As Integer = boxMidX + CInt(DrawW / 2)
|
|
||||||
Dim p2Y As Integer = boxMidY - CInt(DrawH / 2)
|
|
||||||
Dim p3X As Integer = boxMidX + CInt(DrawW / 2)
|
|
||||||
Dim p3Y As Integer = boxMidY + CInt(DrawH / 2)
|
|
||||||
Dim p4X As Integer = boxMidX - CInt(DrawW / 2)
|
|
||||||
Dim p4Y As Integer = boxMidY + CInt(DrawH / 2)
|
|
||||||
|
|
||||||
|
|
||||||
Dim pen As Pen = New Pen(Color.Red, 2)
|
Dim pen As Pen = New Pen(Color.Red, 2)
|
||||||
e.Graphics.DrawLine(pen, p1X, p1Y, p2X, p2Y)
|
e.Graphics.DrawLine(pen, p1X, p1Y, p2X, p2Y)
|
||||||
e.Graphics.DrawLine(pen, p2X, p2Y, p3X, p3Y)
|
e.Graphics.DrawLine(pen, p2X, p2Y, p3X, p3Y)
|
||||||
|
|
@ -60,9 +62,26 @@ Public Class GUI
|
||||||
Aspect2 = GratingW / GratingH
|
Aspect2 = GratingW / GratingH
|
||||||
If Aspect2 > Aspect1 Then
|
If Aspect2 > Aspect1 Then
|
||||||
'Change draw height
|
'Change draw height
|
||||||
|
Dim wDiff As Double
|
||||||
|
wDiff = GratingW / DrawW
|
||||||
|
|
||||||
|
p1Y = boxMidY - CInt(GratingH / (wDiff * 2))
|
||||||
|
p2Y = boxMidY - CInt(GratingH / (wDiff * 2))
|
||||||
|
p3Y = boxMidY + CInt(GratingH / (wDiff * 2))
|
||||||
|
p4Y = boxMidY + CInt(GratingH / (wDiff * 2))
|
||||||
Else
|
Else
|
||||||
|
'Change draw width
|
||||||
|
Dim hDiff As Double
|
||||||
|
hDiff = GratingH / DrawH
|
||||||
|
|
||||||
|
p1X = boxMidX - CInt(GratingW / (hDiff * 2))
|
||||||
|
p2X = boxMidX + CInt(GratingW / (hDiff * 2))
|
||||||
|
p3X = boxMidX + CInt(GratingW / (hDiff * 2))
|
||||||
|
p4X = boxMidX - CInt(GratingW / (hDiff * 2))
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
'Redraw rectangle
|
||||||
|
Me.Refresh()
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
End Class
|
End Class
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue