Draw lines on panel
This commit is contained in:
parent
ad8dc6f6dc
commit
5921ba4b84
|
|
@ -23,30 +23,30 @@ Partial Class GUI
|
||||||
<System.Diagnostics.DebuggerStepThrough()> _
|
<System.Diagnostics.DebuggerStepThrough()> _
|
||||||
Private Sub InitializeComponent()
|
Private Sub InitializeComponent()
|
||||||
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(GUI))
|
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(GUI))
|
||||||
Me.Panel1 = New System.Windows.Forms.Panel()
|
Me.DrawingPanel = New System.Windows.Forms.Panel()
|
||||||
Me.SuspendLayout()
|
Me.SuspendLayout()
|
||||||
'
|
'
|
||||||
'Panel1
|
'DrawingPanel
|
||||||
'
|
'
|
||||||
Me.Panel1.BackColor = System.Drawing.SystemColors.ControlLight
|
Me.DrawingPanel.BackColor = System.Drawing.SystemColors.ActiveCaption
|
||||||
Me.Panel1.Location = New System.Drawing.Point(702, 152)
|
Me.DrawingPanel.Location = New System.Drawing.Point(277, 138)
|
||||||
Me.Panel1.Name = "Panel1"
|
Me.DrawingPanel.Name = "DrawingPanel"
|
||||||
Me.Panel1.Size = New System.Drawing.Size(610, 388)
|
Me.DrawingPanel.Size = New System.Drawing.Size(751, 339)
|
||||||
Me.Panel1.TabIndex = 0
|
Me.DrawingPanel.TabIndex = 0
|
||||||
'
|
'
|
||||||
'GUI
|
'GUI
|
||||||
'
|
'
|
||||||
Me.AutoScaleDimensions = New System.Drawing.SizeF(8.0!, 16.0!)
|
Me.AutoScaleDimensions = New System.Drawing.SizeF(8.0!, 16.0!)
|
||||||
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
|
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
|
||||||
Me.ClientSize = New System.Drawing.Size(1324, 552)
|
Me.ClientSize = New System.Drawing.Size(1324, 552)
|
||||||
Me.Controls.Add(Me.Panel1)
|
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, 4, 4, 4)
|
Me.Margin = New System.Windows.Forms.Padding(4)
|
||||||
Me.Name = "GUI"
|
Me.Name = "GUI"
|
||||||
Me.Text = "Build a wardrobe"
|
Me.Text = "Build a wardrobe"
|
||||||
Me.ResumeLayout(False)
|
Me.ResumeLayout(False)
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Friend WithEvents Panel1 As Panel
|
Friend WithEvents DrawingPanel As Panel
|
||||||
End Class
|
End Class
|
||||||
|
|
|
||||||
|
|
@ -1,52 +1,30 @@
|
||||||
Imports XCCLibrary
|
Imports XCCLibrary
|
||||||
|
|
||||||
Public Class GUI
|
Public Class GUI
|
||||||
Public Shared Surface As Graphics
|
Dim DrawBox As Panel
|
||||||
Public Shared line As Integer = 0
|
Dim boxX, boxY, boxW, boxH, boxMidX, boxMidY As Integer
|
||||||
Public Shared point1 As Integer = 0
|
|
||||||
Public Shared point2 As Integer = 0
|
|
||||||
Public Shared point1p
|
|
||||||
Public Shared point2p
|
|
||||||
Public Shared mpos
|
|
||||||
Sub GUI_load() Handles MyBase.Load
|
|
||||||
Surface = CreateGraphics()
|
|
||||||
get_drawbox()
|
|
||||||
|
|
||||||
|
Sub GUI_load() Handles MyBase.Load
|
||||||
|
DrawBox = DrawingPanel
|
||||||
|
|
||||||
|
AddHandler DrawBox.Paint, AddressOf DrawingPanel_Paint
|
||||||
|
get_drawboxParameters()
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub get_drawbox()
|
Private Sub get_drawboxParameters()
|
||||||
Dim DrawBox As Panel
|
boxX = DrawBox.Location.X
|
||||||
DrawBox = Panel1
|
boxY = DrawBox.Location.Y
|
||||||
|
|
||||||
Dim locX, locY As Integer
|
|
||||||
locX = DrawBox.Location.X
|
|
||||||
locY = DrawBox.Location.Y
|
|
||||||
|
|
||||||
Dim boxW, boxH As Integer
|
|
||||||
boxW = DrawBox.Size.Width
|
boxW = DrawBox.Size.Width
|
||||||
boxH = DrawBox.Size.Height
|
boxH = DrawBox.Size.Height
|
||||||
|
|
||||||
Dim boxMidX, boxMidY As Integer
|
boxMidX = boxX + boxW / 2
|
||||||
boxMidX = locX + boxW / 2
|
boxMidY = boxY + boxH / 2
|
||||||
boxMidY = locY + boxH / 2
|
End Sub
|
||||||
|
|
||||||
|
Private Sub DrawingPanel_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs)
|
||||||
Dim pen As Pen = New Pen(Color.Red, 2)
|
Dim pen As Pen = New Pen(Color.Red, 2)
|
||||||
Surface.DrawLine(pen, boxMidX, boxMidY, locX, locY)
|
e.Graphics.DrawLine(pen, boxMidX, boxMidY, boxMidX + 1, boxMidY + 1)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub mouse_cl(sender As Object, e As MouseEventArgs) Handles Me.MouseClick
|
|
||||||
mpos = e
|
|
||||||
If point1 = 0 And point2 = 0 Then
|
|
||||||
point1p = mpos
|
|
||||||
point1 = 1
|
|
||||||
ElseIf point1 = 1 And point2 = 0 Then
|
|
||||||
point2p = mpos
|
|
||||||
point2 = 1
|
|
||||||
|
|
||||||
Dim pen1 As Pen = New Pen(Color.Red, 2)
|
|
||||||
Surface.DrawLine(pen1, point1p.X, point1p.Y, point2p.X, point2p.Y)
|
|
||||||
point1 = 0
|
|
||||||
point2 = 0
|
|
||||||
End If
|
|
||||||
End Sub
|
|
||||||
End Class
|
End Class
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue