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
| Imports System.Windows.Forms
Public Class frmAlarmes
Private mMesAlarmes As DesAlarmes
Public Property MesAlarmes() As DesAlarmes
Get
Return mMesAlarmes
End Get
Set(ByVal value As DesAlarmes)
mMesAlarmes = value
End Set
End Property
'pour test
Private Sub ActionChangeNiveauA2()
mMesAlarmes.DicoAlarmes("a1").ChangeNiveauPriorite(2)
End Sub
Private Sub frmAlarmes_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'ActionChangeNiveauA2()
'Try
' Dim pair As KeyValuePair(Of String, UneAlarme)
' For Each pair In MesAlarmes.DicoAlarmes
' System.Windows.Forms.MessageBox.Show(" GestAlarme " & pair.Key & " " & pair.Value.IdAlarm)
' Next
'Catch ex As Exception
' System.Windows.Forms.MessageBox.Show(ex.Message)
'End Try
'Label1.Text = mMesAlarmes.DicoAlarmes("a1").IdAlarm
'Label2.Text = mMesAlarmes.DicoAlarmes("a1").Priority
MonDGW.AutoGenerateColumns = True
MonDGW.DataSource = MesAlarmes.DicoAlarmes.Select((Function(kv) New With {.LesCles = kv.Key, .LesPriorités = kv.Value.Priority})).ToArray
dgvPri.AutoGenerateColumns = True
End Sub
Private Sub btnNbAlPArPri_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNbAlPArPri.Click
lblNbAlPArPri.Text = "Nombre d'alarme de priorité (" & txtNbAlPArPri.Text & ") : " _
& MesAlarmes.NbAlarmesDePriorite(Integer.Parse(txtNbAlPArPri.Text))
lblLinq.Text = "Nombre d'alarme de priorité (" & txtNbAlPArPri.Text & ") Linq : " _
& MesAlarmes.LinqNbAlarmesDePriorite(Integer.Parse(txtNbAlPArPri.Text))
dgvPri.DataSource = (From entree In MesAlarmes.DicoAlarmes Where (entree.Value.Priority = Integer.Parse(txtNbAlPArPri.Text)) Select entree).Select((Function(kv) New With {.LesCles = kv.Key, .LesPriorités = kv.Value.Priority})).ToArray
End Sub
Private Sub AffichierMenu_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles MonDGW.CellMouseDown
If e.Button = MouseButtons.Right Then ' Lorsqu'on fait un click *droit*
'un try ... catch pour eviter une exception au clic sur une entete
Try
MonDGW.Rows(e.RowIndex).Selected = True
MesAlarmes.LigneDGVTraitee = e.RowIndex
OuvrirMenu(e.RowIndex) 'Ouvre un menu
Catch ex As ArgumentOutOfRangeException
End Try
End If
End Sub
'Procedure qui permet d'ouvrir un menu
Private Sub OuvrirMenu(ByVal e As Object)
' Create a new ContextMenuStrip control.
Dim z As Integer
ContextMenuStrip1 = New ContextMenuStrip()
AddHandler ContextMenuStrip1.Opening, AddressOf cms_Opening
For z = 0 To MonDGW.Rows.Count - 1
If MonDGW.Rows(z).Selected = True Then
MonDGW.Rows(z).ContextMenuStrip = ContextMenuStrip1
End If
Next
End Sub
'Procedure qui contient ce qui ce trouve dans le menu
Private Sub cms_Opening(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs)
' Acquire references to the owning control and item.
Dim c As Control = ContextMenuStrip1.SourceControl
Dim tsi As ToolStripDropDownItem = ContextMenuStrip1.OwnerItem
' Clear the ContextMenuStrip control's
' Items collection.
ContextMenuStrip1.Items.Clear()
' Populate the ContextMenuStrip control with its default items.
ContextMenuStrip1.Items.Add("Continue Updating")
AddHandler ContextMenuStrip1.Items(0).Click, AddressOf cms_Click
ContextMenuStrip1.Items.Add("-")
ContextMenuStrip1.Items.Add("Acknowledge Single Alarm")
AddHandler ContextMenuStrip1.Items(2).Click, AddressOf cms_Click
ContextMenuStrip1.Items.Add("-")
ContextMenuStrip1.Items.Add("Open Control Display")
AddHandler ContextMenuStrip1.Items(4).Click, AddressOf cms_Click
ContextMenuStrip1.Items.Add("Open Faceplate Display")
AddHandler ContextMenuStrip1.Items(5).Click, AddressOf cms_Click
ContextMenuStrip1.Items.Add("Open Detail Display")
AddHandler ContextMenuStrip1.Items(6).Click, AddressOf cms_Click
ContextMenuStrip1.Items.Add("-")
ContextMenuStrip1.Items.Add("Suppress Alarm")
AddHandler ContextMenuStrip1.Items(8).Click, AddressOf cms_Click
' Set Cancel to false.
' It is optimized to true based on empty entry.
e.Cancel = False
End Sub
Public Sub cms_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
If sender.text = "Suppress Alarm" Then
Dim z As Integer
'MessageBox.Show(sender.text & " = Suppress Alarm")
For z = 0 To MonDGW.Rows.Count - 1
If MonDGW.Rows(z).Selected = True Then
'mMesAlarmes.DicoAlarmes(MonDGW.SelectedRows(0).Cells(3).EditedFormattedValue).Supprimer = True
'MesAlarmes.DicoAlarmes(MonDGW.Rows(MesAlarmes.LigneDGVTraitee).Cells(3).EditedFormattedValue).Supprimer = True
'MesAlarmes.DicoAlarmes(MonDGW.Rows(MesAlarmes.LigneDGVTraitee).Cells(3).EditedFormattedValue).Etat = False
'mMesAlarmes.DicoAlarmes("a1").Etat = True
'mMesAlarmes.DicoAlarmes(MonDGW.SelectedRows(0).Cells(3).EditedFormattedValue).Etat = False
'MonDGW.Rows.RemoveAt(MesAlarmes.LigneDGVTraitee)
MesAlarmes.EtatFaux()
'FenPoubelle.MesAlarmes = MesAlarmes
Exit Sub
End If
Next
End If
End Sub
Public aInterfaceAlarme As InterfaceAlarme
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
'aInterfaceAlarme.aEventAlarme.OnChangeEnable()
MesAlarmes.PositionneEtat(10, 15, True)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
End Class |
Partager