From dd9f8d661712efbc6ee146e0c257969b909c0b75 Mon Sep 17 00:00:00 2001 From: Mans Date: Mon, 25 Jan 2021 12:45:20 +0100 Subject: [PATCH] If sats --- Wardrobe/GUI.Designer.vb | 53 ++++++++++++++++++++++++++++++++++++---- Wardrobe/GUI.resx | 3 +++ Wardrobe/GUI.vb | 42 ++++++++++++++++++++++--------- 3 files changed, 82 insertions(+), 16 deletions(-) diff --git a/Wardrobe/GUI.Designer.vb b/Wardrobe/GUI.Designer.vb index be4d3d8..7307279 100644 --- a/Wardrobe/GUI.Designer.vb +++ b/Wardrobe/GUI.Designer.vb @@ -22,31 +22,74 @@ Partial Class GUI 'Do not modify it using the code editor. _ Private Sub InitializeComponent() + Me.components = New System.ComponentModel.Container() Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(GUI)) Me.DrawingPanel = New System.Windows.Forms.Panel() + Me.HeightBox = New System.Windows.Forms.TextBox() + Me.WidthBox = New System.Windows.Forms.TextBox() + Me.ContextMenuStrip1 = New System.Windows.Forms.ContextMenuStrip(Me.components) + Me.Button1 = New System.Windows.Forms.Button() Me.SuspendLayout() ' 'DrawingPanel ' Me.DrawingPanel.BackColor = System.Drawing.SystemColors.ActiveCaption - Me.DrawingPanel.Location = New System.Drawing.Point(90, 41) - Me.DrawingPanel.Margin = New System.Windows.Forms.Padding(2, 2, 2, 2) + Me.DrawingPanel.Location = New System.Drawing.Point(561, 202) + Me.DrawingPanel.Margin = New System.Windows.Forms.Padding(3, 2, 3, 2) Me.DrawingPanel.Name = "DrawingPanel" - Me.DrawingPanel.Size = New System.Drawing.Size(563, 275) + Me.DrawingPanel.Size = New System.Drawing.Size(751, 338) Me.DrawingPanel.TabIndex = 0 ' + 'HeightBox + ' + Me.HeightBox.Location = New System.Drawing.Point(640, 144) + Me.HeightBox.Name = "HeightBox" + Me.HeightBox.Size = New System.Drawing.Size(100, 22) + Me.HeightBox.TabIndex = 1 + ' + 'WidthBox + ' + Me.WidthBox.Location = New System.Drawing.Point(845, 144) + Me.WidthBox.Name = "WidthBox" + Me.WidthBox.Size = New System.Drawing.Size(100, 22) + Me.WidthBox.TabIndex = 2 + ' + 'ContextMenuStrip1 + ' + Me.ContextMenuStrip1.ImageScalingSize = New System.Drawing.Size(20, 20) + Me.ContextMenuStrip1.Name = "ContextMenuStrip1" + Me.ContextMenuStrip1.Size = New System.Drawing.Size(61, 4) + ' + 'Button1 + ' + Me.Button1.Location = New System.Drawing.Point(1074, 152) + Me.Button1.Name = "Button1" + Me.Button1.Size = New System.Drawing.Size(75, 23) + Me.Button1.TabIndex = 3 + Me.Button1.Text = "Button1" + Me.Button1.UseVisualStyleBackColor = True + ' 'GUI ' - Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleDimensions = New System.Drawing.SizeF(8.0!, 16.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font - Me.ClientSize = New System.Drawing.Size(993, 448) + Me.ClientSize = New System.Drawing.Size(1324, 551) + Me.Controls.Add(Me.Button1) + Me.Controls.Add(Me.WidthBox) + Me.Controls.Add(Me.HeightBox) Me.Controls.Add(Me.DrawingPanel) Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon) + Me.Margin = New System.Windows.Forms.Padding(4) Me.Name = "GUI" Me.Text = "Build a wardrobe" Me.ResumeLayout(False) + Me.PerformLayout() End Sub Friend WithEvents DrawingPanel As Panel + Friend WithEvents HeightBox As TextBox + Friend WithEvents WidthBox As TextBox + Friend WithEvents ContextMenuStrip1 As ContextMenuStrip + Friend WithEvents Button1 As Button End Class diff --git a/Wardrobe/GUI.resx b/Wardrobe/GUI.resx index 7c9b918..c8aa1a5 100644 --- a/Wardrobe/GUI.resx +++ b/Wardrobe/GUI.resx @@ -117,6 +117,9 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + diff --git a/Wardrobe/GUI.vb b/Wardrobe/GUI.vb index d898602..26297f4 100644 --- a/Wardrobe/GUI.vb +++ b/Wardrobe/GUI.vb @@ -3,7 +3,10 @@ Public Class GUI Dim DrawBox As Panel Dim boxX, boxY, boxW, boxH, boxMidX, boxMidY As Integer - Dim gratingW, gratingH As Integer + Dim GratingW, GratingH As Double + Dim DrawW, DrawH As Integer + Dim Aspect1, Aspect2 As Double + Sub GUI_load() Handles MyBase.Load @@ -14,6 +17,8 @@ Public Class GUI End Sub Private Sub get_drawboxParameters() + + boxX = DrawBox.Location.X 'Behövs ej boxY = DrawBox.Location.Y 'Behövs ej @@ -23,19 +28,23 @@ Public Class GUI boxMidX = boxW / 2 boxMidY = boxH / 2 - gratingW = boxW - 30 - gratingH = boxH - 30 + 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(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 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) @@ -45,4 +54,15 @@ Public Class GUI 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