Imports Microsoft.VisualBasic.PowerPacks
Public Class Form1
Dim a As Integer = 1
Dim nbr_lignes As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim canvas As New Microsoft.VisualBasic.PowerPacks.ShapeContainer
canvas.Parent = Me
nbr_lignes = TextBox1.Text
For a = 1 To nbr_lignes
Dim yourline As New LineShape(100, (a * 100), 300, (a * 100))
yourline.Parent = canvas
Next
End Sub
End Class
Imports Microsoft.VisualBasic.PowerPacks
Public Class Form1
Dim nbr_lignes As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim canvas As New Microsoft.VisualBasic.PowerPacks.ShapeContainer
canvas.Parent = Me
nbr_lignes = TextBox1.Text
For i = 0 To nbr_lignes -1
Dim yourline As New LineShape(100, ((i+1) * 100), 300, ((i+1) * 100))
yourline.Parent = canvas
Next
End Sub
End Class
for i = 1 to nbr_lignes
for i = 0 to nbr_lignes - 1
nbr_lignes = TextBox1.Text
nbr_lignes = Convert.ToInt32(TextBox1.Text)
Picturebox1.Image = Nothing
Picturebox1.refresh()
une boucle pour dessiner les 18 rectangles
détermines tu les différentes lignes à y dessiner pour chaque dessin ?
Y-a-t'il un fichier pour le dessin en haut à gauche par exemple ?
La méthode Draw en VB net est bien plus performante
Une solution plus adéquate devrait être possible à mettre en œuvre
Dim g As Graphics
g = Me.PictureBox1.CreateGraphics
Dim p As Pen = New Pen(Color.Green, 2)
p.DashStyle = Drawing2D.DashStyle.Solid
g.DrawLine(p, X1, Y1, X2, X2)
Dim p As Pen = New Pen(Color.Green, 2)
p.DashStyle = Drawing2D.DashStyle.Solid
Dim Graph As Graphics
Graph = Me.PictureBox1.CreateGraphics
Dim paint As Pen = New Pen(Color.Green, 2)
paint.DashStyle = Drawing2D.DashStyle.Solid
Graph.DrawLine(paint, X1, Y1, X2, Y2)
Graph.DrawLine(paint, X1, Y1, X2/2, Y3)
Graph.DrawLine(paint, X2/2, Y3, X2, Y2)
End Sub
Public Sub DrawLinesPoint(ByVal e As PaintEventArgs)
' Create pen.
Dim blackPen As New Pen(Color.Black, 3)
' Create array of points that define lines to draw.
Dim points As Point() = {New Point(10, 10), New Point(10, 100), _
New Point(200, 50), New Point(250, 300)}
'Draw lines to screen.
e.Graphics.DrawLines(blackPen, points)
End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionPublic Sub DrawPolygonPoint(ByVal e As PaintEventArgs)
End Sub
Sub DrawPolygonPoint
End Sub
DrawPolygonPoint()dans le bouton
Dim p As Pen = New Pen(Color.Green, 2)
Dim g As Graphics
g = Me.PictureBox1.CreateGraphics
g.DashStyle = Drawing2D.DashStyle.Solid
g.DrawLine(p, X1, Y1, X2, X2)
' Create pen.
Dim blackPen As New Pen(Color.Black, 3)
Dim g As Graphics
g = Me.PictureBox1.CreateGraphics
' Create points that define polygon.
Dim point1 As New Point(50, 50)
Dim point2 As New Point(100, 25)
Dim point3 As New Point(200, 5)
Dim point4 As New Point(250, 50)
Dim point5 As New Point(300, 100)
Dim point6 As New Point(350, 200)
Dim point7 As New Point(250, 250)
Dim curvePoints As Point() = {point1, point2, point3, point4, _
point5, point6, point7}
' Draw polygon to screen.
g.Graphics.DrawPolygon(blackPen, curvePoints)
Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As PaintEventArgs) Handles Button1.Click
' Create pen.
Dim blackPen As New Pen(Color.Black, 3)
' Create points that define polygon.
Dim point1 As New Point(50, 50)
Dim point2 As New Point(100, 25)
Dim point3 As New Point(200, 5)
Dim point4 As New Point(250, 50)
Dim point5 As New Point(300, 100)
Dim point6 As New Point(350, 200)
Dim point7 As New Point(250, 250)
Dim curvePoints As Point() = {point1, point2, point3, point4, _
point5, point6, point7}
' Draw polygon to screen.
e.Graphics.DrawPolygon(blackPen, curvePoints)
End Sub
Dim g As Graphics
g = Me.PictureBox1.CreateGraphics
Dim p As Pen = New Pen(Color.Green, 2)
p.DashStyle = Drawing2D.DashStyle.Solid
g.DrawLine(p, X1, Y1, X2, X2)
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Dim g As Graphics g = PictureBox1.CreateGraphics ' Create pens Dim greenPen As New Pen(Color.Green, 2) Dim redPen As New Pen(Color.Red, 2) ' Create points for polygon. Dim p1 As New PointF(40.0F, 50.0F) Dim p2 As New PointF(60.0F, 70.0F) Dim p3 As New PointF(80.0F, 34.0F) Dim p4 As New PointF(120.0F, 180.0F) Dim p5 As New PointF(200.0F, 150.0F) Dim ptsArray As PointF() = {p1, p2, p3, p4, p5} ' Draw polygon g.DrawPolygon(greenPen, ptsArray) ' Dispose greenPen.Dispose() redPen.Dispose() End Sub
Option Strict On Public Class Form1 Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Dim g As Graphics Dim _y As Integer = 0 'position Top dans la pictureBox Dim _x As Integer = 0 'position Left dans la pictureBox g = PictureBox1.CreateGraphics ' Create pens Dim greenPen As New Pen(Color.Green, 2) Dim redPen As New Pen(Color.Red, 2) ' Créons les points qui définissent l'étoile: tourne dans le sens inverse des aiguilles d'une montre. Dim point1 As New Point(_y + 210, _x) 'A pointe supérieure Dim point2 As New Point(_y + 165, _x + 100) 'B Dim point3 As New Point(_y + 50, _x + 100) 'C pointe Dim point4 As New Point(_y + 150, _x + 170) 'D Dim point5 As New Point(_y + 100, _x + 280) 'E pointe Dim point6 As New Point(_y + 210, _x + 220) 'F Dim point7 As New Point(_y + 320, _x + 280) 'G pointe Dim point8 As New Point(_y + 280, _x + 170) 'H Dim point9 As New Point(_y + 350, _x + 100) 'I pointe Dim point10 As New Point(_y + 250, _x + 100) 'J Dim ptsArray As Point() = {point1, point2, point3, point4, _ point5, point6, point7, point8, point9, point10} ' Draw polygon g.DrawPolygon(redPen, ptsArray) ' Dispose greenPen.Dispose() redPen.Dispose() End Sub Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click Dim g As Graphics Dim _y As Integer = 10 'position Top dans la pictureBox Dim _x As Integer = 10 'position Left dans la pictureBox g = PictureBox1.CreateGraphics ' Create pens Dim redPen As New Pen(Color.Red, 2) Dim point1 As New Point(_y + 100, _x) 'A pointe supérieure Dim point2 As New Point(_y, _x + 150) 'B Dim point3 As New Point(_y + 200, _x + 150) 'C Dim rect As New Rectangle(_x, _y + 150, 200, 150) Dim curvePoints As Point() = {point1, point2, point3} ' Draw polygon g.DrawPolygon(redPen, curvePoints) g.DrawRectangle(redPen, rect) 'lignes horizontales g.DrawLine(redPen, _x, _y + 200, 210, 210) '_x = pointleft départ, _y pointTop départ, longueur ligne, fin de ligne Top g.DrawLine(redPen, _x, _y + 250, 210, 260) 'lignes verticales g.DrawLine(redPen, _x + 50, _y + 300, 60, 160) g.DrawLine(redPen, _x + 100, _y + 300, 110, 160) g.DrawLine(redPen, _x + 150, _y + 300, 160, 160) ' Dispose redPen.Dispose() End Sub End Class
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click Dim g As Graphics Dim _y As Integer = 0 'position Top dans la pictureBox Dim _x As Integer = 0 'position Left dans la pictureBox g = PictureBox1.CreateGraphics ' Create pens Dim redPen As New Pen(Color.Red, 2) Dim point1 As New Point(_y + 100, _x) 'A pointe supérieure Dim point2 As New Point(_y, _x + 150) 'B Dim point3 As New Point(_y + 200, _x + 150) 'C Dim rect As New Rectangle(_x, _y + 150, 200, 150) Dim curvePoints As Point() = {point1, point2, point3} ' Draw polygon g.DrawPolygon(redPen, curvePoints) g.DrawRectangle(redPen, rect) 'lignes horizontales g.DrawLine(redPen, _x, _y + 200, 200, 200) '_x = pointleft départ, _y pointTop départ, longueur ligne, fin de ligne Top g.DrawLine(redPen, _x, _y + 250, 200, 250) 'lignes verticales g.DrawLine(redPen, _x + 50, _y + 300, 50, 150) g.DrawLine(redPen, _x + 100, _y + 300, 100, 150) g.DrawLine(redPen, _x + 150, _y + 300, 150, 150) ' Dispose redPen.Dispose() End Sub
3 oct. 2016 à 10:26
Je vais appliquer tes conseilles un par un