Small grapahic changes

This commit is contained in:
Anton 2021-01-25 13:21:24 +01:00
parent 3c308ded70
commit 2405176d74
2 changed files with 64 additions and 33 deletions

View File

@ -28,30 +28,34 @@ Partial Class GUI
Me.HeightBox = New System.Windows.Forms.TextBox() Me.HeightBox = New System.Windows.Forms.TextBox()
Me.WidthBox = New System.Windows.Forms.TextBox() Me.WidthBox = New System.Windows.Forms.TextBox()
Me.ContextMenuStrip1 = New System.Windows.Forms.ContextMenuStrip(Me.components) Me.ContextMenuStrip1 = New System.Windows.Forms.ContextMenuStrip(Me.components)
Me.Button1 = New System.Windows.Forms.Button() Me.UpdateButton = New System.Windows.Forms.Button()
Me.Label1 = New System.Windows.Forms.Label()
Me.Label2 = New System.Windows.Forms.Label()
Me.SuspendLayout() Me.SuspendLayout()
' '
'DrawingPanel 'DrawingPanel
' '
Me.DrawingPanel.BackColor = System.Drawing.SystemColors.ActiveCaption Me.DrawingPanel.BackColor = System.Drawing.SystemColors.Window
Me.DrawingPanel.Location = New System.Drawing.Point(561, 202) Me.DrawingPanel.Location = New System.Drawing.Point(239, 95)
Me.DrawingPanel.Margin = New System.Windows.Forms.Padding(3, 2, 3, 2) Me.DrawingPanel.Margin = New System.Windows.Forms.Padding(2)
Me.DrawingPanel.Name = "DrawingPanel" Me.DrawingPanel.Name = "DrawingPanel"
Me.DrawingPanel.Size = New System.Drawing.Size(751, 338) Me.DrawingPanel.Size = New System.Drawing.Size(649, 393)
Me.DrawingPanel.TabIndex = 0 Me.DrawingPanel.TabIndex = 0
' '
'HeightBox 'HeightBox
' '
Me.HeightBox.Location = New System.Drawing.Point(640, 144) Me.HeightBox.Location = New System.Drawing.Point(503, 51)
Me.HeightBox.Margin = New System.Windows.Forms.Padding(2)
Me.HeightBox.Name = "HeightBox" Me.HeightBox.Name = "HeightBox"
Me.HeightBox.Size = New System.Drawing.Size(100, 22) Me.HeightBox.Size = New System.Drawing.Size(76, 20)
Me.HeightBox.TabIndex = 1 Me.HeightBox.TabIndex = 1
' '
'WidthBox 'WidthBox
' '
Me.WidthBox.Location = New System.Drawing.Point(845, 144) Me.WidthBox.Location = New System.Drawing.Point(343, 51)
Me.WidthBox.Margin = New System.Windows.Forms.Padding(2)
Me.WidthBox.Name = "WidthBox" Me.WidthBox.Name = "WidthBox"
Me.WidthBox.Size = New System.Drawing.Size(100, 22) Me.WidthBox.Size = New System.Drawing.Size(76, 20)
Me.WidthBox.TabIndex = 2 Me.WidthBox.TabIndex = 2
' '
'ContextMenuStrip1 'ContextMenuStrip1
@ -60,28 +64,48 @@ Partial Class GUI
Me.ContextMenuStrip1.Name = "ContextMenuStrip1" Me.ContextMenuStrip1.Name = "ContextMenuStrip1"
Me.ContextMenuStrip1.Size = New System.Drawing.Size(61, 4) Me.ContextMenuStrip1.Size = New System.Drawing.Size(61, 4)
' '
'Button1 'UpdateButton
' '
Me.Button1.Location = New System.Drawing.Point(1074, 152) Me.UpdateButton.Location = New System.Drawing.Point(669, 51)
Me.Button1.Name = "Button1" Me.UpdateButton.Margin = New System.Windows.Forms.Padding(2)
Me.Button1.Size = New System.Drawing.Size(75, 23) Me.UpdateButton.Name = "UpdateButton"
Me.Button1.TabIndex = 3 Me.UpdateButton.Size = New System.Drawing.Size(56, 19)
Me.Button1.Text = "Button1" Me.UpdateButton.TabIndex = 3
Me.Button1.UseVisualStyleBackColor = True Me.UpdateButton.Text = "Update"
Me.UpdateButton.UseVisualStyleBackColor = True
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Location = New System.Drawing.Point(303, 54)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(35, 13)
Me.Label1.TabIndex = 4
Me.Label1.Text = "Width"
'
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.Location = New System.Drawing.Point(460, 54)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(38, 13)
Me.Label2.TabIndex = 5
Me.Label2.Text = "Height"
' '
'GUI 'GUI
' '
Me.AutoScaleDimensions = New System.Drawing.SizeF(8.0!, 16.0!) Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(1324, 551) Me.ClientSize = New System.Drawing.Size(899, 499)
Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.UpdateButton)
Me.Controls.Add(Me.WidthBox) Me.Controls.Add(Me.WidthBox)
Me.Controls.Add(Me.HeightBox) Me.Controls.Add(Me.HeightBox)
Me.Controls.Add(Me.DrawingPanel) Me.Controls.Add(Me.DrawingPanel)
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon) Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.Margin = New System.Windows.Forms.Padding(4)
Me.Name = "GUI" Me.Name = "GUI"
Me.Text = "Build a wardrobe" Me.Text = "Floor Gratings"
Me.ResumeLayout(False) Me.ResumeLayout(False)
Me.PerformLayout() Me.PerformLayout()
@ -91,5 +115,7 @@ Partial Class GUI
Friend WithEvents HeightBox As TextBox Friend WithEvents HeightBox As TextBox
Friend WithEvents WidthBox As TextBox Friend WithEvents WidthBox As TextBox
Friend WithEvents ContextMenuStrip1 As ContextMenuStrip Friend WithEvents ContextMenuStrip1 As ContextMenuStrip
Friend WithEvents Button1 As Button Friend WithEvents UpdateButton As Button
Friend WithEvents Label1 As Label
Friend WithEvents Label2 As Label
End Class End Class

View File

@ -15,23 +15,25 @@ Public Class GUI
AddHandler DrawBox.Paint, AddressOf DrawingPanel_Paint AddHandler DrawBox.Paint, AddressOf DrawingPanel_Paint
get_drawboxParameters() get_drawboxParameters()
set_startPoints() set_startPointsX()
set_startPointsY()
End Sub End Sub
Private Sub set_startPoints() Private Sub set_startPointsX()
p1X = boxMidX - CInt(DrawW / 2) p1X = boxMidX - CInt(DrawW / 2)
p1Y = boxMidY - CInt(DrawH / 2)
p2X = boxMidX + CInt(DrawW / 2) p2X = boxMidX + CInt(DrawW / 2)
p2Y = boxMidY - CInt(DrawH / 2)
p3X = boxMidX + CInt(DrawW / 2) p3X = boxMidX + CInt(DrawW / 2)
p3Y = boxMidY + CInt(DrawH / 2)
p4X = boxMidX - CInt(DrawW / 2) p4X = boxMidX - CInt(DrawW / 2)
End Sub
Private Sub set_startPointsY()
p1Y = boxMidY - CInt(DrawH / 2)
p2Y = boxMidY - CInt(DrawH / 2)
p3Y = boxMidY + CInt(DrawH / 2)
p4Y = boxMidY + CInt(DrawH / 2) p4Y = boxMidY + CInt(DrawH / 2)
End Sub End Sub
Private Sub get_drawboxParameters() Private Sub get_drawboxParameters()
boxX = DrawBox.Location.X 'Behövs ej boxX = DrawBox.Location.X 'Behövs ej
boxY = DrawBox.Location.Y 'Behövs ej boxY = DrawBox.Location.Y 'Behövs ej
@ -41,11 +43,10 @@ Public Class GUI
boxMidX = boxW / 2 boxMidX = boxW / 2
boxMidY = boxH / 2 boxMidY = boxH / 2
DrawW = boxW - 30 DrawW = boxW - 50
DrawH = boxH - 30 DrawH = boxH - 50
Aspect1 = DrawW / DrawH Aspect1 = DrawW / DrawH
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)
@ -56,7 +57,7 @@ Public Class GUI
e.Graphics.DrawLine(pen, p4X, p4Y, p1X, p1Y) e.Graphics.DrawLine(pen, p4X, p4Y, p1X, p1Y)
End Sub End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Private Sub UpdateButton_Click(sender As Object, e As EventArgs) Handles UpdateButton.Click
GratingH = HeightBox.Text GratingH = HeightBox.Text
GratingW = WidthBox.Text GratingW = WidthBox.Text
Aspect2 = GratingW / GratingH Aspect2 = GratingW / GratingH
@ -69,6 +70,8 @@ Public Class GUI
p2Y = boxMidY - CInt(GratingH / (wDiff * 2)) p2Y = boxMidY - CInt(GratingH / (wDiff * 2))
p3Y = boxMidY + CInt(GratingH / (wDiff * 2)) p3Y = boxMidY + CInt(GratingH / (wDiff * 2))
p4Y = boxMidY + CInt(GratingH / (wDiff * 2)) p4Y = boxMidY + CInt(GratingH / (wDiff * 2))
set_startPointsX()
Else Else
'Change draw width 'Change draw width
Dim hDiff As Double Dim hDiff As Double
@ -78,6 +81,8 @@ Public Class GUI
p2X = boxMidX + CInt(GratingW / (hDiff * 2)) p2X = boxMidX + CInt(GratingW / (hDiff * 2))
p3X = boxMidX + CInt(GratingW / (hDiff * 2)) p3X = boxMidX + CInt(GratingW / (hDiff * 2))
p4X = boxMidX - CInt(GratingW / (hDiff * 2)) p4X = boxMidX - CInt(GratingW / (hDiff * 2))
set_startPointsY()
End If End If
'Redraw rectangle 'Redraw rectangle