File "VB313.tmp"
Full Path: /home/analogde/www/Documents/DEV2/VB313.tmp
File size: 6.6 KB
MIME-type: text/plain
Charset: 8 bit
Attribute VB_Name = "Module4"
Option Explicit
Dim Num As Integer
Dim Pos_X As Integer
Dim Pos_Y As Integer
Dim Type_Instance As String
Dim Orientation As String
' Filter
Public Const filtre_champ = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*|"
Public Function Ouvrir_Document()
' ouvrir un document existant
On Error GoTo OpenError
Dim Fichier_Nom As String
Dim Data As String
Dim chaine(200) As String
Dim nbre_ligne As Integer
Dim position As Integer
Dim cpt_PAD As Integer
nbre_ligne = 1
With Prog_Frm
.CmDlg.CancelError = True
.CmDlg.DialogTitle = "Selection du fichier ouvrir"
.CmDlg.Filter = filtre_champ
.CmDlg.FilterIndex = 1
.CmDlg.ShowOpen
End With
Fichier_Nom = Prog_Frm.CmDlg.FileName
' lecture du fichier
Open Fichier_Nom For Input As #1
' Dim intFic As Integer
'Dim client As tClient
'intFic = FreeFile
'Open "c:\pad.txt" For Random As intFic Len = Len(client)
'Get intFic, 1, client
'MsgBox client.Num
'Get intFic, 2, client
'MsgBox client.Num
'Close intFic
Dim temp As String
Dim PAD_toto As Integer
While Not EOF(1)
Input #1, Data$
cpt_PAD = cpt_PAD + 1
chaine(nbre_ligne) = Data$ ' + Chr$(13) + Chr$(10)
temp = chaine(nbre_ligne)
extraction_champ (temp)
' insert un pad
PAD_toto = Insert(Pos_X, Pos_Y, Type_Instance, Orientation)
ReDraw Prog_Frm.Schema_Box
nbre_ligne = nbre_ligne + 1
Wend
Close #1
OpenError:
'If Err.Number = 32755 Then Exit Function 'If canceled then exit function
'ErrorLog "modDocument/OpenDocument"
End Function
Sub extraction_champ(chaine As String)
Dim Tableau() As String
Dim i As Integer
'dcoupe la chaine en fonction des espaces " "
'le rsultat de la fonction Split est stock dans un tableau
Tableau = Split(chaine, " ")
'boucle sur le tableau pour visualiser le rsultat
For i = 0 To UBound(Tableau)
'Le rsultat s'affiche dans la fentre d'execution de l'diteur de macros
Debug.Print Tableau(i)
Next i
Num = Tableau(0)
Pos_X = Tableau(1)
Pos_Y = Tableau(2)
Type_Instance = Tableau(3)
Orientation = LCase(Tableau(4))
End Sub
Public Property Get CancelError() As Boolean
CancelError = m_CancelError
End Property
Public Property Let CancelError(ByVal New_CancelError As Boolean)
m_CancelError = New_CancelError
PropertyChanged "CancelError"
End Property
Public Property Get Filter() As String
Filter = m_Filter
End Property
Public Property Let filtre(ByVal New_Filter As String)
m_Filter = New_Filter
PropertyChanged "Filtre"
End Property
Public Property Get FilterIndex() As Integer
FilterIndex = m_FilterIndex
End Property
Public Property Let FilterIndex(ByVal New_FilterIndex As Integer)
m_FilterIndex = New_FilterIndex
PropertyChanged "FilterIndex"
End Property
Public Property Get DialogTitle() As String
DialogTitle = m_DialogTitle
End Property
Public Property Let DialogTitle(ByVal New_DialogTitle As String)
m_DialogTitle = New_DialogTitle
PropertyChanged "DialogTitle"
End Property
Public Function Import_Template()
On Error GoTo OpenError
Dim Fichier_Nom As String
Dim Data As String
Dim chaine(200) As String
Dim nbre_ligne As Integer
Dim position As Integer
Dim cpt_PAD As Integer
nbre_ligne = 1
With Prog_Frm
.CmDlg.CancelError = True
.CmDlg.DialogTitle = "Selection du fichier ouvrir"
.CmDlg.Filter = filtre_champ
.CmDlg.FilterIndex = 1
.CmDlg.ShowOpen
End With
Fichier_Nom = Prog_Frm.CmDlg.FileName
' lecture du fichier
Open Fichier_Nom For Input As #1
Dim temp As String
Dim PAD_toto As Integer
While Not EOF(1)
Input #1, Data$
cpt_PAD = cpt_PAD + 1
chaine(nbre_ligne) = Data$
temp = chaine(nbre_ligne)
extraction_champ (temp)
' ajouter la pin
PAD_toto = Insert_Pin(Pos_X, Pos_Y, Num)
Affiche_PIN Prog_Frm.Schema_Box
nbre_ligne = nbre_ligne + 1
Wend
Close #1
OpenError:
End Function
Public Function Insert_Pin(ByVal cX As Integer, ByVal cY As Integer, ByVal Num) As Long
' incrmente le nombre de pin
NB_PIN = NB_PIN + 1
' redimensionne le tableau de liens
ReDim Preserve Objet_PIN(NB_PIN - 1)
' instancie un nouveau pad
Set Objet_PAD(NB_PIN - 1) = New pin
' defini les parametres de la nouvelle pin
tmp = Objet_PIN(NB_PIN - 1).Set_PIN_Parametres(NB_PIN - 1, cX, cY)
' retourne l'ID de la pin
Insert_Pin = NB_PIN - 1
End Function
Public Sub Affiche_PIN(pic As PictureBox)
Dim i As Integer
Dim PosX As Integer
Dim PosY As Integer
PosX = 0
PosY = 0
pic.Cls
For i = 0 To NB_PIN - 1
' recupere la position de la pin
tmp = Objet_PIN(i).Get_PIN_Position(PosX, PosY)
'dessine le pad
tmp = Dessine_PIN(PosX, PosY, pic)
Next i
End Sub
Public Function Dessine_PIN(ByVal X As Integer, ByVal Y As Integer, pic As PictureBox)
Dim symbole As String
Dim inverse As Long
Dim Boite As Long
' dessine un pad
hauteur = hauteurStd
largeur = largeurStd
If Etat = 1 Then couleur = RGB(255, 0, 0)
If Etat = 0 Then couleur = RGB(0, 255, 0)
If Selectionne = 1 Then couleurboite = RGB(0, 0, 255)
If Selectionne = 0 Then couleurboite = RGB(0, 0, 0)
' pad standard
Boite = 1
' dessine le corps du pad (gomtrie)
If Orientation_PAD = "r" Then
pic.Line (X, Y)-(X + hauteur, Y), couleurboite
pic.Line (X + hauteur, Y)-(X + hauteur, Y + largeur), couleurboite
pic.Line (X, Y)-(X, Y + largeur), couleurboite
pic.Line (X, Y + largeur)-(X + hauteur, Y + largeur), couleurboite
' dessine le point de gravit
pic.Circle (X + hauteur / 2, Y + largeur / 2), taillepuce, couleur
' position
Gravite_Pos_X = X + hauteur / 2
Gravite_Pos_Y = Y + largeur / 2
End If
If Orientation_PAD = "n" Then
'If Boite = 1 Then
pic.Line (X, Y)-(X + largeur, Y), couleurboite
pic.Line -(X + largeur, Y + hauteur), couleurboite
pic.Line -(X, Y + hauteur), couleurboite
pic.Line -(X, Y), couleurboite
' dessine le point de gravit
pic.Circle (X + largeur / 2, Y + hauteur / 2), taillepuce, couleur
' position
Gravite_Pos_X = X + largeur / 2
Gravite_Pos_Y = Y + hauteur / 2
End If
End Function