X2021/Wardrobe/GUI.vb

49 lines
1.5 KiB
VB.net

Imports XCCLibrary
Public Class GUI
Dim DrawBox As Panel
Dim boxX, boxY, boxW, boxH, boxMidX, boxMidY As Integer
Dim gratingW, gratingH As Integer
Sub GUI_load() Handles MyBase.Load
DrawBox = DrawingPanel
AddHandler DrawBox.Paint, AddressOf DrawingPanel_Paint
get_drawboxParameters()
End Sub
Private Sub get_drawboxParameters()
boxX = DrawBox.Location.X 'Behövs ej
boxY = DrawBox.Location.Y 'Behövs ej
boxW = DrawBox.Size.Width
boxH = DrawBox.Size.Height
boxMidX = boxW / 2
boxMidY = boxH / 2
gratingW = boxW - 30
gratingH = boxH - 30
End Sub
Private Sub DrawingPanel_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs)
Dim p1X As Integer = boxMidX - CInt(gratingW / 2)
Dim p1Y As Integer = boxMidY - CInt(gratingH / 2)
Dim p2X As Integer = boxMidX + CInt(gratingW / 2)
Dim p2Y As Integer = boxMidY - CInt(gratingH / 2)
Dim p3X As Integer = boxMidX + CInt(gratingW / 2)
Dim p3Y As Integer = boxMidY + CInt(gratingH / 2)
Dim p4X As Integer = boxMidX - CInt(gratingW / 2)
Dim p4Y As Integer = boxMidY + CInt(gratingH / 2)
Dim pen As Pen = New Pen(Color.Red, 2)
e.Graphics.DrawLine(pen, p1X, p1Y, p2X, p2Y)
e.Graphics.DrawLine(pen, p2X, p2Y, p3X, p3Y)
e.Graphics.DrawLine(pen, p3X, p3Y, p4X, p4Y)
e.Graphics.DrawLine(pen, p4X, p4Y, p1X, p1Y)
End Sub
End Class