Système de signature

Résolu/Fermé
Programming_018 Messages postés 106 Date d'inscription vendredi 13 janvier 2017 Statut Membre Dernière intervention 14 mars 2024 - 3 sept. 2020 à 22:43
Programming_018 Messages postés 106 Date d'inscription vendredi 13 janvier 2017 Statut Membre Dernière intervention 14 mars 2024 - 4 sept. 2020 à 14:15
Bonjour,

Je me permet de poser la question car internet ne me parle pas de ceci.

Je suis entrain de programmer un logiciel sur vb.net de gestion de dépannage auquel quand je créer le bon de dépannage le/la client/e doit signer avec son doigt ou le stylet.

Pour le moment j'ai réussi à créer un pseudo système avec la function DrawEllipse mais le problème c'est que avec le tactile cela ne forme pas de ligne au contraire cela créer plein de rond. Donc ce n'est pas très professionnel.


Voici mon code pour la partie de la signature :

'Signature
Dim mustDraw As Boolean
Dim previousPosition As Point
Dim bmpGraphics As Graphics
Dim bitmap As Bitmap
Dim bitmap_clone As Bitmap
'Fin Signature


Private Sub PBSignature_MouseDown(sender As Object, e As MouseEventArgs) Handles PBSignature.MouseDown
        If e.Button = MouseButtons.Left Then
            mustDraw = True 'Activation de la variable mustDraw si on appuis sur le bouton gauche
        End If
    End Sub

    Private Sub PBSignature_MouseUp(sender As Object, e As MouseEventArgs) Handles PBSignature.MouseUp
        If e.Button = MouseButtons.Left Then
            mustDraw = False 'Désactivation de la variable mustDraw si on relâche le bouton gauche
            previousPosition = Point.Empty
        End If
    End Sub

    Private Sub PBSignature_MouseMove(sender As Object, e As MouseEventArgs) Handles PBSignature.MouseMove
        If mustDraw Then
            Try
                bmpGraphics.Dispose()
            Catch ex As Exception

            End Try
            bmpGraphics = Graphics.FromImage(bitmap)

            Dim currentPosition As Point = New Point(e.X, e.Y)

            If previousPosition = Point.Empty Then
                previousPosition = currentPosition
            End If

            Dim blackPen As Pen = New Pen(Color.Black, 6.5F)

            bmpGraphics.DrawEllipse(blackPen, e.X, e.Y, 1, 1)
            previousPosition = currentPosition
            PBSignature.Invalidate()
        End If
    End Sub

    Private Sub PBSignature_Paint(sender As Object, e As PaintEventArgs) Handles PBSignature.Paint
        Dim g As Graphics = PBSignature.CreateGraphics()
        g.DrawImage(bitmap, 0, 0)
    End Sub

    Private Sub BtnSupprSignature_Click(sender As Object, e As EventArgs) Handles BtnSupprSignature.Click
        bitmap.Dispose()
        PBSignature.Image = Nothing
        bitmap = New Bitmap(PBSignature.Width, PBSignature.Height)
        PBSignature.Image = bitmap
    End Sub


Merci de m'aider à résoudre ce petit problème s'il vous plaît ?

Cordialement.

2 réponses

yg_be Messages postés 22720 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 23 avril 2024 1 476
4 sept. 2020 à 12:55
1
Programming_018 Messages postés 106 Date d'inscription vendredi 13 janvier 2017 Statut Membre Dernière intervention 14 mars 2024 7
4 sept. 2020 à 14:15
Merci beaucoup. Bonne journée.
0