bjr à tous,
svp j'ai besoin de votre aide pour achevé mon mini projet,(VB.NET).
le projet consiste a envoyer un fichier soit .txt ou excel qui contient des coordonnées X,Y par le port serie rs232 et a la reception ontrouve ces coordonnées sous forme d'un graphe représenté sur un repère.
j'ai commencé par ce code là qui permet de dessiner les axes en cliquant sur un bouton et dessiner la courbe en cliquant sur un autre:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
Public Class Courbe 
 
Private Sub Courbe_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize 
PictureBox1.Size = Me.Size 
 
End Sub 
 
Private Sub QuitterToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles QuitterToolStripMenuItem.Click 
End 
End Sub 
 
Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click 
Dim g As Graphics 
g = PictureBox1.CreateGraphics 
g.SmoothingMode = Drawing2D.SmoothingMode.HighQuality 
Dim stylo As Pen = Pens.Black 
g.DrawLine(stylo, 20, 30, 200, 300) 
'stylo.Dispose() 
'g.Dispose() 
 
End Sub 
 
Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click 
PictureBox1.Image = New Bitmap(PictureBox1.Width, PictureBox1.Height) 
Dim myBitmap1 As Bitmap = PictureBox1.Image 
Dim g As Graphics = Graphics.FromImage(myBitmap1) 
g.PageUnit = GraphicsUnit.Millimeter 
g.SmoothingMode = Drawing2D.SmoothingMode.HighQuality 
'Dim stylo As Pen = Pens.Red 
'g.DrawLine(stylo, 50, 40, 200, 300) 
'stylo.Dispose() 
 
 
Axe_H(g, 10, 150) 
g.Dispose() 
 
End Sub 
 
 
Private Sub Axe_H(ByRef g As Graphics, ByVal x0 As Single, ByVal y0 As Single) 
Dim stylo As Pen = New Pen(Color.Blue, 0.1F) 
Dim stylo2 As Pen = New Pen(Color.Red, 0.1F) 
Dim Fnt As Font = New Font("MS Sans Serif", 8.25F) 
 
 
g.DrawLine(stylo, x0, y0, x0 + 200, y0) 
 
For j = 0 To 100 
g.DrawLine(stylo, x0 + j, y0, x0 + j, y0 + 3) 
Next 
 
 
 
For j = 0 To 100 Step 10 
g.DrawLine(stylo2, x0 + j, y0, x0 + j, y0 + 5) 
g.DrawString(Str(j / 10), Fnt, Brushes.Black, x0 + j - Fnt.GetHeight(g) / 2, y0 + 6) 
Next 
 
 
End Sub 
 
Private Sub ToolStripButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton3.Click 
Dim x1 As Single = 200 * Rnd() 
Dim y1 As Single = 150 * Rnd() 
' PictureBox1.Image = New Bitmap(PictureBox1.Width, PictureBox1.Height) 
Dim myBitmap1 As Bitmap = PictureBox1.Image 
Dim g As Graphics = Graphics.FromImage(myBitmap1) 
g.PageUnit = GraphicsUnit.Millimeter 
g.SmoothingMode = Drawing2D.SmoothingMode.HighQuality 
g.DrawRectangle(Pens.Green, x1, y1, 0.1F, 0.1F) 
g.Dispose() 
PictureBox1.Refresh() 
End Sub 
 
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage 
e.Graphics.PageUnit = GraphicsUnit.Millimeter 
Axe_H(e.Graphics, 10, 150) 
End Sub 
 
Private Sub ImprimerToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ImprimerToolStripMenuItem.Click 
PrintDocument1.Print() 
End Sub 
End Class
mon probléme est comment dessiner à partir des coordonnées et comment accéder à eux dans un fichier txt et les utiliser..
J'ai un autre problème c'est que j'ai le code de transfert par port série et je sais pas comment faire le lien entre le reste de code..
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
Public Class Form1
 
Dim WithEvents serialPort As New IO.Ports.SerialPort
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
 
For i As Integer = 0 To _
My.Computer.Ports.SerialPortNames.Count - 1
cbbCOMPorts.Items.Add(My.Computer.Ports.SerialPortNames(i))
Next
If cbbCOMPorts.Items.Count <> 0 Then cbbCOMPorts.SelectedIndex = 0
 
btnDisconnect.Enabled = False
 
End Sub
 
 
'-------------------------------------------
' Event handler for the Connect button
'-------------------------------------------
Private Sub btnConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConnect.Click
 
If serialPort.IsOpen Then
serialPort.Close()
End If
 
Try
With serialPort
.PortName = cbbCOMPorts.Text
.BaudRate = 9600
.Parity = IO.Ports.Parity.None
.DataBits = 8
.StopBits = IO.Ports.StopBits.One
End With
serialPort.Open()
 
lblMessage.Text = cbbCOMPorts.Text & " connected."
btnConnect.Enabled = False
btnDisconnect.Enabled = True
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
 
'-------------------------------------------
' Event handler for the Disconnect button
'-------------------------------------------
Private Sub btnDisconnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisconnect.Click
Try
serialPort.Close()
lblMessage.Text = serialPort.PortName & " disconnected."
btnConnect.Enabled = True
btnDisconnect.Enabled = False
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
 
'-------------------------------------------
' Event handler for the Send button
'-------------------------------------------
Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
Try
serialPort.Write(txtDataToSend.Text & vbCrLf)
With txtDataReceived
.SelectionColor = Color.Black
.AppendText(txtDataToSend.Text & vbCrLf)
.ScrollToCaret()
End With
txtDataToSend.Text = String.Empty
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
 
'-------------------------------------------
' Event handler for the DataReceived
'-------------------------------------------
Private Sub DataReceived( _
ByVal sender As Object, _
ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) _
Handles serialPort.DataReceived
 
txtDataReceived.Invoke(New _
myDelegate(AddressOf updateTextBox), _
New Object() {})
End Sub
 
'------------------------------------------------------
' Delegate and subroutine to update the Textbox control
'------------------------------------------------------
Public Delegate Sub myDelegate()
Public Sub updateTextBox()
With txtDataReceived
.Font = New Font("Garamond", 12.0!, FontStyle.Bold)
.SelectionColor = Color.Red
.AppendText(serialPort.ReadExisting)
.ScrollToCaret()
End With
End Sub
 
End Class
j'aime aussi trouver un logiciel qui fait une liaison série virtuel pour tester tout ca.

je suis débutant en programmation et j'ai besoin de votre aide
merci