Imports XCCLibrary Public Class GUI Dim DrawBox As Panel Dim boxX, boxY, boxW, boxH, boxMidX, boxMidY As Integer Dim GratingW, GratingH As Double Dim DrawW, DrawH As Integer Dim Aspect1, Aspect2 As Double 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 DrawW = boxW - 30 DrawH = boxH - 30 Aspect1 = DrawW / DrawH End Sub 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) 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 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click GratingH = HeightBox.Text GratingW = WidthBox.Text Aspect2 = GratingW / GratingH If Aspect2 > Aspect1 Then 'Change draw height Else End If End Sub End Class