Forum: VB.NET |
Thema:
Re: zeichnen |
Von:
Tobi Ulm (
05.12.2005 10:51) |
Hi ?,
der Code ist zwar quick and dirty, aber ausbauen kannst Du dass ja dann selber!
<code>
Public Class Form3
Inherits System.Windows.Forms.Form
#Region " Vom Windows Form Designer generierter Code "
Public Sub New()
MyBase.New()
' Dieser Aufruf ist für den Windows Form-Designer erforderlich.
InitializeComponent()
' Initialisierungen nach dem Aufruf InitializeComponent() hinzufügen
End Sub
' Die Form überschreibt den Löschvorgang der Basisklasse, um Komponenten zu bereinigen.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
' Für Windows Form-Designer erforderlich
Private components As System.ComponentModel.IContainer
'HINWEIS: Die folgende Prozedur ist für den Windows Form-Designer erforderlich
'Sie kann mit dem Windows Form-Designer modifiziert werden.
'Verwenden Sie nicht den Code-Editor zur Bearbeitung.
Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.PictureBox1 = New System.Windows.Forms.PictureBox
Me.SuspendLayout()
'
'PictureBox1
'
Me.PictureBox1.Dock = System.Windows.Forms.DockStyle.Fill
Me.PictureBox1.Location = New System.Drawing.Point(0, 0)
Me.PictureBox1.Name = "PictureBox1"
Me.PictureBox1.Size = New System.Drawing.Size(292, 266)
Me.PictureBox1.TabIndex = 0
Me.PictureBox1.TabStop = False
'
'Form3
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Controls.Add(Me.PictureBox1)
Me.Name = "Form3"
Me.Text = "Form3"
Me.ResumeLayout(False)
End Sub
#End Region
Private startPoint As PointF
Private Sub DrawTest_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
If e.Button = MouseButtons.Left Then
Dim pointStart As New PointF(e.X, e.Y)
Me.startPoint = pointStart
End If
End Sub
Private Sub DrawLine(ByVal g As Graphics, ByVal pointStart As PointF, ByVal pointEnd As PointF)
Dim drawingPent As New Pen(Color.Black, 2)
g.DrawLine(drawingPent, pointStart, pointEnd)
End Sub
Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
Dim pointEnd As New PointF(e.X, e.Y)
Dim g As Graphics = PictureBox1.CreateGraphics()
DrawLine(g, Me.startPoint, pointEnd)
End Sub
End Class
</code>
cu
Tobi
Betreff |
Von |
Datum |
|
|
G.
Guest
|
05.12.2005 18:45 |
|
|
Antworten
Vorsicht bei der Eingabe: Die Zeichen ' oder -- sind nicht erlaubt!