IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VB.NET Discussion :

Comment implémenter dijkstra


Sujet :

VB.NET

  1. #21
    Membre extrêmement actif
    Inscrit en
    Avril 2008
    Messages
    2 573
    Détails du profil
    Informations personnelles :
    Âge : 65

    Informations forums :
    Inscription : Avril 2008
    Messages : 2 573
    Par défaut DJISKRA,suite
    bonjour chackadar,
    alors pour compter le nombre de ligne lues c'est simple il faut un drapeau dans la derniere ligne,c'est une astuce que j'ai apprise dans les premiers fichiers en fortran.
    il suffit que l'user mette dans la derniere ligne vide premiere colonne une valeur chaine par exemple:
    cells(325,1)="FIN" avec un petit message alerte(messagebox) qui affiche le nombre de lignes lues.
    Une autre methode c'est tester la deniere ligne vide dans excel,voici une fonction de mon cru qui renvoie la derniere ligne de la feuille en cours.

    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
     
    'nota bene:il faut declarer la variable de retour numDernLig au niveau de 
    'la  classe form pourqu'elle soit accessible  à la valeur  nbLig .
    On ecrira suite : nbLig=numDernLig-1
     Private Function DerniereLigVide(ByVal FeuilleCourante As Excel.Worksheet) As Integer
            Dim colonneDepart As Excel.Range = Nothing
            Dim ligVide As Excel.Range = Nothing
     
            numDernLig = 0
            colonneDepart = FeuilleCourante.Cells(1, 1).EntireColumn
            ligVide = colonneDepart.SpecialCells(Excel.XlCellType.xlCellTypeBlanks, Excel.XlSpecialCellsValue.xlTextValues)
            If ligVide Is Nothing Then
                MessageBox.Show("Pas de Derniere Ligne Vide dans votre Feuille sur Colonne depart(A1).Corriger derniere cellule vide avec Format texte et valeur= Touche Suppr..")
                Exit Function
            Else
                'format en couleur de la derniere cellule vide
                ligVide.ClearContents()
                ligVide.Interior.ColorIndex = 8
            End If
     
            numDernLig = ligVide.Row
            Return numDernLig
        End Function
    Maintenant pour afficher le chemin je prefere que tu utilise le graphisme-controle MSGLEE- pour avoir un avant-gout surtout si le graphe est dense.
    Un dessin vaut mieux que cent discours.
    Ensuite tu vas avoir un apercu de l'utilisation des classes et des listes.
    Pour ce faire je l'avais deja prepare et j'attendais cette question.
    Pour cela l'artillerie lourde :
    -une petite classe cheminGraphe
    -une liste des chemins LienChemin
    -un combobox pour choisir le chemin.
    -bouton Rechercher le chemin
    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
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
     
     
    'projet principal frmFloydWarshal
    'NB:frmChemin boite de selection d'un chemin
    'à ajouter au projet principal
    '------------------------------------------
    '1 AJOUTER REFERENCE À  :
    '- Microsoft.Glee.dll,Microsoft.Glee.Drawing.dll
    '- QuickGraph.dll , QuickGraph.Glee.dll
    '- Microsot Excel 11.0 Object Library(office 2003) ou bien
    '- Microsot Excel 12.0 Object Library(office 2007) 
    '2 AJOUTE CONTROLES :
    '-  2 TextBox,2 Button
    '3 DANS BOITE OUTILS (rechercher ce controle): 
    '- ajouter un element->selectionne->GViewer.dll->ok
    '4 AJOUTER LE CONTROLE GVIEWER
    '- mettre le GVIEWER (qui apparait) sur la forme frmFloydWarshal
    '5 GENERATION DU PROJET:
    '- dans projet frmFloydWarshal ajouter reference->projets>InterFacevb->0k
    '6- GENERER LA SOLUTION
     
    Option Explicit On
    Option Compare Text
    Imports System
    Imports System.Globalization
    Imports System.Threading
    Imports System.Windows
    Imports System.Collections
    Imports System.Drawing
    'imports pour MS Office Excel 2003
    Imports Microsoft.Office.Interop
    'imports pour le controle Microsoft GLEE
    Imports Microsoft
    Imports Microsoft.Glee
    Imports Microsoft.Glee.GleeGraph
    Imports Microsoft.Glee.Drawing
    Imports Microsoft.Glee.GraphViewerGdi
    Imports Microsoft.Glee.Splines
    Imports Microsoft.Glee.DataBase
    Imports Microsoft.Glee.NativeMethods
    'imports pour la librairie des graphes(QuickGraph)
    Imports QuickGraph
    Imports Algo_Extension = QuickGraph.Algorithms.AlgorithmExtensions
    Imports Algo_PredObservSommetEnreg = QuickGraph.Algorithms.Observers.VertexPredecessorRecorderObserver(Of String, QuickGraph.Edge(Of String))
    Imports Algo_PredObservArcEnreg = QuickGraph.Algorithms.Observers.EdgeRecorderObserver(Of String, QuickGraph.Edge(Of String))
    Imports Algo_SommetDistObservEnreg = QuickGraph.Algorithms.Observers.VertexDistanceRecorderObserver(Of String, QuickGraph.Edge(Of String))
    Imports FLOYDWARSHAL = QuickGraph.Algorithms.ShortestPath.FloydWarshallAllShortestPathAlgorithm(Of String, QuickGraph.Edge(Of String))
    'imports pour les methodes d'extensions 
    Imports QuickGraph.Glee
    'imports pour projet interfaceVB(classes Lien et LienChemin)
    Imports InterfaceVB
     
    Public Class frmFloydWarshal
     
        'objets donnees liens de MS Excel
        '--------------------------------------------------
        Public listeLiens As List(Of Lien) = New List(Of Lien)
        Public objLien As Lien
     
        'Lib QuickGraph (Partie graphe)
        '------------------------------
        'objet public graphe d'adjacence simple 
        Public objGraph As AdjacencyGraph(Of String, Edge(Of String))
        'objet un lien  du graphe
        Dim lienGraphe As QuickGraph.Edge(Of String)
        'objet "cout d'un lien"  de type Dictionnaire (ArcGraph,Cout)
        Dim coutLien As Dictionary(Of Edge(Of String), Double)
        'objet delegue "fonction cout lien"  (methode d'aide bibliotheque)
        Dim FNCout As Func(Of Edge(Of String), Double)
     
        ' objet Algorithme "FloydWarshal"
        Public objFloydWarshall As FLOYDWARSHAL
     
        'Lib  MS GLEE(Visualisation graphique)
        '-------------------------------------
        Public grapheVisuel As Microsoft.Glee.Drawing.Graph
     
        'Objet classeur MS Excel 2003
        '----------------------------
        Dim appExcel As Excel.Application
     
        'Objets "choix d'un chemin a afficher"
        '------------------------------------
        Public objLienChemin As LienChemin
        Public listeLienChemin As List(Of LienChemin) = New List(Of LienChemin)
        Public objCheminSel As LienChemin
        Public Sub New()
            ' Cet appel est requis par le Concepteur Windows Form.
            InitializeComponent()
            ' Ajoutez une initialisation quelconque après l'appel InitializeComponent()
        End Sub
        'Recherche le fichier excel contenant les arcs du graphe
        Private Sub btnOuvreFichArcs_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOuvreFichLiens.Click
            Dim nomFichierLiens As String = ""
            Dim dlgOuvreFichier As OpenFileDialog = New OpenFileDialog
            dlgOuvreFichier.Filter = "Fichier Arcs(*.xls)|*.xls"
            If dlgOuvreFichier.ShowDialog = Forms.DialogResult.OK Then
                nomFichierLiens = dlgOuvreFichier.FileName
                If Len(nomFichierLiens) = 0 Then
                    MessageBox.Show("entrer un nom de fichier svp...")
                    Exit Sub
                Else
                    'Si fichier excel trouve
                    Call LitFichierGraphe(nomFichierLiens)
                    Call RemplitGraphe()
                    Call demarreFloydWarshal()
                End If
            End If
     
        End Sub
        'Lit le fichier excel et charge liens(arcs) du graphe
        Private Sub LitFichierGraphe(ByVal nomFichierLiens As String)
            Dim nbLig As Integer = 12
            Dim nbCol As Integer = 5
            If appExcel IsNot Nothing Then
                appExcel.Quit()
            End If
            Try
                Dim appExcel As Excel.Application = New Excel.Application
                appExcel.Visible = True
                Dim monClasseur As Excel.Workbook = appExcel.Workbooks.Open(nomFichierLiens)
                Dim maFeuille As Excel.Worksheet = monClasseur.Worksheets(1)
                For I As Integer = 2 To nbLig
                    objLien = New Lien
                    For J As Integer = 1 To nbCol
                        Select Case J
                            Case 1
                                objLien.sommetNom = CType(maFeuille.Cells(I, J).value, String)
                            Case 2
                                objLien.Description = CType(maFeuille.Cells(I, J).value, String)
                            Case 3
                                objLien.sommetLien = CType(maFeuille.Cells(I, J).value, String)
                            Case 4
                                objLien.Cout = CType(maFeuille.Cells(I, J).value, Double)
                            Case 5
                                objLien.monType = CType(maFeuille.Cells(I, J).value, String)
                        End Select
                    Next
                    'ajout à liste liens
                    listeLiens.Add(objLien)
                Next
            Catch ex As Exception
                MessageBox.Show(ex.Message)
                If appExcel IsNot Nothing Then
                    appExcel.Quit()
                End If
     
            End Try
     
        End Sub
        'Remplit(populate) le graphe avec les donnes liens
        Private Sub RemplitGraphe()
            'parcourt liste des liens  
            'Ajoute Sommets et Liens au graphe
            objGraph = New AdjacencyGraph(Of String, Edge(Of String))
            coutLien = New Dictionary(Of Edge(Of String), Double)(objGraph.EdgeCount)
     
            For Each objLien As Lien In listeLiens
                lienGraphe = New QuickGraph.Edge(Of String)(objLien.sommetNom, objLien.sommetLien)
                objGraph.AddVerticesAndEdge(lienGraphe)
                'Ajoute "le cout du lien" au Dictionnaire "Cout Lien"
                coutLien.Add(lienGraphe, Double.Parse(objLien.Cout))
            Next
     
            'Assigne à la fonction "FNCout" delegue 
            'le dictionnaire "CoutLien" 
            FNCout = Algo_Extension.GetIndexer(coutLien)
        End Sub
        'executeFloydWarshal
        Private Sub demarreFloydWarshal()
            'Initialise  Algo FLOYDWARSHAL
            objFloydWarshall = New FLOYDWARSHAL(objGraph, FNCout)
            'Execute Algo "FLOYDWARSHALL" 
            objFloydWarshall.Compute()
            'Affiche lees chemins dans TextBox
            Call AfficheChemin()
        End Sub
        'Affiche le chemin visite dans TextBox.
        Private Sub AfficheChemin()
            txtListeSommet.ForeColor = System.Drawing.Color.DarkOliveGreen
            txtListeSommet.Font = New Font("courier new", 10, FontStyle.Bold)
     
            'compte  sommets(ou noeuds) du "graphe " 
            txtListeSommet.Text = "nombre Sommets :" & objGraph.Vertices.Count.ToString & vbCrLf & vbCrLf
     
            'compte liens (ou arcs) du "graphe " 
            txtListeSommet.Text = txtListeSommet.Text & "nombre Liens :" & objGraph.Edges.Count.ToString & vbCrLf & vbCrLf
     
     
            'Retrouve le cout chemin avec fonction TryGetDistance
            'Retrouve les liens chemin avec fonction TryGetPath
            txtChemin.Text = ""
            Dim objCoutChemin As Double = 0.0
            Dim objChemin As IEnumerable(Of QuickGraph.Edge(Of String)) = Nothing
            For Each objSource In objGraph.Vertices
                For Each objDestination In objGraph.Vertices
                    's'il y un chemin entre Source et Destination 
                    'liste le nom chemin et cout
                    If objFloydWarshall.TryGetDistance(objSource, objDestination, objCoutChemin) Then
                        txtChemin.Text = txtChemin.Text & _
                        "chemin de : " & objSource & " -> " & objDestination & " Cout: " & objCoutChemin.ToString & vbCrLf
                    End If
                    'liste les liens du chemin
                    If objFloydWarshall.TryGetPath(objSource, objDestination, objChemin) Then
                        For Each objLienGraphe In objChemin
                            txtChemin.Text = txtChemin.Text & objLienGraphe.Source & " -" & objLienGraphe.Target & vbCrLf
                        Next
                    End If
                    txtChemin.Text = txtChemin.Text & " --------- " & vbCrLf
                Next 'au chemin suivant
            Next
        End Sub
     
        Private Sub btnAfficheGraphe_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAfficheGraphe.Click
            'Efface GViever
            GViewer_FW.Graph = Nothing
            GViewer_FW.Refresh()
            'Raz de la liste chemin
            listeLienChemin.Clear()
            'Affiche forme de selection Chemin
            Dim objFrm As frmChemin = New frmChemin
            objFrm.ShowDialog()
     
            'Evenements noeudAjoute and  lienAjoute
            Dim noeudAjoute As New QuickGraph.Glee.GleeVertexNodeEventHandler(Of String)(AddressOf populator_NodeAdded)
            Dim arcAjoute As New QuickGraph.Glee.GleeEdgeEventHandler(Of String, Edge(Of String))(AddressOf populator_EdgeAdded)
            'Populator sert à peupler le "graphe du gviewer" avec les elements du "graphe quickgraph"
            Dim populator As QuickGraph.Glee.GleeGraphPopulator(Of String, QuickGraph.Edge(Of String)) = _
            GleeGraphExtensions.CreateGleePopulator(objGraph)
            populator.Compute()
     
            'On obtient le graphe visuel  pour  MS GLEE
            grapheVisuel = populator.VisitedGraph.ToGleeGraph(noeudAjoute, arcAjoute)
     
            'prepare le visualiseur Gviewer
            'active options  Sauvegarde & Scroll
            GViewer_FW.SaveButtonVisible = True
            GViewer_FW.AutoScroll = True
     
            'Affiche le "graphe visuel" dans Gviewer
            GViewer_FW.Graph = grapheVisuel
        End Sub
        'cet evenement permet de mettre en forme les sommets(noeuds)
        'de gviewer (declenche par populateur)
        Private Sub populator_NodeAdded(ByVal sender As Object, ByVal e As QuickGraph.Glee.GleeVertexEventArgs(Of String))
            Dim NoeudStyle As New Microsoft.Glee.Drawing.Style
            NoeudStyle = Microsoft.Glee.Drawing.Style.Rounded
            Dim noeudGlee As Microsoft.Glee.Drawing.Node = e.Node
            Dim nomNoeud As String = e.Vertex
            'mise en forme specifique pour sommet "A"
            If nomNoeud = "A" Then
                noeudGlee.Attr.Color = Microsoft.Glee.Drawing.Color.Black
                noeudGlee.Attr.Fillcolor = Microsoft.Glee.Drawing.Color.Yellow
                noeudGlee.Attr.LineWidth = 2.0
                noeudGlee.Attr.Shape = Microsoft.Glee.Drawing.Shape.Box
                noeudGlee.Attr.AddStyle(NoeudStyle)
                noeudGlee.Attr.FontName = "VERDANA"
                noeudGlee.Attr.Fontcolor = Microsoft.Glee.Drawing.Color.Red
                noeudGlee.Attr.FontName = "Arial"
                noeudGlee.Attr.Fontsize = 10
                noeudGlee.Attr.Label = "Racine: " & nomNoeud
                'mise en forme par defaut pour les sommets 
            Else
                noeudGlee.Attr.Color = Microsoft.Glee.Drawing.Color.Black
                noeudGlee.Attr.Fillcolor = Microsoft.Glee.Drawing.Color.GreenYellow
                noeudGlee.Attr.LineWidth = 1.0
                noeudGlee.Attr.Shape = Microsoft.Glee.Drawing.Shape.Box
                noeudGlee.Attr.AddStyle(NoeudStyle)
                noeudGlee.Attr.Fontcolor = Microsoft.Glee.Drawing.Color.Black
                noeudGlee.Attr.FontName = "Times New Roman"
                noeudGlee.Attr.Fontsize = 8
                noeudGlee.Attr.Label = nomNoeud
            End If
        End Sub
        'Cet evenement permet de mettre en forme les liens(arcs)
        'de GViewer (declenche par populateur)
        Private Sub populator_EdgeAdded(ByVal sender As Object, ByVal e As QuickGraph.Glee.GleeEdgeEventArgs(Of String, Edge(Of String)))
            Dim arcStyle As Microsoft.Glee.Drawing.Style
            arcStyle = Microsoft.Glee.Drawing.Style.Solid
            Dim arcGlee As Microsoft.Glee.Drawing.Edge = e.GEdge
            Dim coutChemin As Double = 0.0
            'mise en forme par defaut pour les liens 
            arcGlee.Attr.Color = Microsoft.Glee.Drawing.Color.Blue
            arcGlee.Attr.LineWidth = 1.0
            arcGlee.Attr.AddStyle(arcStyle)
            arcStyle = Microsoft.Glee.Drawing.Style.Bold
            arcGlee.Attr.AddStyle(arcStyle)
            arcGlee.Attr.FontName = "Verdana"
            arcGlee.Attr.Fontsize = 8
            arcGlee.Attr.Fontcolor = Microsoft.Glee.Drawing.Color.Red
            If objFloydWarshall.TryGetDistance(e.Edge.Source, e.Edge.Target, coutChemin) Then
                arcGlee.Attr.Label = coutChemin.ToString
            End If
            'mise en en forme pour un chemin selectionne
            ' Si un chemin a ete selectionne
            If objCheminSel IsNot Nothing Then
                For Each elemLien In listeLienChemin
                    'Si lien appartient à chemin selectionne 
                    'alors chemin en gras et rouge
                    If elemLien.ID = objCheminSel.ID Then
                        If e.Edge.Source = elemLien.Source And e.Edge.Target = elemLien.Destination Then
                            arcGlee.Attr.LineWidth = 2
                            arcGlee.Attr.Color = Microsoft.Glee.Drawing.Color.Red
                        End If
                    End If
                Next
            End If
        End Sub
    End Class
    'projet projet interfaceVB
    '--------------------------
    'classe Arc sert à stocker les arcs du fichier excel 
    Public Class Lien
        Public sommetNom, sommetLien As String
        Public Description, monType As String
        Public Cout As Double
     
        Public Sub New()
            Me.sommetNom = ""
            Me.sommetLien = ""
            Me.Description = "Neant"
            Me.Cout = 0.0
            Me.monType = ""
        End Sub
    End Class
     
    'projet Classe LienChemin à ajouter 
    'dans  le projet interfaceVB
    '-----------------------------------
    'classe  LienChemin sert à stocker les arcs de chaque chemin trouve
    Public Class LienChemin
        Private m_sommetSrc, m_sommetDest As String
        Private m_nomchemin As String
        Private m_ID As Integer
        Private m_coutChemin As Double
     
        Public Sub New()
            Me.m_sommetSrc = ""
            Me.m_sommetDest = ""
            Me.m_coutChemin = 0.0
            m_nomchemin = ""
        End Sub
        Public Property Source() As String
            Get
                Return m_sommetSrc
            End Get
            Set(ByVal value As String)
                m_sommetSrc = value
            End Set
        End Property
        Public Property Destination() As String
            Get
                Return m_sommetDest
            End Get
            Set(ByVal value As String)
                m_sommetDest = value
            End Set
        End Property
        Public Property CoutChemin() As String
            Get
                Return m_coutChemin
            End Get
            Set(ByVal value As String)
                m_coutChemin = value
            End Set
        End Property
        Public Property ID() As Integer
            Get
                Return m_ID
            End Get
            Set(ByVal value As Integer)
                m_ID = value
            End Set
        End Property
     
        Public Property NomChemin() As String
            Get
                Return m_nomchemin
            End Get
            Set(ByVal value As String)
                m_nomchemin = value
            End Set
        End Property
     
    End Class
    Dans tous les cas tu peux toujours lister tes chemins à l'aide du combobox,mais en regardant un peu dans la boite à outils tu t'est demande quand meme pourquoi cette profusion .
    Enfin derniere question,sur le message d'erreur.
    Parbleu,vous avez reference microsoft office library 14.0 c.à.d office 2010.

    1ere piste l'user n'a pas office 2010 installee.A verifier.

    2eme piste l'office 2010 est installe mais incompletement il suffit de faire modifier dans le panneau de configuration et a la fenetre qui s'affiche faire personnaliser , cocher "programmabilite .net" et reparer installation.A verifier.

    3eme solution pour votre projet c'est referencer les 3 offices pour satisfaire la config de chaque user(bien sur il faut avoir une machine dev c.a.d les 3 sont installes side-by-side cote à cote):
    -microsoft office library 11.0 (office 2003)
    -microsoft office library 12.0(office 2007)
    -microsoft office library 14.0(office 2010)
    Evidement il faut faire chez chaque user en cas d'installation incomplete d'office la manip de reparation d'installation (cocher "programmabilite .net").
    Il y a meme ceux qui ont aussi office 2003 sp1 qu'il faut patcher avec le kb pour office 2003 sp2.
    pj:fichier zip du code.
    ATTENTION il faut rajouter les sous-dossiers MSGLEE et QuickGraph dans le dossier solution car je les ai retires a cause de la taille du fichier zip trop grand pour le quota alloue.
    BONNE SOIREE ET BON CODE......

  2. #22
    Membre habitué
    Profil pro
    Inscrit en
    Novembre 2010
    Messages
    14
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Novembre 2010
    Messages : 14
    Par défaut
    Citation Envoyé par MABROUKI Voir le message
    Enfin derniere question,sur le message d'erreur.
    Parbleu,vous avez reference microsoft office library 14.0 c.à.d office 2010.

    1ere piste l'user n'a pas office 2010 installee.A verifier.

    2eme piste l'office 2010 est installe mais incompletement il suffit de faire modifier dans le panneau de configuration et a la fenetre qui s'affiche faire personnaliser , cocher "programmabilite .net" et reparer installation.A verifier.

    3eme solution pour votre projet c'est referencer les 3 offices pour satisfaire la config de chaque user(bien sur il faut avoir une machine dev c.a.d les 3 sont installes side-by-side cote à cote):
    -microsoft office library 11.0 (office 2003)
    -microsoft office library 12.0(office 2007)
    -microsoft office library 14.0(office 2010)
    Evidement il faut faire chez chaque user en cas d'installation incomplete d'office la manip de reparation d'installation (cocher "programmabilite .net").
    Il y a meme ceux qui ont aussi office 2003 sp1 qu'il faut patcher avec le kb pour office 2003 sp2.
    Et bien, beaucoup utilisent open office... Tout le monde a open office mais pas tout le monde a office... Tu aurais une solution qui utilise open office à la place? Comme un .csv est un format même lisable en mode text de par sa simpicité, il y aurait un autre moyen avec moins de dépendance d'ouvrir le fichier et de le charge rdans le programme?

  3. #23
    Membre extrêmement actif
    Inscrit en
    Avril 2008
    Messages
    2 573
    Détails du profil
    Informations personnelles :
    Âge : 65

    Informations forums :
    Inscription : Avril 2008
    Messages : 2 573
    Par défaut DJISKRA,fichier texte csv
    bonsoir ,chackadar
    eh bien je t'envoie ci-joint le code modifie qui lit aussi bien un fichier Excel qu'un Fichier Texte extension csv standard (separateur .

    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
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
     
     
    'projet principal frmFloydWarshal
    '----------------------------------------------------------------------
    '-----------------Version Fichier Texte Delimite .CSV------------------
    '----------------------------------------------------------------------
    '1 AJOUTER REFERENCE À  :
    '- Microsoft.Glee.dll,Microsoft.Glee.Drawing.dll
    '- QuickGraph.dll , QuickGraph.Glee.dll
    '- Microsot Excel 11.0 Object Library(office 2003) ou bien
    '- Microsot Excel 12.0 Object Library(office 2007) 
    '2 AJOUTE CONTROLES :
    '-  2 TextBox,2 Button
    '3 DANS BOITE OUTILS (rechercher ce controle): 
    '- ajouter un element->selectionne->GViewer.dll->ok
    '4 AJOUTER LE CONTROLE GVIEWER
    '- mettre le GVIEWER (qui apparait) sur la forme frmFloydWarshal
    '5 GENERATION DU PROJET:
    '- dans projet frmFloydWarshal ajouter reference->projets>InterFacevb->0k
    '6- GENERER LA SOLUTION
     
    Option Explicit On
    Option Compare Text
    Imports System
    Imports System.Globalization
    Imports System.Threading
    Imports System.Windows
    Imports System.Collections
    Imports System.Drawing
    'imports pour MS Office Excel 2003
    Imports Microsoft.Office.Interop
    'imports pour le controle Microsoft GLEE
    Imports Microsoft
    Imports Microsoft.Glee
    Imports Microsoft.Glee.GleeGraph
    Imports Microsoft.Glee.Drawing
    Imports Microsoft.Glee.GraphViewerGdi
    Imports Microsoft.Glee.Splines
    Imports Microsoft.Glee.DataBase
    Imports Microsoft.Glee.NativeMethods
    'imports pour la librairie des graphes(QuickGraph)
    Imports QuickGraph
    Imports Algo_Extension = QuickGraph.Algorithms.AlgorithmExtensions
    Imports Algo_PredObservSommetEnreg = QuickGraph.Algorithms.Observers.VertexPredecessorRecorderObserver(Of String, QuickGraph.Edge(Of String))
    Imports Algo_PredObservArcEnreg = QuickGraph.Algorithms.Observers.EdgeRecorderObserver(Of String, QuickGraph.Edge(Of String))
    Imports Algo_SommetDistObservEnreg = QuickGraph.Algorithms.Observers.VertexDistanceRecorderObserver(Of String, QuickGraph.Edge(Of String))
    Imports FLOYDWARSHAL = QuickGraph.Algorithms.ShortestPath.FloydWarshallAllShortestPathAlgorithm(Of String, QuickGraph.Edge(Of String))
    'imports pour les methodes d'extensions 
    Imports QuickGraph.Glee
    'imports pour projet interfaceVB(classes Lien et LienChemin)
    Imports InterfaceVB
     
    Public Class frmFloydWarshal
     
        'objets donnees liens de MS Excel
        '--------------------------------------------------
        Public listeLiens As List(Of Lien) = New List(Of Lien)
        Public objLien As Lien
     
        'Lib QuickGraph (Partie graphe)
        '------------------------------
        'objet public graphe d'adjacence simple 
        Public objGraph As AdjacencyGraph(Of String, Edge(Of String))
        'objet un lien  du graphe
        Dim lienGraphe As QuickGraph.Edge(Of String)
        'objet "cout d'un lien"  de type Dictionnaire (ArcGraph,Cout)
        Dim coutLien As Dictionary(Of Edge(Of String), Double)
        'objet delegue "fonction cout lien"  (methode d'aide bibliotheque)
        Dim FNCout As Func(Of Edge(Of String), Double)
     
        ' objet Algorithme "FloydWarshal"
        Public objFloydWarshall As FLOYDWARSHAL
     
        'Lib  MS GLEE(Visualisation graphique)
        '-------------------------------------
        Public grapheVisuel As Microsoft.Glee.Drawing.Graph
     
        'Objet classeur MS Excel 2003
        '----------------------------
        Dim appExcel As Excel.Application
        '-----------Ici declaration pour Fichier Texte-----------
        'Objet Fichier Texte Delimite par virgule au lieu d'Excel
        '--------------------------------------------------------
        Public ligneCourante As String()
        Public NbLigne As Integer
     
        'Objets "choix d'un chemin a afficher"
        '------------------------------------
        Public objLienChemin As LienChemin
        Public listeLienChemin As List(Of LienChemin) = New List(Of LienChemin)
        Public objCheminSel As LienChemin
        Public Sub New()
            ' Cet appel est requis par le Concepteur Windows Form.
            InitializeComponent()
            ' Ajoutez une initialisation quelconque après l'appel InitializeComponent()
        End Sub
        'Recherche le fichier -Excel ou bien Texte-contenant les arcs du graphe
        Private Sub btnOuvreFichArcs_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOuvreFichLiens.Click
            Dim nomFichierLiens As String = ""
            Dim dlgOuvreFichier As OpenFileDialog = New OpenFileDialog
            dlgOuvreFichier.Filter = "Fichier Arcs(*.xls)|*.xls|Fichier Texte(*.csv)|*.csv"
            If dlgOuvreFichier.ShowDialog = Forms.DialogResult.OK Then
                nomFichierLiens = dlgOuvreFichier.FileName
                If Len(nomFichierLiens) = 0 Then
                    MessageBox.Show("entrer un nom de fichier svp...")
                    Exit Sub
                Else
                    If nomFichierLiens.EndsWith("xls") Then
                        'Si fichier excel trouve
                        Call LitFichierGraphe(nomFichierLiens)
                    Else
                        'Si fichier texte delimite trouve
                        Call LitFichierGrapheTexte(nomFichierLiens)
                    End If
                    Call RemplitGraphe()
                    Call demarreFloydWarshal()
                End If
            End If
     
        End Sub
        '----------------Ici Sub Lecture Fichier Texte---------------
        'Lit le fichier Texte et charge liens(arcs) du graphe
        'lit  autant lignes qu'il y en a jusqu'à Fin de Fichier
        Private Sub LitFichierGrapheTexte(ByVal nomFichierLiens As String)
            'Utilise fonction VB dedie au fichier texte delimite
            Using Lecteur As New Microsoft.VisualBasic.FileIO.TextFieldParser _
                                      (nomFichierLiens)
                Lecteur.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited
                'Option pour le point virgule(ou virgule)
                Lecteur.SetDelimiters(";")
     
                NbLigne = 1
                While Not Lecteur.EndOfData
     
                    Try
                        ligneCourante = Lecteur.ReadFields()
                        Dim champCourant As String = ""
                        Dim numChamp As Integer = 1
                        Dim monLien As Lien = New Lien
                        For Each champCourant In ligneCourante
                            'si nbligne =1 -> saute en-tete 
                            'sinon traiter ligne
                            If NbLigne > 1 Then
                                Select Case numChamp
                                    Case 1
                                        monLien.sommetNom = champCourant
                                    Case 2
                                        monLien.Description = champCourant
                                    Case 3
                                        monLien.sommetLien = champCourant
                                    Case 4
                                        monLien.Cout = Double.Parse(champCourant)
                                    Case 5
                                        monLien.monType = champCourant
                                    Case 6
                                        monLien.motPasse = champCourant
                                    Case Else
                                End Select
                                numChamp = numChamp + 1
                            End If
                            'MessageBox.Show(numChamp.ToString & "-" & champCourant)
                        Next
                        If NbLigne > 1 Then
                            'ajout à liste liens
                            listeLiens.Add(monLien)
                        End If
                        NbLigne = NbLigne + 1
                    Catch ex As  _
                    Microsoft.VisualBasic.FileIO.MalformedLineException
                        MsgBox("Ligne " & ex.Message & _
                       "n'est pas valide,malformee et sera sautée.")
                    End Try
                End While
            End Using
        End Sub
        'Lit le fichier excel et charge liens(arcs) du graphe
        Private Sub LitFichierGraphe(ByVal nomFichierLiens As String)
            Dim nbLig As Integer = 12
            Dim nbCol As Integer = 5
            If appExcel IsNot Nothing Then
                appExcel.Quit()
            End If
            Try
                Dim appExcel As Excel.Application = New Excel.Application
                appExcel.Visible = True
                Dim monClasseur As Excel.Workbook = appExcel.Workbooks.Open(nomFichierLiens)
                Dim maFeuille As Excel.Worksheet = monClasseur.Worksheets(1)
                For I As Integer = 2 To nbLig
                    objLien = New Lien
                    For J As Integer = 1 To nbCol
                        Select Case J
                            Case 1
                                objLien.sommetNom = CType(maFeuille.Cells(I, J).value, String)
                            Case 2
                                objLien.Description = CType(maFeuille.Cells(I, J).value, String)
                            Case 3
                                objLien.sommetLien = CType(maFeuille.Cells(I, J).value, String)
                            Case 4
                                objLien.Cout = CType(maFeuille.Cells(I, J).value, Double)
                            Case 5
                                objLien.monType = CType(maFeuille.Cells(I, J).value, String)
                        End Select
                    Next
                    'ajout à liste liens
                    listeLiens.Add(objLien)
                Next
            Catch ex As Exception
                MessageBox.Show(ex.Message)
                If appExcel IsNot Nothing Then
                    appExcel.Quit()
                End If
            End Try
        End Sub
        'Remplit(populate) le graphe avec les donnes liens
        Private Sub RemplitGraphe()
            'parcourt liste des liens  
            'Ajoute Sommets et Liens au graphe
            objGraph = New AdjacencyGraph(Of String, Edge(Of String))
            coutLien = New Dictionary(Of Edge(Of String), Double)(objGraph.EdgeCount)
     
            For Each objLien As Lien In listeLiens
                lienGraphe = New QuickGraph.Edge(Of String)(objLien.sommetNom, objLien.sommetLien)
                objGraph.AddVerticesAndEdge(lienGraphe)
                'Ajoute "le cout du lien" au Dictionnaire "Cout Lien"
                coutLien.Add(lienGraphe, Double.Parse(objLien.Cout))
            Next
            'Assigne à la fonction "FNCout" delegue 
            'le dictionnaire "CoutLien" 
            FNCout = Algo_Extension.GetIndexer(coutLien)
        End Sub
        'ExecuteFloydWarshal
        Private Sub demarreFloydWarshal()
            'Initialise  Algo FLOYDWARSHAL
            objFloydWarshall = New FLOYDWARSHAL(objGraph, FNCout)
            'Execute Algo "FLOYDWARSHALL" 
            objFloydWarshall.Compute()
            'Affiche lees chemins dans TextBox
            Call AfficheChemin()
        End Sub
        'Affiche le chemin visite dans TextBox.
        Private Sub AfficheChemin()
            txtListeSommet.ForeColor = System.Drawing.Color.DarkOliveGreen
            txtListeSommet.Font = New Font("courier new", 10, FontStyle.Bold)
     
            'compte  sommets(ou noeuds) du "graphe " 
            txtListeSommet.Text = "nombre Sommets :" & objGraph.Vertices.Count.ToString & vbCrLf & vbCrLf
     
            'compte liens (ou arcs) du "graphe " 
            txtListeSommet.Text = txtListeSommet.Text & "nombre Liens :" & objGraph.Edges.Count.ToString & vbCrLf & vbCrLf
     
     
            'Retrouve le cout chemin avec fonction TryGetDistance
            'Retrouve les liens chemin avec fonction TryGetPath
            txtChemin.Text = ""
            Dim objCoutChemin As Double = 0.0
            Dim objChemin As IEnumerable(Of QuickGraph.Edge(Of String)) = Nothing
            For Each objSource In objGraph.Vertices
                For Each objDestination In objGraph.Vertices
                    's'il y un chemin entre Source et Destination 
                    'liste le nom chemin et cout
                    If objFloydWarshall.TryGetDistance(objSource, objDestination, objCoutChemin) Then
                        txtChemin.Text = txtChemin.Text & _
                        "chemin de : " & objSource & " -> " & objDestination & " Cout: " & objCoutChemin.ToString & vbCrLf
                    End If
                    'liste les liens du chemin
                    If objFloydWarshall.TryGetPath(objSource, objDestination, objChemin) Then
                        For Each objLienGraphe In objChemin
                            txtChemin.Text = txtChemin.Text & objLienGraphe.Source & " -" & objLienGraphe.Target & vbCrLf
                        Next
                    End If
                    txtChemin.Text = txtChemin.Text & " --------- " & vbCrLf
                Next 'au chemin suivant
            Next
        End Sub
     
        Private Sub btnAfficheGraphe_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAfficheGraphe.Click
            'Efface GViever
            GViewer_FW.Graph = Nothing
            GViewer_FW.Refresh()
            'Raz de la liste chemin
            listeLienChemin.Clear()
            'Affiche forme de selection Chemin
            Dim objFrm As frmChemin = New frmChemin
            objFrm.ShowDialog()
     
            'Evenements noeudAjoute and  lienAjoute
            Dim noeudAjoute As New QuickGraph.Glee.GleeVertexNodeEventHandler(Of String)(AddressOf populator_NodeAdded)
            Dim arcAjoute As New QuickGraph.Glee.GleeEdgeEventHandler(Of String, Edge(Of String))(AddressOf populator_EdgeAdded)
            'Populator sert à peupler le "graphe du gviewer" avec les elements du "graphe quickgraph"
            Dim populator As QuickGraph.Glee.GleeGraphPopulator(Of String, QuickGraph.Edge(Of String)) = _
            GleeGraphExtensions.CreateGleePopulator(objGraph)
            populator.Compute()
     
            'On obtient le graphe visuel  pour  MS GLEE
            grapheVisuel = populator.VisitedGraph.ToGleeGraph(noeudAjoute, arcAjoute)
     
            'prepare le visualiseur Gviewer
            'active options  Sauvegarde & Scroll
            GViewer_FW.SaveButtonVisible = True
            GViewer_FW.AutoScroll = True
     
            'Affiche le "graphe visuel" dans Gviewer
            GViewer_FW.Graph = grapheVisuel
        End Sub
        'cet evenement permet de mettre en forme les sommets(noeuds)
        'de GViewer (declenche par populateur)
        Private Sub populator_NodeAdded(ByVal sender As Object, ByVal e As QuickGraph.Glee.GleeVertexEventArgs(Of String))
            Dim NoeudStyle As New Microsoft.Glee.Drawing.Style
            NoeudStyle = Microsoft.Glee.Drawing.Style.Rounded
            Dim noeudGlee As Microsoft.Glee.Drawing.Node = e.Node
            Dim nomNoeud As String = e.Vertex
            'mise en forme specifique pour sommet "A"
            If nomNoeud = "A" Then
                noeudGlee.Attr.Color = Microsoft.Glee.Drawing.Color.Black
                noeudGlee.Attr.Fillcolor = Microsoft.Glee.Drawing.Color.Yellow
                noeudGlee.Attr.LineWidth = 2.0
                noeudGlee.Attr.Shape = Microsoft.Glee.Drawing.Shape.Box
                noeudGlee.Attr.AddStyle(NoeudStyle)
                noeudGlee.Attr.FontName = "VERDANA"
                noeudGlee.Attr.Fontcolor = Microsoft.Glee.Drawing.Color.Red
                noeudGlee.Attr.FontName = "Arial"
                noeudGlee.Attr.Fontsize = 10
                noeudGlee.Attr.Label = "Racine: " & nomNoeud
                'mise en forme par defaut pour les sommets 
            Else
                noeudGlee.Attr.Color = Microsoft.Glee.Drawing.Color.Black
                noeudGlee.Attr.Fillcolor = Microsoft.Glee.Drawing.Color.GreenYellow
                noeudGlee.Attr.LineWidth = 1.0
                noeudGlee.Attr.Shape = Microsoft.Glee.Drawing.Shape.Box
                noeudGlee.Attr.AddStyle(NoeudStyle)
                noeudGlee.Attr.Fontcolor = Microsoft.Glee.Drawing.Color.Black
                noeudGlee.Attr.FontName = "Times New Roman"
                noeudGlee.Attr.Fontsize = 8
                noeudGlee.Attr.Label = nomNoeud
            End If
        End Sub
        'Cet evenement permet de mettre en forme les liens(arcs)
        'de GViewer (declenche par populateur)
        Private Sub populator_EdgeAdded(ByVal sender As Object, ByVal e As QuickGraph.Glee.GleeEdgeEventArgs(Of String, Edge(Of String)))
            Dim arcStyle As Microsoft.Glee.Drawing.Style
            arcStyle = Microsoft.Glee.Drawing.Style.Solid
            Dim arcGlee As Microsoft.Glee.Drawing.Edge = e.GEdge
            Dim coutChemin As Double = 0.0
            'mise en forme par defaut pour les liens 
            arcGlee.Attr.Color = Microsoft.Glee.Drawing.Color.Blue
            arcGlee.Attr.LineWidth = 1.0
            arcGlee.Attr.AddStyle(arcStyle)
            arcStyle = Microsoft.Glee.Drawing.Style.Bold
            arcGlee.Attr.AddStyle(arcStyle)
            arcGlee.Attr.FontName = "Verdana"
            arcGlee.Attr.Fontsize = 8
            arcGlee.Attr.Fontcolor = Microsoft.Glee.Drawing.Color.Red
            If objFloydWarshall.TryGetDistance(e.Edge.Source, e.Edge.Target, coutChemin) Then
                arcGlee.Attr.Label = coutChemin.ToString
            End If
            'mise en en forme pour un chemin selectionne
            ' Si un chemin a ete selectionne
            If objCheminSel IsNot Nothing Then
                For Each elemLien In listeLienChemin
                    'Si lien appartient à chemin selectionne 
                    'alors chemin en gras et rouge
                    If elemLien.ID = objCheminSel.ID Then
                        If e.Edge.Source = elemLien.Source And e.Edge.Target = elemLien.Destination Then
                            arcGlee.Attr.LineWidth = 2
                            arcGlee.Attr.Color = Microsoft.Glee.Drawing.Color.Red
                        End If
                    End If
                Next
            End If
        End Sub
    End Class
    'frmChemin boite de selection d'un chemin
    'à ajouter au projet principal frmFloydWarshal
    '-----------------------------------------
    Imports InterfaceVB
     
    Public Class frmChemin
        Public Sub New()
            ' Cet appel est requis par le Concepteur Windows Form.
            InitializeComponent()
            ' Ajoutez une initialisation quelconque après l'appel InitializeComponent().
        End Sub
     
        Private Sub frmChemin_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Me.AcceptButton = Me.btnOK
            Me.CancelButton = Me.btnAnnuler
            Me.MaximumSize = New Size(276, 158)
     
     
            'Parcourir matrice sommet x sommet à la recheche des chemins
            'trouve par algo FloydWarshal
            'Remplir liste des chemins dans listeLienChemin 
            'Charge comboxbox  avec listeLienChemin 
            Dim Chemin As IEnumerable(Of QuickGraph.Edge(Of String)) = Nothing
            Dim objID As Integer = 0
            For Each source In frmFloydWarshal.objGraph.Vertices
                For Each destination In frmFloydWarshal.objGraph.Vertices
                    If frmFloydWarshal.objFloydWarshall.TryGetPath(source, destination, Chemin) Then
                        objID = objID + 1
                        For Each objLienGraphe In Chemin
                            frmFloydWarshal.objLienChemin = New LienChemin
                            frmFloydWarshal.objLienChemin.NomChemin = source & "->" & destination & " " & objID.ToString
                            frmFloydWarshal.objLienChemin.Source = objLienGraphe.Source
                            frmFloydWarshal.objLienChemin.Destination = objLienGraphe.Target
                            frmFloydWarshal.objLienChemin.ID = objID
                            frmFloydWarshal.listeLienChemin.Add(frmFloydWarshal.objLienChemin)
                            Me.cboChoixChemin.Items.Add(frmFloydWarshal.objLienChemin)
                        Next
                    End If
                Next
            Next
            Me.cboChoixChemin.DisplayMember = "NomChemin"
        End Sub
     
        Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
            'valide selection s'il y en a
            Me.Close()
        End Sub
     
        Private Sub btnAnnuler_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAnnuler.Click
            'Raz liste des chemins
            frmFloydWarshal.listeLienChemin.Clear()
            Me.Close()
        End Sub
     
        Private Sub cboChoixChemin_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboChoixChemin.SelectedValueChanged
            frmFloydWarshal.objCheminSel = CType(cboChoixChemin.SelectedItem, LienChemin)
        End Sub
    End Class
     
    'projet projet interfaceVB
    '--------------------------
    'classe Arc sert à stocker les arcs du fichier excel 
    Public Class Lien
        Public sommetNom As String
        Public Description As String
        Public sommetLien As String
        Public Cout As Double
        Public monType As String
        Public motPasse As String
     
        Public Sub New()
            Me.sommetNom = ""
            Me.sommetLien = ""
            Me.Description = "Neant"
            Me.Cout = 0.0
            Me.monType = ""
            Me.motPasse = ""
        End Sub
    End Class
    'Classe LienChemin à ajouter 
    '-----------------------------------
    'classe  LienChemin sert à stocker les arcs de chaque chemin trouve
    Public Class LienChemin
        Private m_sommetSrc, m_sommetDest As String
        Private m_nomchemin As String
        Private m_ID As Integer
        Private m_coutChemin As Double
     
        Public Sub New()
            Me.m_sommetSrc = ""
            Me.m_sommetDest = ""
            Me.m_coutChemin = 0.0
            m_nomchemin = ""
        End Sub
        Public Property Source() As String
            Get
                Return m_sommetSrc
            End Get
            Set(ByVal value As String)
                m_sommetSrc = value
            End Set
        End Property
        Public Property Destination() As String
            Get
                Return m_sommetDest
            End Get
            Set(ByVal value As String)
                m_sommetDest = value
            End Set
        End Property
        Public Property CoutChemin() As String
            Get
                Return m_coutChemin
            End Get
            Set(ByVal value As String)
                m_coutChemin = value
            End Set
        End Property
        Public Property ID() As Integer
            Get
                Return m_ID
            End Get
            Set(ByVal value As Integer)
                m_ID = value
            End Set
        End Property
     
        Public Property NomChemin() As String
            Get
                Return m_nomchemin
            End Get
            Set(ByVal value As String)
                m_nomchemin = value
            End Set
        End Property
     
    End Class
    ci-joint fichier zip
    bon code....

  4. #24
    Membre habitué
    Profil pro
    Inscrit en
    Novembre 2010
    Messages
    14
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Novembre 2010
    Messages : 14
    Par défaut
    Les choses marchent bien. Merci.

    Il resterait un autre petti détail. Dans ton graphique fait avec glee, est-il possible d'avoir une couleur différente pour les flèches selon le champ type et si oui, comment?

  5. #25
    Membre extrêmement actif
    Inscrit en
    Avril 2008
    Messages
    2 573
    Détails du profil
    Informations personnelles :
    Âge : 65

    Informations forums :
    Inscription : Avril 2008
    Messages : 2 573
    Par défaut algo djiskra,msglee
    bonjour nabuchdonosor le conquerant de l'asie ,pardon chackadar,
    Eh bien helas pour nous MSGLEE qui est gratuit gere l'arc graphique comme un tout c.a.d couleur des fleches est la meme que celle de l'arc.

    Il faudrait voir du cote de MSAGL (sur le meme site que celui MSGLEE) du meme auteur Lev Nachmanson un gars de microsoft research mais il est payant.

    Il permet l'edition des noeuds et des arcs dans l'interface graphique(modifie un libelle ,une valeur) ce que ne fait pas MSGLEE.
    Il inclut egalement des couches(layer).

    Toujours dans les payants il y a aussi un autre logiciel qui fait meme l'animation des couleurs des arcs et noeuds c'est ILOG de IBM.

    Il y a egalement Graphiz gratuit mais il utilise une api en c++.
    regarde dans cet Faqs de developpez.com ici
    http://www.google.fr/url?sa=t&source...NiGWL7A-8UJ8hw

    bon code...

  6. #26
    Membre habitué
    Profil pro
    Inscrit en
    Novembre 2010
    Messages
    14
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Novembre 2010
    Messages : 14
    Par défaut
    Merci beaucoup.

  7. #27
    Membre averti
    Profil pro
    Inscrit en
    Décembre 2010
    Messages
    26
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2010
    Messages : 26
    Par défaut
    Bonjour !

    Certains des problèmes mentionnés dans cette discussion pourrait être résolus, me semble-t-il, tout simplement en n'utilisant qu'une simple feuille de calcul, sans macro ni VBAsic.

    Si cela vous intéresse, regarder ma proposition dans la discussion suivante :

    http://www.developpez.net/forums/d11...a/#post6656368

    Hope this helps !

+ Répondre à la discussion
Cette discussion est résolue.
Page 2 sur 2 PremièrePremière 12

Discussions similaires

  1. Comment implémenter lemonldap?
    Par Aldo dans le forum Apache
    Réponses: 7
    Dernier message: 25/01/2007, 21h32
  2. [VB.Net]Comment implémenter un Simulateur de combats?
    Par stargatejojo dans le forum Windows Forms
    Réponses: 19
    Dernier message: 20/04/2006, 16h04
  3. Réponses: 4
    Dernier message: 07/04/2006, 18h08
  4. Réponses: 2
    Dernier message: 02/12/2005, 17h22
  5. Comment implémenter un Datawarehouse ?
    Par raslain dans le forum Alimentation
    Réponses: 2
    Dernier message: 20/10/2005, 11h09

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo