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
|
''' <summary>
''' Formulaire MDI qui gere l'affichage des autres fenetres et des evenement de ceux ci
''' </summary>
Public Class FrmPrincipal
#Region "EVENEMENT"
Private Sub FrmPrincipal_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
AfficherFenetrePSB()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub FrmPrincipal_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
Try
If (QuitterApplication() = False) Then
e.Cancel = True
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' ABONNEMENT EVENEMENT
' evenement crée dans les formulaires permet l'intéraction entre les différents Formulaires
Private Sub eventQuitterApplication(sender As Object, e As EventArgs)
Me.Close()
End Sub
Private Sub eventAfficherPottingConnexion(sender As Object, e As EventArgs)
AfficherFenetrePottingConnexion()
End Sub
Private Sub eventFermerPottingConnexion()
FrmPottingRAZ.Close()
FrmPottingDetail.Close()
gestionPanelCollapsed(Me)
End Sub
Private Sub eventAfficherPottingDetail()
AfficherFenetrePottingDetail()
End Sub
Private Sub eventFermerPottingDetail()
FrmPottingRAZ.Close()
gestionPanelCollapsed(Me)
End Sub
Private Sub eventAfficherPottingRAZ()
AfficherFenetrePottingRAZ()
End Sub
Private Sub eventFermerPottingRAZ()
gestionPanelCollapsed(Me)
End Sub
#End Region
#Region "ACTION"
' la partie action concerne les méthodes génériques lié a l'IHM
' les méthode implémenté dedans doivent etre autonome et réutilisable facilement
''' <summary>
''' affiche un message demandans si l'on veut vraiment quitté
''' </summary>
''' <returns>Retourne true si on a cliqué sur Oui sinon en retourne false</returns>
Private Function QuitterApplication() As Boolean
Try
If (MessageBox.Show("Voulez vous vraiment quitter l'application ?",
"Fermeture de l'application", MessageBoxButtons.YesNo, MessageBoxIcon.Question,
MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification) = DialogResult.Yes) Then
Return True
Else
Return False
End If
Catch ex As Exception
Throw New ApplicationException(ex.Message)
End Try
End Function
''' <summary>
''' gere l'affichage des fenetres
''' </summary>
''' <param name="frm">le formulaire crée grace a un new</param>
''' <param name="panel">le panel dans lequel mettre la fenetre choisie</param>
''' <param name="dock">comment doit ce mettre la fenetre pleinne ecran, normal, sur la gauche ...</param>
''' <param name="position">si il n'est pas en plein écran</param>
''' <param name="location">définie le point de départ, utile si vous souhaité mettre une fenetre au centre d'un control</param>
Private Sub gestionFenetreAffichage(frm As Form, panel As Control.ControlCollection,
Optional dock As DockStyle = DockStyle.Fill,
Optional position As FormStartPosition = FormStartPosition.WindowsDefaultLocation,
Optional location As Point = Nothing)
frm.MdiParent = Me
frm.Dock = dock
frm.Location = location
frm.StartPosition = position
Me.gestionFenetreSuppression(panel)
panel.Add(frm)
frm.Show()
Me.gestionPanelCollapsed(Me)
End Sub
''' <summary>
''' méthode appellé par gestionFenetreAffichage, cette méthode supprimera les controls existant a
''' l'intérieur du panel donné avant de mettre le nouveau control,
''' ce qui permet d'évité des doublon de formulaire
''' </summary>
''' <param name="panel"></param>
Private Sub gestionFenetreSuppression(panel As Control.ControlCollection)
Dim NbFenetre As Integer = panel.Count
Do
If (NbFenetre <> 0) Then
panel.RemoveAt(0)
End If
Loop While (panel.Count <> 0)
End Sub
''' <summary>
''' méthode appellé par gestionFenetreAffichage, cette méthode rendra disponible les panels
''' en fonction de si ces meme panel possede des formulaires oui ou non
''' ce qui donnera un aspect d'application dynamique
''' </summary>
''' <param name="control"></param>
Private Sub gestionPanelCollapsed(control As Control)
Try
If (SC_Potting.Panel1.Controls.Count = 0 And SC_Potting.Panel2.Controls.Count = 0) Then
SC_Principal.Panel2Collapsed = True
Else
SC_Principal.Panel2Collapsed = False
End If
If (SC_Potting.Panel2.Controls.Count = 0) Then
SC_Potting.Panel2Collapsed = True
Else
SC_Potting.Panel2Collapsed = False
End If
'For Each c As Control In control.Controls
' If (c.GetType() Is GetType(SplitContainer)) Then
' Dim sc As SplitContainer = c
' If sc.Panel1.HasChildren Then
' gestionPanelCollapsed(sc.Panel1)
' sc.Panel1Collapsed = False
' Else
' sc.Panel1Collapsed = True
' End If
' If sc.Panel2.HasChildren Then
' gestionPanelCollapsed(sc.Panel2)
' sc.Panel2Collapsed = False
' Else
' sc.Panel2Collapsed = True
' End If
' End If
'Next
Catch ex As Exception
Throw New ApplicationException("Exception Occured")
End Try
End Sub
''' <summary>
''' méthode rendre l'écran Principal vide
''' </summary>
''' <remarks></remarks>
Private Sub fermerTouteFenetre()
For Each c As Control In Me.Controls
If (c.GetType() Is GetType(SplitContainer)) Then
Dim sc As SplitContainer = c
sc.Panel1.Controls.Clear()
sc.Panel2.Controls.Clear()
End If
Next
Me.gestionPanelCollapsed(Me)
End Sub
#End Region
#Region "Affichage"
''' la partie affichage est sencé gérée les fenetres
''' doit contenir
''' - la déclaration des formulaires
''' - ensuite les abonnement au évenement propre au formulaire déclaré
''' - et pour terminer la méthode gestion des fenetres pour parametre et afficher le formulaire crées
Private Sub AfficherFenetrePSB()
Try
Dim frm As FrmPSB = New FrmPSB()
AddHandler frm.e_quitter, AddressOf Me.eventQuitterApplication
AddHandler frm.e_afficherPotting, AddressOf Me.eventAfficherPottingConnexion
Me.gestionFenetreAffichage(frm, Me.SC_Principal.Panel1.Controls)
Catch ex As ApplicationException
Throw New ApplicationException("fenetre PSB" + ex.Message)
End Try
End Sub
Private Sub AfficherFenetrePottingConnexion()
Try
Dim frm As FrmPottingConnexion = New FrmPottingConnexion()
AddHandler frm.e_afficherDetail, AddressOf Me.eventAfficherPottingDetail
AddHandler frm.e_masquerDetail, AddressOf Me.eventFermerPottingDetail
AddHandler frm.e_annulerConnexion, AddressOf Me.eventFermerPottingConnexion
Me.gestionFenetreAffichage(frm, Me.SC_Potting.Panel1.Controls)
Catch ex As ApplicationException
Throw New ApplicationException("fenetre PSB" + ex.Message)
End Try
End Sub
Private Sub AfficherFenetrePottingDetail()
Try
Dim frm As FrmPottingDetail = New FrmPottingDetail()
AddHandler frm.e_afficherRAZ, AddressOf Me.eventAfficherPottingRAZ
AddHandler frm.e_quitterDetail, AddressOf Me.eventFermerPottingDetail
Me.gestionFenetreAffichage(frm, Me.SC_Potting.Panel1.Controls)
Catch ex As ApplicationException
Throw New ApplicationException("fenetre PSB" + ex.Message)
End Try
End Sub
Private Sub AfficherFenetrePottingRAZ()
Try
Dim frm As FrmPottingRAZ = New FrmPottingRAZ()
AddHandler frm.e_annulerRAZ, AddressOf eventFermerPottingRAZ
Me.gestionFenetreAffichage(frm, Me.SC_Potting.Panel2.Controls)
Catch ex As ApplicationException
Throw New ApplicationException("fenetre PSB" + ex.Message)
End Try
End Sub
#End Region |
Partager