private void m_btnOk_Click(object sender, EventArgs e) { if (m_txtNom.Text == "") { MessageBox.Show("LE NOM !"); return; } m_typeAlarme.ClearChamps(); foreach (ListViewItem item in m_wndListeChamps.Items) { IChampAlarme champ = item.Tag as IChampAlarme; if (m_listeChampsHerites.FirstOrDefault(c => c.NomChamp == champ.NomChamp) == null) { if (champ != null) { m_typeAlarme.AddChamp(champ); } } } if (m_typeAlarme.TypeParent != null) { m_typeAlarme.ActionsSurParent = m_txtFormuleSurParent.Formule; } m_typeAlarme.Libelle = m_txtNom.Text; m_typeAlarme.FormuleLibelle = m_txtFormuleLibelleAlarme.Formule; m_typeAlarme.EtatDefaut = (EEtatAlarme)m_cmbEtatCreation.SelectedItem; m_typeAlarme.ModeCalculEtat = (EModeCalculEtatParent)m_cmbModeCaluclEtat.SelectedItem; DialogResult = DialogResult.OK; Close(); }
private void m_lnkSupprimerChamp_LinkClicked(object sender, EventArgs e) { if (m_wndListeChamps.SelectedItems.Count == 1) { IChampAlarme champ = m_wndListeChamps.SelectedItems[0].Tag as IChampAlarme; if (champ != null) { m_typeAlarme.RemoveChamp(champ); FillListeChamps(); } } }
public static bool EditeChamp(IChampAlarme champ) { CFormEditeChampAlarme form = new CFormEditeChampAlarme(); form.m_champ = champ; bool bResult = false; if (form.ShowDialog() == DialogResult.OK) { bResult = true; } form.Dispose(); return(bResult); }
//-------------------------------------- private void m_wndListeChamps_MouseDoubleClick(object sender, MouseEventArgs e) { ListViewHitTestInfo info = m_wndListeChamps.HitTest(e.X, e.Y); if (info != null && info.Item != null) { IChampAlarme champ = info.Item.Tag as IChampAlarme; if (champ != null) { if (CFormEditeChampAlarme.EditeChamp(champ)) { FillItem(info.Item, champ); } } } }
private void FillItem(ListViewItem item, IChampAlarme champ) { item.Text = champ.NomChamp; item.Tag = champ; item.BackColor = champ.IsKey?Color.FromArgb(0, 255, 0):Color.FromArgb(255, 255, 255); }